@buaa_smat/hometrans 0.1.16 → 0.1.19

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 (235) hide show
  1. package/README.md +162 -54
  2. package/agents/code-reviewer.md +321 -65
  3. package/agents/logic-coder.md +113 -88
  4. package/agents/logic-context-builder.md +47 -29
  5. package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
  6. package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
  7. package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
  8. package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
  9. package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
  10. package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
  11. package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
  12. package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
  13. package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
  14. package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
  15. package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
  16. package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
  17. package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
  18. package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
  19. package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
  20. package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
  21. package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
  22. package/agents/scripts/hmos-precheck/index.mjs +17 -0
  23. package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
  24. package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
  25. package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
  26. package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
  27. package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
  28. package/agents/scripts/platform_query.mjs +626 -0
  29. package/agents/scripts/platform_query.test.mjs +422 -0
  30. package/agents/self-test-fixer.md +36 -34
  31. package/agents/self-tester.md +123 -143
  32. package/agents/test-case-generation-generator.md +317 -0
  33. package/agents/test-case-generation-validator.md +231 -0
  34. package/dist/cli/config-store.js +16 -63
  35. package/dist/cli/env-vars.js +1 -3
  36. package/dist/cli/index.js +0 -11
  37. package/dist/cli/init.js +127 -144
  38. package/dist/cli/uninstall.js +76 -110
  39. package/dist/utils/regex.js +8 -0
  40. package/env-requirements.json +55 -54
  41. package/package.json +6 -6
  42. package/resource/convert_pipeline_process.svg +103 -0
  43. package/resource/project_architecture.svg +122 -0
  44. package/resource/title_dark.png +0 -0
  45. package/skills/hmos-batch-ui-align/SKILL.md +345 -41
  46. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
  47. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  48. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  49. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  61. 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
  62. 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
  63. package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
  64. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
  65. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
  66. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
  67. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
  68. package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
  69. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
  70. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
  71. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
  72. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
  73. package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
  74. package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
  75. package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/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 +1220 -0
  76. package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
  77. package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -0
  78. package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
  79. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
  80. package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
  81. package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
  82. package/skills/hmos-convert-pipeline/SKILL.md +168 -121
  83. package/skills/hmos-fix-build-errors/SKILL.md +87 -67
  84. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
  85. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
  86. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
  87. package/skills/hmos-incremental-ui-align/README.md +53 -36
  88. package/skills/hmos-incremental-ui-align/SKILL.md +179 -23
  89. package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
  90. package/skills/hmos-incremental-ui-align/page_align.md +62 -62
  91. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
  92. 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
  93. 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
  94. 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
  95. 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
  96. 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
  97. 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
  98. 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
  99. 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
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
  106. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
  107. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
  108. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
  109. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
  110. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
  111. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
  112. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
  113. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
  114. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
  115. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
  116. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
  117. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/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 +1220 -0
  118. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
  119. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
  120. package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
  121. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
  122. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  123. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  124. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  125. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
  126. package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
  127. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
  128. package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
  129. package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
  130. package/skills/hmos-integration-test/README.md +61 -70
  131. package/skills/hmos-integration-test/SKILL.md +128 -111
  132. package/skills/hmos-resources-convert/SKILL.md +334 -66
  133. package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
  134. package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
  135. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
  136. package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
  137. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
  138. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
  139. package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
  140. package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
  141. package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
  142. package/skills/hmos-spec-generate/SKILL.md +293 -214
  143. package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
  144. package/skills/hmos-spec-generate/template/REQ.txt +22 -0
  145. package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
  146. package/skills/hmos-test-case-generation/README.md +241 -0
  147. package/skills/hmos-test-case-generation/SKILL.md +324 -0
  148. package/skills/hmos-test-case-generation/references/contract.md +315 -0
  149. package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
  150. package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
  151. package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
  152. package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
  153. package/tools/bfs-crawl/README.md +73 -0
  154. package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
  155. package/tools/test-tools/autotest/config.ts +175 -0
  156. package/tools/test-tools/autotest/deps/autotest-agent-0.1.1.tgz +0 -0
  157. package/tools/test-tools/autotest/docs/README.md +266 -0
  158. package/tools/test-tools/autotest/{testcases_schema.md → docs/testcases_schema.md} +1 -1
  159. package/tools/test-tools/autotest/engine/batch-launcher.ts +327 -0
  160. package/tools/test-tools/autotest/engine/report-tool.ts +773 -0
  161. package/tools/test-tools/autotest/engine/self-test-runner.ts +961 -0
  162. package/tools/test-tools/autotest/engine/testcases-tool.ts +246 -0
  163. package/tools/test-tools/autotest/paths.ts +41 -0
  164. package/tools/test-tools/autotest/resolve-metadata-tool.ts +143 -0
  165. package/tools/test-tools/autotest/runner/logger.ts +45 -0
  166. package/tools/test-tools/autotest/runner/process-utils.ts +41 -0
  167. package/tools/test-tools/autotest/validate.ts +167 -0
  168. package/agents/build-fixer.md +0 -385
  169. package/agents/logic-coder/scripts/platform_context_query.py +0 -568
  170. package/agents/review-fixer.md +0 -405
  171. package/agents/spec-generator.md +0 -541
  172. package/dist/cli/mcp-setup.js +0 -258
  173. package/dist/cli/mcp.js +0 -94
  174. package/dist/context/index.js +0 -694
  175. package/resource/migration_process.svg +0 -94
  176. package/resource/migration_process_transparent.svg +0 -93
  177. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
  178. package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
  179. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
  180. package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
  181. package/skills/hmos-resources-convert/evals/evals.json +0 -171
  182. package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
  183. package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
  184. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
  185. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
  186. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
  187. package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
  188. package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
  189. package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
  190. package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
  191. package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
  192. package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
  193. package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
  194. package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
  195. package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
  196. package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
  197. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
  198. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
  199. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
  200. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
  201. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
  202. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
  203. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
  204. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
  205. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
  206. package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
  207. package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
  208. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
  209. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
  210. package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
  211. package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
  212. package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
  213. package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
  214. package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
  215. package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
  216. package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
  217. package/skills/hmos-resources-convert/tools/apktool.bat +0 -85
  218. package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
  219. package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
  220. package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
  221. package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
  222. package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
  223. package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
  224. package/tools/test-tools/autotest/README.md +0 -238
  225. package/tools/test-tools/autotest/pyproject.toml +0 -26
  226. package/tools/test-tools/autotest/report_tool.py +0 -759
  227. package/tools/test-tools/autotest/self_test_runner.py +0 -895
  228. package/tools/test-tools/autotest/testcases_tool.py +0 -215
  229. package/tools/test-tools/autotest/uv.lock +0 -3156
  230. package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
  231. package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
  232. package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
  233. package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
  234. package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
  235. package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
@@ -1,388 +1,410 @@
1
- # Android Resource Dependency Analysis Rules
2
-
3
- This document defines how to extract, track, and resolve inter-resource dependencies during Android-to-HarmonyOS resource conversion. Dependency analysis runs regardless of resource source — whether from a decompiled APK (complete resource set) or from the project's source `res/` directory (potentially missing library resources). When working from source `res/`, more references will be unresolvable, but the analysis is still essential to identify exactly what's missing and why. It also provides the evidence used to infer screen ownership, source ownership, and review-oriented function descriptions for the markdown written to `resource_mapping_path`.
4
-
5
- ## Table of Contents
6
- 1. [Resource Reference Patterns](#resource-reference-patterns)
7
- 2. [Building the Resource Value Lookup Table](#building-the-resource-value-lookup-table)
8
- 3. [Resolving References to True Values](#resolving-references-to-true-values)
9
- 4. [Where to Scan for Dependencies](#where-to-scan-for-dependencies)
10
- 5. [Dependency Verification](#dependency-verification)
11
- 6. [Handling Missing Library Resources](#handling-missing-library-resources)
12
-
13
- ---
14
-
15
- ## Resource Reference Patterns
16
-
17
- Android resources reference each other using `@type/name` syntax. Extract these references from XML attribute values and text content.
18
-
19
- ### Reference Regex Pattern
20
-
21
- Use the following pattern to extract resource references from any XML content:
22
-
23
- ```
24
- @(color|drawable|mipmap|string|dimen|integer|bool|array|style|attr|id|layout|menu|anim|animator|raw|font|xml|plurals)/([a-zA-Z_][a-zA-Z0-9_]*)
25
- ```
26
-
27
- This captures:
28
- - Group 1: resource type (`color`, `drawable`, etc.)
29
- - Group 2: resource name
30
-
31
- ### System Resource References
32
-
33
- References prefixed with `@android:` (e.g., `@android:color/black`, `@android:drawable/ic_menu_close`) are Android framework resources provided by the OS. These resources do NOT exist in HarmonyOS and MUST be resolved to concrete values during conversion — they cannot be left as-is in the output.
34
-
35
- **Resolution rules for system resources:**
36
- - `@android:color/*` — resolve using the built-in Android system color lookup table (defined in SKILL.md Step 5.2). NEVER leave `@android:color/*` references in the converted output. If a color is not in the lookup table, use the decompiled APK's framework resources or fall back to `#ff000000` with a warning.
37
- - `@android:dimen/*` — resolve using the built-in Android system dimension lookup table (defined in SKILL.md Step 5.2). Fall back to `0vp` with a warning if not found.
38
- - `@android:string/*` — resolve to the known English string value if available, otherwise use `""` with a warning.
39
- - `@android:integer/*` — resolve to the known value if available, otherwise use `0` with a warning.
40
- - `@android:drawable/*` — these are Android framework drawables (icons, backgrounds). Log as "system drawable — requires manual replacement" in the report. If converting from a decompiled APK, extract and convert the drawable. Otherwise, create a placeholder SVG.
41
-
42
- In the conversion report, list all resolved system resource references in a dedicated section so the developer can verify the resolved values are correct.
43
-
44
- ### Theme Attribute References
45
-
46
- References using `?attr/name` or `?android:attr/name` are theme attribute references resolved at runtime. These **cannot** be statically resolved — they depend on which theme is applied at runtime. Log them as "unresolvable theme attribute" and keep the reference as-is in the converted output.
47
-
48
- ### Reference Locations in XML
49
-
50
- Resource references can appear in several places within Android XML files:
51
-
52
- **1. XML attribute values:**
53
- ```xml
54
- <background android:drawable="@color/md_amber_700" />
55
- <TextView android:text="@string/hello" android:textColor="@color/primary" />
56
- <ImageView android:src="@drawable/icon" />
57
- ```
58
-
59
- **2. Style/theme item values:**
60
- ```xml
61
- <style name="AppTheme">
62
- <item name="colorPrimary">@color/primary</item>
63
- <item name="android:windowBackground">@drawable/bg_window</item>
64
- </style>
65
- ```
66
-
67
- **3. Color state list references:**
68
- ```xml
69
- <selector>
70
- <item android:color="@color/pressed_color" android:state_pressed="true" />
71
- <item android:color="@color/default_color" />
72
- </selector>
73
- ```
74
-
75
- **4. Drawable XML references:**
76
- ```xml
77
- <layer-list>
78
- <item android:drawable="@drawable/bg_layer" />
79
- </layer-list>
80
-
81
- <adaptive-icon>
82
- <background android:drawable="@color/ic_bg" />
83
- <foreground android:drawable="@mipmap/ic_fg" />
84
- </adaptive-icon>
85
- ```
86
-
87
- **5. Values XML cross-references (these are the primary targets for resolution):**
88
- ```xml
89
- <!-- colors.xml -->
90
- <color name="primary_light">@color/primary</color>
91
-
92
- <!-- dimens.xml -->
93
- <color name="margin_double">@dimen/margin_base</color>
94
- ```
95
-
96
- ## Screen and Source Attribution Support
97
-
98
- Use dependency analysis not only to resolve resources, but also to collect evidence for the mapping markdown.
99
-
100
- ### Screen attribution evidence sources
101
-
102
- Collect evidence from:
103
- - Activities
104
- - Fragments
105
- - Compose / UI page files
106
- - Navigation graphs
107
- - Layout XML files referenced by Activities or Fragments
108
- - Menu XML files referenced by screens
109
- - Direct `R.type.name` references in code
110
-
111
- ### Screen attribution rules
112
-
113
- - If a screen directly references a resource, attribute the resource to that screen.
114
- - If a screen references a layout and the layout references additional resources, attribute those resources to that screen.
115
- - If a shared component is referenced by multiple screens, record all known screens or use `Common`.
116
- - For launcher icons, round icons, adaptive icons, app name, and app-wide theme resources, use `Launcher` or `Global` as defined by `references/resource-mapping-rules.md`.
117
- - If evidence is insufficient, use `Unknown`.
118
-
119
- ### Source attribution evidence sources
120
-
121
- Collect evidence from:
122
- - Actual source path (`app/src/...`, local module `src/...`)
123
- - Decompiled APK presence without a matching source resource
124
- - Resource naming prefixes such as `abc_*`, `mtrl_*`, `design_*`, `material_*`
125
- - Declared Gradle dependencies
126
- - Android framework reference prefix `@android:`
127
- - Runtime URL / remote-loading code patterns
128
-
129
- ### Function-description evidence sources
130
-
131
- Collect evidence from:
132
- - resource name semantics
133
- - XML root type (`vector`, `shape`, `selector`, `layer-list`, `adaptive-icon`)
134
- - usage site labels or surrounding code context
135
- - manifest usage (`android:icon`, `android:roundIcon`, etc.)
136
-
137
- Do not overstate certainty. If the conclusion is inferred, retain that explanation in the eventual mapping-row notes.
138
-
139
- ---
140
-
141
-
142
- Before resolving references, build a complete lookup table from the resource source directory (either decompiled `res/` or source `res/`). When using the decompiled APK, this table will be comprehensive. When using source `res/`, it will only contain app-defined resources — library resources will be absent, and references to them will be flagged during verification.
143
-
144
- ### Value Resources
145
-
146
- Parse all `values*/*.xml` files and build mappings:
147
-
148
- ```
149
- colors:
150
- "primary" → "#FF6200EE"
151
- "primary_light" → "@color/primary" # reference chain — will be resolved
152
- "md_blue_500" → "#2196F3"
153
-
154
- dimens:
155
- "margin_base" → "16dp"
156
- "margin_double" → "@dimen/margin_base" # reference chain
157
-
158
- strings:
159
- "app_name" → "My App"
160
- "greeting" → "Hello, %1$s!"
161
-
162
- integers:
163
- "max_items" → "10"
164
-
165
- bools:
166
- "is_tablet" → "false"
167
- ```
168
-
169
- Include ALL qualifier variants (e.g., `values/colors.xml`, `values-night/colors.xml`, `values-ar/colors.xml`). Each qualifier variant gets its own entry in the lookup table.
170
-
171
- ### File Resources
172
-
173
- Record all drawable and mipmap files:
174
-
175
- ```
176
- drawables:
177
- "icon" → "drawable/icon.png"
178
- "bg_card" → "drawable/bg_card.xml" (shape)
179
- "ic_arrow" → "drawable/ic_arrow.xml" (vector)
180
-
181
- mipmaps:
182
- "ic_launcher" → "mipmap-anydpi-v26/ic_launcher.xml" (adaptive-icon)
183
- "ic_launcher_foreground" → "mipmap-xxxhdpi/ic_launcher_foreground.png"
184
- ```
185
-
186
- ---
187
-
188
- ## Resolving References to True Values
189
-
190
- The key step: walk through all resource values and replace references with actual concrete values.
191
-
192
- ### Resolution Algorithm
193
-
194
- ```
195
- function resolve(type, name, qualifier, depth=0):
196
- if depth > 5: return UNRESOLVABLE # prevent infinite loops
197
- value = lookup_table[qualifier][type][name]
198
- if value is a concrete value (hex color, number, string literal):
199
- return value
200
- if value matches @type/other_name:
201
- return resolve(type, other_name, qualifier, depth+1)
202
- if value matches ?attr/name:
203
- return UNRESOLVABLE # theme attribute, cannot resolve statically
204
- return value
205
- ```
206
-
207
- ### What Gets Resolved
208
-
209
- **Value-to-value references** (primary targets):
210
- - `@color/name` → resolved hex color (e.g., `@color/primary` → `#FF6200EE`)
211
- - `@dimen/name` → resolved dimension value (e.g., `@dimen/margin_base` → `16dp`)
212
- - `@string/name` → resolved string value
213
- - `@integer/name` → resolved integer value
214
- - `@bool/name` → resolved boolean value
215
-
216
- **File references** (kept as HarmonyOS references, not resolved to values):
217
- - `@drawable/name` → `$media:name` (the file itself is converted separately)
218
- - `@mipmap/name` → `$media:name`
219
-
220
- **Unresolvable references** (logged but kept as-is):
221
- - `?attr/name` — theme attributes depend on runtime theme
222
- - `@style/name` — styles have no HarmonyOS equivalent
223
-
224
- **System resources** (resolved to concrete values, NOT kept as references):
225
- - `@android:color/name` — resolved via built-in lookup table to hex values
226
- - `@android:dimen/name` — resolved via built-in lookup table
227
- - `@android:string/name` — resolved to known string values
228
- - `@android:drawable/name` — extracted from APK or replaced with placeholder
229
-
230
- ### Resolution During Conversion
231
-
232
- Resolution happens at conversion time, not as a separate pass. When converting a value from Android XML to HarmonyOS JSON:
233
-
234
- 1. Parse the XML value
235
- 2. If it's a concrete value (hex color, number, string), convert directly using format rules
236
- 3. If it's a resource reference (`@type/name`):
237
- a. Look up in the lookup table
238
- b. Follow the chain to the concrete value
239
- c. Convert the concrete value using format rules
240
- d. Use the resolved concrete value in the HarmonyOS JSON output
241
- 4. If the reference can't be resolved, use HarmonyOS reference syntax (`$color:name`, `$float:name`, etc.) and log it
242
-
243
- ### Example: Full Resolution Chain
244
-
245
- Android `values/colors.xml`:
246
- ```xml
247
- <color name="app_background">@color/surface_color</color>
248
- <color name="surface_color">@color/md_grey_50</color>
249
- <color name="md_grey_50">#FAFAFA</color>
250
- ```
251
-
252
- Resolution:
253
- - `app_background` → `@color/surface_color` → `@color/md_grey_50` → `#FAFAFA`
254
-
255
- HarmonyOS `color.json` output:
256
- ```json
257
- {
258
- "color": [
259
- {"name": "app_background", "value": "#ffFAFAFA"},
260
- {"name": "surface_color", "value": "#ffFAFAFA"},
261
- {"name": "md_grey_50", "value": "#ffFAFAFA"}
262
- ]
263
- }
264
- ```
265
-
266
- All three resolve to the same concrete value. The `#ffFAFAFA` format is after applying the `#RRGGBB` → `#ffRRGGBB` color format conversion.
267
-
268
- ---
269
-
270
- ## Where to Scan for Dependencies
271
-
272
- Scan ALL resource files from the resource source directory for dependencies, organized by priority:
273
-
274
- ### High Priority (converted resources — broken dependencies cause direct errors)
275
-
276
- | File Type | Typical Location | Why It Matters |
277
- |---|---|---|
278
- | Adaptive icon XML | `mipmap-anydpi-v26/*.xml` | References colors, drawables, mipmaps for icon layers |
279
- | Vector drawables | `drawable/*.xml` (root: `<vector>`) | May reference colors via theme attrs |
280
- | Shape drawables | `drawable/*.xml` (root: `<shape>`) | May reference colors, dimens |
281
- | Layer-list drawables | `drawable/*.xml` (root: `<layer-list>`) | References other drawables |
282
- | Selector drawables | `drawable/*.xml` (root: `<selector>`) | References other drawables for states |
283
- | Color state lists | `color/*.xml` | References other colors |
284
- | Values XML | `values*/*.xml` | Cross-references between value types |
285
-
286
- ### Required — Layout and Menu (not converted, but dependencies must be verified)
287
-
288
- Layout and menu files are **not** converted to HarmonyOS (they use ArkUI instead), but the resources they reference — strings, colors, drawables, dimensions — **must** be present in the converted output so the developer has everything needed when rebuilding the UI.
289
-
290
- | File Type | Typical Location | Why It Matters |
291
- |---|---|---|
292
- | Layout XML | `layout*/*.xml` | References strings, colors, drawables, dimens used by every UI component |
293
- | Menu XML | `menu/*.xml` | References strings and drawables for action bar / navigation items |
294
-
295
- ### Skip (no meaningful dependencies)
296
-
297
- - Raw files (`raw/`)
298
- - Font files (`font/`) — unless font XML family definitions reference other fonts
299
- - Image files (PNG, JPG, WEBP, etc.) — binary files, no references
300
-
301
- ---
302
-
303
- ## Dependency Verification
304
-
305
- After conversion with reference resolution, verify that the output is self-consistent:
306
-
307
- ### Check by Resource Type
308
-
309
- | Dependency Type | Where to Check in HarmonyOS Output |
310
- |---|---|
311
- | `@color/name` | Should be resolved to hex in `*/element/color.json`. If not resolved, check `name` exists. |
312
- | `@drawable/name` | Look for `name.*` (any extension: .png, .svg, .jpg, etc.) in `*/media/` |
313
- | `@mipmap/name` | Same as drawable — mipmaps go to `media/` in HarmonyOS |
314
- | `@string/name` | Should be resolved to literal in `*/element/string.json`. If not resolved, check `name` exists. |
315
- | `@dimen/name` | Should be resolved to value in `*/element/float.json`. If not resolved, check `name` exists. |
316
- | `@integer/name` | Look for `name` in `*/element/integer.json` |
317
- | `@bool/name` | Look for `name` in `*/element/boolean.json` |
318
- | `@array/name` | Look for `name` in `*/element/strarray.json` or `*/element/intarray.json` |
319
- | `@plurals/name` | Look for `name` in `*/element/plural.json` |
320
- | `@style/name` | Mark as "unmappable type" (styles have no HarmonyOS equivalent) |
321
- | `@attr/name` | Mark as "unmappable type" |
322
- | `@layout/name` | Mark as "not applicable" (layouts aren't converted) |
323
- | `@id/name` | Mark as "not applicable" (IDs are code-level concerns) |
324
-
325
- ### Qualifier Coverage Check
326
-
327
- When a dependency is satisfied, also verify qualifier coverage. If the dependent resource exists in multiple qualifier directories (e.g., `base`, `dark`, `ldpi`), the dependency should ideally exist in matching qualifier directories. Flag cases where a dependency exists in `base` but the dependent resource also has `dark` or density-qualified variants — the dependency may need those variants too.
328
-
329
- ---
330
-
331
- ## Handling Missing Library Resources
332
-
333
- When converting from source `res/` (because the APK build failed or no APK was available), library-provided resources will be absent from the lookup table. This section describes how to handle these gaps gracefully.
334
-
335
- ### Identifying Library Resources
336
-
337
- Many common Android libraries define resources with recognizable naming patterns. Use these heuristics to correlate unsatisfied dependencies with likely library sources:
338
-
339
- | Library | Common Resource Prefixes |
340
- |---|---|
341
- | Material Components (`com.google.android.material`) | `material_*`, `design_*`, `mtrl_*`, `Widget.Material*`, `Theme.Material*` |
342
- | AndroidX AppCompat (`androidx.appcompat`) | `abc_*`, `Widget.AppCompat.*` |
343
- | AndroidX Core (`androidx.core`) | `notification_*`, `compat_*` |
344
- | AndroidX ConstraintLayout | `constraint_*` |
345
- | Google Play Services | `common_google_*` |
346
-
347
- ### Extracting Library Dependencies from build.gradle
348
-
349
- Parse `build.gradle` or `build.gradle.kts` to identify declared library dependencies:
350
-
351
- ```groovy
352
- // build.gradle
353
- dependencies {
354
- implementation 'com.google.android.material:material:1.9.0'
355
- implementation 'androidx.appcompat:appcompat:1.6.1'
356
- implementation 'androidx.core:core-ktx:1.12.0'
357
- }
358
- ```
359
-
360
- Extract the group:artifact for each dependency. In the conversion report, list these libraries with their likely resource prefixes so the developer knows which libraries contribute which missing resources.
361
-
362
- ### Resolution Behavior for Missing Resources
363
-
364
- When a reference cannot be resolved because the target resource is not in the lookup table:
365
-
366
- 1. **Apply a type-appropriate fallback value** to ensure the output compiles without errors:
367
- - `$color:name` → `#ff000000` (black)
368
- - `$float:name` → `0vp`
369
- - `$string:name` → `""`
370
- - `$integer:name` → `0`
371
- - `$boolean:name` → `false`
372
- 2. **Log it as an unsatisfied dependency** with:
373
- - The original reference (`@color/design_default_color_primary`)
374
- - The fallback value applied (`#ff000000`)
375
- - The source file where it was found
376
- - The likely library source (if identifiable from naming patterns)
377
- - The reason: "Library resource not available in source res/ — fallback applied"
378
- 3. **Why fallback instead of keeping the reference**: Keeping `$color:name` references in the output causes HarmonyOS compilation errors. Applying a safe default ensures the project compiles and the developer can identify and fix the fallback values by searching for the logged warnings. The conversion report provides a complete list of all fallbacks applied.
379
- 4. **When converting from a decompiled APK**: unresolved references should be very rare (the APK contains all merged resources). If they occur, log them as errors rather than warnings — they indicate a bug in the resolution logic.
380
-
381
- ### Categorizing Unresolved References
382
-
383
- In the report, separate unresolved references into categories:
384
-
385
- 1. **Missing library resources** — references to resources that likely come from declared library dependencies. These are expected when converting from source `res/`.
386
- 2. **Theme attributes** (`?attr/name`) — cannot be statically resolved regardless of resource source.
387
- 3. **System resources** (`@android:type/name`) — Android framework resources that MUST be resolved to concrete values using the built-in lookup tables. If resolution fails, use a type-appropriate default (colors → `#ff000000`, dimens → `0vp`, integers → `0`, strings → `""`) and log a warning. System resource references must NEVER appear in the final converted output.
388
- 4. **Truly missing** — references that don't match any known library pattern and aren't in the lookup table. These may indicate a project misconfiguration or an undeclared dependency.
1
+ # Android Resource Dependency Analysis Rules
2
+
3
+ This document defines how to extract, track, and resolve inter-resource dependencies during Android-to-HarmonyOS resource conversion. Dependency analysis runs regardless of resource source — whether from a decoded APK (complete resource set) or from the project's source `res/` directory (potentially missing library resources). When working from source `res/`, more references will be unresolvable, but the analysis is still essential to identify exactly what's missing and why. It also provides the evidence used to infer screen ownership, source ownership, and review-oriented function descriptions for the markdown written to `resource_mapping_path`.
4
+
5
+ ## Table of Contents
6
+ 1. [Resource Reference Patterns](#resource-reference-patterns)
7
+ 2. [Building the Resource Value Lookup Table](#building-the-resource-value-lookup-table)
8
+ 3. [Resolving References to True Values](#resolving-references-to-true-values)
9
+ 4. [Where to Scan for Dependencies](#where-to-scan-for-dependencies)
10
+ 5. [Dependency Verification](#dependency-verification)
11
+ 6. [Handling Missing Library Resources](#handling-missing-library-resources)
12
+
13
+ ---
14
+
15
+ ## Resource Reference Patterns
16
+
17
+ Android resources reference each other using `@type/name` syntax. Extract these references from XML attribute values and text content.
18
+
19
+ ### Reference Regex Pattern
20
+
21
+ Use the following pattern to extract resource references from any XML content:
22
+
23
+ ```
24
+ @(color|drawable|mipmap|string|dimen|integer|bool|array|style|attr|id|layout|menu|anim|animator|raw|font|xml|plurals)/([a-zA-Z_][a-zA-Z0-9_]*)
25
+ ```
26
+
27
+ This captures:
28
+ - Group 1: resource type (`color`, `drawable`, etc.)
29
+ - Group 2: resource name
30
+
31
+ ### System Resource References
32
+
33
+ References prefixed with `@android:` (e.g., `@android:color/black`, `@android:drawable/ic_menu_close`) are Android framework resources provided by the OS. These resources do NOT exist in HarmonyOS and MUST be resolved to concrete values during conversion — they cannot be left as-is in the output.
34
+
35
+ **Resolution rules for system resources:**
36
+ - `@android:color/*` — resolve using the built-in Android system color lookup table (defined in SKILL.md Step 5.2). NEVER leave `@android:color/*` references in the converted output. If a color is not in the lookup table, use the decoded APK's framework resources or fall back to `#ff000000` with a warning.
37
+ - `@android:dimen/*` — resolve using the built-in Android system dimension lookup table (defined in SKILL.md Step 5.2). Fall back to `0vp` with a warning if not found.
38
+ - `@android:string/*` — resolve to the known English string value if available, otherwise use `""` with a warning.
39
+ - `@android:integer/*` — resolve to the known value if available, otherwise use `0` with a warning.
40
+ - `@android:drawable/*` — these are Android framework drawables (icons, backgrounds). Log as "system drawable — requires manual replacement" in the report. If converting from a decoded APK, extract and convert the drawable. Otherwise, create a placeholder SVG.
41
+
42
+ In the conversion report, list all resolved system resource references in a dedicated section so the developer can verify the resolved values are correct.
43
+
44
+ ### Theme Attribute References
45
+
46
+ References using `?attr/name` or `?android:attr/name` are theme attribute references resolved at runtime. These **cannot** be statically resolved — they depend on which theme is applied at runtime. Log them as "unresolvable theme attribute" and keep the reference as-is in the converted output.
47
+
48
+ ### Reference Locations in XML
49
+
50
+ Resource references can appear in several places within Android XML files:
51
+
52
+ **1. XML attribute values:**
53
+ ```xml
54
+ <background android:drawable="@color/md_amber_700" />
55
+ <TextView android:text="@string/hello" android:textColor="@color/primary" />
56
+ <ImageView android:src="@drawable/icon" />
57
+ ```
58
+
59
+ **2. Style/theme item values:**
60
+ ```xml
61
+ <style name="AppTheme">
62
+ <item name="colorPrimary">@color/primary</item>
63
+ <item name="android:windowBackground">@drawable/bg_window</item>
64
+ </style>
65
+ ```
66
+
67
+ **3. Color state list references:**
68
+ ```xml
69
+ <selector>
70
+ <item android:color="@color/pressed_color" android:state_pressed="true" />
71
+ <item android:color="@color/default_color" />
72
+ </selector>
73
+ ```
74
+
75
+ **4. Drawable XML references:**
76
+ ```xml
77
+ <layer-list>
78
+ <item android:drawable="@drawable/bg_layer" />
79
+ </layer-list>
80
+
81
+ <adaptive-icon>
82
+ <background android:drawable="@color/ic_bg" />
83
+ <foreground android:drawable="@mipmap/ic_fg" />
84
+ </adaptive-icon>
85
+ ```
86
+
87
+ **5. Values XML cross-references (these are the primary targets for resolution):**
88
+ ```xml
89
+ <!-- colors.xml -->
90
+ <color name="primary_light">@color/primary</color>
91
+
92
+ <!-- dimens.xml -->
93
+ <color name="margin_double">@dimen/margin_base</color>
94
+ ```
95
+
96
+ ### Lottie-Specific Reference Patterns (Extended)
97
+
98
+ Lottie asset references do NOT use the generic `@type/name` syntax and are not caught by the reference regex above. They need their own extraction pass — see `references/lottie-conversion-rules.md` for the full rules. Summary:
99
+
100
+ **XML attribute patterns** (namespace prefix varies; match by local name only):
101
+
102
+ | Attribute | Points at | Migration classification |
103
+ |---|---|---|
104
+ | `lottie_fileName="Xxx.json"` | Assets-relative path under `assets/` | Local Lottie asset — migrate to `rawfile/lottie/<normalized>.json` |
105
+ | `lottie_rawRes="@raw/name"` | `res/raw/name.json` | Local Lottie asset — migrate to `rawfile/lottie/<normalized>.json` |
106
+ | `lottie_url="https://..."` | Runtime URL | Remote resource — no local target |
107
+ | `lottie_fallbackRes="@drawable/xxx"` | Fallback drawable | Handled by normal drawable rules; note the association in the Lottie row |
108
+
109
+ **Code patterns** (Kotlin/Java):
110
+
111
+ - Literal string / resource id arg to `LottieCompositionFactory.fromAsset(...)`, `.fromRawRes(...)`, `.fromJsonInputStream(...)`, `.fromUrl(...)`, or to `LottieAnimationView.setAnimation(...)`.
112
+ - `AssetManager.list(...)` results filtered by `.json` and dispatched to any factory method above — the "dynamic picker" pattern. Attribute the listed JSONs to the **detail screen** navigated to by the picker's click handler, not the picker itself.
113
+ - `CompositionArgs`-style data classes carrying `assetName` / `fileUri` / `url` fields consumed by a factory method — resolve to the actual factory call site.
114
+
115
+ **Host-screen binding.** For each Lottie asset, additionally record the Activity/Fragment that plays it (evidence: layout inflation, factory call site, or picker navigation target). This host attribution is required by `references/lottie-conversion-rules.md` and is consumed by the mapping document.
116
+
117
+ ## Screen and Source Attribution Support
118
+
119
+ Use dependency analysis not only to resolve resources, but also to collect evidence for the mapping markdown.
120
+
121
+ ### Screen attribution evidence sources
122
+
123
+ Collect evidence from:
124
+ - Activities
125
+ - Fragments
126
+ - Compose / UI page files
127
+ - Navigation graphs
128
+ - Layout XML files referenced by Activities or Fragments
129
+ - Menu XML files referenced by screens
130
+ - Direct `R.type.name` references in code
131
+
132
+ ### Screen attribution rules
133
+
134
+ - If a screen directly references a resource, attribute the resource to that screen.
135
+ - If a screen references a layout and the layout references additional resources, attribute those resources to that screen.
136
+ - If a shared component is referenced by multiple screens, record all known screens or use `Common`.
137
+ - For launcher icons, round icons, adaptive icons, app name, and app-wide theme resources, use `Launcher` or `Global` as defined by `references/resource-mapping-rules.md`.
138
+ - If evidence is insufficient, use `Unknown`.
139
+
140
+ ### Source attribution evidence sources
141
+
142
+ Collect evidence from:
143
+ - Actual source path (`app/src/...`, local module `src/...`)
144
+ - Decoded APK presence without a matching source resource
145
+ - Resource naming prefixes such as `abc_*`, `mtrl_*`, `design_*`, `material_*`
146
+ - Declared Gradle dependencies
147
+ - Android framework reference prefix `@android:`
148
+ - Runtime URL / remote-loading code patterns
149
+
150
+ ### Function-description evidence sources
151
+
152
+ Collect evidence from:
153
+ - resource name semantics
154
+ - XML root type (`vector`, `shape`, `selector`, `layer-list`, `adaptive-icon`)
155
+ - usage site labels or surrounding code context
156
+ - manifest usage (`android:icon`, `android:roundIcon`, etc.)
157
+
158
+ Do not overstate certainty. If the conclusion is inferred, retain that explanation in the eventual mapping-row notes.
159
+
160
+ ---
161
+
162
+
163
+ Before resolving references, build a complete lookup table from the resource source directory (either decoded `res/` or source `res/`). When using the decoded APK, this table will be comprehensive. When using source `res/`, it will only contain app-defined resources — library resources will be absent, and references to them will be flagged during verification.
164
+
165
+ ### Value Resources
166
+
167
+ Parse all `values*/*.xml` files and build mappings:
168
+
169
+ ```
170
+ colors:
171
+ "primary" → "#FF6200EE"
172
+ "primary_light" → "@color/primary" # reference chain — will be resolved
173
+ "md_blue_500" → "#2196F3"
174
+
175
+ dimens:
176
+ "margin_base" → "16dp"
177
+ "margin_double" → "@dimen/margin_base" # reference chain
178
+
179
+ strings:
180
+ "app_name" → "My App"
181
+ "greeting" → "Hello, %1$s!"
182
+
183
+ integers:
184
+ "max_items" → "10"
185
+
186
+ bools:
187
+ "is_tablet" → "false"
188
+ ```
189
+
190
+ Include ALL qualifier variants (e.g., `values/colors.xml`, `values-night/colors.xml`, `values-ar/colors.xml`). Each qualifier variant gets its own entry in the lookup table.
191
+
192
+ ### File Resources
193
+
194
+ Record all drawable and mipmap files:
195
+
196
+ ```
197
+ drawables:
198
+ "icon" → "drawable/icon.png"
199
+ "bg_card" → "drawable/bg_card.xml" (shape)
200
+ "ic_arrow" → "drawable/ic_arrow.xml" (vector)
201
+
202
+ mipmaps:
203
+ "ic_launcher" → "mipmap-anydpi-v26/ic_launcher.xml" (adaptive-icon)
204
+ "ic_launcher_foreground" → "mipmap-xxxhdpi/ic_launcher_foreground.png"
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Resolving References to True Values
210
+
211
+ The key step: walk through all resource values and replace references with actual concrete values.
212
+
213
+ ### Resolution Algorithm
214
+
215
+ ```
216
+ function resolve(type, name, qualifier, depth=0):
217
+ if depth > 5: return UNRESOLVABLE # prevent infinite loops
218
+ value = lookup_table[qualifier][type][name]
219
+ if value is a concrete value (hex color, number, string literal):
220
+ return value
221
+ if value matches @type/other_name:
222
+ return resolve(type, other_name, qualifier, depth+1)
223
+ if value matches ?attr/name:
224
+ return UNRESOLVABLE # theme attribute, cannot resolve statically
225
+ return value
226
+ ```
227
+
228
+ ### What Gets Resolved
229
+
230
+ **Value-to-value references** (primary targets):
231
+ - `@color/name` → resolved hex color (e.g., `@color/primary` → `#FF6200EE`)
232
+ - `@dimen/name` → resolved dimension value (e.g., `@dimen/margin_base` → `16dp`)
233
+ - `@string/name` → resolved string value
234
+ - `@integer/name` → resolved integer value
235
+ - `@bool/name` → resolved boolean value
236
+
237
+ **File references** (kept as HarmonyOS references, not resolved to values):
238
+ - `@drawable/name` → `$media:name` (the file itself is converted separately)
239
+ - `@mipmap/name` → `$media:name`
240
+
241
+ **Unresolvable references** (logged but kept as-is):
242
+ - `?attr/name` — theme attributes depend on runtime theme
243
+ - `@style/name` — styles have no HarmonyOS equivalent
244
+
245
+ **System resources** (resolved to concrete values, NOT kept as references):
246
+ - `@android:color/name` — resolved via built-in lookup table to hex values
247
+ - `@android:dimen/name` — resolved via built-in lookup table
248
+ - `@android:string/name` — resolved to known string values
249
+ - `@android:drawable/name` — extracted from APK or replaced with placeholder
250
+
251
+ ### Resolution During Conversion
252
+
253
+ Resolution happens at conversion time, not as a separate pass. When converting a value from Android XML to HarmonyOS JSON:
254
+
255
+ 1. Parse the XML value
256
+ 2. If it's a concrete value (hex color, number, string), convert directly using format rules
257
+ 3. If it's a resource reference (`@type/name`):
258
+ a. Look up in the lookup table
259
+ b. Follow the chain to the concrete value
260
+ c. Convert the concrete value using format rules
261
+ d. Use the resolved concrete value in the HarmonyOS JSON output
262
+ 4. If the reference can't be resolved, use HarmonyOS reference syntax (`$color:name`, `$float:name`, etc.) and log it
263
+
264
+ ### Example: Full Resolution Chain
265
+
266
+ Android `values/colors.xml`:
267
+ ```xml
268
+ <color name="app_background">@color/surface_color</color>
269
+ <color name="surface_color">@color/md_grey_50</color>
270
+ <color name="md_grey_50">#FAFAFA</color>
271
+ ```
272
+
273
+ Resolution:
274
+ - `app_background` → `@color/surface_color` → `@color/md_grey_50` → `#FAFAFA`
275
+
276
+ HarmonyOS `color.json` output:
277
+ ```json
278
+ {
279
+ "color": [
280
+ {"name": "app_background", "value": "#ffFAFAFA"},
281
+ {"name": "surface_color", "value": "#ffFAFAFA"},
282
+ {"name": "md_grey_50", "value": "#ffFAFAFA"}
283
+ ]
284
+ }
285
+ ```
286
+
287
+ All three resolve to the same concrete value. The `#ffFAFAFA` format is after applying the `#RRGGBB` → `#ffRRGGBB` color format conversion.
288
+
289
+ ---
290
+
291
+ ## Where to Scan for Dependencies
292
+
293
+ Scan ALL resource files from the resource source directory for dependencies, organized by priority:
294
+
295
+ ### High Priority (converted resources — broken dependencies cause direct errors)
296
+
297
+ | File Type | Typical Location | Why It Matters |
298
+ |---|---|---|
299
+ | Adaptive icon XML | `mipmap-anydpi-v26/*.xml` | References colors, drawables, mipmaps for icon layers |
300
+ | Vector drawables | `drawable/*.xml` (root: `<vector>`) | May reference colors via theme attrs |
301
+ | Shape drawables | `drawable/*.xml` (root: `<shape>`) | May reference colors, dimens |
302
+ | Layer-list drawables | `drawable/*.xml` (root: `<layer-list>`) | References other drawables |
303
+ | Selector drawables | `drawable/*.xml` (root: `<selector>`) | References other drawables for states |
304
+ | Color state lists | `color/*.xml` | References other colors |
305
+ | Values XML | `values*/*.xml` | Cross-references between value types |
306
+
307
+ ### Required — Layout and Menu (not converted, but dependencies must be verified)
308
+
309
+ Layout and menu files are **not** converted to HarmonyOS (they use ArkUI instead), but the resources they reference — strings, colors, drawables, dimensions — **must** be present in the converted output so the developer has everything needed when rebuilding the UI.
310
+
311
+ | File Type | Typical Location | Why It Matters |
312
+ |---|---|---|
313
+ | Layout XML | `layout*/*.xml` | References strings, colors, drawables, dimens used by every UI component |
314
+ | Menu XML | `menu/*.xml` | References strings and drawables for action bar / navigation items |
315
+
316
+ ### Skip (no meaningful dependencies)
317
+
318
+ - Raw files (`raw/`) — **except** when the file is a Lottie animation JSON (identified by signature `v`+`fr`+`ip`+`op`+`layers`), which must be recorded per `references/lottie-conversion-rules.md`. The Lottie JSON itself has no `@type/name` references to resolve, but it must be inventoried and bound to a host screen.
319
+ - `assets/` — same rule: skip generic files, but detect and record Lottie JSON.
320
+ - Font files (`font/`) — unless font XML family definitions reference other fonts
321
+ - Image files (PNG, JPG, WEBP, etc.) — binary files, no references
322
+
323
+ ---
324
+
325
+ ## Dependency Verification
326
+
327
+ After conversion with reference resolution, verify that the output is self-consistent:
328
+
329
+ ### Check by Resource Type
330
+
331
+ | Dependency Type | Where to Check in HarmonyOS Output |
332
+ |---|---|
333
+ | `@color/name` | Should be resolved to hex in `*/element/color.json`. If not resolved, check `name` exists. |
334
+ | `@drawable/name` | Look for `name.*` (any extension: .png, .svg, .jpg, etc.) in `*/media/` |
335
+ | `@mipmap/name` | Same as drawable — mipmaps go to `media/` in HarmonyOS |
336
+ | `@string/name` | Should be resolved to literal in `*/element/string.json`. If not resolved, check `name` exists. |
337
+ | `@dimen/name` | Should be resolved to value in `*/element/float.json`. If not resolved, check `name` exists. |
338
+ | `@integer/name` | Look for `name` in `*/element/integer.json` |
339
+ | `@bool/name` | Look for `name` in `*/element/boolean.json` |
340
+ | `@array/name` | Look for `name` in `*/element/strarray.json` or `*/element/intarray.json` |
341
+ | `@plurals/name` | Look for `name` in `*/element/plural.json` |
342
+ | `@style/name` | Mark as "unmappable type" (styles have no HarmonyOS equivalent) |
343
+ | `@attr/name` | Mark as "unmappable type" |
344
+ | `@layout/name` | Mark as "not applicable" (layouts aren't converted) |
345
+ | `@id/name` | Mark as "not applicable" (IDs are code-level concerns) |
346
+
347
+ ### Qualifier Coverage Check
348
+
349
+ When a dependency is satisfied, also verify qualifier coverage. If the dependent resource exists in multiple qualifier directories (e.g., `base`, `dark`, `ldpi`), the dependency should ideally exist in matching qualifier directories. Flag cases where a dependency exists in `base` but the dependent resource also has `dark` or density-qualified variants — the dependency may need those variants too.
350
+
351
+ ---
352
+
353
+ ## Handling Missing Library Resources
354
+
355
+ When converting from source `res/` (because decoding `apk_path` failed), library-provided resources will be absent from the lookup table. This section describes how to handle these gaps gracefully.
356
+
357
+ ### Identifying Library Resources
358
+
359
+ Many common Android libraries define resources with recognizable naming patterns. Use these heuristics to correlate unsatisfied dependencies with likely library sources:
360
+
361
+ | Library | Common Resource Prefixes |
362
+ |---|---|
363
+ | Material Components (`com.google.android.material`) | `material_*`, `design_*`, `mtrl_*`, `Widget.Material*`, `Theme.Material*` |
364
+ | AndroidX AppCompat (`androidx.appcompat`) | `abc_*`, `Widget.AppCompat.*` |
365
+ | AndroidX Core (`androidx.core`) | `notification_*`, `compat_*` |
366
+ | AndroidX ConstraintLayout | `constraint_*` |
367
+ | Google Play Services | `common_google_*` |
368
+
369
+ ### Extracting Library Dependencies from build.gradle
370
+
371
+ Parse `build.gradle` or `build.gradle.kts` to identify declared library dependencies:
372
+
373
+ ```groovy
374
+ // build.gradle
375
+ dependencies {
376
+ implementation 'com.google.android.material:material:1.9.0'
377
+ implementation 'androidx.appcompat:appcompat:1.6.1'
378
+ implementation 'androidx.core:core-ktx:1.12.0'
379
+ }
380
+ ```
381
+
382
+ Extract the group:artifact for each dependency. In the conversion report, list these libraries with their likely resource prefixes so the developer knows which libraries contribute which missing resources.
383
+
384
+ ### Resolution Behavior for Missing Resources
385
+
386
+ When a reference cannot be resolved because the target resource is not in the lookup table:
387
+
388
+ 1. **Apply a type-appropriate fallback value** to ensure the output compiles without errors:
389
+ - `$color:name` → `#ff000000` (black)
390
+ - `$float:name` → `0vp`
391
+ - `$string:name` → `""`
392
+ - `$integer:name` → `0`
393
+ - `$boolean:name` → `false`
394
+ 2. **Log it as an unsatisfied dependency** with:
395
+ - The original reference (`@color/design_default_color_primary`)
396
+ - The fallback value applied (`#ff000000`)
397
+ - The source file where it was found
398
+ - The likely library source (if identifiable from naming patterns)
399
+ - The reason: "Library resource not available in source res/ — fallback applied"
400
+ 3. **Why fallback instead of keeping the reference**: Keeping `$color:name` references in the output causes HarmonyOS compilation errors. Applying a safe default ensures the project compiles and the developer can identify and fix the fallback values by searching for the logged warnings. The conversion report provides a complete list of all fallbacks applied.
401
+ 4. **When converting from a decoded APK**: unresolved references should be very rare (the APK contains all merged resources). If they occur, log them as errors rather than warnings — they indicate a bug in the resolution logic.
402
+
403
+ ### Categorizing Unresolved References
404
+
405
+ In the report, separate unresolved references into categories:
406
+
407
+ 1. **Missing library resources** — references to resources that likely come from declared library dependencies. These are expected when converting from source `res/`.
408
+ 2. **Theme attributes** (`?attr/name`) — cannot be statically resolved regardless of resource source.
409
+ 3. **System resources** (`@android:type/name`) — Android framework resources that MUST be resolved to concrete values using the built-in lookup tables. If resolution fails, use a type-appropriate default (colors → `#ff000000`, dimens → `0vp`, integers → `0`, strings → `""`) and log a warning. System resource references must NEVER appear in the final converted output.
410
+ 4. **Truly missing** — references that don't match any known library pattern and aren't in the lookup table. These may indicate a project misconfiguration or an undeclared dependency.