@buaa_smat/hometrans 0.1.13 → 0.1.15
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 +194 -136
- package/agents/build-fixer.md +38 -48
- package/agents/code-reviewer.md +20 -20
- package/agents/logic-coder.md +8 -8
- package/agents/logic-context-builder.md +5 -5
- package/agents/review-fixer.md +16 -16
- package/agents/self-test-fixer.md +15 -15
- package/agents/self-tester.md +56 -55
- package/agents/spec-generator.md +16 -16
- package/dist/cli/config-store.js +120 -9
- package/dist/cli/config.js +4 -4
- package/dist/cli/env-vars.js +129 -0
- package/dist/cli/init.js +315 -276
- package/dist/cli/uninstall.js +152 -17
- package/dist/context/index.js +10 -197
- package/env-requirements.json +181 -181
- 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/migration_process.svg +94 -0
- package/resource/migration_process_transparent.svg +93 -0
- package/resource/set_env.png +0 -0
- package/resource/ui_align_config.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +10 -0
- 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 +63 -49
- package/skills/hmos-fix-build-errors/SKILL.md +5 -6
- 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/{readme.md → README.md} +28 -21
- package/skills/hmos-incremental-ui-align/SKILL.md +46 -27
- 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/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/{readme.md → README.md} +38 -38
- package/skills/hmos-integration-test/SKILL.md +63 -52
- package/skills/hmos-resources-convert/SKILL.md +5 -5
- 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 +19 -19
- 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
|
@@ -14,38 +14,57 @@ You are writing ArkTS codes.
|
|
|
14
14
|
- Do not proceed to Step 3 until every page pair has its `UI_comparison.md` written in Step 2
|
|
15
15
|
- Step 2 MUST be executed by the main agent sequentially (not delegated to background agents). Each sub-step (2.1 → 2.2 → 2.3) must complete and be verified before the next begins.
|
|
16
16
|
- If mock data is required, write them in `{harmony_project_dir}/entry/src/main/ets/model/` according to the hmos MVVM mode.
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
## Step 0: Load Config
|
|
20
|
-
Resolve the config file in this order — stop at the first hit:
|
|
17
|
+
- Do not make any other changes unrelated to the user's requirements.
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
2. **`config.json` in this skill's own directory** — `ht init` seeds it from `config-example.json` and fills `glm_api_key` + `hmos_sdk_dir` from `~/.hometrans/config.json`.
|
|
24
|
-
3. Neither exists → **ask the user** for a valid path.
|
|
19
|
+
## Step 0: Resolve Inputs
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
This skill takes three path inputs from the invocation and reads its other settings **directly from the OS environment variables**.
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
### Skill input arguments (provided by the user when invoking the skill)
|
|
29
24
|
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `harmony.app_name` | HarmonyOS app name for navigation |
|
|
36
|
-
| `harmony.package` | HarmonyOS app package name |
|
|
37
|
-
| `harmony.project_dir` | HarmonyOS project root path |
|
|
38
|
-
| `hmos_sdk_dir` | HarmonyOS SDK path (ETS API reference) |
|
|
39
|
-
| `glm_api_key` | Zhipu GLM API key for phone-agent |
|
|
40
|
-
| `capture_output_dir` | Base directory for captured page data |
|
|
25
|
+
| Argument | Required | Description |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `android_project_dir` | yes | Android source code root path |
|
|
28
|
+
| `harmony_project_dir` | yes | HarmonyOS project root path (will be modified) |
|
|
29
|
+
| `capture_output_dir` | no | Base dir for captured page data (screenshots / view trees / analysis). Default: `<harmony_project_dir>/.hometrans/capture_output` under the current working directory |
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
The user may pass them as named args (e.g. `android_project_dir: D:\path\to\android`) or describe them in the request. If `android_project_dir` or `harmony_project_dir` cannot be determined from the invocation, **ask the user** before proceeding.
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
2. Environment variables: derive `hmos_sdk_dir` from `DEVECO_SDK_HOME` (append `/default`); `glm_api_key` from `GLM_API_KEY`.
|
|
46
|
-
3. **Ask the user** (suggest running `ht init` to persist them).
|
|
33
|
+
### Step 0.0: Environment Variables Check (run first)
|
|
47
34
|
|
|
48
|
-
|
|
35
|
+
Read each variable below **directly from the OS environment** (`echo "$VAR"` on macOS/Linux; `$env:VAR` in PowerShell / `echo %VAR%` in cmd on Windows).
|
|
36
|
+
|
|
37
|
+
| Variable | Purpose | Valid when |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `GLM_API_KEY` | Zhipu GLM key for the phone-agent (Step 1 navigation) | non-empty |
|
|
40
|
+
| `OHOS_SDK_PATH` | HarmonyOS SDK ETS API reference (Step 3) | path exists on disk |
|
|
41
|
+
| `HMS_SDK_PATH` | HMS SDK ETS API reference (Step 3) | path exists on disk |
|
|
42
|
+
|
|
43
|
+
For `OHOS_SDK_PATH` / `HMS_SDK_PATH`, if unset but `DEVECO_SDK_HOME` is set, derive them as `<DEVECO_SDK_HOME>/default/openharmony/ets` and `<DEVECO_SDK_HOME>/default/hms/ets`.
|
|
44
|
+
|
|
45
|
+
For each variable that is still missing/empty (or a path that does not exist), **stop and ask the user to provide a value**, then use what they give for this run. Suggest running `ht init` to persist them as machine environment variables for next time.
|
|
46
|
+
|
|
47
|
+
### Step 0.1: Auto-derive App Names & Package Names
|
|
48
|
+
|
|
49
|
+
`android.app_name` / `android.package` / `harmony.app_name` / `harmony.package` are required for navigation (passed to `scripts/app_feature_verify.py` as `--app` / `--package`). They are not provided as inputs — resolve them from the project dirs (`android_project_dir` / `harmony_project_dir`) as follows.
|
|
50
|
+
|
|
51
|
+
**`app_name` matters because it is the launcher label phone-agent taps to open the app** — when the resolved label is a localized resource and a Chinese (`zh`) variant exists, prefer the Chinese value (devices are typically zh-CN).
|
|
52
|
+
|
|
53
|
+
#### Android (from `android_project_dir`)
|
|
54
|
+
1. **`android.package`** — locate the application module (the module whose Gradle file applies `com.android.application`, usually `app/`):
|
|
55
|
+
- Read `applicationId` from `{module}/build.gradle` (Groovy: `applicationId "com.x"`) or `build.gradle.kts` (Kotlin DSL: `applicationId = "com.x"`). Use the default/base `applicationId`; ignore flavor-specific `applicationIdSuffix`.
|
|
56
|
+
- Fallback: the `package="..."` attribute in `{module}/src/main/AndroidManifest.xml`.
|
|
57
|
+
2. **`android.app_name`** — in `{module}/src/main/AndroidManifest.xml`, read `android:label`. Prefer the launcher `<activity>` label (the activity whose `<intent-filter>` has `android.intent.action.MAIN` + `android.intent.category.LAUNCHER`); if it has none, use the `<application>` label.
|
|
58
|
+
- If the label is a literal string, use it directly.
|
|
59
|
+
- If it is `@string/<name>`, resolve `<name>` in the string resources: prefer a Chinese variant (`{module}/src/main/res/values-zh-rCN/strings.xml`, else `values-zh/strings.xml`), falling back to the default `values/strings.xml`. Use the matching `<string name="<name>">…</string>` value.
|
|
60
|
+
|
|
61
|
+
#### HarmonyOS (from `harmony_project_dir`)
|
|
62
|
+
1. **`harmony.package`** — read `app.bundleName` from `{harmony_project_dir}/AppScope/app.json5`.
|
|
63
|
+
2. **`harmony.app_name`** — read `app.label` from `{harmony_project_dir}/AppScope/app.json5`.
|
|
64
|
+
- If it is a literal string, use it directly.
|
|
65
|
+
- If it is `$string:<name>`, resolve `<name>`: prefer a Chinese element dir (`{harmony_project_dir}/AppScope/resources/zh_CN/element/string.json`, else `zh/element/string.json`), falling back to `base/element/string.json`. Find the entry in `string[]` whose `name` equals `<name>` and use its `value`.
|
|
66
|
+
|
|
67
|
+
After resolving all four, briefly echo them to the user (e.g. `android.app_name="…", android.package="…", harmony.app_name="…", harmony.package="…"`) before starting Step 1. If any value cannot be resolved from the project dir, ask the user to supply it.
|
|
49
68
|
|
|
50
69
|
## Step 1: Capture All Related Pages on Android & HarmonyOS Devices
|
|
51
70
|
|
|
@@ -119,7 +138,7 @@ For each page <`android_page_{i}_{name}`,`hmos_page_{i}_{name}`> collected in {
|
|
|
119
138
|
Read `hmos_page_{i}_{name}` 目录下的 screenshot 和 view tree 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
|
|
120
139
|
**MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to Write the result to `hmos_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
|
|
121
140
|
if `hmos_page_{i}_{name}` is empty (no screenshots/view trees captured):
|
|
122
|
-
Read the HarmonyOS source code at `
|
|
141
|
+
Read the HarmonyOS source code at `harmony_project_dir` to find the corresponding page implementation. Analyze the source code to extract all UI components, their properties, layout structure, colors, dimensions, and text content. Create a comprehensive component table from the code analysis.
|
|
123
142
|
**MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to Write the result to `hmos_page_{i}_{name}/UI_Analysis_from_code.md`,写完后确认文件已创建。
|
|
124
143
|
**DO NOT** write a placeholder like "page not captured" — you must actually read the source code and produce a real analysis.
|
|
125
144
|
### Step 2.3 Make UI Diff Analysis and Write the Comparison Table
|
|
@@ -197,4 +216,4 @@ if available, use `hmos-fix-build-errors` skill to verify the project is compila
|
|
|
197
216
|
- Handle responsive layouts: prefer percentage widths and `Flex` over fixed dimensions where appropriate.
|
|
198
217
|
- Maintain accessibility: convert `content-desc` to `.accessibilityText()`, convert meaningful `text` to proper labels.
|
|
199
218
|
- Group related UI into `@Component` sub-components when the hierarchy is deep (> 5 nesting levels).
|
|
200
|
-
- **鸿蒙 API 可参考 `
|
|
219
|
+
- **鸿蒙 API 可参考 `OHOS_SDK_PATH` / `HMS_SDK_PATH`(HarmonyOS SDK 的 ETS 目录,取自 OS 环境变量),鸿蒙MVVM开发模式可参考`./references/MVVM开发文档/`**
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
### Diff Analysis
|
|
2
|
-
use `{android_page_info}`, `{hmos_page_info}`,`{android_project_dir}`,`{harmony_project_dir}` to make a detailed comparison on visual effects
|
|
3
|
-
|
|
4
|
-
#### Step 1: Parse Android View Hierarchy
|
|
5
|
-
|
|
6
|
-
Read `{android_page_info}/view.xml` and build a structural understanding:
|
|
7
|
-
- Parse the XML node tree to understand the full view hierarchy
|
|
8
|
-
- Identify the key structural containers (root layouts, toolbar, content area, bottom navigation)
|
|
9
|
-
- Map each Android widget node to its attributes: `class`, `resource-id`, `text`, `content-desc`, `bounds`, `clickable`, `scrollable`, `checkable`, `checked`, `enabled`
|
|
10
|
-
- Calculate layout relationships from `bounds` (parent-child containment, sibling positioning)
|
|
11
|
-
- Identify recurring patterns (list items, grid items, card layouts)
|
|
12
|
-
|
|
13
|
-
If there exist `view_scroll_n.xml` files (n = 1, 2, 3, ...), read each one and merge their structural understanding with `view.xml` (the Android UI is longer than one screen).
|
|
14
|
-
|
|
15
|
-
Read the Android `screenshot.png` (and `screenshot_scroll_n.png` if they exist) to visually understand the target UI.
|
|
16
|
-
|
|
17
|
-
Additionally, find and read the static XML layout files and Kotlin/Java code files in `{android_project_dir}` that correspond to this page. Use atomic Android components to replace user-defined and third-party components, building a **final Android structural understanding**.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
#### Step 2: Parse HarmonyOS Current State
|
|
21
|
-
|
|
22
|
-
Read the HarmonyOS view tree XML and screenshot from `{hmos_page_info}/`:
|
|
23
|
-
- Parse the HarmonyOS view hierarchy to understand the current UI structure
|
|
24
|
-
- Read the screenshot to visually understand the current state
|
|
25
|
-
|
|
26
|
-
Also read the corresponding `.ets` source file(s) in `{harmony_project_dir}` for this page:
|
|
27
|
-
- Identify the existing component structure, state variables, child components
|
|
28
|
-
- Understand how the page is currently implemented
|
|
29
|
-
|
|
30
|
-
Build a **current HarmonyOS structural understanding**.
|
|
31
|
-
|
|
32
|
-
#### Step 3: Diff Analysis
|
|
33
|
-
|
|
34
|
-
Compare the Android final structural understanding (Step 4.1) against the HarmonyOS current structural understanding (Step 4.2):
|
|
35
|
-
Android pages and Harmony pages may be running on different devices, so be robust to the differences caused by devices (e.g., 组件间的间距、截图上显示的颜色等等)
|
|
36
|
-
|
|
37
|
-
1. **Structural diff**:
|
|
38
|
-
- Missing pages/components (in Android but not in HarmonyOS)
|
|
39
|
-
- Extra pages/components (in HarmonyOS but not in Android)
|
|
40
|
-
- Wrong nesting / layout structure differences
|
|
41
|
-
- Incorrect component type mappings
|
|
42
|
-
|
|
43
|
-
2. **Visual diff**:
|
|
44
|
-
- Color mismatches (background, foreground, fill)
|
|
45
|
-
- Size / spacing differences
|
|
46
|
-
- Position / alignment issues
|
|
47
|
-
- Shape mismatches (rounded corners, borders)
|
|
48
|
-
- Text content or font differences
|
|
49
|
-
- Icon / image mismatches
|
|
50
|
-
|
|
51
|
-
3. **Interaction diff** — compare clickable elements, navigation targets, gestures
|
|
52
|
-
|
|
1
|
+
### Diff Analysis
|
|
2
|
+
use `{android_page_info}`, `{hmos_page_info}`,`{android_project_dir}`,`{harmony_project_dir}` to make a detailed comparison on visual effects
|
|
3
|
+
|
|
4
|
+
#### Step 1: Parse Android View Hierarchy
|
|
5
|
+
|
|
6
|
+
Read `{android_page_info}/view.xml` and build a structural understanding:
|
|
7
|
+
- Parse the XML node tree to understand the full view hierarchy
|
|
8
|
+
- Identify the key structural containers (root layouts, toolbar, content area, bottom navigation)
|
|
9
|
+
- Map each Android widget node to its attributes: `class`, `resource-id`, `text`, `content-desc`, `bounds`, `clickable`, `scrollable`, `checkable`, `checked`, `enabled`
|
|
10
|
+
- Calculate layout relationships from `bounds` (parent-child containment, sibling positioning)
|
|
11
|
+
- Identify recurring patterns (list items, grid items, card layouts)
|
|
12
|
+
|
|
13
|
+
If there exist `view_scroll_n.xml` files (n = 1, 2, 3, ...), read each one and merge their structural understanding with `view.xml` (the Android UI is longer than one screen).
|
|
14
|
+
|
|
15
|
+
Read the Android `screenshot.png` (and `screenshot_scroll_n.png` if they exist) to visually understand the target UI.
|
|
16
|
+
|
|
17
|
+
Additionally, find and read the static XML layout files and Kotlin/Java code files in `{android_project_dir}` that correspond to this page. Use atomic Android components to replace user-defined and third-party components, building a **final Android structural understanding**.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
#### Step 2: Parse HarmonyOS Current State
|
|
21
|
+
|
|
22
|
+
Read the HarmonyOS view tree XML and screenshot from `{hmos_page_info}/`:
|
|
23
|
+
- Parse the HarmonyOS view hierarchy to understand the current UI structure
|
|
24
|
+
- Read the screenshot to visually understand the current state
|
|
25
|
+
|
|
26
|
+
Also read the corresponding `.ets` source file(s) in `{harmony_project_dir}` for this page:
|
|
27
|
+
- Identify the existing component structure, state variables, child components
|
|
28
|
+
- Understand how the page is currently implemented
|
|
29
|
+
|
|
30
|
+
Build a **current HarmonyOS structural understanding**.
|
|
31
|
+
|
|
32
|
+
#### Step 3: Diff Analysis
|
|
33
|
+
|
|
34
|
+
Compare the Android final structural understanding (Step 4.1) against the HarmonyOS current structural understanding (Step 4.2):
|
|
35
|
+
Android pages and Harmony pages may be running on different devices, so be robust to the differences caused by devices (e.g., 组件间的间距、截图上显示的颜色等等)
|
|
36
|
+
|
|
37
|
+
1. **Structural diff**:
|
|
38
|
+
- Missing pages/components (in Android but not in HarmonyOS)
|
|
39
|
+
- Extra pages/components (in HarmonyOS but not in Android)
|
|
40
|
+
- Wrong nesting / layout structure differences
|
|
41
|
+
- Incorrect component type mappings
|
|
42
|
+
|
|
43
|
+
2. **Visual diff**:
|
|
44
|
+
- Color mismatches (background, foreground, fill)
|
|
45
|
+
- Size / spacing differences
|
|
46
|
+
- Position / alignment issues
|
|
47
|
+
- Shape mismatches (rounded corners, borders)
|
|
48
|
+
- Text content or font differences
|
|
49
|
+
- Icon / image mismatches
|
|
50
|
+
|
|
51
|
+
3. **Interaction diff** — compare clickable elements, navigation targets, gestures
|
|
52
|
+
|
|
53
53
|
Return a diff analysis report which lists all diffs
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# Page Align Insruction
|
|
2
|
-
|
|
3
|
-
Based on the diff analysis, flexibly combine editing and creation as needed — a single page may require both aligning existing code and adding new components/files:
|
|
4
|
-
|
|
5
|
-
**For existing files that need alignment:**
|
|
6
|
-
- Read the existing `.ets` file(s) for this page
|
|
7
|
-
- For each discrepancy identified in the diff, make **targeted edits** using the Edit tool:
|
|
8
|
-
- Fix layout structure mismatches (wrong container type, missing nesting)
|
|
9
|
-
- Add missing components
|
|
10
|
-
- Remove extra components that don't exist in the Android UI
|
|
11
|
-
- Fix styling (colors, sizes, spacing, shapes)
|
|
12
|
-
- Fix resource references to use correct `$r('app.xxx.yyy')`
|
|
13
|
-
|
|
14
|
-
**For new files that need to be created** (new pages, new sub-components, new viewmodels/models):
|
|
15
|
-
- Generate new `.ets` files following the conventions discovered in Phase 1:
|
|
16
|
-
- Use the same import patterns as existing pages
|
|
17
|
-
- Use the same state management patterns
|
|
18
|
-
- Reuse existing shared components from `components/`
|
|
19
|
-
- Reuse or extend existing viewmodels/models
|
|
20
|
-
- Follow the same naming conventions
|
|
21
|
-
- Write page files to `{harmony_project_dir}/entry/src/main/ets/pages/`
|
|
22
|
-
- Write component files to `{harmony_project_dir}/entry/src/main/ets/components/`
|
|
23
|
-
- Write viewmodel files to `{harmony_project_dir}/entry/src/main/ets/viewmodel/`
|
|
24
|
-
- Write model files to `{harmony_project_dir}/entry/src/main/ets/model/`
|
|
25
|
-
- Register any new page in the router configuration
|
|
26
|
-
|
|
27
|
-
## For all changes, apply these conversion rules:
|
|
28
|
-
|
|
29
|
-
**Resource Conversion:**
|
|
30
|
-
- For each resource referenced by the Android UI, find the corresponding mapping in `{harmony_project_dir}/entry/src/main/resources`
|
|
31
|
-
- If a needed resource does not exist, use the **`hmos-resources-convert`** skill to convert it
|
|
32
|
-
|
|
33
|
-
**Layout Conversion:**
|
|
34
|
-
- Consult `./references/android-to-harmonyOS-ui-layout-mapping-reference.md` for all layout container mappings and layout attribute mappings
|
|
35
|
-
- Apply the layout property mappings (e.g., `layout_weight` → `.layoutWeight()`, `padding` → `.padding()`, visibility handling, etc.)
|
|
36
|
-
|
|
37
|
-
**Widget Conversion:**
|
|
38
|
-
- Consult `./references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md` for all atomic widget mappings
|
|
39
|
-
- Apply the detailed attribute-level mappings for each component
|
|
40
|
-
|
|
41
|
-
**Interaction Conversion:**
|
|
42
|
-
- Consult `./references/android-to-harmonyOS-ui-interaction-mapping-reference.md` for all event and gesture mappings
|
|
43
|
-
- Apply touch event mappings, click event mappings, gesture mappings, and animation mappings
|
|
44
|
-
|
|
45
|
-
**Always consult the reference files first** — they contain project-specific and comprehensive mappings that take priority over built-in knowledge.
|
|
46
|
-
|
|
47
|
-
**Styling Conversion:**
|
|
48
|
-
- Android `dp` → HarmonyOS `vp`
|
|
49
|
-
- Android `sp` → HarmonyOS `fp`
|
|
50
|
-
- Calculate dimensions from `bounds` in the XML: `width = x2 - x1`, `height = y2 - y1`
|
|
51
|
-
- Convert absolute pixel values to `vp` using the device density (assume 3x density: `1vp ≈ 3px`)
|
|
52
|
-
- Use `$r('app.color.xxx')` for colors when available in the resource list
|
|
53
|
-
- Use `$r('app.string.xxx')` for text strings when available in the resource list
|
|
54
|
-
- Use `$r('app.media.xxx')` for images when available in the resource list
|
|
55
|
-
|
|
56
|
-
**Router Conversion:**
|
|
57
|
-
- Convert router relationships among UIs and components
|
|
58
|
-
- Register new page routes in the router configuration when new pages are created
|
|
59
|
-
- Fix any incorrect router targets in existing pages
|
|
60
|
-
|
|
61
|
-
**Interactive Elements:**
|
|
62
|
-
- **Prefer real implementation over mocking**: before mocking any click event, navigation jump, or interaction, first check whether the target component or page already exists in the HarmonyOS project. If the target is already implemented, wire up the real event handler (e.g., actual `router.pushUrl()` with the correct page path). **Only mock when the related component or page has not yet been implemented** — in that case, use placeholder implementations to ensure the program compiles (e.g., `console.info('TODO: navigate to SettingsActivity — target page not yet implemented')`)
|
|
1
|
+
# Page Align Insruction
|
|
2
|
+
|
|
3
|
+
Based on the diff analysis, flexibly combine editing and creation as needed — a single page may require both aligning existing code and adding new components/files:
|
|
4
|
+
|
|
5
|
+
**For existing files that need alignment:**
|
|
6
|
+
- Read the existing `.ets` file(s) for this page
|
|
7
|
+
- For each discrepancy identified in the diff, make **targeted edits** using the Edit tool:
|
|
8
|
+
- Fix layout structure mismatches (wrong container type, missing nesting)
|
|
9
|
+
- Add missing components
|
|
10
|
+
- Remove extra components that don't exist in the Android UI
|
|
11
|
+
- Fix styling (colors, sizes, spacing, shapes)
|
|
12
|
+
- Fix resource references to use correct `$r('app.xxx.yyy')`
|
|
13
|
+
|
|
14
|
+
**For new files that need to be created** (new pages, new sub-components, new viewmodels/models):
|
|
15
|
+
- Generate new `.ets` files following the conventions discovered in Phase 1:
|
|
16
|
+
- Use the same import patterns as existing pages
|
|
17
|
+
- Use the same state management patterns
|
|
18
|
+
- Reuse existing shared components from `components/`
|
|
19
|
+
- Reuse or extend existing viewmodels/models
|
|
20
|
+
- Follow the same naming conventions
|
|
21
|
+
- Write page files to `{harmony_project_dir}/entry/src/main/ets/pages/`
|
|
22
|
+
- Write component files to `{harmony_project_dir}/entry/src/main/ets/components/`
|
|
23
|
+
- Write viewmodel files to `{harmony_project_dir}/entry/src/main/ets/viewmodel/`
|
|
24
|
+
- Write model files to `{harmony_project_dir}/entry/src/main/ets/model/`
|
|
25
|
+
- Register any new page in the router configuration
|
|
26
|
+
|
|
27
|
+
## For all changes, apply these conversion rules:
|
|
28
|
+
|
|
29
|
+
**Resource Conversion:**
|
|
30
|
+
- For each resource referenced by the Android UI, find the corresponding mapping in `{harmony_project_dir}/entry/src/main/resources`
|
|
31
|
+
- If a needed resource does not exist, use the **`hmos-resources-convert`** skill to convert it
|
|
32
|
+
|
|
33
|
+
**Layout Conversion:**
|
|
34
|
+
- Consult `./references/android-to-harmonyOS-ui-layout-mapping-reference.md` for all layout container mappings and layout attribute mappings
|
|
35
|
+
- Apply the layout property mappings (e.g., `layout_weight` → `.layoutWeight()`, `padding` → `.padding()`, visibility handling, etc.)
|
|
36
|
+
|
|
37
|
+
**Widget Conversion:**
|
|
38
|
+
- Consult `./references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md` for all atomic widget mappings
|
|
39
|
+
- Apply the detailed attribute-level mappings for each component
|
|
40
|
+
|
|
41
|
+
**Interaction Conversion:**
|
|
42
|
+
- Consult `./references/android-to-harmonyOS-ui-interaction-mapping-reference.md` for all event and gesture mappings
|
|
43
|
+
- Apply touch event mappings, click event mappings, gesture mappings, and animation mappings
|
|
44
|
+
|
|
45
|
+
**Always consult the reference files first** — they contain project-specific and comprehensive mappings that take priority over built-in knowledge.
|
|
46
|
+
|
|
47
|
+
**Styling Conversion:**
|
|
48
|
+
- Android `dp` → HarmonyOS `vp`
|
|
49
|
+
- Android `sp` → HarmonyOS `fp`
|
|
50
|
+
- Calculate dimensions from `bounds` in the XML: `width = x2 - x1`, `height = y2 - y1`
|
|
51
|
+
- Convert absolute pixel values to `vp` using the device density (assume 3x density: `1vp ≈ 3px`)
|
|
52
|
+
- Use `$r('app.color.xxx')` for colors when available in the resource list
|
|
53
|
+
- Use `$r('app.string.xxx')` for text strings when available in the resource list
|
|
54
|
+
- Use `$r('app.media.xxx')` for images when available in the resource list
|
|
55
|
+
|
|
56
|
+
**Router Conversion:**
|
|
57
|
+
- Convert router relationships among UIs and components
|
|
58
|
+
- Register new page routes in the router configuration when new pages are created
|
|
59
|
+
- Fix any incorrect router targets in existing pages
|
|
60
|
+
|
|
61
|
+
**Interactive Elements:**
|
|
62
|
+
- **Prefer real implementation over mocking**: before mocking any click event, navigation jump, or interaction, first check whether the target component or page already exists in the HarmonyOS project. If the target is already implemented, wire up the real event handler (e.g., actual `router.pushUrl()` with the correct page path). **Only mock when the related component or page has not yet been implemented** — in that case, use placeholder implementations to ensure the program compiles (e.g., `console.info('TODO: navigate to SettingsActivity — target page not yet implemented')`)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
| UI Component | 文本内容 | 尺寸与布局 | 颜色与背景 | 边框与轮廓 | 文本样式 | 变换与效果 | 状态与交互反馈 | Diff |
|
|
2
|
-
|:-------------|:-----|:------|:------|:------|:-----|:------|:--------|:--------|
|
|
1
|
+
| UI Component | 文本内容 | 尺寸与布局 | 颜色与背景 | 边框与轮廓 | 文本样式 | 变换与效果 | 状态与交互反馈 | Diff |
|
|
2
|
+
|:-------------|:-----|:------|:------|:------|:-----|:------|:--------|:--------|
|