@buaa_smat/hometrans 0.1.4 → 0.1.6
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 +17 -18
- package/agents/build-fixer.md +6 -5
- package/agents/{logic-coding.md → logic-coder.md} +2 -2
- package/agents/logic-context-builder.md +1 -1
- package/agents/self-tester.md +19 -8
- 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 +4 -2
- 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/{self-test → hmos-integration-test}/readme.md +3 -3
- package/skills/{spec-generator-skill → hmos-spec-generate}/SKILL.md +1 -1
- package/agents/code-review-fix.md +0 -356
- package/dist/cli/config-store.js +0 -143
- package/dist/cli/config.js +0 -40
- package/dist/cli/index.js +0 -43
- package/dist/cli/init.js +0 -366
- 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 -788
- 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/{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
|
@@ -45,13 +45,15 @@ Requires Node.js **>= 18**.
|
|
|
45
45
|
- `OHOS_SDK_PATH` — OpenHarmony SDK ETS path
|
|
46
46
|
- `HMS_SDK_PATH` — HMS SDK ETS path
|
|
47
47
|
- `TEST_API_KEY` — API key written into the autotest `config.yaml`
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
These are stored under a single `env` object in `~/.hometrans/config.json` (alongside `TOOL_PATH`, set in the next step).
|
|
49
|
+
3. **Installs bundled tools** to `~/.hometrans/tools` (the AutoTest toolchain lives at `~/.hometrans/tools/test-tools/autotest`) and records the destination as `env.TOOL_PATH` in `~/.hometrans/config.json`. Agents/skills resolve the AutoTest dir from `env.TOOL_PATH`.
|
|
50
|
+
4. **Seeds/refreshes the autotest config**: if `<TOOL_PATH>/test-tools/autotest/config.yaml` is missing it is created from `config.yaml.example`, and every `api_key:` line is filled with the supplied `TEST_API_KEY`.
|
|
51
|
+
5. For every selected editor, **copies**:
|
|
50
52
|
- every skill folder under `skills/` (those containing a `SKILL.md`) → `<editor>/skills/<skill-name>/` (recursive — preserves subdirectory structure)
|
|
51
|
-
- every agent under `agents/` → `<editor>/agents/` (recursive — preserves `<agent>/scripts/`
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
- every agent under `agents/` → `<editor>/agents/` (recursive — preserves `<agent>/scripts/` subtrees)
|
|
54
|
+
6. **Registers the MCP server** (auto-adapts to editor config format: jsonc-object / jsonc-command-array / codex-cli / toml-section).
|
|
55
|
+
7. Editors whose marker directory is missing are reported as **`skipped`** — nothing is written for them.
|
|
56
|
+
8. The install is **idempotent** — re-running overwrites bundled content only. It never touches files under `<editor>/skills/` or `<editor>/agents/` that don't share a name with a bundled item.
|
|
55
57
|
|
|
56
58
|
### Target directories
|
|
57
59
|
|
|
@@ -92,15 +94,14 @@ Extracts code context index from a given git commit in a HarmonyOS project (git
|
|
|
92
94
|
|
|
93
95
|
| Skill | Trigger phrases | Description |
|
|
94
96
|
|-------|-----------------|-------------|
|
|
95
|
-
| `convert-pipeline` | "full Android-to-HarmonyOS pipeline", "run the conversion pipeline end-to-end", "
|
|
96
|
-
| `
|
|
97
|
-
| `spec-generator-skill` | "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 |
|
|
97
|
+
| `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. 9 stages: Logic Context → Logic Coding → Build → Code Review → Review Fix → Rebuild → Self-Test → Self-Test Fix → Rebuild |
|
|
98
|
+
| `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 |
|
|
98
99
|
| `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 |
|
|
99
|
-
| `hmos-ui-align` | "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 |
|
|
100
|
-
| `hmos-ui-align
|
|
101
|
-
| `
|
|
100
|
+
| `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 |
|
|
101
|
+
| `hmos-batch-ui-align` | "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS" | Batch-converts multiple Android Activity UI snapshots (`page_NNNN_ActivityName`) to HarmonyOS ArkUI (ArkTS) pages |
|
|
102
|
+
| `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 |
|
|
102
103
|
|
|
103
|
-
### `convert-pipeline` Arguments
|
|
104
|
+
### `hmos-convert-pipeline` Arguments
|
|
104
105
|
|
|
105
106
|
1. `android-project-path` (required): path to the Android source project
|
|
106
107
|
2. `harmonyos-project-path` (required): path to the target HarmonyOS project
|
|
@@ -109,7 +110,7 @@ Extracts code context index from a given git commit in a HarmonyOS project (git
|
|
|
109
110
|
5. `max-rounds-test` (optional, default `2`): max Self-Test → Fix loop rounds
|
|
110
111
|
6. `variant` (optional, default `enhanced`): `enhanced` | `baseline` — selects the Stage 1/1a agent family
|
|
111
112
|
|
|
112
|
-
### `spec-
|
|
113
|
+
### `hmos-spec-generate` Arguments
|
|
113
114
|
|
|
114
115
|
1. `requirement-description-file` (required): absolute path to a single `.txt` file containing one or more REQ blocks separated by blank lines
|
|
115
116
|
2. `android-project-path` (required): absolute path to the Android project root (must be inside a Git repo)
|
|
@@ -122,11 +123,9 @@ Extracts code context index from a given git commit in a HarmonyOS project (git
|
|
|
122
123
|
| Agent | Description |
|
|
123
124
|
|-------|-------------|
|
|
124
125
|
| `logic-context-builder` | Constrains HarmonyOS ArkTS app changes into an executable decision contract |
|
|
125
|
-
| `logic-
|
|
126
|
+
| `logic-coder` | Executes HarmonyOS ArkTS code implementation from the decision contract (ships with `scripts/platform_context_query.py`) |
|
|
126
127
|
| `build-fixer` | Automatically builds a HarmonyOS project, parses compile errors, fixes them, and retries in a loop until the build succeeds |
|
|
127
|
-
| `code-reviewer` | Reviews HarmonyOS code against user scenarios to validate functional coverage |
|
|
128
|
-
| `code-review-fix` | One-pass review-fix-build cycle — reviews code, verifies and fixes confirmed issues, rebuilds the project |
|
|
129
|
-
| `review-fixer` | Fixes issues from code review reports — verifies each issue before fixing, references Android source, uses cautious per-scenario fix strategies |
|
|
128
|
+
| `code-reviewer` | Reviews HarmonyOS code against user scenarios to validate functional coverage || `review-fixer` | Fixes issues from code review reports — verifies each issue before fixing, references Android source, uses cautious per-scenario fix strategies |
|
|
130
129
|
| `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 |
|
|
131
130
|
| `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) |
|
|
132
131
|
| `self-test-fixer` | Fixes issues identified by self-testing — reads the self-test report, white-box verifies failures, plans and executes fixes in order |
|
package/agents/build-fixer.md
CHANGED
|
@@ -36,15 +36,16 @@ Read the config file written by `ht init` at `~/.hometrans/config.json` (`$HOME/
|
|
|
36
36
|
```jsonc
|
|
37
37
|
{
|
|
38
38
|
"editors": [ /* ... */ ],
|
|
39
|
-
"
|
|
39
|
+
"env": {
|
|
40
40
|
"OHOS_SDK_PATH": "...", // OpenHarmony SDK ETS path, e.g. "D:/DevEco Studio/sdk/default/openharmony/ets"
|
|
41
41
|
"HMS_SDK_PATH": "...", // HMS SDK ETS path, e.g. "D:/DevEco Studio/sdk/default/hms/ets"
|
|
42
|
-
"TEST_API_KEY": "..."
|
|
42
|
+
"TEST_API_KEY": "...",
|
|
43
|
+
"TOOL_PATH": "..." // HomeTrans tools dir, e.g. "C:/Users/<you>/.hometrans/tools"
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
```
|
|
46
47
|
|
|
47
|
-
Read `
|
|
48
|
+
Read `env.OHOS_SDK_PATH` from this file.
|
|
48
49
|
|
|
49
50
|
### 0b. Derive the DevEco Studio root and tool paths
|
|
50
51
|
|
|
@@ -58,11 +59,11 @@ From `<deveco>`, derive:
|
|
|
58
59
|
- **ohpm**: `<deveco>/tools/ohpm/bin/ohpm`
|
|
59
60
|
- **SDK directory**: `<deveco>/sdk`
|
|
60
61
|
|
|
61
|
-
Verify these files exist. If they do, use them and skip auto-detection. (Fall back to `
|
|
62
|
+
Verify these files exist. If they do, use them and skip auto-detection. (Fall back to `env.HMS_SDK_PATH` — stripping `/sdk/default/hms/ets` — if `OHOS_SDK_PATH` is absent but `HMS_SDK_PATH` is present.)
|
|
62
63
|
|
|
63
64
|
### 0c. Auto-detect if config is missing or invalid
|
|
64
65
|
|
|
65
|
-
If `~/.hometrans/config.json` is missing, has empty `
|
|
66
|
+
If `~/.hometrans/config.json` is missing, has empty `env.OHOS_SDK_PATH`/`HMS_SDK_PATH`, or the derived paths don't point to real files, auto-detect:
|
|
66
67
|
|
|
67
68
|
1. **Find DevEco Studio installation**:
|
|
68
69
|
- Search common locations: `D:\DevEco Studio`, `C:\DevEco Studio`, `C:\Program Files\DevEco Studio`
|
|
@@ -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/agents/self-tester.md
CHANGED
|
@@ -38,25 +38,36 @@ You are a self-tester for HarmonyOS applications. You run a single pipeline: par
|
|
|
38
38
|
|
|
39
39
|
### AutoTest Directory Locator
|
|
40
40
|
|
|
41
|
-
Used independently by S5 and T4.
|
|
41
|
+
Used independently by S5 and T4. The AutoTest tools are installed by `ht init` under the HomeTrans tools dir; resolve their location from config rather than searching the filesystem.
|
|
42
|
+
|
|
43
|
+
**Primary — read `env.TOOL_PATH` from the HomeTrans config** at `~/.hometrans/config.json` (`$HOME/.hometrans/config.json`; on Windows `%USERPROFILE%\.hometrans\config.json`). The autotest dir is `<TOOL_PATH>/test-tools/autotest`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cfg="$HOME/.hometrans/config.json"; [ -n "$USERPROFILE" ] && [ -f "$USERPROFILE/.hometrans/config.json" ] && cfg="$USERPROFILE/.hometrans/config.json"
|
|
47
|
+
tool_path="$(python -c "import json,os;print(json.load(open(os.path.expanduser(r'$cfg'),encoding='utf-8')).get('env',{}).get('TOOL_PATH',''))" 2>/dev/null)"
|
|
48
|
+
if [ -n "$tool_path" ] && [ -d "$tool_path/test-tools/autotest" ]; then echo "$tool_path/test-tools/autotest"; fi
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If config is missing or `TOOL_PATH` is empty/invalid, **fall back** to walking up from `<output-path>` for a sibling `test-tools/autotest` (then `agents/test-tools/autotest` for legacy layouts) — **anchor the search at `<output-path>`, the sub-agent cwd is not guaranteed**:
|
|
42
52
|
|
|
43
53
|
```bash
|
|
44
54
|
d="<output-path>"; while [ "$d" != "/" ] && [ "$d" != "" ]; do \
|
|
55
|
+
if [ -d "$d/test-tools/autotest" ]; then echo "$d/test-tools/autotest"; break; fi; \
|
|
45
56
|
if [ -d "$d/agents/test-tools/autotest" ]; then echo "$d/agents/test-tools/autotest"; break; fi; \
|
|
46
57
|
d="$(dirname "$d")"; \
|
|
47
58
|
done
|
|
48
59
|
```
|
|
49
60
|
|
|
50
|
-
|
|
61
|
+
As a last resort, a `$(pwd)`-anchored search:
|
|
51
62
|
|
|
52
63
|
```bash
|
|
53
|
-
find "$(pwd)" -type d -path "*/
|
|
64
|
+
find "$(pwd)" -type d -path "*/test-tools/autotest" -print -quit 2>/dev/null
|
|
54
65
|
```
|
|
55
66
|
|
|
56
67
|
| Caller | Purpose | On failure |
|
|
57
68
|
|--------|---------|------------|
|
|
58
|
-
| S5 | Locate then run testcases_tool.py | Emit `Error: cannot locate
|
|
59
|
-
| T4 | Locate then verify config.yaml | Write `self-test-report.md` with status **FAIL** and reason "AutoTest directory not found from output-path", then exit |
|
|
69
|
+
| S5 | Locate then run testcases_tool.py | Emit `Error: cannot locate test-tools/autotest from config env.TOOL_PATH or <output-path>` and exit |
|
|
70
|
+
| T4 | Locate then verify config.yaml | Write `self-test-report.md` with status **FAIL** and reason "AutoTest directory not found from config TOOL_PATH or output-path", then exit |
|
|
60
71
|
|
|
61
72
|
### Input Validation Template
|
|
62
73
|
|
|
@@ -173,7 +184,7 @@ Write to `<output-path>/_extracted.json`:
|
|
|
173
184
|
|
|
174
185
|
### S5 — Generate testcases.json via Python script
|
|
175
186
|
|
|
176
|
-
Find the `
|
|
187
|
+
Find the `test-tools/autotest` directory using the **AutoTest Directory Locator** in Shared Utilities (prefer config `env.TOOL_PATH`, fall back to walking up from `<output-path>`). Set `<autotest_dir>` to the resolved path. If not found, emit the documented error and exit. Run:
|
|
177
188
|
|
|
178
189
|
```bash
|
|
179
190
|
cd "<autotest_dir>" && uv run python testcases_tool.py generate "<output-path>/_extracted.json" "<output-path>/testcases.json" --validate
|
|
@@ -236,7 +247,7 @@ Record the device serial number.
|
|
|
236
247
|
|
|
237
248
|
### T4 — Locate AutoTest Directory & Verify config.yaml
|
|
238
249
|
|
|
239
|
-
Find the `
|
|
250
|
+
Find the `test-tools/autotest` directory using the **AutoTest Directory Locator** in Shared Utilities (prefer config `env.TOOL_PATH`, fall back to walking up from `<output-path>`). If not found, write a `self-test-report.md` with the sentinel format (`status: FAIL` / `reason: AutoTest directory not found from config TOOL_PATH or output-path`), then stop.
|
|
240
251
|
|
|
241
252
|
Set `<autotest_dir>` to the found path. Check config.yaml:
|
|
242
253
|
|
|
@@ -370,7 +381,7 @@ cd "<autotest_dir>" && uv run python report_tool.py validate "<output-path>/self
|
|
|
370
381
|
- **Two-phase architecture**: When the parse phase runs, the LLM writes `_extracted.json` → `testcases_tool.py` writes `testcases.json`. Never write `testcases.json` directly. If `testcases.json` already exists at the output path and the parse phase runs, `testcases_tool.py` overwrites it — never skip the script.
|
|
371
382
|
- **App name → bundle_name is critical**: `test_steps` must use `bundle_name` (e.g., `com.example.tuku`), NOT the display name. AutoTest uses this to launch the correct app. Using the display name instead may launch the wrong app entirely.
|
|
372
383
|
- **JSON contract**: `app-metadata.json` and `testcases.json` always live at `<output-path>/app-metadata.json` and `<output-path>/testcases.json`. T2 reads from the file (not from memory).
|
|
373
|
-
- **AutoTest directory locator**:
|
|
384
|
+
- **AutoTest directory locator**: Resolve `<TOOL_PATH>/test-tools/autotest` from `~/.hometrans/config.json` (`env.TOOL_PATH`); fall back to walking up from `<output-path>` (see Shared Utilities). Do not assume `$(pwd)` is anchored anywhere in particular.
|
|
374
385
|
- **Sentinel-format early-exit reports**: When T1 / T3 / T4 / T7 write a degraded FAIL report (config error, no device, missing autotest dir, crashed batch, timeout, or `setup=false` precondition failure), the report's first non-frontmatter line MUST be `status: FAIL` and the second MUST be `reason: <one-line reason>`. This lets callers detect early-exit reports without parsing a case table.
|
|
375
386
|
- **Quote all paths** — paths may contain spaces.
|
|
376
387
|
- **Capture complete output** — never truncate command output; it is essential for diagnosis.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buaa_smat/hometrans",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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(数据库实体相关)
|