@buaa_smat/hometrans 0.1.13 → 0.1.14
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/README.md +164 -112
- package/agents/build-fixer.md +384 -394
- package/agents/code-reviewer.md +240 -240
- package/agents/logic-coder.md +199 -199
- package/agents/logic-context-builder.md +194 -194
- package/agents/review-fixer.md +405 -405
- package/agents/self-test-fixer.md +296 -296
- package/agents/self-tester.md +393 -392
- package/agents/spec-generator.md +540 -540
- package/dist/cli/config-store.js +84 -8
- package/dist/cli/config.js +3 -3
- package/dist/cli/env-vars.js +129 -0
- package/dist/cli/init.js +272 -272
- package/dist/cli/uninstall.js +152 -17
- package/dist/context/index.js +10 -197
- package/env-requirements.json +3 -3
- package/package.json +1 -1
- package/resource/choose_editor.png +0 -0
- package/resource/common_config.png +0 -0
- package/resource/integration_test_config.png +0 -0
- package/resource/set_env.png +0 -0
- package/resource/ui_align_config.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +108 -98
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +180 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/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 +648 -648
- package/skills/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 +2088 -2088
- package/skills/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 +1033 -1033
- package/skills/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 +1183 -1183
- package/skills/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 +576 -576
- package/skills/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 +297 -297
- package/skills/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 +395 -395
- package/skills/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 +902 -902
- package/skills/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 +106 -106
- package/skills/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 +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/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 +354 -354
- package/skills/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 +11 -11
- package/skills/hmos-convert-pipeline/SKILL.md +429 -415
- package/skills/hmos-fix-build-errors/SKILL.md +272 -273
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/SKILL.md +219 -200
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/readme.md +237 -230
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +2 -2
- package/skills/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 +648 -648
- package/skills/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 +2088 -2088
- package/skills/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 +1033 -1033
- package/skills/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 +1183 -1183
- package/skills/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 +576 -576
- package/skills/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 +297 -297
- package/skills/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 +395 -395
- package/skills/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 +902 -902
- package/skills/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 +106 -106
- package/skills/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 +1178 -1178
- package/skills/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 +911 -911
- package/skills/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 +354 -354
- package/skills/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 +11 -11
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +3 -3
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +37 -37
- package/skills/hmos-integration-test/SKILL.md +380 -369
- package/skills/hmos-integration-test/readme.md +309 -309
- package/skills/hmos-resources-convert/SKILL.md +623 -623
- package/skills/hmos-resources-convert/references/conversion-rules.md +663 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -388
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -513
- package/skills/hmos-spec-generate/SKILL.md +331 -331
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +105 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +78 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +58 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +116 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +33 -33
- package/tools/test-tools/autotest/README.md +33 -17
- package/tools/test-tools/autotest/self_test_runner.py +109 -15
- package/resource/hometrans_config.png +0 -0
- package/skills/hmos-incremental-ui-align/config-example.json +0 -11
- package/tools/test-tools/autotest/config.yaml.example +0 -58
|
@@ -1,273 +1,272 @@
|
|
|
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: <
|
|
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** (optional): `$ARGUMENTS[1]` (DevEco Studio installation root, e.g. `D:/DevEco Studio`) — when omitted, resolved automatically (see Step 0.2)
|
|
16
|
-
- **--signed** (optional): if any argument equals `--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. **Resolve `<deveco-path>`** — stop at the first source that yields a valid path:
|
|
25
|
-
1. `$ARGUMENTS[1]` if provided (and not `--signed`).
|
|
26
|
-
2.
|
|
27
|
-
3.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- `tools/
|
|
32
|
-
- `tools/
|
|
33
|
-
- `
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- **If
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- If `signingConfigs`
|
|
69
|
-
|
|
70
|
-
>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
set "
|
|
104
|
-
set "
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- If output contains `BUILD
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
| `arkts-
|
|
152
|
-
| `arkts-no-obj-literals
|
|
153
|
-
| `arkts-no-
|
|
154
|
-
| `arkts-no-
|
|
155
|
-
| `
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
|
|
|
159
|
-
| Missing
|
|
160
|
-
| Missing `
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
import {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
import {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
import {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
- `ohos.permission.
|
|
228
|
-
- `ohos.permission.
|
|
229
|
-
- `ohos.permission.
|
|
230
|
-
- `ohos.permission.
|
|
231
|
-
- `ohos.permission.
|
|
232
|
-
- `ohos.permission.
|
|
233
|
-
- `ohos.permission.
|
|
234
|
-
- `ohos.permission.
|
|
235
|
-
- `ohos.permission.
|
|
236
|
-
- `ohos.permission.
|
|
237
|
-
- `ohos.permission.
|
|
238
|
-
- `ohos.permission.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
- **
|
|
261
|
-
- **
|
|
262
|
-
- **
|
|
263
|
-
- **
|
|
264
|
-
- **
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
- `references/
|
|
272
|
-
- `references/
|
|
273
|
-
- `references/rdb-entity-pattern.md` — RDB 实体类编译错误 Pattern(数据库实体相关)
|
|
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: <harmony_project_dir> [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** (optional): `$ARGUMENTS[1]` (DevEco Studio installation root, e.g. `D:/DevEco Studio`) — when omitted, resolved automatically (see Step 0.2)
|
|
16
|
+
- **--signed** (optional): if any argument equals `--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. **Resolve `<deveco-path>`** — read **directly from the OS environment**; stop at the first source that yields a valid path:
|
|
25
|
+
1. `$ARGUMENTS[1]` if provided (and not `--signed`).
|
|
26
|
+
2. Environment variables (`echo "$VAR"` on macOS/Linux; `$env:VAR` in PowerShell on Windows): `DEVECO_HOME` → parent of `DEVECO_SDK_HOME` → strip the trailing `/sdk/default/openharmony/ets` from `OHOS_SDK_PATH` (legacy).
|
|
27
|
+
3. **Ask the user** for the DevEco Studio install path (suggest running `ht init` to persist it as an environment variable).
|
|
28
|
+
|
|
29
|
+
**Verify the resolved `<deveco-path>`** contains:
|
|
30
|
+
- `tools/node/node.exe`
|
|
31
|
+
- `tools/hvigor/bin/hvigorw.js`
|
|
32
|
+
- `tools/ohpm/bin/ohpm`
|
|
33
|
+
- `sdk/` directory
|
|
34
|
+
|
|
35
|
+
If verification fails for an env-sourced path, treat that source as invalid and continue down the list; if it fails for a user-supplied path, report what is missing and ask again.
|
|
36
|
+
|
|
37
|
+
3. **Set up `local.properties`** — Ensure the project root has `local.properties` with:
|
|
38
|
+
```properties
|
|
39
|
+
hwsdk.dir=<deveco-path>/sdk
|
|
40
|
+
```
|
|
41
|
+
Create it if missing. Use forward slashes in the path.
|
|
42
|
+
|
|
43
|
+
4. **Run `ohpm install`** — Install dependencies before first build:
|
|
44
|
+
```bash
|
|
45
|
+
cd "<project-dir>"
|
|
46
|
+
export PATH="<deveco-path>/tools/ohpm/bin:$PATH"
|
|
47
|
+
"<deveco-path>/tools/ohpm/bin/ohpm" install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
5. **Determine Build Mode** — Check if any argument equals `--signed` (it may be `$ARGUMENTS[1]` when the DevEco path is omitted, or `$ARGUMENTS[2]` when it is provided):
|
|
51
|
+
- **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.
|
|
52
|
+
- **If `--signed`** → **Signed build mode**. Proceed to Step 0.5 to validate signing config.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Step 0.5: Validate Signing Config (Only for --signed Builds)
|
|
57
|
+
|
|
58
|
+
This step is ONLY executed when `--signed` is specified.
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
### Steps:
|
|
63
|
+
|
|
64
|
+
1. **Read `build-profile.json5`** in the project root.
|
|
65
|
+
|
|
66
|
+
2. **Check for `signingConfigs`** — Look for `app.signingConfigs` array in the file.
|
|
67
|
+
- If `signingConfigs` exists and has at least one entry with valid `material` fields (`certpath`, `storeFile`, `profile`), proceed to step 3.
|
|
68
|
+
- If `signingConfigs` is missing or empty, **STOP and report to the user**:
|
|
69
|
+
> Signing configuration not found in `build-profile.json5`.
|
|
70
|
+
> 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`.
|
|
71
|
+
|
|
72
|
+
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.
|
|
73
|
+
- 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.
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
5. Proceed to Step 1.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Step 1: Build-Fix Loop
|
|
82
|
+
|
|
83
|
+
Execute the following loop. **Maximum 20 iterations** to prevent infinite loops.
|
|
84
|
+
|
|
85
|
+
### 1.1 Run CLI Build
|
|
86
|
+
|
|
87
|
+
**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`.
|
|
88
|
+
|
|
89
|
+
1. **Write a temporary batch file** (e.g. `<project-dir>/build_temp.bat`):
|
|
90
|
+
|
|
91
|
+
**For unsigned builds** (no `--signed`):
|
|
92
|
+
```bat
|
|
93
|
+
@echo off
|
|
94
|
+
set "DEVECO_SDK_HOME=<deveco-path>\sdk"
|
|
95
|
+
cd /d "<project-dir>"
|
|
96
|
+
"<deveco-path>\tools\node\node.exe" "<deveco-path>\tools\hvigor\bin\hvigorw.js" assembleHap --mode module -p module=entry --no-daemon
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**For signed builds** (`--signed`):
|
|
100
|
+
```bat
|
|
101
|
+
@echo off
|
|
102
|
+
set "PATH=<deveco-path>\jbr\bin;%PATH%"
|
|
103
|
+
set "JAVA_HOME=<deveco-path>\jbr"
|
|
104
|
+
set "DEVECO_SDK_HOME=<deveco-path>\sdk"
|
|
105
|
+
cd /d "<project-dir>"
|
|
106
|
+
"<deveco-path>\tools\node\node.exe" "<deveco-path>\tools\hvigor\bin\hvigorw.js" assembleHap --mode module -p module=entry --no-daemon
|
|
107
|
+
```
|
|
108
|
+
Note: Signed builds need `JAVA_HOME` and `jbr\bin` in PATH because the `SignHap` step spawns `java` as a child process.
|
|
109
|
+
|
|
110
|
+
Use backslashes (`\`) in paths inside the `.bat` file (Windows convention).
|
|
111
|
+
|
|
112
|
+
2. **Run the batch file** via `cmd.exe`:
|
|
113
|
+
```bash
|
|
114
|
+
cmd.exe //c "<project-dir>/build_temp.bat" 2>&1
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
3. **Delete the batch file** after the build completes (success or failure).
|
|
118
|
+
|
|
119
|
+
- Capture the **full output** into a variable.
|
|
120
|
+
- The build command may take 1-3 minutes. Use a timeout of 300000ms (5 minutes).
|
|
121
|
+
|
|
122
|
+
### 1.2 Check Build Result
|
|
123
|
+
|
|
124
|
+
- If output contains `BUILD SUCCESSFUL` → **Build succeeded!** Exit the loop, go to Step 2.
|
|
125
|
+
- If output contains `ERROR` or `BUILD FAILED` → Parse errors and continue to 1.3.
|
|
126
|
+
|
|
127
|
+
### 1.3 Parse Errors
|
|
128
|
+
|
|
129
|
+
Extract error information from the build output. Errors typically appear in these formats:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
ERROR: <file-path>:<line>:<col> - <error-code>: <message>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
or
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
ArkTS:ERROR File: <file-path>:<line>:<col>
|
|
139
|
+
<error message>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Group errors by file. Focus on **actual errors**, not warnings.
|
|
143
|
+
|
|
144
|
+
### 1.4 Fix Errors
|
|
145
|
+
|
|
146
|
+
Read each file that has errors and apply fixes. Use the error reference table below to identify and fix common issues:
|
|
147
|
+
|
|
148
|
+
| Error Code / Pattern | Message | Fix |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| `arkts-limited-throw` | "throw statements cannot accept values of arbitrary types" | Change `throw err` to `throw (err instanceof Error) ? err : new Error(String(err))` |
|
|
151
|
+
| `arkts-no-obj-literals-as-types` | "Object literals cannot be used as type declarations" | Define a named `interface` instead of inline `{ key: Type }` |
|
|
152
|
+
| `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;` |
|
|
153
|
+
| `arkts-no-any-type` / `any` type usage | "Use explicit types instead of any" | Replace `any` with the correct concrete type or `object` |
|
|
154
|
+
| `arkts-no-var` | "Use 'let' or 'const' instead of 'var'" | Replace `var` with `let` or `const` |
|
|
155
|
+
| `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/` |
|
|
156
|
+
| `10505001` | "Resource[] is not assignable to ResourceColor" | Remove array brackets: `.fontColor($r('app.color.x'))` not `.fontColor([$r('app.color.x')])` |
|
|
157
|
+
| `00303221` | "permission must be a value that is predefined within the SDK" | Remove invalid permission from `module.json5`. See valid permissions list below |
|
|
158
|
+
| Missing import | "Cannot find name 'xxx'" | Add the correct import (see import reference below) |
|
|
159
|
+
| Missing `async` | "await expression requires async function" | Add `async` to the enclosing function |
|
|
160
|
+
| Missing `build()` | "@Component must have build() method" | Add a `build() {}` method to the @Component struct |
|
|
161
|
+
| Type mismatch | Various type errors | Fix the type annotation or cast appropriately |
|
|
162
|
+
| Duplicate identifier | "Duplicate identifier 'xxx'" | Remove or rename the duplicate declaration |
|
|
163
|
+
|
|
164
|
+
**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.
|
|
165
|
+
|
|
166
|
+
### 1.5 Log Progress
|
|
167
|
+
|
|
168
|
+
After each fix iteration, briefly report:
|
|
169
|
+
- Iteration number
|
|
170
|
+
- Number of errors found
|
|
171
|
+
- Summary of fixes applied
|
|
172
|
+
- Whether re-building
|
|
173
|
+
|
|
174
|
+
Then go back to **1.1** and rebuild.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Step 2: Build Success Report
|
|
179
|
+
|
|
180
|
+
When the build succeeds, present a summary:
|
|
181
|
+
|
|
182
|
+
1. **Build Status**: SUCCESS
|
|
183
|
+
2. **Build Type**: Signed HAP or Unsigned HAP
|
|
184
|
+
3. **Signing** (if signed): Confirm signing config from `build-profile.json5` was used
|
|
185
|
+
4. **Iterations**: How many build-fix cycles were needed
|
|
186
|
+
5. **Total Errors Fixed**: Count of errors fixed across all iterations
|
|
187
|
+
6. **Summary of Changes**: List of files modified and what was fixed in each
|
|
188
|
+
7. **Output HAP Path**:
|
|
189
|
+
- Signed: `<project>/entry/build/default/outputs/default/entry-default-signed.hap`
|
|
190
|
+
- Unsigned: `<project>/entry/build/default/outputs/default/entry-default-unsigned.hap`
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Reference: Common HarmonyOS Imports
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// Network
|
|
198
|
+
import { http } from '@kit.NetworkKit';
|
|
199
|
+
|
|
200
|
+
// Data persistence
|
|
201
|
+
import { preferences } from '@kit.ArkData';
|
|
202
|
+
import { relationalStore } from '@kit.ArkData';
|
|
203
|
+
|
|
204
|
+
// UI utilities
|
|
205
|
+
import { router } from '@kit.ArkUI';
|
|
206
|
+
import { promptAction } from '@kit.ArkUI';
|
|
207
|
+
|
|
208
|
+
// Ability & Context
|
|
209
|
+
import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit';
|
|
210
|
+
import { common } from '@kit.AbilityKit';
|
|
211
|
+
|
|
212
|
+
// File I/O
|
|
213
|
+
import { fileIo } from '@kit.CoreFileKit';
|
|
214
|
+
|
|
215
|
+
// Logging
|
|
216
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
217
|
+
|
|
218
|
+
// JSON parsing — built-in, no import needed
|
|
219
|
+
// ArkUI built-in components (Text, Column, Row, List, Button, Image, etc.) — NO import needed
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Reference: Valid Permission Names
|
|
223
|
+
|
|
224
|
+
Commonly used SDK-validated permissions for `module.json5`:
|
|
225
|
+
|
|
226
|
+
- `ohos.permission.INTERNET`
|
|
227
|
+
- `ohos.permission.GET_NETWORK_INFO`
|
|
228
|
+
- `ohos.permission.GET_WIFI_INFO`
|
|
229
|
+
- `ohos.permission.KEEP_BACKGROUND_RUNNING`
|
|
230
|
+
- `ohos.permission.PUBLISH_AGENT_REMINDER`
|
|
231
|
+
- `ohos.permission.CAMERA`
|
|
232
|
+
- `ohos.permission.MICROPHONE`
|
|
233
|
+
- `ohos.permission.APPROXIMATELY_LOCATION`
|
|
234
|
+
- `ohos.permission.LOCATION`
|
|
235
|
+
- `ohos.permission.READ_MEDIA`
|
|
236
|
+
- `ohos.permission.WRITE_MEDIA`
|
|
237
|
+
- `ohos.permission.USE_BLUETOOTH`
|
|
238
|
+
- `ohos.permission.VIBRATE`
|
|
239
|
+
|
|
240
|
+
**Note**: `ohos.permission.NOTIFICATION` does NOT exist. When in doubt, omit the permission.
|
|
241
|
+
|
|
242
|
+
## Reference: ArkTS Strict Mode Rules
|
|
243
|
+
|
|
244
|
+
All code must comply with ArkTS strict mode:
|
|
245
|
+
|
|
246
|
+
1. **No `any` type** — Use explicit types or `object`
|
|
247
|
+
2. **No `var`** — Only `let` and `const`
|
|
248
|
+
3. **No dynamic property access** — Use typed interfaces instead of `obj['key']` on typed objects
|
|
249
|
+
4. **`throw` must throw Error instances** — Never `throw 'string'` or `throw unknownVar`
|
|
250
|
+
5. **All object literals must match declared interfaces** — No anonymous `{ key: val }` returns without a matching interface
|
|
251
|
+
6. **No inline object literal types** — `function(): { a: string }` is forbidden; define a named `interface`
|
|
252
|
+
7. **All `@Component` structs must have `build()`** — Missing build method is a compile error
|
|
253
|
+
8. **`$r()` resource references validated at compile time** — All referenced resources must exist
|
|
254
|
+
9. **`fontColor()` expects `ResourceColor`**, not `Resource[]` — Don't wrap in array brackets (exception: `SymbolGlyph`)
|
|
255
|
+
10. **Permission names in `module.json5`** — Must be SDK-predefined values
|
|
256
|
+
|
|
257
|
+
## Important Notes
|
|
258
|
+
|
|
259
|
+
- **Timeout**: Individual build commands may take up to 5 minutes. Use a 300000ms timeout.
|
|
260
|
+
- **Max iterations**: Stop after 20 iterations to prevent infinite loops. If build still fails after 20 attempts, report the remaining errors to the user.
|
|
261
|
+
- **Don't over-fix**: Only fix errors reported by the compiler. Don't proactively refactor unrelated code.
|
|
262
|
+
- **Read before edit**: Always read a file before modifying it. Understand the surrounding context.
|
|
263
|
+
- **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.
|
|
264
|
+
- **ohpm errors**: If the build fails because of missing packages, run `ohpm install` again.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## References
|
|
269
|
+
|
|
270
|
+
- `references/arkts-strict-patterns.md` — ArkTS 严格模式编译错误的确定性修复 Pattern(throw/any/var/interface 等)
|
|
271
|
+
- `references/known-patterns.md` — 已知常见编译错误 Pattern 及修复方案
|
|
272
|
+
- `references/rdb-entity-pattern.md` — RDB 实体类编译错误 Pattern(数据库实体相关)
|