@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,62 +1,62 @@
1
- # Page Align Insruction
2
-
3
- Based on the diff analysis, flexibly combine editing and creation as needed — a single page may require both aligning existing code and adding new components/files:
4
-
5
- **For existing files that need alignment:**
6
- - Read the existing `.ets` file(s) for this page
7
- - For each discrepancy identified in the diff, make **targeted edits** using the Edit tool:
8
- - Fix layout structure mismatches (wrong container type, missing nesting)
9
- - Add missing components
10
- - Remove extra components that don't exist in the Android UI
11
- - Fix styling (colors, sizes, spacing, shapes)
12
- - Fix resource references to use correct `$r('app.xxx.yyy')`
13
-
14
- **For new files that need to be created** (new pages, new sub-components, new viewmodels/models):
15
- - Generate new `.ets` files following the conventions discovered in Phase 1:
16
- - Use the same import patterns as existing pages
17
- - Use the same state management patterns
18
- - Reuse existing shared components from `components/`
19
- - Reuse or extend existing viewmodels/models
20
- - Follow the same naming conventions
21
- - Write page files to `{harmony_project_dir}/entry/src/main/ets/pages/`
22
- - Write component files to `{harmony_project_dir}/entry/src/main/ets/components/`
23
- - Write viewmodel files to `{harmony_project_dir}/entry/src/main/ets/viewmodel/`
24
- - Write model files to `{harmony_project_dir}/entry/src/main/ets/model/`
25
- - Register any new page in the router configuration
26
-
27
- ## For all changes, apply these conversion rules:
28
-
29
- **Resource Conversion:**
30
- - For each resource referenced by the Android UI, find the corresponding mapping in `{harmony_project_dir}/entry/src/main/resources`
31
- - If a needed resource does not exist, use the **`hmos-resources-convert`** skill to convert it
32
-
33
- **Layout Conversion:**
34
- - Consult `./references/android-to-harmonyOS-ui-layout-mapping-reference.md` for all layout container mappings and layout attribute mappings
35
- - Apply the layout property mappings (e.g., `layout_weight` → `.layoutWeight()`, `padding` → `.padding()`, visibility handling, etc.)
36
-
37
- **Widget Conversion:**
38
- - Consult `./references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md` for all atomic widget mappings
39
- - Apply the detailed attribute-level mappings for each component
40
-
41
- **Interaction Conversion:**
42
- - Consult `./references/android-to-harmonyOS-ui-interaction-mapping-reference.md` for all event and gesture mappings
43
- - Apply touch event mappings, click event mappings, gesture mappings, and animation mappings
44
-
45
- **Always consult the reference files first** — they contain project-specific and comprehensive mappings that take priority over built-in knowledge.
46
-
47
- **Styling Conversion:**
48
- - Android `dp` → HarmonyOS `vp`
49
- - Android `sp` → HarmonyOS `fp`
50
- - Calculate dimensions from `bounds` in the XML: `width = x2 - x1`, `height = y2 - y1`
51
- - Convert absolute pixel values to `vp` using the device density (assume 3x density: `1vp ≈ 3px`)
52
- - Use `$r('app.color.xxx')` for colors when available in the resource list
53
- - Use `$r('app.string.xxx')` for text strings when available in the resource list
54
- - Use `$r('app.media.xxx')` for images when available in the resource list
55
-
56
- **Router Conversion:**
57
- - Convert router relationships among UIs and components
58
- - Register new page routes in the router configuration when new pages are created
59
- - Fix any incorrect router targets in existing pages
60
-
61
- **Interactive Elements:**
62
- - **Prefer real implementation over mocking**: before mocking any click event, navigation jump, or interaction, first check whether the target component or page already exists in the HarmonyOS project. If the target is already implemented, wire up the real event handler (e.g., actual `router.pushUrl()` with the correct page path). **Only mock when the related component or page has not yet been implemented** — in that case, use placeholder implementations to ensure the program compiles (e.g., `console.info('TODO: navigate to SettingsActivity — target page not yet implemented')`)
1
+ # Page Align Insruction
2
+
3
+ Based on the diff analysis, flexibly combine editing and creation as needed — a single page may require both aligning existing code and adding new components/files:
4
+
5
+ **For existing files that need alignment:**
6
+ - Read the existing `.ets` file(s) for this page
7
+ - For each discrepancy identified in the diff, make **targeted edits** using the Edit tool:
8
+ - Fix layout structure mismatches (wrong container type, missing nesting)
9
+ - Add missing components
10
+ - Remove extra components that don't exist in the Android UI
11
+ - Fix styling (colors, sizes, spacing, shapes)
12
+ - Fix resource references to use correct `$r('app.xxx.yyy')`
13
+
14
+ **For new files that need to be created** (new pages, new sub-components, new viewmodels/models):
15
+ - Generate new `.ets` files following the conventions discovered in Phase 1:
16
+ - Use the same import patterns as existing pages
17
+ - Use the same state management patterns
18
+ - Reuse existing shared components from `components/`
19
+ - Reuse or extend existing viewmodels/models
20
+ - Follow the same naming conventions
21
+ - Write page files to `{harmony_project_dir}/entry/src/main/ets/pages/`
22
+ - Write component files to `{harmony_project_dir}/entry/src/main/ets/components/`
23
+ - Write viewmodel files to `{harmony_project_dir}/entry/src/main/ets/viewmodel/`
24
+ - Write model files to `{harmony_project_dir}/entry/src/main/ets/model/`
25
+ - Register any new page in the router configuration
26
+
27
+ ## For all changes, apply these conversion rules:
28
+
29
+ **Resource Conversion:**
30
+ - For each resource referenced by the Android UI, find the corresponding mapping in `{harmony_project_dir}/entry/src/main/resources`
31
+ - If a needed resource does not exist, use the **`hmos-resources-convert`** skill to convert it
32
+
33
+ **Layout Conversion:**
34
+ - Consult `./references/android-to-harmonyOS-ui-layout-mapping-reference.md` for all layout container mappings and layout attribute mappings
35
+ - Apply the layout property mappings (e.g., `layout_weight` → `.layoutWeight()`, `padding` → `.padding()`, visibility handling, etc.)
36
+
37
+ **Widget Conversion:**
38
+ - Consult `./references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md` for all atomic widget mappings
39
+ - Apply the detailed attribute-level mappings for each component
40
+
41
+ **Interaction Conversion:**
42
+ - Consult `./references/android-to-harmonyOS-ui-interaction-mapping-reference.md` for all event and gesture mappings
43
+ - Apply touch event mappings, click event mappings, gesture mappings, and animation mappings
44
+
45
+ **Always consult the reference files first** — they contain project-specific and comprehensive mappings that take priority over built-in knowledge.
46
+
47
+ **Styling Conversion:**
48
+ - Android `dp` → HarmonyOS `vp`
49
+ - Android `sp` → HarmonyOS `fp`
50
+ - Calculate dimensions from `bounds` in the XML: `width = x2 - x1`, `height = y2 - y1`
51
+ - Convert absolute pixel values to `vp` using the device density (assume 3x density: `1vp ≈ 3px`)
52
+ - Use `$r('app.color.xxx')` for colors when available in the resource list
53
+ - Use `$r('app.string.xxx')` for text strings when available in the resource list
54
+ - Use `$r('app.media.xxx')` for images when available in the resource list
55
+
56
+ **Router Conversion:**
57
+ - Convert router relationships among UIs and components
58
+ - Register new page routes in the router configuration when new pages are created
59
+ - Fix any incorrect router targets in existing pages
60
+
61
+ **Interactive Elements:**
62
+ - **Prefer real implementation over mocking**: before mocking any click event, navigation jump, or interaction, first check whether the target component or page already exists in the HarmonyOS project. If the target is already implemented, wire up the real event handler (e.g., actual `router.pushUrl()` with the correct page path). **Only mock when the related component or page has not yet been implemented** — in that case, use placeholder implementations to ensure the program compiles (e.g., `console.info('TODO: navigate to SettingsActivity — target page not yet implemented')`)
@@ -1,230 +1,237 @@
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
- 首次使用前,自行准备一份 `config.json`(放任何位置都可以),调用 skill 时把它的**绝对路径**作为参数传给 skill。可复制同目录下的 `config-example.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,**必须把准备好的 `config.json` 的绝对路径附在需求里**:
69
-
70
- ```
71
- /hmos-ui-align config: <绝对路径/config.json> <自然语言需求,描述要对齐的页面+点击路径>
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-example.json # 配置样例(实际使用的 config.json 由用户自备并显式传路径)
165
- ├── page_align.md # Step 3 的转换规则
166
- ├── diff_analysis.md # 内部说明
167
- ├── scripts/
168
- │ ├── app_feature_verify.py # phone-agent 寻路工具
169
- │ ├── page_capture.py # view tree + 截图采集工具
170
- │ └── navigation-capure.md # 两个脚本的调用约定
171
- └── references/
172
- ├── UI_Analysis_Template.md # Step 2 分析模板
173
- ├── Comparison_Template.md # Step 2.3 对比模板
174
- ├── MVVM开发文档/ # 鸿蒙 MVVM 参考
175
- ├── android-to-harmonyOS-ui-layout-mapping-reference.md
176
- ├── android-to-harmonyOS-ui-atomic-component-mapping-reference.md
177
- └── android-to-harmonyOS-ui-interaction-mapping-reference.md
178
- ```
179
-
180
- ---
181
-
182
- ## 单独运行脚本(调试用)
183
-
184
- 跳过 skill 手动跑采集:
185
-
186
- ```powershell
187
- # 安卓寻路
188
- $env:PYTHONIOENCODING="utf-8"
189
- python Agents/hmos-ui-align/scripts/app_feature_verify.py `
190
- --device adb `
191
- --app "Salt Player" `
192
- --package "com.salt.music" `
193
- --prompt "进入首页-点击AI智能填报-点击专业筛选按钮" `
194
- --api-key "$env:GLM_API_KEY" `
195
- --max-steps 15
196
-
197
- # 安卓采集
198
- python Agents/hmos-ui-align/scripts/page_capture.py --device adb -o ./tmp/android_page_1_xxx
199
-
200
- # 鸿蒙同理,把 --device adb 换成 --device hdc
201
- ```
202
-
203
- > 注意:`--prompt` 模式会自动在前面加「打开{app_name},」,所以 prompt 里不要再写"打开"。
204
-
205
- ---
206
-
207
- ## 常见问题
208
-
209
- **Q: phone-agent 寻路失败怎么办?**
210
- A: skill 默认重试两次。流水线的内部规则:①先看页面是否存在;②路径错了就 force-stop 重试;③路径对但工具报错就让 agent 自己看截图判断是否到了。超过两次仍失败才会跳过该页。
211
-
212
- **Q: 鸿蒙端页面根本不存在,能新建吗?**
213
- A: 可以。Step 2.2 会改从鸿蒙源码读,Step 3 会按安卓的实现规格新建 `.ets` 文件到 `entry/src/main/ets/pages/`,并登记路由。
214
-
215
- **Q: 为什么同一次任务会采集多个页面?**
216
- A: Step 1.3 默认扫描交互元素(tab / 弹窗 / 展开收起等)并递归采集。想关掉请在需求里写「只对齐主页面」。
217
-
218
- **Q: 改完会自动部署吗?**
219
- A: 不会。Step 4 只跑编译验证(如果 `hmos-fix-build-errors` skill 可用)。部署自己来。
220
-
221
- **Q: 能不能只做差异分析、不改码?**
222
- A: 目前流水线是端到端的。如果只想要分析产物,跑完 Step 2 后手动中断即可,所有 `UI_Analysis.md` 和 `UI_comparison.md` 都会落盘在 `{capture_output_dir}/task_{timestamp}/` 下。
223
-
224
- ---
225
-
226
- ## 已知限制
227
-
228
- - 只对齐 UI,不对齐功能/数据流
229
- - phone-agent 寻路依赖 GLM 模型对页面文本的识别,小字体或非标准控件可能识别不准
230
- - 双端设备的分辨率/密度差异会影响像素到 vp 的换算,流水线已显式带上 density,但同一个 Figma 规格下仍可能出现 ±1vp 偏差
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/ 申请,有免费额度。设为 OS 环境变量 `GLM_API_KEY`(`ht init` 可帮你写入机器环境变量)。
40
+
41
+ 4. **鸿蒙 SDK 路径**(给改码阶段查 API 用)
42
+ 取自 OS 环境变量 `OHOS_SDK_PATH` / `HMS_SDK_PATH`(为空时由 `DEVECO_SDK_HOME` 派生),由 `ht init` 写入机器环境变量;例如 DevEco Studio 自带的 `E:\DevEco Studio\sdk\default\openharmony\ets`。
43
+
44
+ ---
45
+
46
+ ## 入参与配置
47
+
48
+ skill 需要两类信息:
49
+
50
+ **① 调用时传入的入参**(每次按需提供):
51
+
52
+ | 入参 | 必填 | 说明 |
53
+ |---|---|--------------------------------------------------------------------|
54
+ | `android_project_dir` | | 安卓源码根目录 |
55
+ | `harmony_project_dir` | | 鸿蒙工程根目录(会被直接修改) |
56
+ | `capture_output_dir` | | 采集产物输出目录(截图/view tree/分析报告)。默认 `<harmony_project_dir>/.hometrans/capture_output` |
57
+
58
+ **② OS 环境变量直接读取的全局配置**(由 `ht init` 写入机器环境变量,无需每次传):
59
+
60
+ - GLM key 环境变量 `GLM_API_KEY`
61
+ - 鸿蒙 SDK ETS API 目录 ← 环境变量 `OHOS_SDK_PATH` / `HMS_SDK_PATH`(为空时由 `DEVECO_SDK_HOME` 派生为 `<DEVECO_SDK_HOME>/default/openharmony/ets`、`.../hms/ets`)
62
+
63
+ > **Step 0.0** 会在执行前检查这些环境变量是否存在;缺失时会要求用户输入。
64
+
65
+ > 安卓/鸿蒙两端的 **App 显示名**(`android.app_name` / `harmony.app_name`)和 **包名**(`android.package` / `harmony.package`)也无需提供——skill 的 **Step 0.1** 会按 `android_project_dir` / `harmony_project_dir` 自动解析:
66
+ > - 安卓包名取自 app 模块 `build.gradle(.kts)` 的 `applicationId`(兜底 `AndroidManifest.xml` 的 `package`);App 名取自启动 Activity / `<application>` 的 `android:label`(`@string/xxx` 会去 `res/values*/strings.xml` 解析,优先中文)。
67
+ > - 鸿蒙包名取自 `AppScope/app.json5` 的 `bundleName`;App 名取自 `app.json5` 的 `label`(`$string:xxx` 会去 `AppScope/resources/**/element/string.json` 解析,优先中文)。
68
+ >
69
+ > 若某项无法从工程目录解析,skill 会回到询问用户。
70
+
71
+ ---
72
+
73
+ ## 使用方式
74
+
75
+ 在 Claude Code 里直接调用 skill,**把两个工程目录附在需求里**(可作为命名参数,也可在自然语言里说明):
76
+
77
+ ```
78
+ /hmos-ui-align android_project_dir: <安卓工程绝对路径> harmony_project_dir: <鸿蒙工程绝对路径>
79
+ <自然语言需求,描述要对齐的页面+点击路径>
80
+ ```
81
+
82
+ ### 写需求的三个要点
83
+
84
+ 1. **页面路径写清楚**
85
+ 用「→」或「-」标注一级一级的点击步骤,比如 `首页 → 点击"AI智能填报" → 点击"专业"筛选按钮`。路径越具体,phone-agent 寻路成功率越高。
86
+
87
+ 2. **说明是否要覆盖交互态**
88
+ 默认会自动扫描 tab、弹窗、下拉等交互元素并逐个采集。如果只想对齐主页面,请明确说「只对齐主页面,不管弹窗和 tab」。
89
+
90
+ 3. **说明是否用 Mock 数据**
91
+ 默认用 mock 数据。如果想调真实后台,在需求里写「不要 mock 数据,调用真实后台」。
92
+
93
+ ### 例子
94
+
95
+ **例 1(单个弹窗对齐)**
96
+ ```
97
+ /hmos-ui-align 鸿蒙版本app(登录状态下,进入首页-点击"AI智能填报"-点击"专业"筛选按钮)
98
+ 得到的弹窗样式和安卓同样路径得到的页面不一致,请修改鸿蒙源码将上述页面与安卓版本完全对齐
99
+ ```
100
+
101
+ **例 2(补齐缺失页面 + 调真实后台)**
102
+ ```
103
+ /hmos-ui-align 鸿蒙版本app(点击我的-超级会员组件)显示与安卓不一致,且安卓版本在超级会员
104
+ 上点击"会员中心"会跳到超级会员弹窗页,鸿蒙也没有这页。请修改鸿蒙源码将这些页面与安卓版本
105
+ 完全对齐,不要mock数据,调用真实后台数据
106
+ ```
107
+
108
+ **例 3(多级路径 + 多个页面)**
109
+ ```
110
+ /hmos-ui-align 鸿蒙版本(点击底部高考按钮 -> 带年纪查专业 -> 点击某一具体专业(如临床医学)
111
+ -> 点击就业分析,到达"专业就业健康度"展示页面)以及在"专业就业健康度"页面上点击"完整数
112
+ 据指标"到达的就业健康度详情页都和安卓同一路径的不一致。比较这些页面的差别并将他们在视觉
113
+ 效果上完全对齐,不要用mock数据,调用后台真实逻辑
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 运行过程中会发生什么
119
+
120
+ skill 会严格按 `SKILL.md` 里的 5 步流水线跑:
121
+
122
+ ### Step 0 · 解析入参
123
+ 读取调用入参 `android_project_dir` / `harmony_project_dir` / `capture_output_dir`,并从 OS 环境变量直接读取 `GLM_API_KEY` 与 `OHOS_SDK_PATH` / `HMS_SDK_PATH`(**Step 0.0** 会先做存在性检查,缺失则要求用户输入)。随后 **Step 0.1** 按两个工程目录自动解析两端的 App 显示名与包名(无需手动配置)。
124
+
125
+ ### Step 1 · 双端页面采集
126
+ 1.1 解析你的需求,拆成一组「基础页」,每个基础页有 `android_nav_path` 和 `hmos_nav_path`
127
+ 1.2 对每个基础页,两端分别:phone-agent 寻路 → 成功后 `page_capture.py` 截图 + dump view tree
128
+ 1.3 扫描基础页 view tree,发现 tab、弹窗、下拉等交互元素,自动对每个子状态再采集一遍
129
+ 1.4 鸿蒙端页面不存在时,寻路会失败,对应目录留空(Step 2 会改从源码读)
130
+
131
+ 产物目录结构:
132
+ ```
133
+ {capture_output_dir}/
134
+ task_{timestamp}/
135
+ android_page_1_{name}/
136
+ screenshot.png
137
+ view_tree.xml
138
+ hmos_page_1_{name}/
139
+ screenshot.png
140
+ view_tree.xml
141
+ android_page_1_{name}_popup_filter/
142
+ ...
143
+ ```
144
+
145
+ ### Step 2 · UI 差异分析
146
+ agent 串行执行,不会下放给子 agent(保证质量):
147
+ - **2.1** 读安卓 screenshot + view tree,写 `android_page_*/UI_Analysis.md`(组件清单 + 位置 / 颜色 / icon / 尺寸 / 对齐方式等)
148
+ - **2.2** 读鸿蒙 screenshot + view tree,写 `hmos_page_*/UI_Analysis.md`;鸿蒙页不存在时改读源码写 `UI_Analysis_from_code.md`
149
+ - **2.3** 两份 Analysis 对比,按 `references/Comparison_Template.md` 生成 `UI_comparison.md`(markdown diff 表)
150
+ - **2.4** 验证所有 `UI_Analysis*.md` `UI_comparison.md` 都已写全
151
+
152
+ 所有尺寸都会以 `126px (3x → 42vp)` 的格式同时给出原始 px、设备密度、换算后的 vp。
153
+
154
+ ### Step 3 · 改鸿蒙源码
155
+ - 把每个 `UI_comparison.md` 里的 diff 项汇总到 `{task_dir}/fix_checklist.md`(唯一 source of truth)
156
+ - 读 `references/MVVM开发文档/` 学习 MVVM 模式
157
+ - 读 `page_align.md` 学习转换规则
158
+ - 逐条修 diff,每修一个把 `- [ ]` 改成 `- [x]`
159
+ - 每个尺寸 / icon / alignment 都要回溯到安卓源码的 XML 或资源值,不允许"看起来差不多"
160
+
161
+ ### Step 4 · 编译校验
162
+ 若可用,调 `hmos-fix-build-errors` skill 确保工程能编过。**不会自动部署**。
163
+
164
+ ---
165
+
166
+ ## 目录结构
167
+
168
+ ```
169
+ Agents/hmos-ui-align/
170
+ ├── SKILL.md # 流水线定义(主 agent 执行逻辑)
171
+ ├── readme.md # 本文档
172
+ ├── page_align.md # Step 3 的转换规则
173
+ ├── diff_analysis.md # 内部说明
174
+ ├── scripts/
175
+ ├── app_feature_verify.py # phone-agent 寻路工具
176
+ ├── page_capture.py # view tree + 截图采集工具
177
+ └── navigation-capure.md # 两个脚本的调用约定
178
+ └── references/
179
+ ├── UI_Analysis_Template.md # Step 2 分析模板
180
+ ├── Comparison_Template.md # Step 2.3 对比模板
181
+ ├── MVVM开发文档/ # 鸿蒙 MVVM 参考
182
+ ├── android-to-harmonyOS-ui-layout-mapping-reference.md
183
+ ├── android-to-harmonyOS-ui-atomic-component-mapping-reference.md
184
+ └── android-to-harmonyOS-ui-interaction-mapping-reference.md
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 单独运行脚本(调试用)
190
+
191
+ 跳过 skill 手动跑采集:
192
+
193
+ ```powershell
194
+ # 安卓寻路
195
+ $env:PYTHONIOENCODING="utf-8"
196
+ python Agents/hmos-ui-align/scripts/app_feature_verify.py `
197
+ --device adb `
198
+ --app "Salt Player" `
199
+ --package "com.salt.music" `
200
+ --prompt "进入首页-点击AI智能填报-点击专业筛选按钮" `
201
+ --api-key "$env:GLM_API_KEY" `
202
+ --max-steps 15
203
+
204
+ # 安卓采集
205
+ python Agents/hmos-ui-align/scripts/page_capture.py --device adb -o ./tmp/android_page_1_xxx
206
+
207
+ # 鸿蒙同理,把 --device adb 换成 --device hdc
208
+ ```
209
+
210
+ > 注意:`--prompt` 模式会自动在前面加「打开{app_name},」,所以 prompt 里不要再写"打开"。
211
+
212
+ ---
213
+
214
+ ## 常见问题
215
+
216
+ **Q: phone-agent 寻路失败怎么办?**
217
+ A: skill 默认重试两次。流水线的内部规则:①先看页面是否存在;②路径错了就 force-stop 重试;③路径对但工具报错就让 agent 自己看截图判断是否到了。超过两次仍失败才会跳过该页。
218
+
219
+ **Q: 鸿蒙端页面根本不存在,能新建吗?**
220
+ A: 可以。Step 2.2 会改从鸿蒙源码读,Step 3 会按安卓的实现规格新建 `.ets` 文件到 `entry/src/main/ets/pages/`,并登记路由。
221
+
222
+ **Q: 为什么同一次任务会采集多个页面?**
223
+ A: Step 1.3 默认扫描交互元素(tab / 弹窗 / 展开收起等)并递归采集。想关掉请在需求里写「只对齐主页面」。
224
+
225
+ **Q: 改完会自动部署吗?**
226
+ A: 不会。Step 4 只跑编译验证(如果 `hmos-fix-build-errors` skill 可用)。部署自己来。
227
+
228
+ **Q: 能不能只做差异分析、不改码?**
229
+ A: 目前流水线是端到端的。如果只想要分析产物,跑完 Step 2 后手动中断即可,所有 `UI_Analysis.md` 和 `UI_comparison.md` 都会落盘在 `{capture_output_dir}/task_{timestamp}/` 下。
230
+
231
+ ---
232
+
233
+ ## 已知限制
234
+
235
+ - 只对齐 UI,不对齐功能/数据流
236
+ - phone-agent 寻路依赖 GLM 模型对页面文本的识别,小字体或非标准控件可能识别不准
237
+ - 双端设备的分辨率/密度差异会影响像素到 vp 的换算,流水线已显式带上 density,但同一个 Figma 规格下仍可能出现 ±1vp 偏差
@@ -1,2 +1,2 @@
1
- | UI Component | 文本内容 | 尺寸与布局 | 颜色与背景 | 边框与轮廓 | 文本样式 | 变换与效果 | 状态与交互反馈 | Diff |
2
- |:-------------|:-----|:------|:------|:------|:-----|:------|:--------|:--------|
1
+ | UI Component | 文本内容 | 尺寸与布局 | 颜色与背景 | 边框与轮廓 | 文本样式 | 变换与效果 | 状态与交互反馈 | Diff |
2
+ |:-------------|:-----|:------|:------|:------|:-----|:------|:--------|:--------|