@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,99 +1,109 @@
1
- ---
2
- name: hmos-batch-ui-align
3
- description: Batch-convert multiple Android Activity UI snapshots to HarmonyOS ArkUI (ArkTS) pages. Use when the user wants to migrate Android UI pages to HarmonyOS in bulk, port multiple Activity screens to ArkTS, or run an Android-to-HarmonyOS UI conversion across a folder of page snapshots (page_NNNN_ActivityName). Triggers on phrases like "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS", "hmos-batch-ui-align", or any request that supplies an Android project path + Harmony project path + a directory of page snapshots.
4
- ---
5
-
6
- # hmos-batch-ui-align — Android → HarmonyOS UI Batch Conversion
7
-
8
- Batch-convert a set of Android page snapshots (each snapshot is a `page_NNNN_ActivityName/` directory containing `meta.json` + `view.xml` + optional `screenshot.png`) into HarmonyOS ArkTS pages following MVVM architecture.
9
-
10
- ## Step 1Parse User Request
11
-
12
- Extract 4 paths from the user's message (natural language, no fixed format):
13
-
14
- | Variable | Meaning | Typical Phrases |
15
- |---|---|---|
16
- | `android_project_dir` | Android source project root | "Android project path", "安卓项目", "source project" |
17
- | `harmony_project_dir` | HarmonyOS target project root | "target Harmony project", "鸿蒙项目", "output project" |
18
- | `ui_info_root` | **Parent directory containing all `page_NNNN_*` subdirectories** | "page screenshots and view tree", "page snapshots", "page folder" |
19
- | `pages` (optional) | User-explicitly listed page subset | When user lists `1. .../page_0001_X` ... take these |
20
-
21
- **`references_dir` and MVVM document directories always use skill-bundled relative paths** — **do not** accept user-provided overrides:
22
-
23
- - mappings: `./references/mappings/`
24
- - mvvm: `./references/mvvm/`
25
-
26
- If any required path cannot be extracted from the user's message, **ask the user** — do not guess.
27
-
28
- ## Step 2 Resource Conversion
29
-
30
- Invoke the `hmos-resources-convert` skill with the following parameters:
31
- 1. **Android project path** = `android_project_dir`
32
- 2. **HarmonyOS project output path** = `harmony_project_dir`
33
- 3. **resource_mapping_path** = generate the resource mapping document under `harmony_project_dir` at `${harmony_project_dir}/resource_mapping.md`
34
-
35
- This skill batch-converts Android resources (strings, colors, drawables, images, etc.) to HarmonyOS resource format and generates the mapping document.
36
-
37
- ## Step 3 — Page Exploration
38
-
39
- 1. Check if `ui_info_root` already contains `page_*` subdirectories. If yes, inform the user "N page snapshots already exist, skipping exploration" and skip this step.
40
- 2. Otherwise, determine the target App package name (`package`). If the user didn't provide it, extract the `package` attribute from `AndroidManifest.xml` in `android_project_dir`; if still unavailable, ask the user.
41
- 3. Execute with Bash:
42
- ```
43
- python ./scripts/android_parse_fast.py --package <package_name> --output <ui_info_root_absolute_path>
44
- ```
45
- This script connects to the Android emulator via ADB, BFS-traverses all reachable pages in the App, and for each page saves `screenshot.png`, `view.xml`, `meta.json` into `page_NNNN_ActivityName/` subdirectories. It also generates `index.json` and `report.html` under `ui_info_root`.
46
- 4. After execution, confirm that `index.json` has been generated under `ui_info_root`. If not, report an error and abort.
47
-
48
- ## Step 4 — Discover Pages
49
-
50
- If the user did not explicitly list pages: use Glob `page_*_*` under `ui_info_root` to find all page subdirectories, sorted by name (`page_0001_*` first).
51
-
52
- If the user explicitly listed pages (e.g. "1. .../page_0001_MainActivity ... 19. .../page_0019_MainActivity"): use the user's list.
53
-
54
- After discovery, create a task for each page via TaskCreate to track progress.
55
-
56
- ## Step 5 Per-Page Conversion
57
-
58
- **For each page**, invoke the Agent tool (`subagent_type: general-purpose`) to perform conversion. The prompt must include:
59
-
60
- 1. The page's `ui_info` absolute path (`{ui_info_root}/page_NNNN_ActivityName`)
61
- 2. `android_project_dir`, `harmony_project_dir`
62
- 3. Absolute paths for mappings and mvvm directories (skill-bundled)
63
- 4. **Copy the full contents of `references/conversion-procedure.md` as the sub-agent's work instructions** (use Read to read it and paste into the prompt)
64
-
65
- Why use sub-agents: single-page conversion reads many mapping/MVVM documents + Android source code. Sub-agents isolate context to avoid overwhelming the main session.
66
-
67
- After receiving a sub-agent's conversion report, append a brief summary to a cumulative report and mark the corresponding task as completed.
68
-
69
- **Execute serially** — do not parallelize (multiple sub-agents modifying the same Harmony project simultaneously will conflict).
70
-
71
- ## Step 6 — Unified Build Fix
72
-
73
- After all page conversions are complete, call the `hmos_fix_build_errors` skill **only once at the end** (passing `harmony_project_dir`) to make the entire project compile. Do not fix per-page (wasteful, and sub-agents are instructed to skip this step).
74
-
75
- ## Step 7 Summary Report
76
-
77
- Output an overview:
78
-
79
- ```
80
- ## Batch Conversion Overview
81
- - Pages processed: N
82
- - Successful: M Failed/partial: K
83
- - Final build status: SUCCESS / PARTIAL
84
-
85
- ### Per-Page Results
86
- | Page | Activity | Output File | Status |
87
- |---|---|---|---|
88
- | 0001 | MainActivity | pages/MainPage.ets | ✓ |
89
- | ... | | | |
90
-
91
- ### Manual Follow-up TODOs
92
- - (Aggregate mocked items / unimplemented navigation / business logic from sub-reports)
93
- ```
94
-
95
- ## Key Constraints
96
-
97
- - **Never** let a per-page sub-agent call `hmos_fix_build_errors`; do it once in Step 6 only.
98
- - If the user's `harmony_project_dir` lacks entry/resources subdirectories or the target project doesn't exist, stop and ask — do not generate code.
1
+ ---
2
+ name: hmos-batch-ui-align
3
+ description: Batch-convert multiple Android Activity UI snapshots to HarmonyOS ArkUI (ArkTS) pages. Use when the user wants to migrate Android UI pages to HarmonyOS in bulk, port multiple Activity screens to ArkTS, or run an Android-to-HarmonyOS UI conversion across a folder of page snapshots (page_NNNN_ActivityName). Triggers on phrases like "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS", "hmos-batch-ui-align", or any request that supplies an Android project path + Harmony project path + a directory of page snapshots.
4
+ ---
5
+
6
+ # hmos-batch-ui-align — Android → HarmonyOS UI Batch Conversion
7
+
8
+ Batch-convert a set of Android page snapshots (each snapshot is a `page_NNNN_ActivityName/` directory containing `meta.json` + `view.xml` + optional `screenshot.png`) into HarmonyOS ArkTS pages following MVVM architecture.
9
+
10
+ ## Step 0Environment Variables Check (run first)
11
+
12
+ The final build (Step 6, via `hmos_fix_build_errors`) reads the DevEco location **directly from the OS environment variables** (`echo "$VAR"` on macOS/Linux; `$env:VAR` in PowerShell on Windows):
13
+
14
+ | Variable | Needed for | Valid when |
15
+ |---|---|---|
16
+ | `DEVECO_HOME` *(or `DEVECO_SDK_HOME`)* | Step 6 unified build | resolves to a valid DevEco install |
17
+
18
+ If neither `DEVECO_HOME` nor `DEVECO_SDK_HOME` is set, **ask the user** for the DevEco Studio install path before proceeding (suggest running `ht init` to persist it as a machine environment variable).
19
+
20
+ ## Step 1 — Parse User Request
21
+
22
+ Extract 4 paths from the user's message (natural language, no fixed format):
23
+
24
+ | Variable | Meaning | Typical Phrases |
25
+ |---|---|---|
26
+ | `android_project_dir` | Android source project root | "Android project path", "安卓项目", "source project" |
27
+ | `harmony_project_dir` | HarmonyOS target project root | "target Harmony project", "鸿蒙项目", "output project" |
28
+ | `ui_info_root` | **Parent directory containing all `page_NNNN_*` subdirectories** | "page screenshots and view tree", "page snapshots", "page folder" |
29
+ | `pages` (optional) | User-explicitly listed page subset | When user lists `1. .../page_0001_X` ... take these |
30
+
31
+ **`references_dir` and MVVM document directories always use skill-bundled relative paths** **do not** accept user-provided overrides:
32
+
33
+ - mappings: `./references/mappings/`
34
+ - mvvm: `./references/mvvm/`
35
+
36
+ If any required path cannot be extracted from the user's message, **ask the user** — do not guess.
37
+
38
+ ## Step 2 — Resource Conversion
39
+
40
+ Invoke the `hmos-resources-convert` skill with the following parameters:
41
+ 1. **Android project path** = `android_project_dir`
42
+ 2. **HarmonyOS project output path** = `harmony_project_dir`
43
+ 3. **resource_mapping_path** = generate the resource mapping document under `harmony_project_dir` at `${harmony_project_dir}/resource_mapping.md`
44
+
45
+ This skill batch-converts Android resources (strings, colors, drawables, images, etc.) to HarmonyOS resource format and generates the mapping document.
46
+
47
+ ## Step 3 — Page Exploration
48
+
49
+ 1. Check if `ui_info_root` already contains `page_*` subdirectories. If yes, inform the user "N page snapshots already exist, skipping exploration" and skip this step.
50
+ 2. Otherwise, determine the target App package name (`package`). If the user didn't provide it, extract the `package` attribute from `AndroidManifest.xml` in `android_project_dir`; if still unavailable, ask the user.
51
+ 3. Execute with Bash:
52
+ ```
53
+ python ./scripts/android_parse_fast.py --package <package_name> --output <ui_info_root_absolute_path>
54
+ ```
55
+ This script connects to the Android emulator via ADB, BFS-traverses all reachable pages in the App, and for each page saves `screenshot.png`, `view.xml`, `meta.json` into `page_NNNN_ActivityName/` subdirectories. It also generates `index.json` and `report.html` under `ui_info_root`.
56
+ 4. After execution, confirm that `index.json` has been generated under `ui_info_root`. If not, report an error and abort.
57
+
58
+ ## Step 4 Discover Pages
59
+
60
+ If the user did not explicitly list pages: use Glob `page_*_*` under `ui_info_root` to find all page subdirectories, sorted by name (`page_0001_*` first).
61
+
62
+ If the user explicitly listed pages (e.g. "1. .../page_0001_MainActivity ... 19. .../page_0019_MainActivity"): use the user's list.
63
+
64
+ After discovery, create a task for each page via TaskCreate to track progress.
65
+
66
+ ## Step 5 — Per-Page Conversion
67
+
68
+ **For each page**, invoke the Agent tool (`subagent_type: general-purpose`) to perform conversion. The prompt must include:
69
+
70
+ 1. The page's `ui_info` absolute path (`{ui_info_root}/page_NNNN_ActivityName`)
71
+ 2. `android_project_dir`, `harmony_project_dir`
72
+ 3. Absolute paths for mappings and mvvm directories (skill-bundled)
73
+ 4. **Copy the full contents of `references/conversion-procedure.md` as the sub-agent's work instructions** (use Read to read it and paste into the prompt)
74
+
75
+ Why use sub-agents: single-page conversion reads many mapping/MVVM documents + Android source code. Sub-agents isolate context to avoid overwhelming the main session.
76
+
77
+ After receiving a sub-agent's conversion report, append a brief summary to a cumulative report and mark the corresponding task as completed.
78
+
79
+ **Execute serially** — do not parallelize (multiple sub-agents modifying the same Harmony project simultaneously will conflict).
80
+
81
+ ## Step 6 — Unified Build Fix
82
+
83
+ After all page conversions are complete, call the `hmos_fix_build_errors` skill **only once at the end** (passing `harmony_project_dir`) to make the entire project compile. Do not fix per-page (wasteful, and sub-agents are instructed to skip this step).
84
+
85
+ ## Step 7 — Summary Report
86
+
87
+ Output an overview:
88
+
89
+ ```
90
+ ## Batch Conversion Overview
91
+ - Pages processed: N
92
+ - Successful: M Failed/partial: K
93
+ - Final build status: SUCCESS / PARTIAL
94
+
95
+ ### Per-Page Results
96
+ | Page | Activity | Output File | Status |
97
+ |---|---|---|---|
98
+ | 0001 | MainActivity | pages/MainPage.ets | |
99
+ | ... | | | |
100
+
101
+ ### Manual Follow-up TODOs
102
+ - (Aggregate mocked items / unimplemented navigation / business logic from sub-reports)
103
+ ```
104
+
105
+ ## Key Constraints
106
+
107
+ - **Never** let a per-page sub-agent call `hmos_fix_build_errors`; do it once in Step 6 only.
108
+ - If the user's `harmony_project_dir` lacks entry/resources subdirectories or the target project doesn't exist, stop and ask — do not generate code.
99
109
  - If input paths are Windows paths (with backslashes), pass them as-is to sub-agents; internal Read/Glob support them.
@@ -1,180 +1,180 @@
1
- # Single-Page Android → HarmonyOS UI 转换流程
2
-
3
- > 这是 `hmos-batch-ui-align` skill 在每个子 agent 中执行的单页转换流程。基于 `a2h-ui-conversion-new` agent 改写:去掉 Phase 6 build 修复(由父 skill 统一在最后做一次)。
4
-
5
- 你是一个 **UI Activity 转换器**,专门把单个 Android Activity 的某一页 UI 迁移到 HarmonyOS ArkUI(ArkTS)。
6
-
7
- ## 输入(由父 skill 传入 prompt)
8
-
9
- 1. `activity_name` — Android Activity 类名
10
- 2. `android_project_dir` — Android 源项目根
11
- 3. `ui_info` — **单个** `page_NNNN_ActivityName/` 目录绝对路径(含 `meta.json` + `view.xml` + 可能的 `view_scroll_n.xml` / `screenshot.png`)
12
- 4. `harmony_project_dir` — HarmonyOS 项目根
13
- 5. `mappings_dir` — 三份映射表所在目录(skill 自带)
14
- 6. `mvvm_dir` — 13 份 MVVM 装饰器文档所在目录(skill 自带)
15
-
16
- ## 输出
17
-
18
- - ArkTS `.ets` 页面写到 `{harmony_project_dir}/entry/src/main/ets/pages/`
19
- - dialog/fragment/adapter 等组件写到 `.../ets/components/`
20
- - ViewModel 写到 `.../ets/viewmodel/`,Model 写到 `.../ets/model/`
21
- - 文本格式的转换报告(不落盘,作为最终回复返回给父 skill)
22
-
23
- ## Phase 1 — 定位页面
24
-
25
- `ui_info` 已是单个页面目录,无需再筛选。
26
-
27
- ## Phase 2 — 加载 MVVM 参考
28
-
29
- 读 `{mvvm_dir}/` 下全部 13 份文档:
30
- - `MVVM模式(V1).md`
31
- - `@Track装饰器:class对象属性级更新.md`
32
- - `@State装饰器:组件内状态.md`
33
- - `@Prop装饰器:父子单向同步.md`
34
- - `@Link装饰器:父子双向同步.md`
35
- - `@Provide装饰器和@Consume装饰器:与后代组件双向同步.md`
36
- - `@Observed装饰器和@ObjectLink装饰器:嵌套类对象属性变化.md`
37
- - `@Watch装饰器:状态变量更改通知.md`
38
- - `管理应用拥有的状态概述.md`
39
- - `LocalStorage:页面级UI状态存储.md`
40
- - `AppStorage:应用全局的UI状态存储.md`
41
- - `PersistentStorage:持久化存储UI状态.md`
42
- - `Environment:设备环境查询.md`
43
-
44
- ## Phase 3 — 加载映射参考
45
-
46
- 读 `{mappings_dir}/` 下:
47
- 1. `android-to-harmonyOS-ui-layout-mapping-reference.md` — 布局容器与布局属性映射(LinearLayout→Column/Row、FrameLayout→Stack、RecyclerView→List、layout_weight→.layoutWeight()、padding→.padding() 等)
48
- 2. `android-to-harmonyOS-ui-atomic-component-mapping-reference.md` — 原子组件映射(TextView→Text、EditText→TextInput/TextArea、Button→Button),含属性级映射(文本/样式/对齐/省略 等)
49
- 3. `android-to-harmonyOS-ui-interaction-mapping-reference.md` — 交互映射(onClick→.onClick()、onLongClick→LongPressGesture、touch、gesture、animation)
50
-
51
- > 这三份映射是**首要依据**,优先于内置知识。
52
-
53
- ## Phase 4 — 单页转换
54
-
55
- ### 4.1 解析 meta.json
56
-
57
- 提取:`page_id`、`label`、`clickable_elements`(含 class/resource-id/text/content-desc/bounds)、`click_path`、`came_from`/`trigger_element`。
58
-
59
- ### 4.2 解析视图树
60
-
61
- 读 `view.xml`,建立结构化理解:根布局、toolbar、content、bottom nav、各 widget 的 class/resource-id/text/content-desc/bounds/clickable/scrollable/checkable/checked/enabled、由 bounds 推断父子+兄弟关系、识别复用模式(list item / card)。
62
-
63
- 若存在 `view_scroll_n.xml`(n=1,2,...):表示 Android UI 太长需滚动捕获,按编号 1→n 依次读取,**以 `view.xml` 为根**合并所有 `view_scroll_n.xml` 得到合并结构。
64
-
65
- 合并结构仍可能不完整(某些组件未出现在任何快照中)。**必须**在 `android_project_dir` 中查找并阅读与 `meta.json`、合并结构最相关的静态 XML 布局文件 + Kotlin/Java 代码,以静态源码为主结构,把合并结构作为动态信息补充,并把用户自定义/三方组件展开成原子 Android 布局/组件,得到**最终结构理解**。输出该理解。
66
-
67
- 可选:调用 `android-ui-graph-query` skill 补充 UI 图谱信息(widget 详细属性、样式、theme)。
68
-
69
- ### 4.3 生成 ArkUI 代码
70
-
71
- **与现有 Harmony 文件冲突处理**:转换前若目标 .ets 已存在,三种情形——
72
- 1. 动态刷新组件(toolbar 不同状态显示不同图标)
73
- 2. 增量实现
74
- 3. 现有代码或最终结构理解有错
75
-
76
- 无论哪种,必须通过对照静态 XML/Kotlin/Java + view.xml + view_scroll_n.xml 验证。**不要删除已有 Harmony 代码**。
77
-
78
- dialog/fragment/adapter 等必须从主页面拆出去到 `{harmony_project_dir}/entry/src/main/ets/components/`。
79
-
80
- **架构**:
81
- - MVVM:page/component 用 viewmodel,viewmodel 用 model
82
- - 转换前先扫 `{harmony_project_dir}` 找可复用组件/VM/Model;toolbar 等通用组件抽到 components 复用;相关 model/viewmodel 合并复用,不要每页新建一份
83
-
84
- **资源**:每个 Android UI 引用的资源(图片/字符串/颜色/尺寸等)必须使用 `{harmony_project_dir}\entry\src\main\resources` 中**同名**的转换后资源。
85
-
86
- **布局**:查 layout mapping ref。
87
-
88
- **组件**:查 atomic component mapping ref。
89
-
90
- **交互**:查 interaction mapping ref。
91
-
92
- **始终先查映射文件**(项目专属、覆盖更全),覆盖内置知识。
93
-
94
- **单位与样式**:
95
- - `dp` → `vp`,`sp` → `fp`
96
- - 由 bounds 算尺寸:`width = x2 - x1`,`height = y2 - y1`
97
- - 假定 3x 密度:`1vp ≈ 3px`
98
- - 资源用 `$r('app.color.xxx')` / `$r('app.string.xxx')` / `$r('app.media.xxx')`
99
-
100
- **路由**:实现 UI 与组件之间的路由关系。
101
-
102
- **交互元素**:
103
- - 给每个 `clickable_element` 挂 `.onClick()`
104
- - `click_path` 显示跳到另一 Activity → `router.pushUrl()`
105
- - 状态切换(dialog/menu/toggle)→ 用 `@State` 管理
106
- - **优先真实实现**:mock 之前先在 `{harmony_project_dir}` 搜目标页面/组件 .ets 是否存在;存在则接真实 `router.pushUrl()`;**仅当目标尚未实现**才 mock + `console.info('TODO: ...')`
107
-
108
- ### 4.4 截图复核(如有)
109
-
110
- `screenshot.png` 仅覆盖屏内 UI,**不要**用它去校验屏外组件。
111
-
112
- 存在则读取:视觉校验布局理解,对照视图层级,调整 `view.xml` 未捕获的间距/对齐/样式。`screenshot_scroll_n.png` 同理对照 `view_scroll_n.xml`。
113
-
114
- ## Phase 5 — 一致性校验(关键,必跑 3 轮)
115
-
116
- 列出转换后 HarmonyOS UI 中所有 layout/component/resource reference,对每一个**逐项**走完以下检查(不可省略):
117
-
118
- - **@Track 缺失**:`@Observed` 类中所有在 UI 中使用的属性是否都加了 `@Track`?没有则补
119
- - **颜色冲突**:fill/background/foreground 颜色是否冲突导致不可见(白底白图)?有则修
120
- - **颜色设置**:背景/填充/前景色是否与 Android UI 一致(漏设、错设)?有则修
121
- - **资源引用错用**:资源引用是否与 Android UI 一致;不存在的资源要重新查找正确名
122
- - **形状错用**:圆角/直角等形状是否与 Android UI 一致
123
- - **尺寸问题**:图标/组件大小是否一致
124
- - **位置问题**:toolbar 是否在顶部、图标位置是否过左/过右等
125
- - **路由关系**:UI 与组件间路由是否正确实现
126
-
127
- **必须跑 3 轮验证迭代,并输出验证报告**。
128
-
129
- ## Phase 6 — Build 修复
130
-
131
- **跳过**。父 skill `hmos-batch-ui-align` 会在所有页面转换完后统一调用 `hmos_fix_build_errors` 修一次。
132
-
133
- ## 返回转换报告
134
-
135
- ```
136
- ## Conversion Report: {ActivityName} (page_NNNN)
137
-
138
- ### Page Processed
139
- | Page ID | Label | Type | Output File |
140
- |---------|-------|------|-------------|
141
- | page_NNNN_XXX | ... | Base Page | XxxPage.ets |
142
-
143
- ### Component Mapping Decisions
144
- - ...
145
-
146
- ### State Variables
147
- - ...
148
-
149
- ### Resources Converted
150
- - ...
151
-
152
- ### Implemented Interactions
153
- - ...(接通真实跳转的事件)
154
-
155
- ### TODOs & Mocked Items
156
- - ...(mock 的事件、未实现的目标页)
157
-
158
- ### Navigation
159
- - ...(从 click_path 抽取的导航目标)
160
-
161
- ### Validation Report (3 iterations)
162
- - 第 1 轮:发现/修复 N 项
163
- - 第 2 轮:发现/修复 M 项
164
- - 第 3 轮:稳定/剩余 K 项
165
- ```
166
-
167
- ## 全局准则
168
-
169
- - **一个 Activity = 一个主页面文件**(仅最小编号那张快照)
170
- - **严格保真**:layout 结构、组件层级、资源引用必须与 Android 源一一对应;不增删/重排 UI 元素
171
- - **资源精确匹配**:所有 color/string/dimension/image 必须有对应 HarmonyOS 资源;不要硬编码
172
- - **可编译性是必须的**:已实现目标接真实事件;未实现才 mock 至可编译
173
- - 仅用声明式 ArkUI;绝不写命令式 DOM 操作
174
- - 保留原 Android 视觉与 UX 保真度
175
- - 资源一律 `$r('app.type.name')`
176
- - 留 `// TODO:` 注释给:业务逻辑、ViewModel 数据绑定、未转换的目标 Activity
177
- - 响应式布局:优先百分比宽度 + Flex,少用固定尺寸
178
- - 无障碍:`content-desc` → `.accessibilityText()`,有意义的 `text` → 正确的 label
179
- - 嵌套 > 5 层时把相关 UI 拆为 `@Component` 子组件
180
- - 任一 mapping 文件缺失/为空:用内置知识继续,并在报告中注明
1
+ # Single-Page Android → HarmonyOS UI 转换流程
2
+
3
+ > 这是 `hmos-batch-ui-align` skill 在每个子 agent 中执行的单页转换流程。基于 `a2h-ui-conversion-new` agent 改写:去掉 Phase 6 build 修复(由父 skill 统一在最后做一次)。
4
+
5
+ 你是一个 **UI Activity 转换器**,专门把单个 Android Activity 的某一页 UI 迁移到 HarmonyOS ArkUI(ArkTS)。
6
+
7
+ ## 输入(由父 skill 传入 prompt)
8
+
9
+ 1. `activity_name` — Android Activity 类名
10
+ 2. `android_project_dir` — Android 源项目根
11
+ 3. `ui_info` — **单个** `page_NNNN_ActivityName/` 目录绝对路径(含 `meta.json` + `view.xml` + 可能的 `view_scroll_n.xml` / `screenshot.png`)
12
+ 4. `harmony_project_dir` — HarmonyOS 项目根
13
+ 5. `mappings_dir` — 三份映射表所在目录(skill 自带)
14
+ 6. `mvvm_dir` — 13 份 MVVM 装饰器文档所在目录(skill 自带)
15
+
16
+ ## 输出
17
+
18
+ - ArkTS `.ets` 页面写到 `{harmony_project_dir}/entry/src/main/ets/pages/`
19
+ - dialog/fragment/adapter 等组件写到 `.../ets/components/`
20
+ - ViewModel 写到 `.../ets/viewmodel/`,Model 写到 `.../ets/model/`
21
+ - 文本格式的转换报告(不落盘,作为最终回复返回给父 skill)
22
+
23
+ ## Phase 1 — 定位页面
24
+
25
+ `ui_info` 已是单个页面目录,无需再筛选。
26
+
27
+ ## Phase 2 — 加载 MVVM 参考
28
+
29
+ 读 `{mvvm_dir}/` 下全部 13 份文档:
30
+ - `MVVM模式(V1).md`
31
+ - `@Track装饰器:class对象属性级更新.md`
32
+ - `@State装饰器:组件内状态.md`
33
+ - `@Prop装饰器:父子单向同步.md`
34
+ - `@Link装饰器:父子双向同步.md`
35
+ - `@Provide装饰器和@Consume装饰器:与后代组件双向同步.md`
36
+ - `@Observed装饰器和@ObjectLink装饰器:嵌套类对象属性变化.md`
37
+ - `@Watch装饰器:状态变量更改通知.md`
38
+ - `管理应用拥有的状态概述.md`
39
+ - `LocalStorage:页面级UI状态存储.md`
40
+ - `AppStorage:应用全局的UI状态存储.md`
41
+ - `PersistentStorage:持久化存储UI状态.md`
42
+ - `Environment:设备环境查询.md`
43
+
44
+ ## Phase 3 — 加载映射参考
45
+
46
+ 读 `{mappings_dir}/` 下:
47
+ 1. `android-to-harmonyOS-ui-layout-mapping-reference.md` — 布局容器与布局属性映射(LinearLayout→Column/Row、FrameLayout→Stack、RecyclerView→List、layout_weight→.layoutWeight()、padding→.padding() 等)
48
+ 2. `android-to-harmonyOS-ui-atomic-component-mapping-reference.md` — 原子组件映射(TextView→Text、EditText→TextInput/TextArea、Button→Button),含属性级映射(文本/样式/对齐/省略 等)
49
+ 3. `android-to-harmonyOS-ui-interaction-mapping-reference.md` — 交互映射(onClick→.onClick()、onLongClick→LongPressGesture、touch、gesture、animation)
50
+
51
+ > 这三份映射是**首要依据**,优先于内置知识。
52
+
53
+ ## Phase 4 — 单页转换
54
+
55
+ ### 4.1 解析 meta.json
56
+
57
+ 提取:`page_id`、`label`、`clickable_elements`(含 class/resource-id/text/content-desc/bounds)、`click_path`、`came_from`/`trigger_element`。
58
+
59
+ ### 4.2 解析视图树
60
+
61
+ 读 `view.xml`,建立结构化理解:根布局、toolbar、content、bottom nav、各 widget 的 class/resource-id/text/content-desc/bounds/clickable/scrollable/checkable/checked/enabled、由 bounds 推断父子+兄弟关系、识别复用模式(list item / card)。
62
+
63
+ 若存在 `view_scroll_n.xml`(n=1,2,...):表示 Android UI 太长需滚动捕获,按编号 1→n 依次读取,**以 `view.xml` 为根**合并所有 `view_scroll_n.xml` 得到合并结构。
64
+
65
+ 合并结构仍可能不完整(某些组件未出现在任何快照中)。**必须**在 `android_project_dir` 中查找并阅读与 `meta.json`、合并结构最相关的静态 XML 布局文件 + Kotlin/Java 代码,以静态源码为主结构,把合并结构作为动态信息补充,并把用户自定义/三方组件展开成原子 Android 布局/组件,得到**最终结构理解**。输出该理解。
66
+
67
+ 可选:调用 `android-ui-graph-query` skill 补充 UI 图谱信息(widget 详细属性、样式、theme)。
68
+
69
+ ### 4.3 生成 ArkUI 代码
70
+
71
+ **与现有 Harmony 文件冲突处理**:转换前若目标 .ets 已存在,三种情形——
72
+ 1. 动态刷新组件(toolbar 不同状态显示不同图标)
73
+ 2. 增量实现
74
+ 3. 现有代码或最终结构理解有错
75
+
76
+ 无论哪种,必须通过对照静态 XML/Kotlin/Java + view.xml + view_scroll_n.xml 验证。**不要删除已有 Harmony 代码**。
77
+
78
+ dialog/fragment/adapter 等必须从主页面拆出去到 `{harmony_project_dir}/entry/src/main/ets/components/`。
79
+
80
+ **架构**:
81
+ - MVVM:page/component 用 viewmodel,viewmodel 用 model
82
+ - 转换前先扫 `{harmony_project_dir}` 找可复用组件/VM/Model;toolbar 等通用组件抽到 components 复用;相关 model/viewmodel 合并复用,不要每页新建一份
83
+
84
+ **资源**:每个 Android UI 引用的资源(图片/字符串/颜色/尺寸等)必须使用 `{harmony_project_dir}\entry\src\main\resources` 中**同名**的转换后资源。
85
+
86
+ **布局**:查 layout mapping ref。
87
+
88
+ **组件**:查 atomic component mapping ref。
89
+
90
+ **交互**:查 interaction mapping ref。
91
+
92
+ **始终先查映射文件**(项目专属、覆盖更全),覆盖内置知识。
93
+
94
+ **单位与样式**:
95
+ - `dp` → `vp`,`sp` → `fp`
96
+ - 由 bounds 算尺寸:`width = x2 - x1`,`height = y2 - y1`
97
+ - 假定 3x 密度:`1vp ≈ 3px`
98
+ - 资源用 `$r('app.color.xxx')` / `$r('app.string.xxx')` / `$r('app.media.xxx')`
99
+
100
+ **路由**:实现 UI 与组件之间的路由关系。
101
+
102
+ **交互元素**:
103
+ - 给每个 `clickable_element` 挂 `.onClick()`
104
+ - `click_path` 显示跳到另一 Activity → `router.pushUrl()`
105
+ - 状态切换(dialog/menu/toggle)→ 用 `@State` 管理
106
+ - **优先真实实现**:mock 之前先在 `{harmony_project_dir}` 搜目标页面/组件 .ets 是否存在;存在则接真实 `router.pushUrl()`;**仅当目标尚未实现**才 mock + `console.info('TODO: ...')`
107
+
108
+ ### 4.4 截图复核(如有)
109
+
110
+ `screenshot.png` 仅覆盖屏内 UI,**不要**用它去校验屏外组件。
111
+
112
+ 存在则读取:视觉校验布局理解,对照视图层级,调整 `view.xml` 未捕获的间距/对齐/样式。`screenshot_scroll_n.png` 同理对照 `view_scroll_n.xml`。
113
+
114
+ ## Phase 5 — 一致性校验(关键,必跑 3 轮)
115
+
116
+ 列出转换后 HarmonyOS UI 中所有 layout/component/resource reference,对每一个**逐项**走完以下检查(不可省略):
117
+
118
+ - **@Track 缺失**:`@Observed` 类中所有在 UI 中使用的属性是否都加了 `@Track`?没有则补
119
+ - **颜色冲突**:fill/background/foreground 颜色是否冲突导致不可见(白底白图)?有则修
120
+ - **颜色设置**:背景/填充/前景色是否与 Android UI 一致(漏设、错设)?有则修
121
+ - **资源引用错用**:资源引用是否与 Android UI 一致;不存在的资源要重新查找正确名
122
+ - **形状错用**:圆角/直角等形状是否与 Android UI 一致
123
+ - **尺寸问题**:图标/组件大小是否一致
124
+ - **位置问题**:toolbar 是否在顶部、图标位置是否过左/过右等
125
+ - **路由关系**:UI 与组件间路由是否正确实现
126
+
127
+ **必须跑 3 轮验证迭代,并输出验证报告**。
128
+
129
+ ## Phase 6 — Build 修复
130
+
131
+ **跳过**。父 skill `hmos-batch-ui-align` 会在所有页面转换完后统一调用 `hmos_fix_build_errors` 修一次。
132
+
133
+ ## 返回转换报告
134
+
135
+ ```
136
+ ## Conversion Report: {ActivityName} (page_NNNN)
137
+
138
+ ### Page Processed
139
+ | Page ID | Label | Type | Output File |
140
+ |---------|-------|------|-------------|
141
+ | page_NNNN_XXX | ... | Base Page | XxxPage.ets |
142
+
143
+ ### Component Mapping Decisions
144
+ - ...
145
+
146
+ ### State Variables
147
+ - ...
148
+
149
+ ### Resources Converted
150
+ - ...
151
+
152
+ ### Implemented Interactions
153
+ - ...(接通真实跳转的事件)
154
+
155
+ ### TODOs & Mocked Items
156
+ - ...(mock 的事件、未实现的目标页)
157
+
158
+ ### Navigation
159
+ - ...(从 click_path 抽取的导航目标)
160
+
161
+ ### Validation Report (3 iterations)
162
+ - 第 1 轮:发现/修复 N 项
163
+ - 第 2 轮:发现/修复 M 项
164
+ - 第 3 轮:稳定/剩余 K 项
165
+ ```
166
+
167
+ ## 全局准则
168
+
169
+ - **一个 Activity = 一个主页面文件**(仅最小编号那张快照)
170
+ - **严格保真**:layout 结构、组件层级、资源引用必须与 Android 源一一对应;不增删/重排 UI 元素
171
+ - **资源精确匹配**:所有 color/string/dimension/image 必须有对应 HarmonyOS 资源;不要硬编码
172
+ - **可编译性是必须的**:已实现目标接真实事件;未实现才 mock 至可编译
173
+ - 仅用声明式 ArkUI;绝不写命令式 DOM 操作
174
+ - 保留原 Android 视觉与 UX 保真度
175
+ - 资源一律 `$r('app.type.name')`
176
+ - 留 `// TODO:` 注释给:业务逻辑、ViewModel 数据绑定、未转换的目标 Activity
177
+ - 响应式布局:优先百分比宽度 + Flex,少用固定尺寸
178
+ - 无障碍:`content-desc` → `.accessibilityText()`,有意义的 `text` → 正确的 label
179
+ - 嵌套 > 5 层时把相关 UI 拆为 `@Component` 子组件
180
+ - 任一 mapping 文件缺失/为空:用内置知识继续,并在报告中注明