@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.
Files changed (86) hide show
  1. package/README.md +164 -112
  2. package/agents/build-fixer.md +384 -394
  3. package/agents/code-reviewer.md +240 -240
  4. package/agents/logic-coder.md +199 -199
  5. package/agents/logic-context-builder.md +194 -194
  6. package/agents/review-fixer.md +405 -405
  7. package/agents/self-test-fixer.md +296 -296
  8. package/agents/self-tester.md +393 -392
  9. package/agents/spec-generator.md +540 -540
  10. package/dist/cli/config-store.js +84 -8
  11. package/dist/cli/config.js +3 -3
  12. package/dist/cli/env-vars.js +129 -0
  13. package/dist/cli/init.js +272 -272
  14. package/dist/cli/uninstall.js +152 -17
  15. package/dist/context/index.js +10 -197
  16. package/env-requirements.json +3 -3
  17. package/package.json +1 -1
  18. package/resource/choose_editor.png +0 -0
  19. package/resource/common_config.png +0 -0
  20. package/resource/integration_test_config.png +0 -0
  21. package/resource/set_env.png +0 -0
  22. package/resource/ui_align_config.png +0 -0
  23. package/skills/hmos-batch-ui-align/SKILL.md +108 -98
  24. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +180 -180
  25. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  26. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  27. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  39. 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
  40. 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
  41. package/skills/hmos-convert-pipeline/SKILL.md +429 -415
  42. package/skills/hmos-fix-build-errors/SKILL.md +272 -273
  43. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
  44. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
  45. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
  46. package/skills/hmos-incremental-ui-align/SKILL.md +219 -200
  47. package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
  48. package/skills/hmos-incremental-ui-align/page_align.md +62 -62
  49. package/skills/hmos-incremental-ui-align/readme.md +237 -230
  50. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +2 -2
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. 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
  61. 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
  62. 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
  63. 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
  64. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +3 -3
  65. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  66. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  67. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  68. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +37 -37
  69. package/skills/hmos-integration-test/SKILL.md +380 -369
  70. package/skills/hmos-integration-test/readme.md +309 -309
  71. package/skills/hmos-resources-convert/SKILL.md +623 -623
  72. package/skills/hmos-resources-convert/references/conversion-rules.md +663 -663
  73. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -388
  74. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -457
  75. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -513
  76. package/skills/hmos-spec-generate/SKILL.md +331 -331
  77. package/skills/hmos-spec-generate/references/android-platform-tokens.md +105 -105
  78. package/skills/hmos-spec-generate/references/spec-sample-1.md +78 -78
  79. package/skills/hmos-spec-generate/references/spec-sample-2.md +58 -58
  80. package/skills/hmos-spec-generate/references/spec-sample-3.md +116 -116
  81. package/skills/hmos-spec-generate/references/step4-report-template.md +33 -33
  82. package/tools/test-tools/autotest/README.md +33 -17
  83. package/tools/test-tools/autotest/self_test_runner.py +109 -15
  84. package/resource/hometrans_config.png +0 -0
  85. package/skills/hmos-incremental-ui-align/config-example.json +0 -11
  86. package/tools/test-tools/autotest/config.yaml.example +0 -58
@@ -1,200 +1,219 @@
1
- ---
2
- name: hmos-incremental-ui-align
3
- description: "Automated HarmonyOS-Android UI alignment pipeline. Takes a natural language task description, automatically navigates to the target pages on both Android and HarmonyOS devices, captures view trees and screenshots, then aligns HarmonyOS code to match Android. Use this skill whenever the user wants to align a HarmonyOS page with its Android counterpart, fix visual differences between Android and HarmonyOS, add missing HarmonyOS pages based on Android, or describes a page path like '首页-设置-关于' that needs UI alignment. Also trigger on phrases like 'UI对齐', '页面对齐', '和安卓对齐', '鸿蒙页面修复','UI增量开发','align HarmonyOS with Android', or any request involving comparing and fixing HarmonyOS UI to match Android."
4
- ---
5
-
6
- # HarmonyOS-Android UI Alignment
7
- You are a senior engineer proficient in Android and HarmonyOS app development, with expertise in HarmonyOS technologies such as ArkTS and ArkUI.
8
- You must follow the pipeline in this document, executing the steps one by one.
9
- You are writing ArkTS codes.
10
-
11
- # Rules
12
- - Use Mock Data unless the user tell you to implement/align the feature together**
13
- - you can not start Step 2 until Step 1 is completely finished
14
- - Do not proceed to Step 3 until every page pair has its `UI_comparison.md` written in Step 2
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
- - 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:
21
-
22
- 1. **`config-path` argument** if the user provided one (e.g., `config-path: D:\path\to\config.json`).
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.
25
-
26
- Verify the resolved file with a Read; if it's missing or unreadable, fall through to the next source (or ask the user). Refer to `config-example.json` in this skill's directory for the expected schema.
27
-
28
- Config fields:
29
-
30
- | Field | Description |
31
- |---|---|
32
- | `android.app_name` | Android app name for navigation |
33
- | `android.package` | Android app package name |
34
- | `android.project_dir` | Android source code root path |
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 |
41
-
42
- **Fallbacks for `hmos_sdk_dir` and `glm_api_key`** when empty or missing in the resolved config — stop at the first hit:
43
-
44
- 1. `~/.hometrans/config.json` (on Windows `%USERPROFILE%\.hometrans\config.json`): `hmos_sdk_dir` = `<env.DEVECO_SDK_HOME>/default`; `glm_api_key` = `env.GLM_API_KEY`.
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).
47
-
48
- Validate that `hmos_sdk_dir` exists on disk before use; if it doesn't, continue down the fallback list.
49
-
50
- ## Step 1: Capture All Related Pages on Android & HarmonyOS Devices
51
-
52
- Read `scripts/navigation-capure.md` to learn the usage of `scripts/app_feature_verify.py` (navigation) and `scripts/page_capture.py` (capture).
53
-
54
- ### Step 1.1: Parse User Request and Build Capture Plan
55
- Analyze the user's description and build a list of **base pages** to capture.
56
- - **Specific path** (e.g., "首页 → 设置 → 关于"): add it directly as a base page with the given click path.
57
- - **Ambiguous scope** (e.g., "播放列表歌曲页的所有二级弹窗"): identify one determinable base page first interactive sub-states (tabs, popups, etc.) will be discovered automatically in Step 1.3.
58
-
59
- For each base page, define:
60
- - `page_name`: short identifier (e.g., `enterprise_detail`)
61
- - `android_nav_path` / `hmos_nav_path`: the navigation prompt for each device
62
-
63
- Create the timestamped output directory and per-page sub-directories following the pattern in `scripts/navigation-capure.md`.
64
-
65
- ### Step 1.2: Capture Base Pages
66
- For each base page in the plan, on **both** Android and HarmonyOS devices:
67
- 1. Use `scripts/app_feature_verify.py` to navigate to the page.
68
- 2. On success, use `scripts/page_capture.py` to capture the view tree and screenshot.
69
- 3. For HarmonyOS pages that don't exist yet, navigation will fail — leave the directory empty (expected).
70
-
71
- ### Step 1.3: Discover and Capture Interactive States
72
- After capturing each base page, scan its view tree for **interactive elements that change the visible UI**, including but not limited to:
73
- - Tabs / Segmented controls (each tab shows different content)
74
- - Filter / Sort / Dropdown trigger buttons (clicking opens a popup, bottom sheet, or dropdown)
75
- - Expandable / Collapsible sections ("展开"/"收起", accordion)
76
- - Any other clickable element that reveals content not visible in the current capture (toggle, switch-mode button, etc.)
77
-
78
- **For each interactive element found:**
79
- 1. Create a separate capture directory: `{platform}_page_{i}_{base_name}_{state_type}_{state_name}` (e.g., `android_page_1_detail_tab_city`, `android_page_1_detail_popup_filter_identity`).
80
- 2. Navigate to the base page (reuse the same nav path), then append the click action to trigger the state change. Capture with `scripts/page_capture.py`.
81
- 3. Repeat for **both** Android and HarmonyOS devices.
82
- 4. Each captured state is treated as a separate page pair in Step 2 and Step 3.
83
-
84
- **Skip condition**: Only skip this step for a specific page if the user explicitly says to ignore interactive states (e.g., "只对齐主页面,不管弹窗和tab").
85
-
86
- ### Navigation Rules (apply to all capture operations in Step 1)
87
-
88
- **Click path extraction**: do not replace or translate key operations of hdc/adb (such as drag, swipe).
89
- **When navigation fails**:
90
- Firstly, make sure whether the page exists, then:
91
- 1. Page does not exist record the result and skip the capture.
92
- 2. Page exists but click path is wrong → force-stop and restart the app, retry with the corrected path.
93
- 3. Page exists, path is correct, but the tool reports failure review the screenshot yourself and decide whether the target was actually reached.
94
- **Must Remember**: Do not skip any page on Android/HarmonyOS unless navigation fails more than twice.
95
-
96
- ## Step 2: UI Diff Analysis
97
-
98
- **CRITICAL RULES for Step 2**:
99
- - Android `UI_Analysis.md` MUST be generated for EVERY page, even if HarmonyOS capture is empty
100
- - HarmonyOS `UI_Analysis.md` (or `UI_Analysis_from_code.md`) MUST be generated for EVERY page
101
- - `UI_comparison.md` MUST contain a real markdown diff table (not just a status note)
102
-
103
- **Dimension rule (applies to Step 2.1, 2.2, and 2.3)**:
104
- All size/position values must include:
105
- - raw px value (from view tree bounds)
106
- - device density (e.g. 3x)
107
- - converted dp/vp value (px ÷ density)
108
- Format: "126px (3x → 42vp)". Never write bare px or vp without the other.
109
- **MANDATORY OUTPUT**: Write the result to `android_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
110
- **This step is NEVER skippable** even if the HarmonyOS counterpart is empty, the Android analysis must still be written.
111
-
112
- For each page <`android_page_{i}_{name}`,`hmos_page_{i}_{name}`> collected in {Step 1}, write UI Analysis using the Analysis Template in `references/UI_Analysis_Template.md`:
113
- ### Step 2.1 UI Analysis of `android_page_{i}_{name}`
114
- Read `android_page_{i}_{name}` 目录下的 screenshot(_n) 和 view tree(_n) 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
115
- **MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to write the result to `android_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
116
-
117
- ### Step 2.2 UI Analysis of `hmos_page_{i}_{name}`
118
- if `hmos_page_{i}_{name}` has screenshots and view trees:
119
- Read `hmos_page_{i}_{name}` 目录下的 screenshot view tree 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
120
- **MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to Write the result to `hmos_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
121
- if `hmos_page_{i}_{name}` is empty (no screenshots/view trees captured):
122
- 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
- **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
- **DO NOT** write a placeholder like "page not captured" — you must actually read the source code and produce a real analysis.
125
- ### Step 2.3 Make UI Diff Analysis and Write the Comparison Table
126
- **Input requirement**: You MUST Read the already-written `android_page_{i}_{name}/UI_Analysis.md` and `hmos_page_{i}_{name}/UI_Analysis.md` (or `UI_Analysis_from_code.md`) files using the Read tool before writing the comparison. Do NOT generate the comparison from raw view trees, screenshots, or source code directly — the comparison must be derived from the two Analysis documents.
127
-
128
- Using `android_page_{i}_{name}/UI_Analysis.md` as the ground truth, compare the detailed differences of each component between `android_page_{i}_{name}/UI_Analysis.md` and `hmos_page_{i}_{name}/UI_Analysis.md` (or `hmos_page_{i}_{name}/UI_Analysis_from_code.md` if hmos page was empty), and list them in a table like `references/Comparison_Template.md`
129
-
130
- **Quality requirement for UI_comparison.md**:
131
- - The file MUST contain a markdown table with `|` delimiters listing every component
132
- - If HarmonyOS page is missing entirely, each diff column must state the Android target value as the implementation spec, not just "缺失". Format: "HarmonyOS: 缺失 → 目标: {Android的具体值}". Example: Alignment Diff = "HarmonyOS: 缺失 → 目标: 左对齐". Example: Text Color Diff = "HarmonyOS: 缺失 → 目标: #333333". A column that only says "缺失" without a target value is INVALID.
133
- - A comparison that only says "page not captured" or "needs implementation" without a component-level table is INVALID
134
-
135
- **MANDATORY OUTPUT**: Write the comparison table into `hmos_page_{i}_{name}/UI_comparison.md`
136
-
137
- ### Step 2.4 Output Verification (Main Agent)
138
- MUST verify:
139
- 1. Use Glob to list all `**/UI_Analysis*.md` files confirm one exists for every `android_page_*` and every `hmos_page_*` directory
140
- 2. Use Glob to list all `**/UI_comparison.md` files confirm one exists for every `hmos_page_*` directory
141
- 3. For each `UI_comparison.md`, Read the first 10 lines and confirm it contains a markdown table (has `|` characters)
142
- 4. If ANY file is missing or invalid, re-run Step 2 for that specific page pair before proceeding
143
-
144
- ## Step 3: Fix UI Diffs or Implement Missed Pages (MainAgent)
145
-
146
- **CHECKPOINT — before proceeding, you MUST**:
147
- 1. For every page pair, use the Read tool to open `hmos_page_{i}_{name}/UI_comparison.md` and confirm it exists and contains a markdown diff table (has `|` delimiters with component rows).
148
- 2. If any `UI_comparison.md` is missing or contains only a status note without a component table, go back to Step 2 and complete it. For pages where HarmonyOS was not captured, read the source code to generate `UI_Analysis_from_code.md` first, then regenerate the comparison with a proper component-level diff table.
149
- 3. Extract EVERY diff items from ALL comparison tables and write them into `{task_dir}/fix_checklist.md` in this format:
150
- ```
151
- # Fix Checklist
152
- ## Page 1: {name}
153
- - [ ] {diff description 1}
154
- - [ ] {diff description 2}
155
- - [ ] {diff description 3}
156
- ## Page 2: {name}
157
- - [ ] {diff description 1}
158
- ...
159
- ```
160
- This checklist is your single source of truth for what needs to be fixed.
161
-
162
- ### Step 3.1: Analyze Project Architecture and load knowledge (Main Agent)
163
- 1. understand the existing HarmonyOS project's architecture, analyze existing patterns and identify {reusable components}.
164
- 2. read `./references/MVVM开发文档/MVVM模式V1.md` to understand the MVVM mode
165
- **Note**: If mock data is required, add them in **Model Layer** according to the MVVM mode.
166
-
167
- ### Step 3.2: Learn typical transformation rules
168
- read `page_align.md` to learn typical transformation rules
169
-
170
- ### Step 3.3 Fix all Diffs
171
- Read `{task_dir}/fix_checklist.md` and **Fix Every Diffs (No Matter significant or minor)**,
172
- Use {reusable components} if it is available and has been aligned with Android
173
- Following the MVVM mode
174
-
175
- **Value tracing rule**: Before fixing any dimension/size/icon-size/alignment diff, you MUST trace the target value back to Android source code (layout XML `layout_width`/`layout_height`/`padding`/`src`, drawable intrinsic size, or style definition). Write the source reference (file:line or resource name) next to the checklist item. Estimating from screenshots or "looks about right" is NOT acceptable — if the Android source cannot be located, flag the item and ask the user.
176
- **Alignment rule**: When implementing a new component or fixing an existing one, explicitly set alignment/justification for EVERY text and container element. Copy the alignment value directly from the Android UI_Analysis.md (e.g., "左对齐" → `.textAlign(TextAlign.Start)` + `.width('100%')`). Never rely on default alignment — always set it explicitly.
177
- **After fixing each diff, update `fix_checklist.md`**: change `- [ ]` to `- [x]` for the completed item.
178
- **CRITICAL RULE**:
179
- - Do not skip any diff item in `fix_checklist.md`, regardless of the priority.
180
- - Fixing compile errors does NOT count as fixing UI diffs. After the build passes, you MUST return to `fix_checklist.md` and continue fixing any remaining unchecked items. The task is not complete until every item in the checklist is marked `[x]`.
181
-
182
- ### Step 3.4 Final Checklist Review
183
- Read `fix_checklist.md` and verify every item is marked `[x]`. If any items remain unchecked:
184
- 1. List the unchecked items
185
- 2. For each, explain why it was not fixed (blocked by missing API, requires backend, etc.) or fix it now
186
- 3. Items that genuinely cannot be fixed should be marked with `- [~]` and a reason
187
-
188
- ## Step 4 validate and build (Main Agent)
189
- if available, use `hmos-fix-build-errors` skill to verify the project is compilable, do not deploy.
190
-
191
- ## Guidelines
192
- - **Preserve existing code**: When editing existing files, make targeted edits — never rewrite an entire file from scratch. Respect the existing code structure, variable names, and patterns.
193
- - **Follow existing conventions**: All new code must match the HarmonyOS project's established naming conventions, import patterns, state management approach, and component composition style.
194
- - **Reuse rather than creating**: Always check for existing shared components, viewmodels, and models before creating new ones.
195
- - **Resource references must match exactly**: every color, string, dimension, image, and other resource used in the Android source must have a corresponding HarmonyOS resource. Do not hardcode values.
196
- - Use `$r('app.type.name')` for all resource references available in the resource list.
197
- - Handle responsive layouts: prefer percentage widths and `Flex` over fixed dimensions where appropriate.
198
- - Maintain accessibility: convert `content-desc` to `.accessibilityText()`, convert meaningful `text` to proper labels.
199
- - Group related UI into `@Component` sub-components when the hierarchy is deep (> 5 nesting levels).
200
- - **鸿蒙 API 可参考 `{hmos_sdk_dir}`, 鸿蒙MVVM开发模式可参考`./references/MVVM开发文档/`**
1
+ ---
2
+ name: hmos-incremental-ui-align
3
+ description: "Automated HarmonyOS-Android UI alignment pipeline. Takes a natural language task description, automatically navigates to the target pages on both Android and HarmonyOS devices, captures view trees and screenshots, then aligns HarmonyOS code to match Android. Use this skill whenever the user wants to align a HarmonyOS page with its Android counterpart, fix visual differences between Android and HarmonyOS, add missing HarmonyOS pages based on Android, or describes a page path like '首页-设置-关于' that needs UI alignment. Also trigger on phrases like 'UI对齐', '页面对齐', '和安卓对齐', '鸿蒙页面修复','UI增量开发','align HarmonyOS with Android', or any request involving comparing and fixing HarmonyOS UI to match Android."
4
+ ---
5
+
6
+ # HarmonyOS-Android UI Alignment
7
+ You are a senior engineer proficient in Android and HarmonyOS app development, with expertise in HarmonyOS technologies such as ArkTS and ArkUI.
8
+ You must follow the pipeline in this document, executing the steps one by one.
9
+ You are writing ArkTS codes.
10
+
11
+ # Rules
12
+ - Use Mock Data unless the user tell you to implement/align the feature together**
13
+ - you can not start Step 2 until Step 1 is completely finished
14
+ - Do not proceed to Step 3 until every page pair has its `UI_comparison.md` written in Step 2
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
+ - If mock data is required, write them in `{harmony_project_dir}/entry/src/main/ets/model/` according to the hmos MVVM mode.
17
+ - Do not make any other changes unrelated to the user's requirements.
18
+
19
+ ## Step 0: Resolve Inputs
20
+
21
+ This skill takes three path inputs from the invocation and reads its other settings **directly from the OS environment variables**.
22
+
23
+ ### Skill input arguments (provided by the user when invoking the skill)
24
+
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 |
30
+
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.
32
+
33
+ ### Step 0.0: Environment Variables Check (run first)
34
+
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.
68
+
69
+ ## Step 1: Capture All Related Pages on Android & HarmonyOS Devices
70
+
71
+ Read `scripts/navigation-capure.md` to learn the usage of `scripts/app_feature_verify.py` (navigation) and `scripts/page_capture.py` (capture).
72
+
73
+ ### Step 1.1: Parse User Request and Build Capture Plan
74
+ Analyze the user's description and build a list of **base pages** to capture.
75
+ - **Specific path** (e.g., "首页 → 设置 → 关于"): add it directly as a base page with the given click path.
76
+ - **Ambiguous scope** (e.g., "播放列表歌曲页的所有二级弹窗"): identify one determinable base page first interactive sub-states (tabs, popups, etc.) will be discovered automatically in Step 1.3.
77
+
78
+ For each base page, define:
79
+ - `page_name`: short identifier (e.g., `enterprise_detail`)
80
+ - `android_nav_path` / `hmos_nav_path`: the navigation prompt for each device
81
+
82
+ Create the timestamped output directory and per-page sub-directories following the pattern in `scripts/navigation-capure.md`.
83
+
84
+ ### Step 1.2: Capture Base Pages
85
+ For each base page in the plan, on **both** Android and HarmonyOS devices:
86
+ 1. Use `scripts/app_feature_verify.py` to navigate to the page.
87
+ 2. On success, use `scripts/page_capture.py` to capture the view tree and screenshot.
88
+ 3. For HarmonyOS pages that don't exist yet, navigation will fail leave the directory empty (expected).
89
+
90
+ ### Step 1.3: Discover and Capture Interactive States
91
+ After capturing each base page, scan its view tree for **interactive elements that change the visible UI**, including but not limited to:
92
+ - Tabs / Segmented controls (each tab shows different content)
93
+ - Filter / Sort / Dropdown trigger buttons (clicking opens a popup, bottom sheet, or dropdown)
94
+ - Expandable / Collapsible sections ("展开"/"收起", accordion)
95
+ - Any other clickable element that reveals content not visible in the current capture (toggle, switch-mode button, etc.)
96
+
97
+ **For each interactive element found:**
98
+ 1. Create a separate capture directory: `{platform}_page_{i}_{base_name}_{state_type}_{state_name}` (e.g., `android_page_1_detail_tab_city`, `android_page_1_detail_popup_filter_identity`).
99
+ 2. Navigate to the base page (reuse the same nav path), then append the click action to trigger the state change. Capture with `scripts/page_capture.py`.
100
+ 3. Repeat for **both** Android and HarmonyOS devices.
101
+ 4. Each captured state is treated as a separate page pair in Step 2 and Step 3.
102
+
103
+ **Skip condition**: Only skip this step for a specific page if the user explicitly says to ignore interactive states (e.g., "只对齐主页面,不管弹窗和tab").
104
+
105
+ ### Navigation Rules (apply to all capture operations in Step 1)
106
+
107
+ **Click path extraction**: do not replace or translate key operations of hdc/adb (such as drag, swipe).
108
+ **When navigation fails**:
109
+ Firstly, make sure whether the page exists, then:
110
+ 1. Page does not exist record the result and skip the capture.
111
+ 2. Page exists but click path is wrong → force-stop and restart the app, retry with the corrected path.
112
+ 3. Page exists, path is correct, but the tool reports failure → review the screenshot yourself and decide whether the target was actually reached.
113
+ **Must Remember**: Do not skip any page on Android/HarmonyOS unless navigation fails more than twice.
114
+
115
+ ## Step 2: UI Diff Analysis
116
+
117
+ **CRITICAL RULES for Step 2**:
118
+ - Android `UI_Analysis.md` MUST be generated for EVERY page, even if HarmonyOS capture is empty
119
+ - HarmonyOS `UI_Analysis.md` (or `UI_Analysis_from_code.md`) MUST be generated for EVERY page
120
+ - `UI_comparison.md` MUST contain a real markdown diff table (not just a status note)
121
+
122
+ **Dimension rule (applies to Step 2.1, 2.2, and 2.3)**:
123
+ All size/position values must include:
124
+ - raw px value (from view tree bounds)
125
+ - device density (e.g. 3x)
126
+ - converted dp/vp value (px ÷ density)
127
+ Format: "126px (3x → 42vp)". Never write bare px or vp without the other.
128
+ **MANDATORY OUTPUT**: Write the result to `android_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
129
+ **This step is NEVER skippable** — even if the HarmonyOS counterpart is empty, the Android analysis must still be written.
130
+
131
+ For each page <`android_page_{i}_{name}`,`hmos_page_{i}_{name}`> collected in {Step 1}, write UI Analysis using the Analysis Template in `references/UI_Analysis_Template.md`:
132
+ ### Step 2.1 UI Analysis of `android_page_{i}_{name}`
133
+ Read `android_page_{i}_{name}` 目录下的 screenshot(_n) view tree(_n) 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
134
+ **MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to write the result to `android_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
135
+
136
+ ### Step 2.2 UI Analysis of `hmos_page_{i}_{name}`
137
+ if `hmos_page_{i}_{name}` has screenshots and view trees:
138
+ Read `hmos_page_{i}_{name}` 目录下的 screenshot 和 view tree 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
139
+ **MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to Write the result to `hmos_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
140
+ if `hmos_page_{i}_{name}` is empty (no screenshots/view trees captured):
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.
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`,写完后确认文件已创建。
143
+ **DO NOT** write a placeholder like "page not captured" — you must actually read the source code and produce a real analysis.
144
+ ### Step 2.3 Make UI Diff Analysis and Write the Comparison Table
145
+ **Input requirement**: You MUST Read the already-written `android_page_{i}_{name}/UI_Analysis.md` and `hmos_page_{i}_{name}/UI_Analysis.md` (or `UI_Analysis_from_code.md`) files using the Read tool before writing the comparison. Do NOT generate the comparison from raw view trees, screenshots, or source code directly — the comparison must be derived from the two Analysis documents.
146
+
147
+ Using `android_page_{i}_{name}/UI_Analysis.md` as the ground truth, compare the detailed differences of each component between `android_page_{i}_{name}/UI_Analysis.md` and `hmos_page_{i}_{name}/UI_Analysis.md` (or `hmos_page_{i}_{name}/UI_Analysis_from_code.md` if hmos page was empty), and list them in a table like `references/Comparison_Template.md`
148
+
149
+ **Quality requirement for UI_comparison.md**:
150
+ - The file MUST contain a markdown table with `|` delimiters listing every component
151
+ - If HarmonyOS page is missing entirely, each diff column must state the Android target value as the implementation spec, not just "缺失". Format: "HarmonyOS: 缺失 → 目标: {Android的具体值}". Example: Alignment Diff = "HarmonyOS: 缺失 → 目标: 左对齐". Example: Text Color Diff = "HarmonyOS: 缺失 → 目标: #333333". A column that only says "缺失" without a target value is INVALID.
152
+ - A comparison that only says "page not captured" or "needs implementation" without a component-level table is INVALID
153
+
154
+ **MANDATORY OUTPUT**: Write the comparison table into `hmos_page_{i}_{name}/UI_comparison.md`
155
+
156
+ ### Step 2.4 Output Verification (Main Agent)
157
+ MUST verify:
158
+ 1. Use Glob to list all `**/UI_Analysis*.md` files — confirm one exists for every `android_page_*` and every `hmos_page_*` directory
159
+ 2. Use Glob to list all `**/UI_comparison.md` files — confirm one exists for every `hmos_page_*` directory
160
+ 3. For each `UI_comparison.md`, Read the first 10 lines and confirm it contains a markdown table (has `|` characters)
161
+ 4. If ANY file is missing or invalid, re-run Step 2 for that specific page pair before proceeding
162
+
163
+ ## Step 3: Fix UI Diffs or Implement Missed Pages (MainAgent)
164
+
165
+ **CHECKPOINT before proceeding, you MUST**:
166
+ 1. For every page pair, use the Read tool to open `hmos_page_{i}_{name}/UI_comparison.md` and confirm it exists and contains a markdown diff table (has `|` delimiters with component rows).
167
+ 2. If any `UI_comparison.md` is missing or contains only a status note without a component table, go back to Step 2 and complete it. For pages where HarmonyOS was not captured, read the source code to generate `UI_Analysis_from_code.md` first, then regenerate the comparison with a proper component-level diff table.
168
+ 3. Extract EVERY diff items from ALL comparison tables and write them into `{task_dir}/fix_checklist.md` in this format:
169
+ ```
170
+ # Fix Checklist
171
+ ## Page 1: {name}
172
+ - [ ] {diff description 1}
173
+ - [ ] {diff description 2}
174
+ - [ ] {diff description 3}
175
+ ## Page 2: {name}
176
+ - [ ] {diff description 1}
177
+ ...
178
+ ```
179
+ This checklist is your single source of truth for what needs to be fixed.
180
+
181
+ ### Step 3.1: Analyze Project Architecture and load knowledge (Main Agent)
182
+ 1. understand the existing HarmonyOS project's architecture, analyze existing patterns and identify {reusable components}.
183
+ 2. read `./references/MVVM开发文档/MVVM模式V1.md` to understand the MVVM mode
184
+ **Note**: If mock data is required, add them in **Model Layer** according to the MVVM mode.
185
+
186
+ ### Step 3.2: Learn typical transformation rules
187
+ read `page_align.md` to learn typical transformation rules
188
+
189
+ ### Step 3.3 Fix all Diffs
190
+ Read `{task_dir}/fix_checklist.md` and **Fix Every Diffs (No Matter significant or minor)**,
191
+ Use {reusable components} if it is available and has been aligned with Android
192
+ Following the MVVM mode
193
+
194
+ **Value tracing rule**: Before fixing any dimension/size/icon-size/alignment diff, you MUST trace the target value back to Android source code (layout XML `layout_width`/`layout_height`/`padding`/`src`, drawable intrinsic size, or style definition). Write the source reference (file:line or resource name) next to the checklist item. Estimating from screenshots or "looks about right" is NOT acceptable — if the Android source cannot be located, flag the item and ask the user.
195
+ **Alignment rule**: When implementing a new component or fixing an existing one, explicitly set alignment/justification for EVERY text and container element. Copy the alignment value directly from the Android UI_Analysis.md (e.g., "左对齐" `.textAlign(TextAlign.Start)` + `.width('100%')`). Never rely on default alignment — always set it explicitly.
196
+ **After fixing each diff, update `fix_checklist.md`**: change `- [ ]` to `- [x]` for the completed item.
197
+ **CRITICAL RULE**:
198
+ - Do not skip any diff item in `fix_checklist.md`, regardless of the priority.
199
+ - Fixing compile errors does NOT count as fixing UI diffs. After the build passes, you MUST return to `fix_checklist.md` and continue fixing any remaining unchecked items. The task is not complete until every item in the checklist is marked `[x]`.
200
+
201
+ ### Step 3.4 Final Checklist Review
202
+ Read `fix_checklist.md` and verify every item is marked `[x]`. If any items remain unchecked:
203
+ 1. List the unchecked items
204
+ 2. For each, explain why it was not fixed (blocked by missing API, requires backend, etc.) or fix it now
205
+ 3. Items that genuinely cannot be fixed should be marked with `- [~]` and a reason
206
+
207
+ ## Step 4 validate and build (Main Agent)
208
+ if available, use `hmos-fix-build-errors` skill to verify the project is compilable, do not deploy.
209
+
210
+ ## Guidelines
211
+ - **Preserve existing code**: When editing existing files, make targeted edits — never rewrite an entire file from scratch. Respect the existing code structure, variable names, and patterns.
212
+ - **Follow existing conventions**: All new code must match the HarmonyOS project's established naming conventions, import patterns, state management approach, and component composition style.
213
+ - **Reuse rather than creating**: Always check for existing shared components, viewmodels, and models before creating new ones.
214
+ - **Resource references must match exactly**: every color, string, dimension, image, and other resource used in the Android source must have a corresponding HarmonyOS resource. Do not hardcode values.
215
+ - Use `$r('app.type.name')` for all resource references available in the resource list.
216
+ - Handle responsive layouts: prefer percentage widths and `Flex` over fixed dimensions where appropriate.
217
+ - Maintain accessibility: convert `content-desc` to `.accessibilityText()`, convert meaningful `text` to proper labels.
218
+ - Group related UI into `@Component` sub-components when the hierarchy is deep (> 5 nesting levels).
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