@buaa_smat/hometrans 0.1.0 → 0.1.2
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 +141 -124
- package/agents/build-fixer.md +1 -0
- package/agents/code-review-fix.md +1 -0
- package/agents/code-reviewer.md +1 -0
- package/agents/logic-coding.md +1 -0
- package/agents/logic-context-builder.md +1 -0
- package/agents/review-fixer.md +1 -0
- package/agents/self-test-fixer.md +1 -0
- package/agents/self-tester.md +260 -233
- package/agents/spec-generator.md +1 -0
- package/agents/test-tools/autotest/README.md +223 -0
- package/agents/test-tools/autotest/config.yaml.example +58 -0
- package/agents/test-tools/autotest/pyproject.toml +16 -0
- package/agents/test-tools/autotest/report_tool.py +759 -0
- package/agents/test-tools/autotest/self_test_runner.py +773 -0
- package/agents/test-tools/autotest/testcases_schema.md +143 -0
- package/agents/test-tools/autotest/testcases_tool.py +215 -0
- package/agents/test-tools/autotest/uv.lock +3156 -0
- package/agents/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- package/agents/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- package/agents/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- package/agents/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- package/agents/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- package/agents/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
- package/dist/cli/config-store.js +27 -2
- package/dist/cli/config.js +17 -6
- package/dist/cli/index.js +3 -2
- package/dist/cli/init.js +135 -22
- package/dist/cli/mcp.js +2 -2
- package/dist/context/index.js +165 -69
- package/package.json +59 -60
- package/skills/code-dev-review-fix/SKILL.md +279 -0
- package/skills/code-dev-review-fix-workspace/evals/evals.json +56 -0
- package/skills/code-dev-review-fix-workspace/iteration-1/routing-results.md +23 -0
- package/skills/convert_pipeline/SKILL.md +423 -439
- package/skills/hmos-resources-convert/SKILL.md +623 -0
- package/skills/hmos-resources-convert/evals/evals.json +171 -0
- package/skills/hmos-resources-convert/references/conversion-rules.md +663 -0
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -0
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -0
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -0
- package/skills/hmos-resources-convert/template/AppScope/app.json5 +10 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +8 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +7 -0
- package/skills/hmos-resources-convert/template/build-profile.json5 +42 -0
- package/skills/hmos-resources-convert/template/code-linter.json5 +32 -0
- package/skills/hmos-resources-convert/template/entry/build-profile.json5 +33 -0
- package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +6 -0
- package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +23 -0
- package/skills/hmos-resources-convert/template/entry/oh-package.json5 +10 -0
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
- package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +23 -0
- package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +55 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +8 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +8 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +16 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +3 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +8 -0
- package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +2 -0
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +16 -0
- package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +5 -0
- package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +33 -0
- package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +23 -0
- package/skills/hmos-resources-convert/template/hvigorfile.ts +6 -0
- package/skills/hmos-resources-convert/template/oh-package-lock.json5 +28 -0
- package/skills/hmos-resources-convert/template/oh-package.json5 +10 -0
- package/skills/hmos-resources-convert/tools/apktool.bat +85 -0
- package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
- package/skills/hmos-ui-align/SKILL.md +182 -0
- package/skills/hmos-ui-align/config-example.json +11 -0
- package/skills/hmos-ui-align/config.json +11 -0
- package/skills/hmos-ui-align/diff_analysis.md +53 -0
- package/skills/hmos-ui-align/page_align.md +62 -0
- package/skills/hmos-ui-align/readme.md +231 -0
- package/skills/hmos-ui-align/references/Comparison_Template.md +2 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 +2089 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 +903 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
- package/skills/hmos-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 +355 -0
- package/skills/hmos-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 -0
- package/skills/hmos-ui-align/references/UI_Analysis_Template.md +4 -0
- package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -0
- package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
- package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
- package/skills/hmos-ui-align/scripts/app_feature_verify.py +443 -0
- package/skills/hmos-ui-align/scripts/navigation-capure.md +37 -0
- package/skills/hmos-ui-align/scripts/page_capture.py +592 -0
- package/skills/hmos-ui-align-batch/SKILL.md +99 -0
- package/skills/hmos-ui-align-batch/references/conversion-procedure.md +180 -0
- package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -0
- package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
- package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 +2089 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 +903 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
- package/skills/hmos-ui-align-batch/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 +355 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/scripts/android_parse_fast.py +1606 -0
- package/skills/self-test/SKILL.md +369 -0
- package/skills/self-test/readme.md +309 -0
- package/skills/spec-generator-skill/SKILL.md +332 -0
- package/skills/spec-generator-skill/references/android-platform-tokens.md +105 -0
- package/skills/spec-generator-skill/references/spec-sample-1.md +78 -0
- package/skills/spec-generator-skill/references/spec-sample-2.md +58 -0
- package/skills/spec-generator-skill/references/spec-sample-3.md +116 -0
- package/skills/spec-generator-skill/references/step4-report-template.md +33 -0
- package/agents/self-test-setup.md +0 -165
- package/dist/context/resources/sdkConfig.json +0 -24
- package/src/context/resources/sdkConfig.json +0 -24
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hmos-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
|
+
Read `config.json` from this skill's directory. The config provides all fixed paths so the user only describes what needs to be aligned.
|
|
21
|
+
Key config fields:
|
|
22
|
+
- `android.app_name`, `android.package` — Android app info for navigation
|
|
23
|
+
- `android.project_dir` — Android source code root
|
|
24
|
+
- `harmony.app_name`, `harmony.package` — HarmonyOS app info for navigation
|
|
25
|
+
- `harmony.project_dir` — HarmonyOS project root
|
|
26
|
+
- `hmos_sdk_dir` — HarmonyOS SDK path for API reference
|
|
27
|
+
- `glm_api_key` — Zhipu GLM API key for phone-agent
|
|
28
|
+
- `capture_output_dir` — base directory for captured page data
|
|
29
|
+
- `navigation_tool` = `scripts/app_feature_verify.py`
|
|
30
|
+
- `capture_tool` = `scripts/page_capture.py`
|
|
31
|
+
|
|
32
|
+
## Step 1: Capture All Related Pages on Android & HarmonyOS Devices
|
|
33
|
+
|
|
34
|
+
Read `scripts/navigation-capure.md` to learn the usage of `navigation_tool` and `capture_tool`.
|
|
35
|
+
|
|
36
|
+
### Step 1.1: Parse User Request and Build Capture Plan
|
|
37
|
+
Analyze the user's description and build a list of **base pages** to capture.
|
|
38
|
+
- **Specific path** (e.g., "首页 → 设置 → 关于"): add it directly as a base page with the given click path.
|
|
39
|
+
- **Ambiguous scope** (e.g., "播放列表歌曲页的所有二级弹窗"): identify one determinable base page first — interactive sub-states (tabs, popups, etc.) will be discovered automatically in Step 1.3.
|
|
40
|
+
|
|
41
|
+
For each base page, define:
|
|
42
|
+
- `page_name`: short identifier (e.g., `enterprise_detail`)
|
|
43
|
+
- `android_nav_path` / `hmos_nav_path`: the navigation prompt for each device
|
|
44
|
+
|
|
45
|
+
Create the timestamped output directory and per-page sub-directories following the pattern in `scripts/navigation-capure.md`.
|
|
46
|
+
|
|
47
|
+
### Step 1.2: Capture Base Pages
|
|
48
|
+
For each base page in the plan, on **both** Android and HarmonyOS devices:
|
|
49
|
+
1. Use `navigation_tool` to navigate to the page.
|
|
50
|
+
2. On success, use `capture_tool` to capture the view tree and screenshot.
|
|
51
|
+
3. For HarmonyOS pages that don't exist yet, navigation will fail — leave the directory empty (expected).
|
|
52
|
+
|
|
53
|
+
### Step 1.3: Discover and Capture Interactive States
|
|
54
|
+
After capturing each base page, scan its view tree for **interactive elements that change the visible UI**, including but not limited to:
|
|
55
|
+
- Tabs / Segmented controls (each tab shows different content)
|
|
56
|
+
- Filter / Sort / Dropdown trigger buttons (clicking opens a popup, bottom sheet, or dropdown)
|
|
57
|
+
- Expandable / Collapsible sections ("展开"/"收起", accordion)
|
|
58
|
+
- Any other clickable element that reveals content not visible in the current capture (toggle, switch-mode button, etc.)
|
|
59
|
+
|
|
60
|
+
**For each interactive element found:**
|
|
61
|
+
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`).
|
|
62
|
+
2. Navigate to the base page (reuse the same nav path), then append the click action to trigger the state change. Capture with `capture_tool`.
|
|
63
|
+
3. Repeat for **both** Android and HarmonyOS devices.
|
|
64
|
+
4. Each captured state is treated as a separate page pair in Step 2 and Step 3.
|
|
65
|
+
|
|
66
|
+
**Skip condition**: Only skip this step for a specific page if the user explicitly says to ignore interactive states (e.g., "只对齐主页面,不管弹窗和tab").
|
|
67
|
+
|
|
68
|
+
### Navigation Rules (apply to all capture operations in Step 1)
|
|
69
|
+
|
|
70
|
+
**Click path extraction**: do not replace or translate key operations of hdc/adb (such as drag, swipe).
|
|
71
|
+
**When navigation fails**:
|
|
72
|
+
Firstly, make sure whether the page exists, then:
|
|
73
|
+
1. Page does not exist → record the result and skip the capture.
|
|
74
|
+
2. Page exists but click path is wrong → force-stop and restart the app, retry with the corrected path.
|
|
75
|
+
3. Page exists, path is correct, but the tool reports failure → review the screenshot yourself and decide whether the target was actually reached.
|
|
76
|
+
**Must Remember**: Do not skip any page on Android/HarmonyOS unless navigation fails more than twice.
|
|
77
|
+
|
|
78
|
+
## Step 2: UI Diff Analysis
|
|
79
|
+
|
|
80
|
+
**CRITICAL RULES for Step 2**:
|
|
81
|
+
- Android `UI_Analysis.md` MUST be generated for EVERY page, even if HarmonyOS capture is empty
|
|
82
|
+
- HarmonyOS `UI_Analysis.md` (or `UI_Analysis_from_code.md`) MUST be generated for EVERY page
|
|
83
|
+
- `UI_comparison.md` MUST contain a real markdown diff table (not just a status note)
|
|
84
|
+
|
|
85
|
+
**Dimension rule (applies to Step 2.1, 2.2, and 2.3)**:
|
|
86
|
+
All size/position values must include:
|
|
87
|
+
- raw px value (from view tree bounds)
|
|
88
|
+
- device density (e.g. 3x)
|
|
89
|
+
- converted dp/vp value (px ÷ density)
|
|
90
|
+
Format: "126px (3x → 42vp)". Never write bare px or vp without the other.
|
|
91
|
+
**MANDATORY OUTPUT**: Write the result to `android_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
|
|
92
|
+
**This step is NEVER skippable** — even if the HarmonyOS counterpart is empty, the Android analysis must still be written.
|
|
93
|
+
|
|
94
|
+
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`:
|
|
95
|
+
### Step 2.1 UI Analysis of `android_page_{i}_{name}`
|
|
96
|
+
Read `android_page_{i}_{name}` 目录下的 screenshot(_n) 和 view tree(_n) 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
|
|
97
|
+
**MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to write the result to `android_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
|
|
98
|
+
|
|
99
|
+
### Step 2.2 UI Analysis of `hmos_page_{i}_{name}`
|
|
100
|
+
if `hmos_page_{i}_{name}` has screenshots and view trees:
|
|
101
|
+
Read `hmos_page_{i}_{name}` 目录下的 screenshot 和 view tree 信息,以 table 形式列举出该页面所有组件,每个组件包含位置、颜色、icon、大小、形状、文字内容、alignment(居中、靠左、靠右等)等一切视觉要素。
|
|
102
|
+
**MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to Write the result to `hmos_page_{i}_{name}/UI_Analysis.md`,写完后确认文件已创建。
|
|
103
|
+
if `hmos_page_{i}_{name}` is empty (no screenshots/view trees captured):
|
|
104
|
+
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.
|
|
105
|
+
**MANDATORY OUTPUT**: following the template `references/UI_Analysis_Template.md` to Write the result to `hmos_page_{i}_{name}/UI_Analysis_from_code.md`,写完后确认文件已创建。
|
|
106
|
+
**DO NOT** write a placeholder like "page not captured" — you must actually read the source code and produce a real analysis.
|
|
107
|
+
### Step 2.3 Make UI Diff Analysis and Write the Comparison Table
|
|
108
|
+
**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.
|
|
109
|
+
|
|
110
|
+
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`
|
|
111
|
+
|
|
112
|
+
**Quality requirement for UI_comparison.md**:
|
|
113
|
+
- The file MUST contain a markdown table with `|` delimiters listing every component
|
|
114
|
+
- 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.
|
|
115
|
+
- A comparison that only says "page not captured" or "needs implementation" without a component-level table is INVALID
|
|
116
|
+
|
|
117
|
+
**MANDATORY OUTPUT**: Write the comparison table into `hmos_page_{i}_{name}/UI_comparison.md`
|
|
118
|
+
|
|
119
|
+
### Step 2.4 Output Verification (Main Agent)
|
|
120
|
+
MUST verify:
|
|
121
|
+
1. Use Glob to list all `**/UI_Analysis*.md` files — confirm one exists for every `android_page_*` and every `hmos_page_*` directory
|
|
122
|
+
2. Use Glob to list all `**/UI_comparison.md` files — confirm one exists for every `hmos_page_*` directory
|
|
123
|
+
3. For each `UI_comparison.md`, Read the first 10 lines and confirm it contains a markdown table (has `|` characters)
|
|
124
|
+
4. If ANY file is missing or invalid, re-run Step 2 for that specific page pair before proceeding
|
|
125
|
+
|
|
126
|
+
## Step 3: Fix UI Diffs or Implement Missed Pages (MainAgent)
|
|
127
|
+
|
|
128
|
+
**CHECKPOINT — before proceeding, you MUST**:
|
|
129
|
+
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).
|
|
130
|
+
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.
|
|
131
|
+
3. Extract EVERY diff items from ALL comparison tables and write them into `{task_dir}/fix_checklist.md` in this format:
|
|
132
|
+
```
|
|
133
|
+
# Fix Checklist
|
|
134
|
+
## Page 1: {name}
|
|
135
|
+
- [ ] {diff description 1}
|
|
136
|
+
- [ ] {diff description 2}
|
|
137
|
+
- [ ] {diff description 3}
|
|
138
|
+
## Page 2: {name}
|
|
139
|
+
- [ ] {diff description 1}
|
|
140
|
+
...
|
|
141
|
+
```
|
|
142
|
+
This checklist is your single source of truth for what needs to be fixed.
|
|
143
|
+
|
|
144
|
+
### Step 3.1: Analyze Project Architecture and load knowledge (Main Agent)
|
|
145
|
+
1. understand the existing HarmonyOS project's architecture, analyze existing patterns and identify {reusable components}.
|
|
146
|
+
2. read `./references/MVVM开发文档/MVVM模式V1.md` to understand the MVVM mode
|
|
147
|
+
**Note**: If mock data is required, add them in **Model Layer** according to the MVVM mode.
|
|
148
|
+
|
|
149
|
+
### Step 3.2: Learn typical transformation rules
|
|
150
|
+
read `page_align.md` to learn typical transformation rules
|
|
151
|
+
|
|
152
|
+
### Step 3.3 Fix all Diffs
|
|
153
|
+
Read `{task_dir}/fix_checklist.md` and **Fix Every Diffs (No Matter significant or minor)**,
|
|
154
|
+
Use {reusable components} if it is available and has been aligned with Android
|
|
155
|
+
Following the MVVM mode
|
|
156
|
+
|
|
157
|
+
**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.
|
|
158
|
+
**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.
|
|
159
|
+
**After fixing each diff, update `fix_checklist.md`**: change `- [ ]` to `- [x]` for the completed item.
|
|
160
|
+
**CRITICAL RULE**:
|
|
161
|
+
- Do not skip any diff item in `fix_checklist.md`, regardless of the priority.
|
|
162
|
+
- 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]`.
|
|
163
|
+
|
|
164
|
+
### Step 3.4 Final Checklist Review
|
|
165
|
+
Read `fix_checklist.md` and verify every item is marked `[x]`. If any items remain unchecked:
|
|
166
|
+
1. List the unchecked items
|
|
167
|
+
2. For each, explain why it was not fixed (blocked by missing API, requires backend, etc.) or fix it now
|
|
168
|
+
3. Items that genuinely cannot be fixed should be marked with `- [~]` and a reason
|
|
169
|
+
|
|
170
|
+
## Step 4 validate and build (Main Agent)
|
|
171
|
+
if available, use `hmos-fix-build-errors` skill to verify the project is compilable, do not deploy.
|
|
172
|
+
|
|
173
|
+
## Guidelines
|
|
174
|
+
- **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.
|
|
175
|
+
- **Follow existing conventions**: All new code must match the HarmonyOS project's established naming conventions, import patterns, state management approach, and component composition style.
|
|
176
|
+
- **Reuse rather than creating**: Always check for existing shared components, viewmodels, and models before creating new ones.
|
|
177
|
+
- **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.
|
|
178
|
+
- Use `$r('app.type.name')` for all resource references available in the resource list.
|
|
179
|
+
- Handle responsive layouts: prefer percentage widths and `Flex` over fixed dimensions where appropriate.
|
|
180
|
+
- Maintain accessibility: convert `content-desc` to `.accessibilityText()`, convert meaningful `text` to proper labels.
|
|
181
|
+
- Group related UI into `@Component` sub-components when the hierarchy is deep (> 5 nesting levels).
|
|
182
|
+
- **鸿蒙 API 可参考 `{hmos_sdk_dir}`, 鸿蒙MVVM开发模式可参考`./references/MVVM开发文档/`**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"android.app_name": "Salt Player",
|
|
3
|
+
"android.package": "com.salt.music",
|
|
4
|
+
"android.project_dir": "E:\\SaltPlayerAndroid-main\\SuvineMusicX",
|
|
5
|
+
"harmony.app_name": "Salt Player",
|
|
6
|
+
"harmony.package": "com.xuncorp.sp2",
|
|
7
|
+
"harmony.project_dir": "E:\\SPH_branches\\SaltPlayerHarmony",
|
|
8
|
+
"hmos_sdk_dir": "E:\\DevEco Studio\\sdk\\default",
|
|
9
|
+
"glm_api_key": "",
|
|
10
|
+
"capture_output_dir": "E:\\tmp_saltplayer"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"android.app_name": "Salt Player",
|
|
3
|
+
"android.package": "com.salt.music",
|
|
4
|
+
"android.project_dir": "E:\\SaltPlayerAndroid-main\\SuvineMusicX",
|
|
5
|
+
"harmony.app_name": "Salt Player",
|
|
6
|
+
"harmony.package": "com.xuncorp.sp2",
|
|
7
|
+
"harmony.project_dir": "E:\\SPH",
|
|
8
|
+
"hmos_sdk_dir": "E:\\DevEco Studio\\sdk\\default",
|
|
9
|
+
"glm_api_key": "",
|
|
10
|
+
"capture_output_dir": "./tmp_saltplayer"
|
|
11
|
+
}
|
|
@@ -0,0 +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
|
+
|
|
53
|
+
Return a diff analysis report which lists all diffs
|
|
@@ -0,0 +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')`)
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# hmos-ui-align
|
|
2
|
+
|
|
3
|
+
HarmonyOS-Android UI 自动对齐流水线。
|
|
4
|
+
|
|
5
|
+
## 它解决什么问题
|
|
6
|
+
|
|
7
|
+
以往对齐鸿蒙和安卓 UI 的流程需要:
|
|
8
|
+
1. 人工把设备点到目标页面
|
|
9
|
+
2. 手动跑 parse 脚本截图 + dump view tree
|
|
10
|
+
3. 肉眼对比差异
|
|
11
|
+
4. 手写改鸿蒙源码
|
|
12
|
+
|
|
13
|
+
每多一个页面/弹窗/tab,上述步骤都要重复一遍,非常费时。
|
|
14
|
+
|
|
15
|
+
本 skill 做了三件事:
|
|
16
|
+
- 用智谱 GLM 驱动的 phone-agent 自动**寻路**(根据自然语言点到指定页面)
|
|
17
|
+
- 自动**采集** view tree + 截图(安卓走 adb、鸿蒙走 hdc)
|
|
18
|
+
- 自动**对比 + 改码**,并按 MVVM 模式把 mock 数据放到 Model 层
|
|
19
|
+
|
|
20
|
+
用户只需要一句自然语言 + 点击路径。
|
|
21
|
+
|
|
22
|
+
> ⚠️ 当前只保证 **UI 对齐**,不保证功能行为对齐。
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 前置条件
|
|
27
|
+
|
|
28
|
+
1. **设备连接**
|
|
29
|
+
- 安卓设备:已装目标 App,`adb devices` 能看到
|
|
30
|
+
- 鸿蒙设备:已装目标 App,`hdc list targets` 能看到
|
|
31
|
+
- 两台设备建议都保持亮屏解锁
|
|
32
|
+
|
|
33
|
+
2. **Python 依赖**
|
|
34
|
+
```bash
|
|
35
|
+
pip install openpyxl phone-agent
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. **智谱 GLM API Key**(phone-agent 调用的模型)
|
|
39
|
+
到 https://open.bigmodel.cn/ 申请,有免费额度,填到 `config.json` 的 `glm_api_key`。
|
|
40
|
+
|
|
41
|
+
4. **鸿蒙 SDK 路径**(给改码阶段查 API 用)
|
|
42
|
+
例如 DevEco Studio 自带的 `E:\DevEco Studio\sdk\default`。
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 配置 `config.json`
|
|
47
|
+
|
|
48
|
+
首次使用前必须改 `Agents/hmos-ui-align/config.json`。字段说明:
|
|
49
|
+
|
|
50
|
+
| 字段 | 说明 | 示例 |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `android.app_name` | 安卓端 App 显示名(桌面上看到的名字,phone-agent 打开 app 时用) | `"Salt Player"` |
|
|
53
|
+
| `android.package` | 安卓包名 | `"com.salt.music"` |
|
|
54
|
+
| `android.project_dir` | 安卓源码根目录 | `"E:\\SaltPlayerAndroid-main\\SuvineMusicX"` |
|
|
55
|
+
| `harmony.app_name` | 鸿蒙端 App 显示名 | `"Salt Player"` |
|
|
56
|
+
| `harmony.package` | 鸿蒙包名 | `"com.xuncorp.sp2"` |
|
|
57
|
+
| `harmony.project_dir` | 鸿蒙工程根目录(会被直接修改) | `"E:\\SPH"` |
|
|
58
|
+
| `hmos_sdk_dir` | 鸿蒙 SDK 路径 | `"E:\\DevEco Studio\\sdk\\default"` |
|
|
59
|
+
| `glm_api_key` | 智谱 GLM API Key | `"xxx.yyy"` |
|
|
60
|
+
| `capture_output_dir` | 采集产物输出目录(截图/view tree/分析报告都在这) | `"./tmp_saltplayer"` |
|
|
61
|
+
|
|
62
|
+
可以直接参考同目录下的 `config-example.json`。
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 使用方式
|
|
67
|
+
|
|
68
|
+
在 Claude Code 里直接调用 skill:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
/hmos-ui-align <自然语言需求,描述要对齐的页面+点击路径>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 写需求的三个要点
|
|
75
|
+
|
|
76
|
+
1. **页面路径写清楚**
|
|
77
|
+
用「→」或「-」标注一级一级的点击步骤,比如 `首页 → 点击"AI智能填报" → 点击"专业"筛选按钮`。路径越具体,phone-agent 寻路成功率越高。
|
|
78
|
+
|
|
79
|
+
2. **说明是否要覆盖交互态**
|
|
80
|
+
默认会自动扫描 tab、弹窗、下拉等交互元素并逐个采集。如果只想对齐主页面,请明确说「只对齐主页面,不管弹窗和 tab」。
|
|
81
|
+
|
|
82
|
+
3. **说明是否用 Mock 数据**
|
|
83
|
+
默认用 mock 数据。如果想调真实后台,在需求里写「不要 mock 数据,调用真实后台」。
|
|
84
|
+
|
|
85
|
+
### 例子
|
|
86
|
+
|
|
87
|
+
**例 1(单个弹窗对齐)**
|
|
88
|
+
```
|
|
89
|
+
/hmos-ui-align 鸿蒙版本app(登录状态下,进入首页-点击"AI智能填报"-点击"专业"筛选按钮)
|
|
90
|
+
得到的弹窗样式和安卓同样路径得到的页面不一致,请修改鸿蒙源码将上述页面与安卓版本完全对齐
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**例 2(补齐缺失页面 + 调真实后台)**
|
|
94
|
+
```
|
|
95
|
+
/hmos-ui-align 鸿蒙版本app(点击我的-超级会员组件)显示与安卓不一致,且安卓版本在超级会员
|
|
96
|
+
上点击"会员中心"会跳到超级会员弹窗页,鸿蒙也没有这页。请修改鸿蒙源码将这些页面与安卓版本
|
|
97
|
+
完全对齐,不要mock数据,调用真实后台数据
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**例 3(多级路径 + 多个页面)**
|
|
101
|
+
```
|
|
102
|
+
/hmos-ui-align 鸿蒙版本(点击底部高考按钮 -> 带年纪查专业 -> 点击某一具体专业(如临床医学)
|
|
103
|
+
-> 点击就业分析,到达"专业就业健康度"展示页面)以及在"专业就业健康度"页面上点击"完整数
|
|
104
|
+
据指标"到达的就业健康度详情页都和安卓同一路径的不一致。比较这些页面的差别并将他们在视觉
|
|
105
|
+
效果上完全对齐,不要用mock数据,调用后台真实逻辑
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 运行过程中会发生什么
|
|
111
|
+
|
|
112
|
+
skill 会严格按 `SKILL.md` 里的 5 步流水线跑:
|
|
113
|
+
|
|
114
|
+
### Step 0 · 加载 config
|
|
115
|
+
读 `config.json`,解析出所有路径和 API Key。
|
|
116
|
+
|
|
117
|
+
### Step 1 · 双端页面采集
|
|
118
|
+
1.1 解析你的需求,拆成一组「基础页」,每个基础页有 `android_nav_path` 和 `hmos_nav_path`
|
|
119
|
+
1.2 对每个基础页,两端分别:phone-agent 寻路 → 成功后 `page_capture.py` 截图 + dump view tree
|
|
120
|
+
1.3 扫描基础页 view tree,发现 tab、弹窗、下拉等交互元素,自动对每个子状态再采集一遍
|
|
121
|
+
1.4 鸿蒙端页面不存在时,寻路会失败,对应目录留空(Step 2 会改从源码读)
|
|
122
|
+
|
|
123
|
+
产物目录结构:
|
|
124
|
+
```
|
|
125
|
+
{capture_output_dir}/
|
|
126
|
+
task_{timestamp}/
|
|
127
|
+
android_page_1_{name}/
|
|
128
|
+
screenshot.png
|
|
129
|
+
view_tree.xml
|
|
130
|
+
hmos_page_1_{name}/
|
|
131
|
+
screenshot.png
|
|
132
|
+
view_tree.xml
|
|
133
|
+
android_page_1_{name}_popup_filter/
|
|
134
|
+
...
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Step 2 · UI 差异分析
|
|
138
|
+
主 agent 串行执行,不会下放给子 agent(保证质量):
|
|
139
|
+
- **2.1** 读安卓 screenshot + view tree,写 `android_page_*/UI_Analysis.md`(组件清单 + 位置 / 颜色 / icon / 尺寸 / 对齐方式等)
|
|
140
|
+
- **2.2** 读鸿蒙 screenshot + view tree,写 `hmos_page_*/UI_Analysis.md`;鸿蒙页不存在时改读源码写 `UI_Analysis_from_code.md`
|
|
141
|
+
- **2.3** 两份 Analysis 对比,按 `references/Comparison_Template.md` 生成 `UI_comparison.md`(markdown diff 表)
|
|
142
|
+
- **2.4** 验证所有 `UI_Analysis*.md` 和 `UI_comparison.md` 都已写全
|
|
143
|
+
|
|
144
|
+
所有尺寸都会以 `126px (3x → 42vp)` 的格式同时给出原始 px、设备密度、换算后的 vp。
|
|
145
|
+
|
|
146
|
+
### Step 3 · 改鸿蒙源码
|
|
147
|
+
- 把每个 `UI_comparison.md` 里的 diff 项汇总到 `{task_dir}/fix_checklist.md`(唯一 source of truth)
|
|
148
|
+
- 读 `references/MVVM开发文档/` 学习 MVVM 模式
|
|
149
|
+
- 读 `page_align.md` 学习转换规则
|
|
150
|
+
- 逐条修 diff,每修一个把 `- [ ]` 改成 `- [x]`
|
|
151
|
+
- 每个尺寸 / icon / alignment 都要回溯到安卓源码的 XML 或资源值,不允许"看起来差不多"
|
|
152
|
+
|
|
153
|
+
### Step 4 · 编译校验
|
|
154
|
+
若可用,调 `hmos-fix-build-errors` skill 确保工程能编过。**不会自动部署**。
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 目录结构
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
Agents/hmos-ui-align/
|
|
162
|
+
├── SKILL.md # 流水线定义(主 agent 执行逻辑)
|
|
163
|
+
├── readme.md # 本文档
|
|
164
|
+
├── config.json # 用户配置
|
|
165
|
+
├── config-example.json # 配置样例
|
|
166
|
+
├── page_align.md # Step 3 的转换规则
|
|
167
|
+
├── diff_analysis.md # 内部说明
|
|
168
|
+
├── scripts/
|
|
169
|
+
│ ├── app_feature_verify.py # phone-agent 寻路工具
|
|
170
|
+
│ ├── page_capture.py # view tree + 截图采集工具
|
|
171
|
+
│ └── navigation-capure.md # 两个脚本的调用约定
|
|
172
|
+
└── references/
|
|
173
|
+
├── UI_Analysis_Template.md # Step 2 分析模板
|
|
174
|
+
├── Comparison_Template.md # Step 2.3 对比模板
|
|
175
|
+
├── MVVM开发文档/ # 鸿蒙 MVVM 参考
|
|
176
|
+
├── android-to-harmonyOS-ui-layout-mapping-reference.md
|
|
177
|
+
├── android-to-harmonyOS-ui-atomic-component-mapping-reference.md
|
|
178
|
+
└── android-to-harmonyOS-ui-interaction-mapping-reference.md
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 单独运行脚本(调试用)
|
|
184
|
+
|
|
185
|
+
跳过 skill 手动跑采集:
|
|
186
|
+
|
|
187
|
+
```powershell
|
|
188
|
+
# 安卓寻路
|
|
189
|
+
$env:PYTHONIOENCODING="utf-8"
|
|
190
|
+
python Agents/hmos-ui-align/scripts/app_feature_verify.py `
|
|
191
|
+
--device adb `
|
|
192
|
+
--app "Salt Player" `
|
|
193
|
+
--package "com.salt.music" `
|
|
194
|
+
--prompt "进入首页-点击AI智能填报-点击专业筛选按钮" `
|
|
195
|
+
--api-key "$env:GLM_API_KEY" `
|
|
196
|
+
--max-steps 15
|
|
197
|
+
|
|
198
|
+
# 安卓采集
|
|
199
|
+
python Agents/hmos-ui-align/scripts/page_capture.py --device adb -o ./tmp/android_page_1_xxx
|
|
200
|
+
|
|
201
|
+
# 鸿蒙同理,把 --device adb 换成 --device hdc
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
> 注意:`--prompt` 模式会自动在前面加「打开{app_name},」,所以 prompt 里不要再写"打开"。
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 常见问题
|
|
209
|
+
|
|
210
|
+
**Q: phone-agent 寻路失败怎么办?**
|
|
211
|
+
A: skill 默认重试两次。流水线的内部规则:①先看页面是否存在;②路径错了就 force-stop 重试;③路径对但工具报错就让 agent 自己看截图判断是否到了。超过两次仍失败才会跳过该页。
|
|
212
|
+
|
|
213
|
+
**Q: 鸿蒙端页面根本不存在,能新建吗?**
|
|
214
|
+
A: 可以。Step 2.2 会改从鸿蒙源码读,Step 3 会按安卓的实现规格新建 `.ets` 文件到 `entry/src/main/ets/pages/`,并登记路由。
|
|
215
|
+
|
|
216
|
+
**Q: 为什么同一次任务会采集多个页面?**
|
|
217
|
+
A: Step 1.3 默认扫描交互元素(tab / 弹窗 / 展开收起等)并递归采集。想关掉请在需求里写「只对齐主页面」。
|
|
218
|
+
|
|
219
|
+
**Q: 改完会自动部署吗?**
|
|
220
|
+
A: 不会。Step 4 只跑编译验证(如果 `hmos-fix-build-errors` skill 可用)。部署自己来。
|
|
221
|
+
|
|
222
|
+
**Q: 能不能只做差异分析、不改码?**
|
|
223
|
+
A: 目前流水线是端到端的。如果只想要分析产物,跑完 Step 2 后手动中断即可,所有 `UI_Analysis.md` 和 `UI_comparison.md` 都会落盘在 `{capture_output_dir}/task_{timestamp}/` 下。
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 已知限制
|
|
228
|
+
|
|
229
|
+
- 只对齐 UI,不对齐功能/数据流
|
|
230
|
+
- phone-agent 寻路依赖 GLM 模型对页面文本的识别,小字体或非标准控件可能识别不准
|
|
231
|
+
- 双端设备的分辨率/密度差异会影响像素到 vp 的换算,流水线已显式带上 density,但同一个 Figma 规格下仍可能出现 ±1vp 偏差
|