@buaa_smat/hometrans 26.0.2 → 26.0.4-devecocli.1

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 (1496) hide show
  1. package/agents/code-reviewer.md +111 -154
  2. package/devecocli-plugin/common.ts +2271 -0
  3. package/devecocli-plugin/content-resolver.ts +363 -0
  4. package/devecocli-plugin/install.ts +72 -0
  5. package/devecocli-plugin/uninstall.ts +26 -0
  6. package/devecocli-plugin/update.ts +77 -0
  7. package/i18n/FILE-NAMES.md +9 -0
  8. package/i18n/agents/code-reviewer.md +436 -0
  9. package/i18n/agents/model-render-worker.md +38 -0
  10. package/i18n/agents/specgen-worker.md +18 -0
  11. package/i18n/commands/hometrans.md +17 -0
  12. package/i18n/skills/a2h-app-migrate/SKILL.md +206 -0
  13. package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
  14. package/i18n/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  15. package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
  16. package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
  17. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +2007 -0
  18. package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +187 -0
  19. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1656 -0
  20. package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +728 -0
  21. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
  22. package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  23. package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  24. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  25. package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  26. package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  27. package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  28. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  29. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  30. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  31. package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  32. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  33. package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  34. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  35. package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  36. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  37. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  38. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  39. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  40. package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  41. package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  42. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +207 -0
  43. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  44. package/i18n/skills/a2h-arch-generate/SKILL.md +378 -0
  45. package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  46. package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  47. package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
  48. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  49. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  50. package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  51. package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  52. package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  53. package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  54. package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  55. package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +131 -0
  56. package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  57. package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
  58. package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
  59. package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  60. package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
  61. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  62. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  63. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  64. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  65. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  66. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  67. package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
  68. package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  69. package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
  70. package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
  71. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +304 -0
  72. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +10 -0
  73. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +249 -0
  74. package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +344 -0
  75. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
  76. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
  77. package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +877 -0
  78. package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  79. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  80. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  81. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  82. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  83. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  84. package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  85. package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +597 -0
  86. package/i18n/skills/a2h-batch-ui-align/SKILL.md +372 -0
  87. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +35 -0
  88. package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  89. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  90. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  91. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +85 -0
  92. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +23 -0
  93. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +89 -0
  94. package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  95. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  96. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +62 -0
  97. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +30 -0
  98. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +930 -0
  99. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +420 -0
  100. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +158 -0
  101. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  102. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2552 -0
  103. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
  104. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +175 -0
  105. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +251 -0
  106. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
  107. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +232 -0
  108. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +206 -0
  109. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +232 -0
  110. package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
  111. package/i18n/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  112. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +2118 -0
  113. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  114. package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  115. package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  116. package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1805 -0
  117. package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  118. package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  119. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1959 -0
  120. package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  121. package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
  122. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1632 -0
  123. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1300 -0
  124. package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1234 -0
  125. package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +417 -0
  126. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  127. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
  128. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +216 -0
  129. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +615 -0
  130. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  131. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +49 -0
  132. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  133. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  134. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  135. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
  136. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  137. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
  138. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  139. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  140. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  141. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  142. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  143. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  144. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  145. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  146. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  147. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  148. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  149. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  150. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  151. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  152. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +780 -0
  153. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  154. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  155. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +408 -0
  156. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  157. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  158. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  159. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  160. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  161. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  162. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  163. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +81 -0
  164. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
  165. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  166. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  167. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  168. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  169. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +147 -0
  170. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  171. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  172. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +127 -0
  173. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  174. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  175. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  176. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  177. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  178. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  179. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  180. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  181. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  182. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  183. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  184. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  185. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  186. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  187. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  188. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
  189. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  190. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  191. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  192. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  193. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  194. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  195. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  196. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  197. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  198. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  199. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  200. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  201. package/i18n/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  202. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  203. package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
  204. package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  205. package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  206. package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  207. package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  208. package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  209. package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  210. package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  211. package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  212. package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  213. package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  214. package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  215. package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  216. package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +62 -0
  217. package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
  218. package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
  219. package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  220. package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  221. package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  222. package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
  223. package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2050 -0
  224. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  225. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  226. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  227. package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  228. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  229. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  230. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
  231. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  232. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  233. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  234. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  235. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  236. package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  237. package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  238. package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
  239. package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  240. package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  241. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +265 -0
  242. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  243. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  244. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  245. package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  246. package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  247. package/i18n/skills/a2h-page-specgen/SKILL.md +239 -0
  248. package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +1174 -0
  249. package/i18n/skills/a2h-page-specgen/references/body-language.md +179 -0
  250. package/i18n/skills/a2h-page-specgen/references/gates.md +329 -0
  251. package/i18n/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  252. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +274 -0
  253. package/i18n/skills/a2h-page-specgen/references/spec-example.md +312 -0
  254. package/i18n/skills/a2h-page-specgen/references/spec-template.md +210 -0
  255. package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  256. package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  257. package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  258. package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  259. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  260. package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  261. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  262. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +864 -0
  263. package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +346 -0
  264. package/i18n/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  265. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  266. package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  267. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +684 -0
  268. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  269. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  270. package/i18n/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  271. package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +252 -0
  272. package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  273. package/i18n/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  274. package/i18n/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  275. package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  276. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +864 -0
  277. package/i18n/skills/a2h-page-specgen/scripts/render.mjs +276 -0
  278. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +897 -0
  279. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +25 -0
  280. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +373 -0
  281. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +300 -0
  282. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +47 -0
  283. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +373 -0
  284. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +300 -0
  285. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  286. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  287. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  288. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +373 -0
  289. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  290. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +267 -0
  291. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +57 -0
  292. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +373 -0
  293. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +300 -0
  294. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  295. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  296. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  297. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  298. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  299. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +553 -0
  300. package/i18n/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  301. package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  302. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +546 -0
  303. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +655 -0
  304. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1234 -0
  305. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +520 -0
  306. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1516 -0
  307. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +759 -0
  308. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +630 -0
  309. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +118 -0
  310. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +798 -0
  311. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +886 -0
  312. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  313. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  314. package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1205 -0
  315. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +271 -0
  316. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
  317. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
  318. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
  319. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  320. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  321. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  322. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  323. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  324. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  325. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  326. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  327. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  328. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  329. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  330. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  331. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  332. package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  333. package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  334. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1121 -0
  335. package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  336. package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  337. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  338. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  339. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  340. package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  341. package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +348 -0
  342. package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  343. package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  344. package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  345. package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  346. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  347. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  348. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  349. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +240 -0
  350. package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +427 -0
  351. package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  352. package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  353. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  354. package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  355. package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +536 -0
  356. package/i18n/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  357. package/i18n/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  358. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1239 -0
  359. package/i18n/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  360. package/i18n/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  361. package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  362. package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  363. package/i18n/skills/a2h-resource-convert/SKILL.md +375 -0
  364. package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +336 -0
  365. package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +272 -0
  366. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +226 -0
  367. package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
  368. package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +251 -0
  369. package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  370. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2596 -0
  371. package/i18n/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  372. package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  373. package/i18n/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  374. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +238 -0
  375. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +358 -0
  376. package/i18n/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +307 -0
  377. package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +103 -0
  378. package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +266 -0
  379. package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  380. package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +71 -0
  381. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +55 -0
  382. package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  383. package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +246 -0
  384. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +752 -0
  385. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +661 -0
  386. package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
  387. package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
  388. package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  389. package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  390. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
  391. package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
  392. package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  393. package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  394. package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  395. package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
  396. package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  397. package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  398. package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  399. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
  400. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  401. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  402. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  403. package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
  404. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
  405. package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  406. package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  407. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
  408. package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
  409. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
  410. package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
  411. package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
  412. package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
  413. package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
  414. package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
  415. package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
  416. package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
  417. package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
  418. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  419. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  420. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  421. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  422. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
  423. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
  424. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
  425. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
  426. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  427. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
  428. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
  429. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
  430. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
  431. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
  432. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
  433. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  434. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
  435. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
  436. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
  437. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  438. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
  439. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  440. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  441. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  442. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  443. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  444. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  445. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
  446. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
  447. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
  448. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
  449. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  450. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  451. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  452. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  453. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  454. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  455. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  456. package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
  457. package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  458. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
  459. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
  460. package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
  461. package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  462. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  463. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  464. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  465. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  466. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  467. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  468. package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  469. package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  470. package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  471. package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  472. package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  473. package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  474. package/i18n/skills/a2h-utg-explorer/SKILL.md +126 -0
  475. package/i18n/skills/a2h-utg-explorer/references/architecture.md +282 -0
  476. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +908 -0
  477. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
  478. package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
  479. package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  480. package/i18n/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  481. package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
  482. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +647 -0
  483. package/i18n/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  484. package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  485. package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  486. package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  487. package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +252 -0
  488. package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  489. package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  490. package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  491. package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  492. package/i18n/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  493. package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  494. package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  495. package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  496. package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  497. package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  498. package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  499. package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  500. package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  501. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  502. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  503. package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  504. package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  505. package/i18n/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  506. package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  507. package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  508. package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  509. package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  510. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  511. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  512. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1562 -0
  513. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  514. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2714 -0
  515. package/i18n/skills/a2h-utg-static/SKILL.md +372 -0
  516. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  517. package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
  518. package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2190 -0
  519. package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  520. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +720 -0
  521. package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
  522. package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
  523. package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  524. package/i18n/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  525. package/i18n/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  526. package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
  527. package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +705 -0
  528. package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  529. package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +958 -0
  530. package/i18n/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  531. package/i18n/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  532. package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +545 -0
  533. package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  534. package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
  535. package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  536. package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  537. package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  538. package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  539. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +125 -0
  540. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  541. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  542. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +113 -0
  543. package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  544. package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  545. package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  546. package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  547. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  548. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  549. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  550. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +457 -0
  551. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  552. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  553. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  554. package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  555. package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
  556. package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  557. package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +78 -0
  558. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  559. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  560. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  561. package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  562. package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  563. package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  564. package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  565. package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  566. package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  567. package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  568. package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  569. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  570. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  571. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  572. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +330 -0
  573. package/i18n/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  574. package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  575. package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1394 -0
  576. package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  577. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  578. package/index.js +1643 -0
  579. package/package.json +18 -168
  580. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  581. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  582. package/plugin.jsonc +12 -0
  583. package/skills/a2h-app-migrate/SKILL.md +31 -12
  584. package/skills/a2h-app-migrate/references/config.example.json +1 -0
  585. package/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  586. package/skills/a2h-app-migrate/references/stage-map.md +4 -2
  587. package/skills/a2h-app-migrate/references/workflow.yaml +427 -103
  588. package/skills/a2h-app-migrate/scripts/android_index.mjs +35 -8
  589. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +39 -1
  590. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -6
  591. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +144 -9
  592. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +14 -1
  593. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +46 -5
  594. package/skills/a2h-app-migrate/scripts/diagnose.mjs +162 -0
  595. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +178 -44
  596. package/skills/a2h-app-migrate/scripts/feature_scope.mjs +347 -0
  597. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +81 -11
  598. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +17 -1
  599. package/skills/a2h-app-migrate/scripts/ledger.mjs +80 -10
  600. package/skills/a2h-app-migrate/scripts/migration_manifest.mjs +351 -0
  601. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +9 -23
  602. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +72 -12
  603. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +33 -1
  604. package/skills/a2h-app-migrate/scripts/run_dir.mjs +137 -41
  605. package/skills/a2h-app-migrate/scripts/scope_model.mjs +255 -0
  606. package/skills/a2h-app-migrate/scripts/scope_report.mjs +128 -0
  607. package/skills/a2h-app-migrate/scripts/source_fp.mjs +120 -0
  608. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
  609. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
  610. package/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  611. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  612. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  613. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  614. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  615. package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
  616. package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  617. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
  618. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  619. package/skills/a2h-app-migrate/test/test_feature_scope.mjs +217 -0
  620. package/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  621. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  622. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  623. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
  624. package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  625. package/skills/a2h-app-migrate/test/test_incremental_acceptance.mjs +145 -0
  626. package/skills/a2h-app-migrate/test/test_incremental_phase2.mjs +223 -0
  627. package/skills/a2h-app-migrate/test/test_incremental_phase2_acceptance.mjs +157 -0
  628. package/skills/a2h-app-migrate/test/test_incremental_profile.mjs +84 -0
  629. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +101 -0
  630. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  631. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  632. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +150 -0
  633. package/skills/a2h-app-migrate/test/test_migration_manifest.mjs +225 -0
  634. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +86 -0
  635. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  636. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  637. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  638. package/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  639. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  640. package/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  641. package/skills/a2h-app-migrate/test/test_scope_model.mjs +172 -0
  642. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  643. package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
  644. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +155 -0
  645. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  646. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  647. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +511 -0
  648. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  649. package/skills/a2h-app-migrate/test/test_ui_batch_capture_audit.mjs +106 -0
  650. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +65 -0
  651. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  652. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  653. package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  654. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
  655. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +214 -0
  656. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  657. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  658. package/skills/a2h-arch-generate/SKILL.md +20 -17
  659. package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
  660. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
  661. package/skills/a2h-arch-generate/references/homegraph-workflow.md +25 -14
  662. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
  663. package/skills/a2h-arch-generate/references/source-baseline.md +4 -4
  664. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +34 -3
  665. package/skills/a2h-arch-generate/scripts/create_project.mjs +24 -1
  666. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
  667. package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +29 -5
  668. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
  669. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
  670. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  671. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  672. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  673. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  674. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  675. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  676. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  677. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  678. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  679. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  680. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  681. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  682. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  683. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  684. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  685. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  686. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  687. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  688. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  689. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  690. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  691. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  692. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  693. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  694. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  695. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  696. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  697. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
  698. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +208 -0
  699. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  700. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  701. package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  702. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +164 -0
  703. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
  704. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +4 -2
  705. package/skills/a2h-arkts-logic-coder/SKILL.md +163 -15
  706. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +3 -1
  707. package/skills/a2h-arkts-logic-coder/references/code-generation.md +120 -1
  708. package/skills/a2h-arkts-logic-coder/references/spec-design.md +46 -11
  709. package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
  710. package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +873 -0
  711. package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
  712. package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  713. package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  714. package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  715. package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
  716. package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  717. package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  718. package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  719. package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +596 -0
  720. package/skills/a2h-batch-ui-align/SKILL.md +78 -26
  721. package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +16 -2
  722. package/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
  723. package/skills/a2h-batch-ui-align/references/cards/geometry.md +6 -1
  724. package/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
  725. package/skills/a2h-batch-ui-align/references/cards/resources.md +9 -3
  726. package/skills/a2h-batch-ui-align/references/cards/widgets.md +27 -3
  727. package/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
  728. package/skills/a2h-batch-ui-align/references/checker-rules.md +301 -13
  729. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +53 -13
  730. package/skills/a2h-batch-ui-align/references/host-dispatch.md +2 -0
  731. package/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
  732. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +14 -9
  733. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
  734. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
  735. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +30 -0
  736. package/skills/a2h-batch-ui-align/references/step3-capture.md +25 -6
  737. package/skills/a2h-batch-ui-align/references/step4-prepare.md +7 -2
  738. package/skills/a2h-batch-ui-align/references/step5-convert.md +33 -9
  739. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
  740. package/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  741. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +463 -22
  742. package/skills/a2h-batch-ui-align/scripts/capture_audit.mjs +474 -0
  743. package/skills/a2h-batch-ui-align/scripts/capture_fast.mjs +665 -0
  744. package/skills/a2h-batch-ui-align/scripts/capture_verify.mjs +552 -0
  745. package/skills/a2h-batch-ui-align/scripts/detach.mjs +5 -2
  746. package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  747. package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +263 -0
  748. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +20 -3
  749. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
  750. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +220 -35
  751. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +517 -41
  752. package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  753. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
  754. package/skills/a2h-batch-ui-align/scripts/list_existing.mjs +141 -0
  755. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +239 -14
  756. package/skills/a2h-batch-ui-align/scripts/page_gap.mjs +210 -0
  757. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +98 -11
  758. package/skills/a2h-batch-ui-align/scripts/progress_identity.mjs +208 -0
  759. package/skills/a2h-batch-ui-align/scripts/scroll_verdict.mjs +62 -0
  760. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +118 -4
  761. package/skills/a2h-batch-ui-align/scripts/shell_requests.mjs +273 -0
  762. package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
  763. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
  764. package/skills/a2h-batch-ui-align/scripts/static_check/core/baseline.ts +79 -0
  765. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
  766. package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +90 -2
  767. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +44 -0
  768. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +61 -12
  769. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +32 -0
  770. package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
  771. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
  772. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
  773. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
  774. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
  775. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
  776. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
  777. package/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  778. package/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  779. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  780. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
  781. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  782. package/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  783. package/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  784. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
  785. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  786. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
  787. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +110 -12
  788. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  789. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  790. package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  791. package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
  792. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
  793. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  794. package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
  795. package/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  796. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
  797. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  798. package/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  799. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  800. package/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  801. package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
  802. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
  803. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +30 -2
  804. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +231 -0
  805. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  806. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
  807. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_baseline.test.mjs +129 -0
  808. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  809. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  810. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  811. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_runtime2.test.mjs +697 -0
  812. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  813. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +298 -0
  814. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  815. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  816. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  817. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  818. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  819. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +269 -0
  820. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  821. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +346 -0
  822. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  823. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
  824. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  825. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
  826. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme_runtime.test.mjs +95 -0
  827. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  828. package/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  829. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  830. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +291 -0
  831. package/skills/a2h-batch-ui-align/scripts/tests/capture_audit.test.mjs +179 -0
  832. package/skills/a2h-batch-ui-align/scripts/tests/capture_fast.test.mjs +56 -0
  833. package/skills/a2h-batch-ui-align/scripts/tests/capture_gate.test.mjs +197 -0
  834. package/skills/a2h-batch-ui-align/scripts/tests/capture_review_fixes.test.mjs +322 -0
  835. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +93 -0
  836. package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
  837. package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
  838. package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +435 -0
  839. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  840. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  841. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/SearchMenuDialog.buggy.ets +95 -0
  842. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/meta.json +21 -0
  843. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/screenshot.png +0 -0
  844. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/view.xml +35 -0
  845. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  846. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  847. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  848. package/skills/a2h-batch-ui-align/scripts/tests/group_pack_evidence.test.mjs +95 -0
  849. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1782 -0
  850. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  851. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  852. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  853. package/skills/a2h-batch-ui-align/scripts/tests/icon_coverage.test.mjs +314 -0
  854. package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  855. package/skills/a2h-batch-ui-align/scripts/tests/list_existing.test.mjs +157 -0
  856. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  857. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  858. package/skills/a2h-batch-ui-align/scripts/tests/page_gap.test.mjs +115 -0
  859. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  860. package/skills/a2h-batch-ui-align/scripts/tests/progress_identity.test.mjs +174 -0
  861. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +302 -0
  862. package/skills/a2h-batch-ui-align/scripts/tests/shell_requests.test.mjs +158 -0
  863. package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  864. package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  865. package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  866. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  867. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  868. package/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
  869. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
  870. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
  871. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  872. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  873. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  874. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  875. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  876. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  877. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  878. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  879. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  880. package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
  881. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  882. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  883. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  884. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  885. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  886. package/skills/a2h-dashboard-render/test/test_device_locale_dialogs.mjs +17 -0
  887. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  888. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  889. package/skills/a2h-module-semantic-docs/SKILL.md +51 -13
  890. package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +66 -11
  891. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  892. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  893. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  894. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  895. package/skills/a2h-module-semantic-docs/test/test_incremental_fingerprint.mjs +94 -0
  896. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  897. package/skills/a2h-page-specgen/SKILL.md +240 -0
  898. package/skills/a2h-page-specgen/references/behavior-ledger.md +1170 -0
  899. package/skills/a2h-page-specgen/references/body-language.md +179 -0
  900. package/skills/a2h-page-specgen/references/evidence.md +105 -0
  901. package/skills/a2h-page-specgen/references/execution-model.md +364 -0
  902. package/skills/a2h-page-specgen/references/footprint-and-grouping.md +255 -0
  903. package/skills/a2h-page-specgen/references/gates.md +323 -0
  904. package/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  905. package/skills/a2h-page-specgen/references/scenario-authoring.md +272 -0
  906. package/skills/a2h-page-specgen/references/spec-example.md +312 -0
  907. package/skills/a2h-page-specgen/references/spec-template.md +210 -0
  908. package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  909. package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  910. package/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  911. package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  912. package/skills/a2h-page-specgen/scripts/dispatch.mjs +212 -0
  913. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  914. package/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  915. package/skills/a2h-page-specgen/scripts/finalize.mjs +825 -0
  916. package/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  917. package/skills/a2h-page-specgen/scripts/gate.mjs +848 -0
  918. package/skills/a2h-page-specgen/scripts/interactions.mjs +344 -0
  919. package/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  920. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  921. package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
  922. package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +229 -0
  923. package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
  924. package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
  925. package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  926. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +683 -0
  927. package/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  928. package/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  929. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +478 -0
  930. package/skills/a2h-page-specgen/scripts/lib/main-module.mjs +24 -0
  931. package/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  932. package/skills/a2h-page-specgen/scripts/lib/prose.mjs +238 -0
  933. package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  934. package/skills/a2h-page-specgen/scripts/lib/recovery-policy.mjs +28 -0
  935. package/skills/a2h-page-specgen/scripts/lib/scope.mjs +355 -0
  936. package/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  937. package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  938. package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
  939. package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
  940. package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
  941. package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  942. package/skills/a2h-page-specgen/scripts/prepare.mjs +840 -0
  943. package/skills/a2h-page-specgen/scripts/render.mjs +294 -0
  944. package/skills/a2h-page-specgen/scripts/report.mjs +340 -0
  945. package/skills/a2h-page-specgen/scripts/submission.mjs +697 -0
  946. package/skills/a2h-page-specgen/scripts/submit.mjs +85 -0
  947. package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
  948. package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +871 -0
  949. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.java +15 -0
  950. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +26 -0
  951. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +347 -0
  952. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +298 -0
  953. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.java +36 -0
  954. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +43 -0
  955. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +347 -0
  956. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +298 -0
  957. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  958. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  959. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  960. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +347 -0
  961. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  962. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +265 -0
  963. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.java +47 -0
  964. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +54 -0
  965. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +347 -0
  966. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +298 -0
  967. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  968. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  969. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  970. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  971. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  972. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +515 -0
  973. package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
  974. package/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  975. package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  976. package/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +543 -0
  977. package/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +652 -0
  978. package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1231 -0
  979. package/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +494 -0
  980. package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1513 -0
  981. package/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +758 -0
  982. package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +623 -0
  983. package/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +116 -0
  984. package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +795 -0
  985. package/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +883 -0
  986. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  987. package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
  988. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  989. package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1203 -0
  990. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +243 -0
  991. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
  992. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
  993. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
  994. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
  995. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
  996. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
  997. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
  998. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
  999. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
  1000. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
  1001. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
  1002. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
  1003. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
  1004. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
  1005. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
  1006. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
  1007. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
  1008. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
  1009. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
  1010. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
  1011. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
  1012. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
  1013. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
  1014. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
  1015. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
  1016. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
  1017. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
  1018. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
  1019. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
  1020. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
  1021. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
  1022. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
  1023. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
  1024. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
  1025. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
  1026. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
  1027. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
  1028. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
  1029. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
  1030. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
  1031. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
  1032. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
  1033. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
  1034. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
  1035. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
  1036. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
  1037. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
  1038. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
  1039. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
  1040. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
  1041. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
  1042. package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
  1043. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +112 -0
  1044. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.java +14 -0
  1045. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.kt +14 -0
  1046. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanelsKotlinForms.kt +12 -0
  1047. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ChildContent.java +6 -0
  1048. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ComposeLifecycle.kt +26 -0
  1049. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleCallAndOverride.java +10 -0
  1050. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleHooks.kt +31 -0
  1051. package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
  1052. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyLifecycleHooks.kt +12 -0
  1053. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
  1054. package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
  1055. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshOnResume.java +7 -0
  1056. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshResultNoise.kt +36 -0
  1057. package/skills/a2h-page-specgen/scripts/test/fixtures/src/SelectionView.java +5 -0
  1058. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ShowPage.vue +12 -0
  1059. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ThirdPartyLifecycle.kt +25 -0
  1060. package/skills/a2h-page-specgen/scripts/test/fixtures/src/fragment_detail.xml +1 -0
  1061. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  1062. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  1063. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  1064. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  1065. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  1066. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  1067. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  1068. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  1069. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  1070. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  1071. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  1072. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  1073. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
  1074. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
  1075. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  1076. package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
  1077. package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  1078. package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  1079. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1078 -0
  1080. package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  1081. package/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  1082. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  1083. package/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  1084. package/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  1085. package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  1086. package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +310 -0
  1087. package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  1088. package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  1089. package/skills/a2h-page-specgen/scripts/test/ledger-lock.test.mjs +77 -0
  1090. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
  1091. package/skills/a2h-page-specgen/scripts/test/main-module.test.mjs +43 -0
  1092. package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  1093. package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  1094. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  1095. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  1096. package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +160 -0
  1097. package/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  1098. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +236 -0
  1099. package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +398 -0
  1100. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  1101. package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  1102. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  1103. package/skills/a2h-page-specgen/scripts/test/recovery-policy.test.mjs +14 -0
  1104. package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  1105. package/skills/a2h-page-specgen/scripts/test/render.test.mjs +546 -0
  1106. package/skills/a2h-page-specgen/scripts/test/report.test.mjs +296 -0
  1107. package/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  1108. package/skills/a2h-page-specgen/scripts/test/scope.test.mjs +292 -0
  1109. package/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  1110. package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
  1111. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1231 -0
  1112. package/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  1113. package/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  1114. package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  1115. package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
  1116. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  1117. package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1993 -0
  1118. package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +342 -0
  1119. package/skills/a2h-page-specgen/scripts/waker.mjs +1301 -0
  1120. package/skills/a2h-page-specgen/scripts/watchdog.mjs +299 -0
  1121. package/skills/a2h-resource-convert/SKILL.md +9 -1
  1122. package/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
  1123. package/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
  1124. package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
  1125. package/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
  1126. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +115 -53
  1127. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +68 -0
  1128. package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +45 -3
  1129. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +42 -5
  1130. package/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  1131. package/skills/a2h-resource-convert/scripts/lottie_refs.ts +398 -0
  1132. package/skills/a2h-resource-convert/scripts/merge_mapping.ts +316 -0
  1133. package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +2 -1
  1134. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  1135. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  1136. package/skills/a2h-resource-convert/scripts/tests/code_vector_guard.test.mjs +75 -0
  1137. package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  1138. package/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  1139. package/skills/a2h-resource-convert/scripts/tests/lottie_incremental.test.mjs +178 -0
  1140. package/skills/a2h-resource-convert/scripts/tests/merge_mapping.test.mjs +201 -0
  1141. package/skills/a2h-spec-design-pipeline/SKILL.md +98 -121
  1142. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +170 -45
  1143. package/skills/a2h-spec-design-pipeline/references/execution-model.md +62 -12
  1144. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -4
  1145. package/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +229 -0
  1146. package/skills/a2h-spec-design-pipeline/references/initialization.md +49 -6
  1147. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +198 -54
  1148. package/skills/a2h-spec-design-pipeline/references/permission-index.json +206 -0
  1149. package/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  1150. package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +67 -0
  1151. package/skills/a2h-spec-design-pipeline/references/review-loop.md +46 -0
  1152. package/skills/a2h-spec-design-pipeline/references/scripts.md +47 -14
  1153. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +390 -0
  1154. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +148 -29
  1155. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +104 -24
  1156. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +18 -0
  1157. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +16 -0
  1158. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +47 -0
  1159. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +31 -0
  1160. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +698 -0
  1161. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +96 -0
  1162. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +103 -0
  1163. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +124 -0
  1164. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +138 -0
  1165. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +106 -0
  1166. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +113 -0
  1167. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +705 -0
  1168. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +1063 -0
  1169. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +473 -0
  1170. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/platform/ExtraDataSubCheck.js +485 -0
  1171. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +13 -0
  1172. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +18 -0
  1173. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
  1174. package/skills/a2h-spec-design-pipeline/scripts/check_design_map.ts +108 -0
  1175. package/skills/a2h-spec-design-pipeline/scripts/check_permissions.ts +420 -0
  1176. package/skills/a2h-spec-design-pipeline/scripts/check_review_evidence.ts +45 -0
  1177. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +95 -7
  1178. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +156 -7
  1179. package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +71 -0
  1180. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +22 -3
  1181. package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +63 -4
  1182. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +33 -3
  1183. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
  1184. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +232 -13
  1185. package/skills/a2h-spec-design-pipeline/scripts/ensure_index.ts +866 -0
  1186. package/skills/a2h-spec-design-pipeline/scripts/fixtures/homecheck-stub.cjs +47 -0
  1187. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +220 -44
  1188. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
  1189. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
  1190. package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
  1191. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +178 -14
  1192. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
  1193. package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +368 -0
  1194. package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
  1195. package/skills/a2h-spec-design-pipeline/scripts/sync_permission_index.ts +340 -0
  1196. package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +281 -0
  1197. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +690 -0
  1198. package/skills/a2h-spec-design-pipeline/scripts/test_check_design_map.ts +46 -0
  1199. package/skills/a2h-spec-design-pipeline/scripts/test_check_permissions.ts +201 -0
  1200. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +42 -8
  1201. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +27 -9
  1202. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +242 -9
  1203. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +192 -7
  1204. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +531 -0
  1205. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +49 -1
  1206. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +92 -4
  1207. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +51 -0
  1208. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index.ts +572 -0
  1209. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index_real.ts +56 -0
  1210. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +17 -10
  1211. package/skills/a2h-spec-design-pipeline/scripts/test_homegraph_docs.ts +217 -0
  1212. package/skills/a2h-spec-design-pipeline/scripts/test_permission_index.ts +214 -0
  1213. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
  1214. package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +308 -0
  1215. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
  1216. package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +401 -0
  1217. package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
  1218. package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
  1219. package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
  1220. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +165 -0
  1221. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
  1222. package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
  1223. package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
  1224. package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
  1225. package/skills/a2h-spec-generate/SKILL.md +89 -23
  1226. package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
  1227. package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  1228. package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
  1229. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  1230. package/skills/a2h-spec-generate/references/specs.schema.json +24 -11
  1231. package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
  1232. package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
  1233. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
  1234. package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
  1235. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
  1236. package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
  1237. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +1 -2
  1238. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
  1239. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
  1240. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
  1241. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
  1242. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
  1243. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
  1244. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
  1245. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
  1246. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
  1247. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
  1248. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
  1249. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
  1250. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  1251. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
  1252. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
  1253. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
  1254. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
  1255. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
  1256. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
  1257. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
  1258. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
  1259. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
  1260. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
  1261. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
  1262. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  1263. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  1264. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  1265. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  1266. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
  1267. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
  1268. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  1269. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  1270. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  1271. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
  1272. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  1273. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
  1274. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
  1275. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
  1276. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
  1277. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
  1278. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  1279. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  1280. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  1281. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  1282. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  1283. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  1284. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  1285. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  1286. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  1287. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  1288. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  1289. package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
  1290. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
  1291. package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
  1292. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
  1293. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  1294. package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
  1295. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +229 -0
  1296. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  1297. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  1298. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  1299. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  1300. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  1301. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  1302. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  1303. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  1304. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  1305. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  1306. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  1307. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  1308. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  1309. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  1310. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  1311. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  1312. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  1313. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  1314. package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  1315. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
  1316. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  1317. package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  1318. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  1319. package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  1320. package/skills/a2h-utg-explorer/SKILL.md +9 -3
  1321. package/skills/a2h-utg-explorer/references/architecture.md +7 -0
  1322. package/skills/a2h-utg-explorer/scripts/audit.mjs +8 -2
  1323. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +120 -85
  1324. package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +47 -2
  1325. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
  1326. package/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  1327. package/skills/a2h-utg-explorer/scripts/plan.mjs +8 -0
  1328. package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
  1329. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
  1330. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
  1331. package/skills/a2h-utg-explorer/scripts/report.mjs +89 -0
  1332. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +67 -10
  1333. package/skills/a2h-utg-explorer/scripts/run_device.mjs +10 -2
  1334. package/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  1335. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  1336. package/skills/a2h-utg-explorer/scripts/tests/blank_wait.test.mjs +126 -0
  1337. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
  1338. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  1339. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  1340. package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  1341. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  1342. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
  1343. package/skills/a2h-utg-explorer/scripts/tests/default_override.test.mjs +109 -0
  1344. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
  1345. package/skills/a2h-utg-explorer/scripts/tests/device_locale_dialogs.test.mjs +29 -0
  1346. package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
  1347. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  1348. package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +254 -0
  1349. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  1350. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
  1351. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  1352. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  1353. package/skills/a2h-utg-explorer/scripts/tests/foreground_spelling.test.mjs +155 -0
  1354. package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
  1355. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  1356. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  1357. package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
  1358. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +120 -0
  1359. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  1360. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  1361. package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  1362. package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
  1363. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  1364. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  1365. package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  1366. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  1367. package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  1368. package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  1369. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  1370. package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +218 -0
  1371. package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +292 -0
  1372. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  1373. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  1374. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  1375. package/skills/a2h-utg-explorer/scripts/tests/recover_d_grounding.test.mjs +164 -0
  1376. package/skills/a2h-utg-explorer/scripts/tests/replay_reroute.test.mjs +143 -0
  1377. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  1378. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  1379. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +458 -0
  1380. package/skills/a2h-utg-explorer/scripts/tests/run_cycle_follow.test.mjs +35 -0
  1381. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  1382. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  1383. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  1384. package/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  1385. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  1386. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
  1387. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  1388. package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
  1389. package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
  1390. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  1391. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  1392. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  1393. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  1394. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  1395. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +135 -7
  1396. package/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  1397. package/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  1398. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +245 -69
  1399. package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  1400. package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +164 -0
  1401. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +718 -42
  1402. package/skills/a2h-utg-explorer/scripts/variant.mjs +57 -11
  1403. package/skills/a2h-utg-static/SKILL.md +6 -2
  1404. package/skills/a2h-utg-static/scripts/assemble.mjs +93 -3
  1405. package/skills/a2h-utg-static/scripts/click_paths.mjs +135 -25
  1406. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
  1407. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +110 -3
  1408. package/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
  1409. package/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
  1410. package/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  1411. package/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  1412. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
  1413. package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +46 -1
  1414. package/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
  1415. package/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  1416. package/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  1417. package/skills/a2h-utg-static/scripts/menu_nav.mjs +1 -1
  1418. package/skills/a2h-utg-static/scripts/nl_hints.mjs +34 -7
  1419. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
  1420. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
  1421. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +86 -4
  1422. package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
  1423. package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
  1424. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +30 -0
  1425. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +18 -0
  1426. package/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  1427. package/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +114 -0
  1428. package/skills/a2h-utg-static/scripts/tests/test_guard_kinds_locale.mjs +12 -0
  1429. package/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  1430. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +165 -1
  1431. package/skills/a2h-utg-static/scripts/tests/test_library_activity.mjs +45 -0
  1432. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
  1433. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
  1434. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_default_override.mjs +50 -0
  1435. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +21 -0
  1436. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +172 -0
  1437. package/skills/a2h-utg-static/scripts/tests/test_redirect_path_cost.mjs +136 -0
  1438. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
  1439. package/skills/a2h-utg-static/scripts/tests/test_uniapp_route_jump.mjs +175 -0
  1440. package/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  1441. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +99 -0
  1442. package/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  1443. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +21 -0
  1444. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +112 -69
  1445. package/skills/a2h-utg-static/scripts/vm_nav.mjs +9 -1
  1446. package/README.md +0 -439
  1447. package/dist/cli/config-store.js +0 -128
  1448. package/dist/cli/config.js +0 -48
  1449. package/dist/cli/editors.json +0 -114
  1450. package/dist/cli/env-vars.js +0 -127
  1451. package/dist/cli/index.js +0 -73
  1452. package/dist/cli/init.js +0 -2513
  1453. package/dist/cli/uninstall.js +0 -406
  1454. package/dist/platform/compose.js +0 -228
  1455. package/dist/platform/frontmatter.js +0 -151
  1456. package/dist/platform/installer.js +0 -417
  1457. package/dist/platform/registry.js +0 -337
  1458. package/dist/platform/transform.js +0 -363
  1459. package/dist/platform/types.js +0 -9
  1460. package/dist/platform/validate.js +0 -152
  1461. package/dist/utils/regex.js +0 -7
  1462. package/env-requirements.json +0 -511
  1463. package/resource/choose_editor.png +0 -0
  1464. package/resource/convert_pipeline_process.svg +0 -114
  1465. package/resource/project_architecture.svg +0 -120
  1466. package/resource/set_environment.png +0 -0
  1467. package/resource/set_multimodel.png +0 -0
  1468. package/resource/set_sdk.png +0 -0
  1469. package/resource/title_dark.png +0 -0
  1470. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
  1471. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
  1472. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
  1473. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
  1474. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
  1475. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
  1476. package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
  1477. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
  1478. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
  1479. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
  1480. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
  1481. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
  1482. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
  1483. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +0 -885
  1484. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
  1485. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
  1486. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +0 -856
  1487. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
  1488. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
  1489. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
  1490. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
  1491. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
  1492. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
  1493. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
  1494. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
  1495. package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
  1496. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
@@ -0,0 +1,2596 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Android → HarmonyOS resource converter (canonical implementation, phase 1)
4
+ *
5
+ * This script is the **only** conversion implementation of the a2h-resource-convert skill. Agents no longer write their own
6
+ * conversion scripts: historically every cell wrote its own (10 cells, 3 languages, about 10k lines),
7
+ * so the same APK produced differing results, counting bases disagreed, and some cells even pulled in
8
+ * floating-version npm dependencies.
9
+ *
10
+ * Coverage (phase 1):
11
+ * - values/*.xml → base/element/*.json (string / color / float / integer /
12
+ * boolean / strarray / intarray / plural)
13
+ * - qualifier directory mapping (density, language/region, orientation, dark mode, API level stripping, screen size skipping)
14
+ * - direct copy of media files + nine-patch renaming (.9.png → _9.png)
15
+ * - raw/ → rawfile/, font/ → rawfile/fonts/, xml/ → base/profile/
16
+ * - unmappable types (layout / menu / anim / animator / color / interpolator …) are recorded
17
+ * - inventory + mapping records (entry level), used by the report and the mapping document
18
+ *
19
+ * Not yet covered (later phases; currently only registered as pending, never silently dropped):
20
+ * - XML drawable → SVG (vector / shape / layer-list / selector)
21
+ * - adaptive-icon → layered-image JSON + solid layers (following the other layer's format/size) + 72/108 safe-zone cropping of vector layers
22
+ * - reference resolution chains, the system resource table, fallback
23
+ *
24
+ * Zero third-party dependencies, only Node built-in modules. Requires Node >= 22.18 (native strip-types).
25
+ *
26
+ * Usage:
27
+ * node a2h_resource_convert.ts --res <decoded res dir> --harmony <harmony project dir>
28
+ * [--filter <deps.json>] [--records <path>] [--dry-run] [--quiet]
29
+ *
30
+ * --filter: optional. Takes the JSON output of extract_project_resources.ts and migrates only the
31
+ * resources listed in it (the reference closure), skipping third-party library resources the project does not reference.
32
+ * Without it everything is migrated (the original behavior).
33
+ *
34
+ * Exit codes:
35
+ * 0 conversion finished (pending items are not failures, but are counted and keep rows in records)
36
+ * 1 some items failed to convert
37
+ * 2 usage error / path does not exist
38
+ */
39
+
40
+ import * as fs from 'node:fs';
41
+ import * as path from 'node:path';
42
+ import * as zlib from 'node:zlib';
43
+
44
+ // ─────────────────────────────────────────────
45
+ // Constant tables
46
+ // ─────────────────────────────────────────────
47
+
48
+ /** Android density qualifier → HarmonyOS density qualifier. See conversion-rules.md "Density Qualifiers". */
49
+ const DENSITY: Record<string, string | null> = {
50
+ ldpi: 'sdpi', mdpi: 'mdpi', tvdpi: 'ldpi', hdpi: 'ldpi',
51
+ xhdpi: 'xldpi', xxhdpi: 'xxldpi', xxxhdpi: 'xxxldpi',
52
+ nodpi: null, anydpi: null, // → base, no qualifier produced
53
+ };
54
+
55
+ const ORIENTATION: Record<string, string> = { land: 'horizontal', port: 'vertical' };
56
+ const COLORMODE: Record<string, string> = { night: 'dark', notnight: 'light' };
57
+
58
+ /** Silently stripped: no HarmonyOS counterpart, but they do not affect the resource's applicability. */
59
+ const STRIP_RE = /^(v\d+|ldrtl|ldltr|round|notround|highdr|lowdr|long|notlong)$/;
60
+
61
+ /** Whole directory skipped: screen-size qualifiers have no HarmonyOS equivalent, and converting them would be wrong. */
62
+ const SKIP_RE = /^(sw\d+dp|w\d+dp|h\d+dp|small|normal|large|xlarge)$/;
63
+
64
+ /** Device type qualifier → HarmonyOS device qualifier. */
65
+ const DEVICE: Record<string, string> = {
66
+ watch: 'wearable', television: 'tv', car: 'car', desk: 'phone', appliance: 'phone',
67
+ };
68
+
69
+ const IMAGE_EXT = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.svg']);
70
+ const FONT_EXT = new Set(['.ttf', '.otf', '.ttc']);
71
+
72
+ /** Directory type → handling. */
73
+ const UNMAPPABLE_TYPES = new Set([
74
+ 'layout', 'menu', 'anim', 'animator', 'color', 'interpolator',
75
+ 'transition', 'navigation', 'id', 'ids',
76
+ ]);
77
+
78
+ /**
79
+ * Android framework built-in colors. See SKILL.md Step 5.2.
80
+ * HarmonyOS has no concept of Android system resources; `@android:` references must **never** remain in the output.
81
+ */
82
+ const ANDROID_SYSTEM_COLORS: Record<string, string> = {
83
+ white: '#ffffffff', black: '#ff000000', transparent: '#00000000',
84
+ background_dark: '#ff000000', background_light: '#ffffffff', darker_gray: '#ffaaaaaa',
85
+ holo_blue_bright: '#ff00ddff', holo_blue_dark: '#ff0099cc', holo_blue_light: '#ff33b5e5',
86
+ holo_green_dark: '#ff669900', holo_green_light: '#ff99cc00',
87
+ holo_orange_dark: '#ffff8800', holo_orange_light: '#ffffbb33',
88
+ holo_purple: '#ffaa66cc', holo_red_dark: '#ffcc0000', holo_red_light: '#ffff4444',
89
+ primary_text_dark: '#ffffffff', primary_text_light: '#de000000',
90
+ secondary_text_dark: '#b3ffffff', secondary_text_light: '#8a000000',
91
+ tab_indicator_text: '#ff808080',
92
+ tertiary_text_dark: '#80ffffff', tertiary_text_light: '#54000000',
93
+ widget_edittext_dark: '#ff000000',
94
+ };
95
+
96
+ /** Android framework built-in dimensions. See SKILL.md Step 5.2. */
97
+ const ANDROID_SYSTEM_DIMENS: Record<string, string> = {
98
+ app_icon_size: '48vp',
99
+ thumbnail_width: '96vp',
100
+ thumbnail_height: '96vp',
101
+ dialog_min_width_major: '65%',
102
+ dialog_min_width_minor: '95%',
103
+ notification_large_icon_width: '64vp',
104
+ notification_large_icon_height: '64vp',
105
+ };
106
+
107
+ /** Android framework built-in strings (English values). */
108
+ const ANDROID_SYSTEM_STRINGS: Record<string, string> = {
109
+ ok: 'OK', cancel: 'Cancel', yes: 'Yes', no: 'No',
110
+ copy: 'Copy', cut: 'Cut', paste: 'Paste', selectAll: 'Select all',
111
+ search_go: 'Search', unknownName: 'Unknown',
112
+ };
113
+
114
+ /** Fallback values by type when resolution fails. See SKILL.md Step 5.2 "Fallback values by type". */
115
+ const FALLBACK_BY_KEY: Record<string, unknown> = {
116
+ color: '#ff000000', float: '0vp', string: '', integer: 0, boolean: false,
117
+ };
118
+
119
+ /**
120
+ * In a decoded APK, enum attributes are numbers rather than names (values compiled by aapt).
121
+ * Writing the number straight into SVG yields an invalid `stroke-linecap="2"`.
122
+ */
123
+ const STROKE_LINECAP = ['butt', 'round', 'square'];
124
+ const STROKE_LINEJOIN = ['miter', 'round', 'bevel'];
125
+
126
+ /** Android dimension unit → HarmonyOS unit / conversion factor. */
127
+ const DIMEN_UNITS: Array<{ re: RegExp; unit: string; factor: number }> = [
128
+ { re: /^(-?[\d.]+)dip$/i, unit: 'vp', factor: 1 },
129
+ { re: /^(-?[\d.]+)dp$/i, unit: 'vp', factor: 1 },
130
+ { re: /^(-?[\d.]+)sp$/i, unit: 'fp', factor: 1 },
131
+ { re: /^(-?[\d.]+)px$/i, unit: 'px', factor: 1 },
132
+ { re: /^(-?[\d.]+)pt$/i, unit: 'vp', factor: 1.33 },
133
+ { re: /^(-?[\d.]+)in$/i, unit: 'vp', factor: 160 },
134
+ { re: /^(-?[\d.]+)mm$/i, unit: 'vp', factor: 6.3 },
135
+ { re: /^(-?[\d.]+)$/, unit: 'vp', factor: 1 },
136
+ ];
137
+
138
+ /** Android values tag → HarmonyOS element file name and JSON root key. */
139
+ const ELEMENT_KIND: Record<string, { file: string; key: string }> = {
140
+ string: { file: 'string.json', key: 'string' },
141
+ color: { file: 'color.json', key: 'color' },
142
+ dimen: { file: 'float.json', key: 'float' },
143
+ integer: { file: 'integer.json', key: 'integer' },
144
+ bool: { file: 'boolean.json', key: 'boolean' },
145
+ 'string-array': { file: 'strarray.json', key: 'strarray' },
146
+ 'integer-array': { file: 'intarray.json', key: 'intarray' },
147
+ plurals: { file: 'plural.json', key: 'plural' },
148
+ };
149
+
150
+ /** These values tags have no HarmonyOS equivalent and are registered as unmappable. */
151
+ const VALUES_UNMAPPABLE = new Set([
152
+ 'style', 'declare-styleable', 'attr', 'item', 'eat-comment', 'skip', 'fraction', 'macro',
153
+ ]);
154
+
155
+ /**
156
+ * When apktool decodes an APK, arrays whose items are all `@string/...` references are written as a generic `<array>`
157
+ * tag rather than the `<string-array>` / `<integer-array>` of the original source (those two tags only appear in
158
+ * hand-written res/values sources; the information compiled by aapt2 does not distinguish them). ELEMENT_KIND has no
159
+ * `array` key, so these arrays used to be silently recorded as unmappable: the page still compiled and every place referencing
160
+ * the array still resolved, but all the array's own entries were lost.
161
+ *
162
+ * rewriteArrayRaw() in a2h_resource_incremental.ts already distinguishes string-array / integer-array by "are all items integers";
163
+ * the same criterion is reused here so both converters behave the same.
164
+ * Returns the original tag (if it is already a concrete tag) or the normalized tag; non-`<array>` elements are returned unchanged.
165
+ */
166
+ function normalizeArrayTag(el: XmlNode): string {
167
+ if (el.name !== 'array') return el.name;
168
+ const items = el.children.filter((c) => c.name === 'item');
169
+ if (items.length === 0) return 'string-array'; // empty array, undecidable; treated as strings by default
170
+ const allNumeric = items.every((c) => /^-?\d+$/.test(decodeEntities(c.inner).trim()));
171
+ return allNumeric ? 'integer-array' : 'string-array';
172
+ }
173
+
174
+ // ─────────────────────────────────────────────
175
+ // Types
176
+ // ─────────────────────────────────────────────
177
+
178
+ interface XmlNode {
179
+ name: string;
180
+ attrs: Record<string, string>;
181
+ children: XmlNode[];
182
+ /** The element's raw inner source snippet (including child tags); string resources need it */
183
+ inner: string;
184
+ }
185
+
186
+ /** Android resource inventory row. Fields aligned with references/resource-mapping-rules.md §2.1. */
187
+ interface InventoryRecord {
188
+ androidResourcePath: string;
189
+ androidResourceName: string;
190
+ function: string;
191
+ screens: string;
192
+ sourceCategory: string;
193
+ typeCategory: string;
194
+ status: string;
195
+ notes: string;
196
+ }
197
+
198
+ /** Android ↔ HarmonyOS mapping row. Fields aligned with §2.2. */
199
+ interface MappingRecord {
200
+ androidResourcePath: string;
201
+ androidScreens: string;
202
+ androidSourceCategory: string;
203
+ androidTypeCategory: string;
204
+ harmonyTarget: string;
205
+ mappingKind: string;
206
+ notes: string;
207
+ }
208
+
209
+ /** Classification result of one adaptive icon layer, see Converter.classifyAdaptiveLayer. */
210
+ type AdaptiveLayer =
211
+ | { kind: 'vector'; vec: XmlNode; source: string; resName?: string }
212
+ | { kind: 'bitmap'; resName: string; w: number; h: number }
213
+ | { kind: 'solid'; ref: string; colorName: string | null; hex: string | null }
214
+ | { kind: 'inline'; child: XmlNode }
215
+ | { kind: 'ref'; resName: string }
216
+ | { kind: 'missing' }
217
+ | { kind: 'unknown'; ref: string };
218
+
219
+ interface QualifierPlan {
220
+ /** HarmonyOS qualifier directory name; `base` means no qualifier */
221
+ dir: string;
222
+ /** Reason when the whole directory is skipped */
223
+ skip: string | null;
224
+ stripped: string[];
225
+ }
226
+
227
+ // ─────────────────────────────────────────────
228
+ // Utilities
229
+ // ─────────────────────────────────────────────
230
+
231
+ function fail(msg: string): never {
232
+ console.error(`[a2h_resource_convert] ${msg}`);
233
+ process.exit(2);
234
+ }
235
+
236
+ const ENTITIES: Record<string, string> = {
237
+ amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ',
238
+ };
239
+
240
+ function decodeEntities(s: string): string {
241
+ return s.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (m, body: string) => {
242
+ if (body[0] === '#') {
243
+ const code = body[1] === 'x' || body[1] === 'X'
244
+ ? parseInt(body.slice(2), 16)
245
+ : parseInt(body.slice(1), 10);
246
+ return Number.isFinite(code) ? String.fromCodePoint(code) : m;
247
+ }
248
+ return ENTITIES[body] ?? m;
249
+ });
250
+ }
251
+
252
+ // ─────────────────────────────────────────────
253
+ // Minimal XML parser
254
+ // ─────────────────────────────────────────────
255
+
256
+ /**
257
+ * Covers only the syntax Android resource XML needs: elements, attributes, text, CDATA, comments,
258
+ * declarations and DOCTYPE. No DTD, entity declarations or namespace resolution (attribute names are kept as is;
259
+ * callers compare by localName).
260
+ */
261
+ function parseXml(src: string): XmlNode {
262
+ let i = 0;
263
+ const n = src.length;
264
+
265
+ function skipUntil(marker: string): void {
266
+ const at = src.indexOf(marker, i);
267
+ i = at < 0 ? n : at + marker.length;
268
+ }
269
+
270
+ function parseAttrs(end: number): Record<string, string> {
271
+ const attrs: Record<string, string> = {};
272
+ const re = /([^\s=/>]+)\s*=\s*("([^"]*)"|'([^']*)')/g;
273
+ const slice = src.slice(i, end);
274
+ let m: RegExpExecArray | null;
275
+ while ((m = re.exec(slice)) !== null) {
276
+ attrs[m[1]] = decodeEntities(m[3] ?? m[4] ?? '');
277
+ }
278
+ return attrs;
279
+ }
280
+
281
+ function parseNode(): XmlNode | null {
282
+ while (i < n) {
283
+ const lt = src.indexOf('<', i);
284
+ if (lt < 0) return null;
285
+ i = lt;
286
+ if (src.startsWith('<!--', i)) { skipUntil('-->'); continue; }
287
+ if (src.startsWith('<?', i)) { skipUntil('?>'); continue; }
288
+ if (src.startsWith('<!DOCTYPE', i) || src.startsWith('<!', i)) { skipUntil('>'); continue; }
289
+ if (src.startsWith('</', i)) return null;
290
+ break;
291
+ }
292
+ if (i >= n) return null;
293
+
294
+ const gt = src.indexOf('>', i);
295
+ if (gt < 0) return null;
296
+ const selfClosing = src[gt - 1] === '/';
297
+ const head = src.slice(i + 1, selfClosing ? gt - 1 : gt);
298
+ const name = head.split(/[\s/]/, 1)[0];
299
+ const attrs = parseAttrs(gt);
300
+ i = gt + 1;
301
+
302
+ const node: XmlNode = { name, attrs, children: [], inner: '' };
303
+ if (selfClosing) return node;
304
+
305
+ const innerStart = i;
306
+ // Consume segment by segment until this element's closing tag
307
+ while (i < n) {
308
+ const lt = src.indexOf('<', i);
309
+ if (lt < 0) { i = n; break; }
310
+ if (src.startsWith('<![CDATA[', lt)) {
311
+ i = lt; skipUntil(']]>'); continue;
312
+ }
313
+ if (src.startsWith('<!--', lt)) { i = lt; skipUntil('-->'); continue; }
314
+ if (src.startsWith(`</${name}`, lt)) {
315
+ node.inner = src.slice(innerStart, lt);
316
+ i = src.indexOf('>', lt);
317
+ i = i < 0 ? n : i + 1;
318
+ return node;
319
+ }
320
+ i = lt;
321
+ const child = parseNode();
322
+ if (child) node.children.push(child);
323
+ else { i = lt + 1; }
324
+ }
325
+ node.inner = src.slice(innerStart);
326
+ return node;
327
+ }
328
+
329
+ const root = parseNode();
330
+ return root ?? { name: '', attrs: {}, children: [], inner: '' };
331
+ }
332
+
333
+ /** Gets an attribute value by localName (ignoring prefixes such as `android:`). */
334
+ function attr(node: XmlNode, local: string): string | undefined {
335
+ for (const [k, v] of Object.entries(node.attrs)) {
336
+ if (k === local || k.endsWith(`:${local}`)) return v;
337
+ }
338
+ return undefined;
339
+ }
340
+
341
+ // ─────────────────────────────────────────────
342
+ // Value conversion
343
+ // ─────────────────────────────────────────────
344
+
345
+ /**
346
+ * Android string literal → HarmonyOS string value.
347
+ *
348
+ * Order matters: first take CDATA / strip tags, then decode entities, then decode Android backslash escapes,
349
+ * and finally strip Android's paired outer quotes (those quotes are syntax protecting leading/trailing whitespace,
350
+ * not text content; SKILL.md Step 6.11 checks exactly this).
351
+ */
352
+ function normalizeString(inner: string): string {
353
+ let s = inner;
354
+ const cdata = [...s.matchAll(/<!\[CDATA\[([\s\S]*?)\]\]>/g)];
355
+ if (cdata.length > 0) s = cdata.map((m) => m[1]).join('');
356
+ s = decodeEntities(s);
357
+ s = s.replace(/\\(['"@?\\])/g, '$1').replace(/\\n/g, '\n').replace(/\\t/g, '\t');
358
+ if (s.length >= 2 && s.startsWith('"') && s.endsWith('"')) s = s.slice(1, -1);
359
+ return s;
360
+ }
361
+
362
+ /** `#RGB` / `#ARGB` / `#RRGGBB` / `#AARRGGBB` → `#AARRGGBB` (lowercase). */
363
+ function normalizeColor(raw: string): string | null {
364
+ const v = raw.trim();
365
+ const m = /^#([0-9a-fA-F]{3,8})$/.exec(v);
366
+ if (!m) return null;
367
+ const h = m[1].toLowerCase();
368
+ if (h.length === 3) return `#ff${h[0]}${h[0]}${h[1]}${h[1]}${h[2]}${h[2]}`;
369
+ if (h.length === 4) return `#${h[0]}${h[0]}${h[1]}${h[1]}${h[2]}${h[2]}${h[3]}${h[3]}`;
370
+ if (h.length === 6) return `#ff${h}`;
371
+ if (h.length === 8) return `#${h}`;
372
+ return null;
373
+ }
374
+
375
+ /** Android dimension → HarmonyOS dimension string. Returns null when it cannot be parsed (the caller registers a fallback). */
376
+ function normalizeDimen(raw: string): string | null {
377
+ const v = raw.trim();
378
+ for (const { re, unit, factor } of DIMEN_UNITS) {
379
+ const m = re.exec(v);
380
+ if (!m) continue;
381
+ const num = parseFloat(m[1]);
382
+ if (!Number.isFinite(num)) return null;
383
+ // Always round to 3 decimals: fixed-point numbers in resources.arsc often carry floating-point noise after decoding
384
+ // (e.g. 6.500001dip), and emitting them verbatim would carry the noise into HarmonyOS resources.
385
+ const scaled = Math.round(num * factor * 1000) / 1000;
386
+ return `${scaled}${unit}`;
387
+ }
388
+ return null;
389
+ }
390
+
391
+ function normalizeInteger(raw: string): number | null {
392
+ const v = raw.trim();
393
+ const parsed = /^0[xX]/.test(v) ? parseInt(v, 16) : parseInt(v, 10);
394
+ return Number.isFinite(parsed) ? parsed : null;
395
+ }
396
+
397
+ // ─────────────────────────────────────────────
398
+ // Solid-color PNG generation (zlib + hand-written PNG wrapping, avoiding pngjs)
399
+ // ─────────────────────────────────────────────
400
+
401
+ let CRC_TABLE: Int32Array | null = null;
402
+
403
+ function crc32(buf: Buffer): number {
404
+ if (!CRC_TABLE) {
405
+ CRC_TABLE = new Int32Array(256);
406
+ for (let n = 0; n < 256; n++) {
407
+ let c = n;
408
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
409
+ CRC_TABLE[n] = c;
410
+ }
411
+ }
412
+ let c = -1;
413
+ for (let i = 0; i < buf.length; i++) c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8);
414
+ return (c ^ -1) >>> 0;
415
+ }
416
+
417
+ function pngChunk(type: string, data: Buffer): Buffer {
418
+ const len = Buffer.alloc(4);
419
+ len.writeUInt32BE(data.length, 0);
420
+ const body = Buffer.concat([Buffer.from(type, 'latin1'), data]);
421
+ const crc = Buffer.alloc(4);
422
+ crc.writeUInt32BE(crc32(body), 0);
423
+ return Buffer.concat([len, body, crc]);
424
+ }
425
+
426
+ /** A w×h solid-color SVG (the solid layer paired with a vector layer in an adaptive icon). `#AARRGGBB` input. */
427
+ function solidSvg(argb: string, w: number, h: number): string {
428
+ const h8 = argb.replace('#', '');
429
+ const a = parseInt(h8.slice(0, 2), 16) / 255;
430
+ const op = a < 0.999 ? ` fill-opacity="${Math.round(a * 1000) / 1000}"` : '';
431
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><rect width="${w}" height="${h}" fill="#${h8.slice(2)}"${op}/></svg>\n`;
432
+ }
433
+
434
+ /** Reads a bitmap's pixel size (PNG / WebP / JPEG / GIF); returns null for unknown formats. Reads only the header, never decodes. */
435
+ function imageSize(buf: Buffer): { w: number; h: number } | null {
436
+ if (buf.length >= 24 && buf.readUInt32BE(0) === 0x89504e47) {
437
+ return { w: buf.readUInt32BE(16), h: buf.readUInt32BE(20) };
438
+ }
439
+ if (buf.length >= 10 && buf.toString('latin1', 0, 3) === 'GIF') {
440
+ return { w: buf.readUInt16LE(6), h: buf.readUInt16LE(8) };
441
+ }
442
+ if (buf.length >= 30 && buf.toString('latin1', 0, 4) === 'RIFF' && buf.toString('latin1', 8, 12) === 'WEBP') {
443
+ const chunk = buf.toString('latin1', 12, 16);
444
+ if (chunk === 'VP8 ') return { w: buf.readUInt16LE(26) & 0x3fff, h: buf.readUInt16LE(28) & 0x3fff };
445
+ if (chunk === 'VP8L') {
446
+ const b = buf.readUInt32LE(21);
447
+ return { w: (b & 0x3fff) + 1, h: ((b >> 14) & 0x3fff) + 1 };
448
+ }
449
+ if (chunk === 'VP8X') return { w: buf.readUIntLE(24, 3) + 1, h: buf.readUIntLE(27, 3) + 1 };
450
+ return null;
451
+ }
452
+ if (buf.length >= 4 && buf[0] === 0xff && buf[1] === 0xd8) {
453
+ let i = 2;
454
+ while (i + 9 < buf.length) {
455
+ if (buf[i] !== 0xff) { i++; continue; }
456
+ const marker = buf[i + 1];
457
+ // SOF0..SOF15, excluding DHT(C4) / JPG(C8) / DAC(CC)
458
+ if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
459
+ return { w: buf.readUInt16BE(i + 7), h: buf.readUInt16BE(i + 5) };
460
+ }
461
+ i += 2 + buf.readUInt16BE(i + 2);
462
+ }
463
+ }
464
+ return null;
465
+ }
466
+
467
+ /** Generates a w×h solid-color RGBA PNG. `#AARRGGBB` input. */
468
+ function solidPng(argb: string, w = 1024, hgt = w): Buffer {
469
+ const h = argb.replace('#', '');
470
+ const a = parseInt(h.slice(0, 2), 16);
471
+ const r = parseInt(h.slice(2, 4), 16);
472
+ const g = parseInt(h.slice(4, 6), 16);
473
+ const b = parseInt(h.slice(6, 8), 16);
474
+
475
+ const row = Buffer.alloc(1 + w * 4);
476
+ for (let x = 0; x < w; x++) {
477
+ row[1 + x * 4] = r; row[2 + x * 4] = g; row[3 + x * 4] = b; row[4 + x * 4] = a;
478
+ }
479
+ const raw = Buffer.concat(Array.from({ length: hgt }, () => row));
480
+
481
+ const ihdr = Buffer.alloc(13);
482
+ ihdr.writeUInt32BE(w, 0);
483
+ ihdr.writeUInt32BE(hgt, 4);
484
+ ihdr[8] = 8; // bit depth
485
+ ihdr[9] = 6; // color type RGBA
486
+ return Buffer.concat([
487
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
488
+ pngChunk('IHDR', ihdr),
489
+ pngChunk('IDAT', zlib.deflateSync(raw, { level: 9 })),
490
+ pngChunk('IEND', Buffer.alloc(0)),
491
+ ]);
492
+ }
493
+
494
+ // ─────────────────────────────────────────────
495
+ // XML drawable → SVG
496
+ // ─────────────────────────────────────────────
497
+
498
+ interface SvgPaint {
499
+ color: string;
500
+ opacity: number | null;
501
+ }
502
+
503
+ /** `#AARRGGBB` / `#RRGGBB` / shorthand → SVG `#RRGGBB` + a separate opacity. */
504
+ function androidColorToSvg(raw: string): SvgPaint | null {
505
+ const c = normalizeColor(raw);
506
+ if (!c) return null;
507
+ const h = c.slice(1);
508
+ const alpha = parseInt(h.slice(0, 2), 16) / 255;
509
+ return {
510
+ color: `#${h.slice(2)}`,
511
+ opacity: alpha >= 0.999 ? null : Math.round(alpha * 1000) / 1000,
512
+ };
513
+ }
514
+
515
+ /** `24dp` / `24dip` / `24` → `24` (SVG user units). */
516
+ function svgNum(raw: string | undefined, fallback: number): number {
517
+ if (!raw) return fallback;
518
+ const m = /^(-?[\d.]+)/.exec(raw.trim());
519
+ const v = m ? parseFloat(m[1]) : NaN;
520
+ return Number.isFinite(v) ? v : fallback;
521
+ }
522
+
523
+ function esc(s: string): string {
524
+ return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
525
+ }
526
+
527
+ // ─────────────────────────────────────────────
528
+ // Qualifier directory parsing
529
+ // ─────────────────────────────────────────────
530
+
531
+ /**
532
+ * `drawable-zh-rCN-night-hdpi` → { type: 'drawable', plan: { dir: 'zh_CN-dark-ldpi' } }
533
+ *
534
+ * Output order follows the HarmonyOS convention:
535
+ * MCC_MNC-language_script_country-orientation-device-colormode-density
536
+ */
537
+ function planQualifiers(dirName: string): { type: string; plan: QualifierPlan } {
538
+ const segs = dirName.split('-');
539
+ const type = segs[0];
540
+ const rest = segs.slice(1);
541
+
542
+ let language = '';
543
+ let script = '';
544
+ let region = '';
545
+ let orientation = '';
546
+ let device = '';
547
+ let colormode = '';
548
+ let density = '';
549
+ const stripped: string[] = [];
550
+
551
+ for (let k = 0; k < rest.length; k++) {
552
+ const q = rest[k];
553
+ if (SKIP_RE.test(q)) {
554
+ return { type, plan: { dir: '', skip: `Unsupported qualifier: ${q} — no HarmonyOS equivalent`, stripped } };
555
+ }
556
+ if (STRIP_RE.test(q)) { stripped.push(q); continue; }
557
+ if (q in DENSITY) {
558
+ const d = DENSITY[q];
559
+ if (d) density = d; else stripped.push(q); // nodpi / anydpi → base
560
+ continue;
561
+ }
562
+ if (q in ORIENTATION) { orientation = ORIENTATION[q]; continue; }
563
+ if (q in COLORMODE) { colormode = COLORMODE[q]; continue; }
564
+ if (q in DEVICE) { device = DEVICE[q]; continue; }
565
+ if (/^b\+/.test(q)) { // BCP 47: b+sr+Latn
566
+ const parts = q.slice(2).split('+');
567
+ language = parts[0] ?? '';
568
+ if (parts[1] && parts[1].length === 4) script = parts[1];
569
+ if (parts[2]) region = parts[2];
570
+ continue;
571
+ }
572
+ // Region qualifier: ISO 3166-1 two letters (rCN), or UN M.49 three digits (r419 = Latin America).
573
+ // Accepting only two letters would treat `values-es-r419` as unrecognized and strip it, merging it straight into generic `es`:
574
+ // Latin American Spanish would overwrite European Spanish, a silent mistranslation. The HarmonyOS region slot accepts three digits too.
575
+ if (/^r(?:[A-Z]{2}|\d{3})$/.test(q) && language) { region = q.slice(1); continue; }
576
+ if (/^[a-z]{2,3}$/.test(q) && !language) { language = q; continue; }
577
+ if (/^mcc\d+$/.test(q) || /^mnc\d+$/.test(q)) { stripped.push(q); continue; }
578
+ stripped.push(q); // other unrecognized qualifiers: stripped, not rejected
579
+ }
580
+
581
+ const locale = [language, script, region].filter(Boolean).join('_');
582
+ const dir = [locale, orientation, device, colormode, density].filter(Boolean).join('-') || 'base';
583
+ return { type, plan: { dir, skip: null, stripped } };
584
+ }
585
+
586
+ // ─────────────────────────────────────────────
587
+ // Conversion core
588
+ // ─────────────────────────────────────────────
589
+
590
+ interface ElementEntry {
591
+ name: string;
592
+ value: unknown;
593
+ /** Raw Android-side text, needed when backtracking during reference resolution */
594
+ raw: string;
595
+ sourcePath: string;
596
+ }
597
+
598
+ /** One reference resolution record, used by the report's "Resource Reference Resolution" section. */
599
+ interface ResolutionRecord {
600
+ file: string;
601
+ name: string;
602
+ reference: string;
603
+ resolved: string;
604
+ chain: string;
605
+ kind: 'project' | 'system' | 'fallback' | 'theme-attr';
606
+ }
607
+
608
+ class Converter {
609
+ resDir: string;
610
+ outRoot: string;
611
+ dryRun: boolean;
612
+ /** Resource allowlist (`type/name`); null means full mode */
613
+ filterSet: Set<string> | null;
614
+
615
+ /** qualifierDir → elementFile → name → entry */
616
+ elements = new Map<string, Map<string, Map<string, ElementEntry>>>();
617
+ /** Raw color / dimen values under the base qualifier, for resolving references in place during SVG conversion */
618
+ rawColors = new Map<string, string>();
619
+ rawDimens = new Map<string, string>();
620
+ /** Raw string values under the base qualifier; pathData may reference them as `@string/xxx` */
621
+ rawStrings = new Map<string, string>();
622
+ rawIntegers = new Map<string, string>();
623
+ rawBools = new Map<string, string>();
624
+ resolutions: ResolutionRecord[] = [];
625
+ /** One entry per processed file, used by the report's "qualifier mapping" aggregate table */
626
+ qualifierUse: Array<{ android: string; harmony: string }> = [];
627
+ /** Solid layer files already written to disk (target relative paths); each path is written only once */
628
+ writtenSolidLayers = new Set<string>();
629
+ /**
630
+ * Solid layer `$media` name → spec (format + size). `$media` names are globally unique;
631
+ * when different icons need different specs of the same color, the later one is renamed instead of reusing a file of the wrong size.
632
+ */
633
+ solidLayerSpecs = new Map<string, string>();
634
+ inventory: InventoryRecord[] = [];
635
+ mappings: MappingRecord[] = [];
636
+ warnings: string[] = [];
637
+ conflicts: string[] = [];
638
+ counts = {
639
+ valuesEntries: 0, mediaCopied: 0, ninePatchRenamed: 0,
640
+ rawCopied: 0, fontCopied: 0, profileCopied: 0,
641
+ unmappable: 0, skippedQualifierDirs: 0, failed: 0,
642
+ svgConverted: 0, layeredImages: 0, solidLayersGenerated: 0, safeZoneLayers: 0, uncroppedBitmapIcons: 0, systemColorsResolved: 0,
643
+ referencesResolved: 0, systemReferencesResolved: 0, fallbacksApplied: 0,
644
+ unresolvedPaint: 0, mediaTargetCollisions: 0,
645
+ };
646
+
647
+ constructor(resDir: string, harmonyDir: string, dryRun: boolean, uiModule = 'entry', filterSet: Set<string> | null = null) {
648
+ this.resDir = resDir;
649
+ // uiModule may be a multi-level relative path (e.g. products/phone in a layered architecture), so it is split by separator
650
+ const moduleSegs = uiModule.split(/[\\/]+/).filter(Boolean);
651
+ this.outRoot = path.join(harmonyDir, ...moduleSegs, 'src', 'main', 'resources');
652
+ this.dryRun = dryRun;
653
+ this.filterSet = filterSet;
654
+ }
655
+
656
+ // ── Records ──
657
+
658
+ inv(r: Partial<InventoryRecord> & { androidResourcePath: string; androidResourceName: string }): void {
659
+ this.inventory.push({
660
+ function: '', screens: 'Common', sourceCategory: "app-own",
661
+ typeCategory: 'drawable', status: 'converted', notes: '', ...r,
662
+ });
663
+ }
664
+
665
+ map(r: Partial<MappingRecord> & { androidResourcePath: string }): void {
666
+ this.mappings.push({
667
+ androidScreens: 'Common', androidSourceCategory: "app-own",
668
+ androidTypeCategory: 'drawable', harmonyTarget: 'N/A',
669
+ mappingKind: 'unmappable', notes: '', ...r,
670
+ });
671
+ }
672
+
673
+ /**
674
+ * Infers the resource origin category. Uses only evidence-backed prefix conventions,
675
+ * see resource-mapping-rules.md §7.3; without evidence it is classified as the app's own resource.
676
+ */
677
+ sourceCategory(name: string): string {
678
+ return /^(abc_|mtrl_|material_|design_|m3_|androidx_|exo_|preference_|common_|gcm_|fcm_|play_)/.test(name)
679
+ ? "third-party-library"
680
+ : "app-own";
681
+ }
682
+
683
+ /** Target media path → the Android source file occupying it and its qualifier count */
684
+ claimedTargets = new Map<string, { source: string; quals: number }>();
685
+
686
+ /**
687
+ * Several Android sources may land on the same HarmonyOS target: `drawable/x.xml`,
688
+ * `drawable-anydpi/x.xml` (anydpi→base) and `drawable-v31/x.xml` (v31 stripped) all write
689
+ * `base/media/x.svg`. HarmonyOS cannot express these qualifiers, so one must be chosen.
690
+ *
691
+ * Rule: **fewer qualifiers wins**: the resource without qualifiers is the one that applies unconditionally.
692
+ * Losers are not silently dropped; they still produce an unmappable mapping row explaining why.
693
+ * Returns false when this write should not happen.
694
+ */
695
+ claimTarget(targetRel: string, relFile: string, androidPath: string, type: string): boolean {
696
+ const quals = relFile.split('/')[0].split('-').length - 1;
697
+ const prev = this.claimedTargets.get(targetRel);
698
+ if (!prev) {
699
+ this.claimedTargets.set(targetRel, { source: relFile, quals });
700
+ return true;
701
+ }
702
+ this.counts.mediaTargetCollisions++;
703
+ const loser = quals < prev.quals ? prev.source : relFile;
704
+ const winner = quals < prev.quals ? relFile : prev.source;
705
+ const note = `HarmonyOS target collision on ${targetRel}: kept res/${winner} (fewer qualifiers), dropped res/${loser}`;
706
+ this.warnings.push(note);
707
+ this.map({
708
+ androidResourcePath: `res/${loser}`, androidTypeCategory: type,
709
+ androidSourceCategory: this.sourceCategory(path.basename(loser).replace(/\.[^.]+$/, '')),
710
+ mappingKind: 'unmappable', notes: note,
711
+ });
712
+ if (quals < prev.quals) {
713
+ this.claimedTargets.set(targetRel, { source: relFile, quals });
714
+ return true;
715
+ }
716
+ return false;
717
+ }
718
+
719
+ /** Target relative paths written in this run; used to tell "leftovers from the previous run" from "this run's output" */
720
+ writtenThisRun = new Set<string>();
721
+
722
+ write(rel: string, data: string | Buffer): void {
723
+ this.writtenThisRun.add(path.normalize(rel));
724
+ if (this.dryRun) return;
725
+ const full = path.join(this.outRoot, rel);
726
+ fs.mkdirSync(path.dirname(full), { recursive: true });
727
+ fs.writeFileSync(full, data);
728
+ }
729
+
730
+ // ── values ──
731
+
732
+ addElement(qdir: string, file: string, entry: ElementEntry): void {
733
+ let byFile = this.elements.get(qdir);
734
+ if (!byFile) { byFile = new Map(); this.elements.set(qdir, byFile); }
735
+ let byName = byFile.get(file);
736
+ if (!byName) { byName = new Map(); byFile.set(file, byName); }
737
+ const prev = byName.get(entry.name);
738
+ if (prev && prev.sourcePath !== entry.sourcePath) {
739
+ // Android semantics: a later definition overrides an earlier one
740
+ this.conflicts.push(`${qdir}/${file}#${entry.name}: ${prev.sourcePath} → ${entry.sourcePath}`);
741
+ }
742
+ byName.set(entry.name, entry);
743
+ }
744
+
745
+ processValuesFile(relFile: string, qdir: string): void {
746
+ const src = fs.readFileSync(path.join(this.resDir, relFile), 'utf8');
747
+ const root = parseXml(src);
748
+ if (root.name !== 'resources') return;
749
+
750
+ for (const el of root.children) {
751
+ const name = attr(el, 'name');
752
+ if (!name) continue;
753
+ const rawTag = el.name;
754
+ const tag = normalizeArrayTag(el); // apktool's generic <array> → string-array/integer-array
755
+ const androidPath = `res/${relFile}#${rawTag}/${name}`;
756
+ const sourceCategory = this.sourceCategory(name);
757
+
758
+ // Filter mode: only process entries in the allowlist
759
+ if (this.filterSet && !this.filterSet.has(`${tag}/${name}`)) continue;
760
+
761
+ if (VALUES_UNMAPPABLE.has(tag)) {
762
+ this.counts.unmappable++;
763
+ this.inv({
764
+ androidResourcePath: androidPath, androidResourceName: name,
765
+ function: `${tag} resource`, sourceCategory, typeCategory: 'values',
766
+ status: 'unmappable', notes: `Android ${tag} has no HarmonyOS equivalent`,
767
+ });
768
+ this.map({
769
+ androidResourcePath: androidPath, androidSourceCategory: sourceCategory,
770
+ androidTypeCategory: 'values', mappingKind: 'unmappable',
771
+ notes: `Android ${tag} has no HarmonyOS equivalent`,
772
+ });
773
+ continue;
774
+ }
775
+
776
+ const kind = ELEMENT_KIND[tag];
777
+ if (!kind) {
778
+ this.counts.unmappable++;
779
+ this.inv({
780
+ androidResourcePath: androidPath, androidResourceName: name,
781
+ function: `${tag} resource`, sourceCategory, typeCategory: 'values',
782
+ status: 'unmappable', notes: `unrecognized values tag: ${tag}`,
783
+ });
784
+ this.map({
785
+ androidResourcePath: androidPath, androidSourceCategory: sourceCategory,
786
+ androidTypeCategory: 'values', notes: `unrecognized values tag: ${tag}`,
787
+ });
788
+ continue;
789
+ }
790
+
791
+ // Raw values of the base qualifier go into the table first; SVG conversion relies on it to resolve @color / @dimen references
792
+ if (qdir === 'base') {
793
+ if (tag === 'color') this.rawColors.set(name, decodeEntities(el.inner).trim());
794
+ else if (tag === 'dimen') this.rawDimens.set(name, decodeEntities(el.inner).trim());
795
+ else if (tag === 'string') this.rawStrings.set(name, normalizeString(el.inner));
796
+ else if (tag === 'integer') this.rawIntegers.set(name, decodeEntities(el.inner).trim());
797
+ else if (tag === 'bool') this.rawBools.set(name, decodeEntities(el.inner).trim());
798
+ }
799
+
800
+ const value = this.convertValue(tag, el, androidPath);
801
+ if (value === undefined) { this.counts.failed++; continue; }
802
+
803
+ this.addElement(qdir, kind.file, {
804
+ name, value, raw: decodeEntities(el.inner).trim(), sourcePath: androidPath,
805
+ });
806
+ this.counts.valuesEntries++;
807
+ const target = `resources/${qdir}/element/${kind.file}#${name}`;
808
+ this.inv({
809
+ androidResourcePath: androidPath, androidResourceName: name,
810
+ function: `${tag} value resource`, sourceCategory, typeCategory: 'values',
811
+ status: 'converted',
812
+ });
813
+ this.map({
814
+ androidResourcePath: androidPath, androidSourceCategory: sourceCategory,
815
+ androidTypeCategory: 'values', harmonyTarget: target, mappingKind: 'merged into json',
816
+ });
817
+ }
818
+ }
819
+
820
+ /** Returns undefined on conversion failure (already counted and warned). */
821
+ convertValue(tag: string, el: XmlNode, androidPath: string): unknown {
822
+ const raw = el.inner;
823
+ switch (tag) {
824
+ case 'string':
825
+ return normalizeString(raw);
826
+ case 'color': {
827
+ const c = normalizeColor(decodeEntities(raw));
828
+ if (c) return c;
829
+ // References are left for later phases to resolve; here they are converted to HarmonyOS reference syntax by the rules
830
+ return this.toHarmonyRef(raw.trim(), androidPath, 'color');
831
+ }
832
+ case 'dimen': {
833
+ const d = normalizeDimen(decodeEntities(raw));
834
+ if (d) return d;
835
+ return this.toHarmonyRef(raw.trim(), androidPath, 'float');
836
+ }
837
+ case 'integer': {
838
+ const v = normalizeInteger(decodeEntities(raw));
839
+ if (v !== null) return v;
840
+ this.warnings.push(`${androidPath}: integer unparseable (${raw.trim()}), reference kept for a later pass`);
841
+ return this.toHarmonyRef(raw.trim(), androidPath, 'integer');
842
+ }
843
+ case 'bool': {
844
+ const t = decodeEntities(raw).trim().toLowerCase();
845
+ if (t === 'true') return true;
846
+ if (t === 'false') return false;
847
+ return this.toHarmonyRef(raw.trim(), androidPath, 'boolean');
848
+ }
849
+ case 'string-array':
850
+ return el.children
851
+ .filter((c) => c.name === 'item')
852
+ .map((c) => ({ value: normalizeString(c.inner) }));
853
+ case 'integer-array':
854
+ return el.children
855
+ .filter((c) => c.name === 'item')
856
+ .map((c) => ({ value: normalizeInteger(decodeEntities(c.inner)) ?? 0 }));
857
+ case 'plurals':
858
+ return el.children
859
+ .filter((c) => c.name === 'item')
860
+ .map((c) => ({ quantity: attr(c, 'quantity') ?? 'other', value: normalizeString(c.inner) }));
861
+ default:
862
+ return undefined;
863
+ }
864
+ }
865
+
866
+ /** `@color/x` → `$color:x`; `?attr/x` and `@android:` are left as is for later phases. */
867
+ toHarmonyRef(raw: string, androidPath: string, expect: string): string {
868
+ const m = /^@(?:([a-zA-Z0-9._]+):)?([a-z]+)\/(.+)$/.exec(raw);
869
+ if (m && m[1] !== 'android') {
870
+ const t = m[2] === 'dimen' ? 'float' : m[2] === 'bool' ? 'boolean' : m[2];
871
+ return `$${t}:${m[3]}`;
872
+ }
873
+ this.warnings.push(`${androidPath}: unresolved ${expect} value "${raw}" (left for a later phase)`);
874
+ return raw;
875
+ }
876
+
877
+ /**
878
+ * Reference resolution pass: resolves the leftover `$type:name` / `@type/name` /
879
+ * `@android:type/name` in element JSON into concrete values.
880
+ *
881
+ * Why it is required: HarmonyOS has no concept of Android system resources, so `@android:` left in the output
882
+ * fails compilation outright; the same goes for a `$color:x` pointing to a nonexistent resource.
883
+ * Unresolvable ones get a per-type fallback and are recorded: **never silently leave an unresolved reference**.
884
+ *
885
+ * Chains go at most 5 levels deep (SKILL.md Step 5.2). Across qualifiers the base value wins.
886
+ */
887
+ resolveReferences(): void {
888
+ const rawOf: Record<string, Map<string, string>> = {
889
+ color: this.rawColors, float: this.rawDimens, string: this.rawStrings,
890
+ integer: this.rawIntegers, boolean: this.rawBools,
891
+ };
892
+ const androidType: Record<string, string> = {
893
+ color: 'color', dimen: 'float', string: 'string', integer: 'integer', bool: 'boolean',
894
+ };
895
+
896
+ /** Resolves one raw Android text into a concrete value; null means it cannot be resolved. */
897
+ const resolve = (
898
+ key: string, raw: string, chain: string[], depth: number,
899
+ ): { value: unknown; kind: ResolutionRecord['kind'] } | null => {
900
+ const v = raw.trim();
901
+ if (depth >= 5) return null;
902
+
903
+ if (v.startsWith('?')) return null; // theme attribute, not statically resolvable
904
+
905
+ const sys = /^@android:([a-z]+)\/(.+)$/.exec(v);
906
+ if (sys) {
907
+ const table = sys[1] === 'color' ? ANDROID_SYSTEM_COLORS
908
+ : sys[1] === 'dimen' ? ANDROID_SYSTEM_DIMENS
909
+ : sys[1] === 'string' ? ANDROID_SYSTEM_STRINGS : null;
910
+ const hit = table?.[sys[2]];
911
+ if (hit !== undefined) {
912
+ chain.push(v);
913
+ return { value: key === 'integer' ? Number(hit) : hit, kind: 'system' };
914
+ }
915
+ return null;
916
+ }
917
+
918
+ const ref = /^@(?:[a-zA-Z0-9._]+:)?([a-z]+)\/(.+)$/.exec(v);
919
+ if (ref) {
920
+ const targetKey = androidType[ref[1]];
921
+ if (!targetKey) return null;
922
+ const next = rawOf[targetKey]?.get(ref[2]);
923
+ if (next === undefined) return null;
924
+ chain.push(v);
925
+ return resolve(key, next, chain, depth + 1);
926
+ }
927
+
928
+ // Reached a literal: do the final conversion by target type
929
+ switch (key) {
930
+ case 'color': { const c = normalizeColor(v); return c ? { value: c, kind: 'project' } : null; }
931
+ case 'float': { const d = normalizeDimen(v); return d ? { value: d, kind: 'project' } : null; }
932
+ case 'integer': { const n = normalizeInteger(v); return n === null ? null : { value: n, kind: 'project' }; }
933
+ case 'boolean': {
934
+ const t = v.toLowerCase();
935
+ return t === 'true' || t === 'false' ? { value: t === 'true', kind: 'project' } : null;
936
+ }
937
+ default: return { value: v, kind: 'project' };
938
+ }
939
+ };
940
+
941
+ /**
942
+ * Reference resolution inside array items.
943
+ *
944
+ * The scalar resolution above has no effect on strarray / intarray: its criterion is `typeof cur === 'string'`,
945
+ * while an array entry's value is `Array<{value}>`, which never enters the branch. After normalizing `<array>`, without
946
+ * this section `<item>@string/language</item>` would land verbatim as `{"value":"@string/language"}`;
947
+ * HarmonyOS strarray does not support that syntax, which is worse than dropping the entry (it compiles and renders the literal).
948
+ * Criterion and value basis are the same as resolveArrayRefs() in a2h_resource_incremental.ts.
949
+ */
950
+ const resolveArrayItems = (
951
+ qdir: string, file: string, key: 'strarray' | 'intarray', byName: Map<string, ElementEntry>,
952
+ ): void => {
953
+ const loc = `${qdir}/element/${file}`;
954
+ const scalarKey = key === 'intarray' ? 'integer' : 'string';
955
+ for (const entry of byName.values()) {
956
+ if (!Array.isArray(entry.value)) continue;
957
+ const items = entry.value as Array<{ value?: unknown }>;
958
+ entry.value = items.map((it) => {
959
+ const cur = it?.value;
960
+ if (typeof cur !== 'string') return it;
961
+ const t = cur.trim();
962
+ if (!(t.startsWith('@') || t.startsWith('$') || t.startsWith('?'))) return it;
963
+ // `$type:name` (produced by toHarmonyRef) is written back as `@type/name` and goes through the same resolution chain
964
+ const asAndroid = t.startsWith('$') ? `@${t.slice(1).replace(':', '/')}` : t;
965
+ const chain: string[] = [];
966
+ const got = resolve(scalarKey, asAndroid, chain, 0);
967
+ if (got) {
968
+ this.counts.referencesResolved++;
969
+ if (got.kind === 'system') this.counts.systemReferencesResolved++;
970
+ this.resolutions.push({
971
+ file: loc, name: `${entry.name}[]`, reference: t,
972
+ resolved: String(got.value), chain: [t, ...chain].join(' → '), kind: got.kind,
973
+ });
974
+ return { ...it, value: got.value };
975
+ }
976
+ this.counts.fallbacksApplied++;
977
+ const fb = key === 'intarray' ? 0 : '';
978
+ this.resolutions.push({
979
+ file: loc, name: `${entry.name}[]`, reference: t,
980
+ resolved: String(fb), chain: t,
981
+ kind: t.startsWith('?') ? 'theme-attr' : 'fallback',
982
+ });
983
+ this.warnings.push(`${loc}#${entry.name}[]: cannot resolve ${t}, type fallback ${JSON.stringify(fb)}`);
984
+ return { ...it, value: fb };
985
+ });
986
+ }
987
+ };
988
+
989
+ for (const [qdir, byFile] of this.elements) {
990
+ for (const [file, byName] of byFile) {
991
+ const key = Object.values(ELEMENT_KIND).find((k) => k.file === file)!.key;
992
+ if (key === 'strarray' || key === 'intarray') {
993
+ resolveArrayItems(qdir, file, key, byName);
994
+ continue;
995
+ }
996
+ if (!(key in FALLBACK_BY_KEY)) continue; // plurals still get no scalar resolution
997
+
998
+ for (const entry of byName.values()) {
999
+ const cur = entry.value;
1000
+ const unresolved = typeof cur === 'string' && (cur.startsWith('$') || cur.startsWith('@') || cur.startsWith('?'));
1001
+ if (!unresolved) continue;
1002
+
1003
+ const chain: string[] = [];
1004
+ const got = resolve(key, entry.raw, chain, 0);
1005
+ const loc = `${qdir}/element/${file}`;
1006
+
1007
+ if (got) {
1008
+ entry.value = got.value;
1009
+ this.counts.referencesResolved++;
1010
+ if (got.kind === 'system') this.counts.systemReferencesResolved++;
1011
+ this.resolutions.push({
1012
+ file: loc, name: entry.name, reference: entry.raw,
1013
+ resolved: String(got.value), chain: [entry.raw, ...chain].join(' → '), kind: got.kind,
1014
+ });
1015
+ continue;
1016
+ }
1017
+
1018
+ entry.value = FALLBACK_BY_KEY[key];
1019
+ this.counts.fallbacksApplied++;
1020
+ this.resolutions.push({
1021
+ file: loc, name: entry.name, reference: entry.raw,
1022
+ resolved: String(entry.value), chain: entry.raw,
1023
+ kind: entry.raw.trim().startsWith('?') ? 'theme-attr' : 'fallback',
1024
+ });
1025
+ this.warnings.push(
1026
+ `${loc}#${entry.name}: cannot resolve ${entry.raw}, type fallback ${JSON.stringify(entry.value)}`,
1027
+ );
1028
+ }
1029
+ }
1030
+ }
1031
+ }
1032
+
1033
+ /**
1034
+ * Writes element JSON.
1035
+ *
1036
+ * If the target file already exists in the HarmonyOS project (the DevEco scaffold generates
1037
+ * base/element/{string,color,float}.json), **merge** instead of overwrite:
1038
+ * existing entries keep their original order first, values of same-named entries are replaced by the conversion result (scaffold defaults
1039
+ * may be overwritten), and the remaining converted entries are appended sorted by name.
1040
+ * See the last item of SKILL.md "Important Notes".
1041
+ */
1042
+ flushElements(): void {
1043
+ for (const [qdir, byFile] of [...this.elements].sort()) {
1044
+ for (const [file, byName] of [...byFile].sort()) {
1045
+ const key = Object.values(ELEMENT_KIND).find((k) => k.file === file)!.key;
1046
+ const rel = path.join(qdir, 'element', file);
1047
+ const converted = new Map([...byName].map(([n, e]) => [n, e.value]));
1048
+
1049
+ const out: Array<{ name: string; value: unknown }> = [];
1050
+ const taken = new Set<string>();
1051
+ const existingPath = path.join(this.outRoot, rel);
1052
+ if (fs.existsSync(existingPath)) {
1053
+ try {
1054
+ const prev = JSON.parse(fs.readFileSync(existingPath, 'utf8')) as Record<string, Array<{ name: string; value: unknown }>>;
1055
+ for (const e of prev[key] ?? []) {
1056
+ if (!e || typeof e.name !== 'string') continue;
1057
+ taken.add(e.name);
1058
+ const replaced = converted.has(e.name);
1059
+ const next = replaced ? converted.get(e.name) : e.value;
1060
+ out.push({ name: e.name, value: next });
1061
+ // Warn only when **the value actually changed**: rerunning the same conversion should not spew tens of thousands of noise lines,
1062
+ // while a scaffold default being replaced by a real resource is worth noting.
1063
+ if (replaced && JSON.stringify(next) !== JSON.stringify(e.value)) {
1064
+ this.warnings.push(`${rel}#${e.name}: overwrites an existing entry in the HarmonyOS project (old value ${JSON.stringify(e.value)})`);
1065
+ }
1066
+ }
1067
+ } catch (err) {
1068
+ this.warnings.push(`${rel}: existing file unparseable, treated as new (${(err as Error).message})`);
1069
+ }
1070
+ }
1071
+
1072
+ for (const [name, value] of [...converted].sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))) {
1073
+ if (!taken.has(name)) out.push({ name, value });
1074
+ }
1075
+
1076
+ if (out.length === 0) continue; // empty files are not produced
1077
+ this.write(rel, `${JSON.stringify({ [key]: out }, null, 2)}\n`);
1078
+ }
1079
+ }
1080
+ }
1081
+
1082
+ // ── In-place reference resolution (for SVG / layered-image) ──
1083
+
1084
+ /** `@color/x` → `#AARRGGBB`, following the reference chain at most 5 levels. `@android:color/*` is left to the system table (phase 3). */
1085
+ resolveColor(raw: string, depth = 0): string | null {
1086
+ const v = raw.trim();
1087
+ if (!v) return null;
1088
+ const direct = normalizeColor(v);
1089
+ if (direct) return direct;
1090
+ if (depth >= 5) return null;
1091
+ const m = /^@(?:([a-zA-Z0-9._]+):)?color\/(.+)$/.exec(v);
1092
+ if (!m) return null;
1093
+ if (m[1] === 'android') {
1094
+ const sys = ANDROID_SYSTEM_COLORS[m[2]];
1095
+ if (sys) { this.counts.systemColorsResolved++; return sys; }
1096
+ this.warnings.push(`unknown Android system color @android:color/${m[2]}, falling back to #ff000000`);
1097
+ return '#ff000000';
1098
+ }
1099
+ const next = this.rawColors.get(m[2]);
1100
+ if (next !== undefined) return this.resolveColor(next, depth + 1);
1101
+ return null;
1102
+ }
1103
+
1104
+ /**
1105
+ * `android:pathData` can be a `@string/xxx` reference, which is common in decoded APKs
1106
+ * (AppCompat's password visibility animation does exactly that). It must be resolved to the real pathData:
1107
+ * writing `@string/...` verbatim into the SVG `d` produces a file that cannot render, and an existence check
1108
+ * that only counts clipPaths cannot catch it.
1109
+ */
1110
+ resolvePathData(raw: string | undefined, where: string): string | null {
1111
+ if (!raw) return null;
1112
+ const v = raw.trim();
1113
+ const m = /^@(?:([a-zA-Z0-9._]+):)?string\/(.+)$/.exec(v);
1114
+ if (!m) return v;
1115
+ const s = m[1] === 'android' ? undefined : this.rawStrings.get(m[2]);
1116
+ if (s === undefined) {
1117
+ this.warnings.push(`${where}: pathData reference ${v} cannot be resolved, path skipped (no invalid d written)`);
1118
+ return null;
1119
+ }
1120
+ return s;
1121
+ }
1122
+
1123
+ /**
1124
+ * `fillColor="@drawable/$icon__0"`: aapt extracted the `<gradient>` inlined in the vector into a separate
1125
+ * drawable resource, which lands in `res/drawable/_icon__0.xml` after decoding (`$` written as `_`).
1126
+ * Without following it, these paths can only fall back to `#000000`: the gradient is painted as a solid black block,
1127
+ * and the fidelity checker's GRADIENT_LOST rule only looks at inline `<gradient>`, so it cannot catch it either.
1128
+ */
1129
+ loadReferencedGradient(ref: string | undefined): XmlNode | null {
1130
+ if (!ref) return null;
1131
+ const m = /^@(?:[a-zA-Z0-9._]+:)?drawable\/(.+)$/.exec(ref.trim());
1132
+ if (!m) return null;
1133
+ // The extracted gradient sometimes exists only in directories like `drawable-v31/`.
1134
+ return this.findResXml('drawable', m[1], 'gradient') ?? this.findResXml('drawable', m[1].replace(/\$/g, '_'), 'gradient');
1135
+ }
1136
+
1137
+ /** `type` itself and all its qualifier directories (`drawable`, `drawable-v24`…), the unqualified directory first. */
1138
+ resTypeDirs(type: string): string[] {
1139
+ return fs.readdirSync(this.resDir)
1140
+ .filter((d) => d === type || d.startsWith(`${type}-`))
1141
+ .sort((a, b) => (a === type ? -1 : b === type ? 1 : a.localeCompare(b)));
1142
+ }
1143
+
1144
+ /**
1145
+ * Finds `<resName>.xml` whose root element is `rootName` in the qualifier directories of `type`.
1146
+ * When a same-named file in one directory has a different root element (e.g. `<inset>` in `mipmap-anydpi-v26`) keep looking in the next directory
1147
+ * instead of giving up: the one we want may be in another qualifier directory.
1148
+ */
1149
+ findResXml(type: string, resName: string, rootName: string): XmlNode | null {
1150
+ for (const d of this.resTypeDirs(type)) {
1151
+ const p = path.join(this.resDir, d, `${resName}.xml`);
1152
+ if (!fs.existsSync(p)) continue;
1153
+ try {
1154
+ const root = parseXml(fs.readFileSync(p, 'utf8'));
1155
+ if (root.name === rootName) return root;
1156
+ } catch {
1157
+ // Skip copies that fail to parse and keep looking
1158
+ }
1159
+ }
1160
+ return null;
1161
+ }
1162
+
1163
+ /** Every copy of `<resName>.<bitmap extension>` in the qualifier directories of `type`: its directory + pixel size (copies whose size cannot be read are skipped). */
1164
+ findBitmapVariants(type: string, resName: string): Array<{ dir: string; w: number; h: number }> {
1165
+ const out: Array<{ dir: string; w: number; h: number }> = [];
1166
+ for (const d of this.resTypeDirs(type)) {
1167
+ for (const ext of ['.png', '.webp', '.jpg', '.jpeg', '.gif']) {
1168
+ const p = path.join(this.resDir, d, `${resName}${ext}`);
1169
+ if (!fs.existsSync(p)) continue;
1170
+ const size = imageSize(fs.readFileSync(p));
1171
+ if (size) out.push({ dir: d, ...size });
1172
+ break;
1173
+ }
1174
+ }
1175
+ return out;
1176
+ }
1177
+
1178
+ resolveDimen(raw: string, depth = 0): string | null {
1179
+ const v = raw.trim();
1180
+ if (!v) return null;
1181
+ if (/^-?[\d.]/.test(v)) return v;
1182
+ if (depth >= 5) return null;
1183
+ const m = /^@(?:([a-zA-Z0-9._]+):)?dimen\/(.+)$/.exec(v);
1184
+ if (m && m[1] !== 'android') {
1185
+ const next = this.rawDimens.get(m[2]);
1186
+ if (next !== undefined) return this.resolveDimen(next, depth + 1);
1187
+ }
1188
+ return null;
1189
+ }
1190
+
1191
+ /** Converts an Android color attribute into an SVG paint attribute string. Returns null when it cannot be resolved. */
1192
+ paintAttrs(rawColor: string | undefined, kind: 'fill' | 'stroke', alphaAttr?: string): string | null {
1193
+ if (rawColor === undefined) return null;
1194
+ const resolved = this.resolveColor(rawColor);
1195
+ if (!resolved) return null;
1196
+ const p = androidColorToSvg(resolved)!;
1197
+ let s = ` ${kind}="${p.color}"`;
1198
+ const explicit = alphaAttr !== undefined ? parseFloat(alphaAttr) : NaN;
1199
+ const alpha = Number.isFinite(explicit)
1200
+ ? (p.opacity ?? 1) * explicit
1201
+ : p.opacity;
1202
+ if (alpha !== null && alpha < 0.999) s += ` ${kind}-opacity="${Math.round(alpha * 1000) / 1000}"`;
1203
+ return s;
1204
+ }
1205
+
1206
+ // ── XML drawable → SVG ──
1207
+
1208
+ /**
1209
+ * `<vector>` → SVG.
1210
+ *
1211
+ * Three error-prone rules that svg_fidelity_check.ts flags as errors are enforced here:
1212
+ * 1. fill three branches: use fillColor when present; without fillColor but with strokeColor, fill="none" must be explicit;
1213
+ * only when both are absent use the platform default black.
1214
+ * 2. clip-path is geometry, not decoration; it must be kept, and every path inside the clipped group must reference it.
1215
+ * 3. A gradient in `<aapt:attr name="android:fillColor">` is treated the same as the attribute form,
1216
+ * otherwise it falls back to the black default branch and the whole area turns solid black.
1217
+ */
1218
+ /**
1219
+ * `adaptiveSafeZone`: for adaptive icon layers. Android layers are 108dp and the launcher shows only the middle 72dp
1220
+ * (1/6 cropped on each side, visible content scaled up 1.5x); HarmonyOS layered-image does no such cropping and shows the whole layer,
1221
+ * so copying the `0 0 vw vh` viewBox shrinks the logo and exposes the background color around it. Shrinking the viewBox to the middle 2/3
1222
+ * makes the visible content match Android after masking.
1223
+ */
1224
+ vectorToSvg(
1225
+ root: XmlNode, name: string,
1226
+ opts: { adaptiveSafeZone?: boolean; size?: { w: number; h: number } } = {},
1227
+ ): string {
1228
+ const adaptiveSafeZone = opts.adaptiveSafeZone ?? false;
1229
+ const vw = svgNum(attr(root, 'viewportWidth'), 24);
1230
+ const vh = svgNum(attr(root, 'viewportHeight'), 24);
1231
+ // `size`: when paired with a bitmap layer in an adaptive icon, align the vector layer's intrinsic size to the bitmap's pixel size
1232
+ const w = opts.size?.w ?? svgNum(attr(root, 'width'), vw);
1233
+ const h = opts.size?.h ?? svgNum(attr(root, 'height'), vh);
1234
+ const alpha = attr(root, 'alpha');
1235
+
1236
+ const defs: string[] = [];
1237
+ const body: string[] = [];
1238
+ let clipSeq = 0;
1239
+ let gradSeq = 0;
1240
+
1241
+ const emitGradient = (g: XmlNode): string | null => {
1242
+ const id = `${name}_grad_${++gradSeq}`;
1243
+ const type = attr(g, 'type') ?? 'linear';
1244
+ const stops: string[] = [];
1245
+ const items = g.children.filter((c) => c.name === 'item');
1246
+ if (items.length > 0) {
1247
+ for (const it of items) {
1248
+ const col = this.resolveColor(attr(it, 'color') ?? '');
1249
+ if (!col) continue;
1250
+ const p = androidColorToSvg(col)!;
1251
+ const off = svgNum(attr(it, 'offset'), 0) * 100;
1252
+ stops.push(`<stop offset="${off}%" stop-color="${p.color}"${p.opacity !== null ? ` stop-opacity="${p.opacity}"` : ''}/>`);
1253
+ }
1254
+ } else {
1255
+ const seq: Array<[string | undefined, number]> = [
1256
+ [attr(g, 'startColor'), 0], [attr(g, 'centerColor'), 50], [attr(g, 'endColor'), 100],
1257
+ ];
1258
+ for (const [c, off] of seq) {
1259
+ if (c === undefined) continue;
1260
+ const col = this.resolveColor(c);
1261
+ if (!col) continue;
1262
+ const p = androidColorToSvg(col)!;
1263
+ stops.push(`<stop offset="${off}%" stop-color="${p.color}"${p.opacity !== null ? ` stop-opacity="${p.opacity}"` : ''}/>`);
1264
+ }
1265
+ }
1266
+ if (stops.length === 0) return null;
1267
+
1268
+ if (type === 'radial') {
1269
+ const cx = svgNum(attr(g, 'centerX'), 0.5) * 100;
1270
+ const cy = svgNum(attr(g, 'centerY'), 0.5) * 100;
1271
+ defs.push(`<radialGradient id="${id}" cx="${cx}%" cy="${cy}%" r="50%">${stops.join('')}</radialGradient>`);
1272
+ } else {
1273
+ // sweep has no native SVG 1.1 equivalent; approximated as linear with a warning
1274
+ if (type === 'sweep') {
1275
+ this.warnings.push(`${name}: sweep gradient has no SVG 1.1 equivalent, approximated with linearGradient`);
1276
+ }
1277
+ const ang = svgNum(attr(g, 'angle'), 0);
1278
+ const rad = (ang * Math.PI) / 180;
1279
+ const x1 = Math.round(50 + 50 * Math.cos(rad + Math.PI));
1280
+ const y1 = Math.round(50 - 50 * Math.sin(rad + Math.PI));
1281
+ const x2 = Math.round(50 + 50 * Math.cos(rad));
1282
+ const y2 = Math.round(50 - 50 * Math.sin(rad));
1283
+ defs.push(`<linearGradient id="${id}" x1="${x1}%" y1="${y1}%" x2="${x2}%" y2="${y2}%">${stops.join('')}</linearGradient>`);
1284
+ }
1285
+ return id;
1286
+ };
1287
+
1288
+ const emitPath = (p: XmlNode, clipRef: string | null, indent: string): void => {
1289
+ const d = this.resolvePathData(attr(p, 'pathData'), name);
1290
+ if (!d) return;
1291
+ let a = '';
1292
+
1293
+ // Gradient wins over the attribute color: aapt:attr is the child-element form of fillColor
1294
+ let gradId: string | null = null;
1295
+ for (const child of p.children) {
1296
+ if (child.name !== 'aapt:attr' && !child.name.endsWith(':attr')) continue;
1297
+ if ((attr(child, 'name') ?? '').endsWith('fillColor')) {
1298
+ const g = child.children.find((c) => c.name === 'gradient');
1299
+ if (g) gradId = emitGradient(g);
1300
+ }
1301
+ }
1302
+ // In a compiled APK the same inline gradient was extracted by aapt into a separate drawable,
1303
+ // leaving only a reference like `@drawable/$icon__0` in the attribute. Without following it, it falls back to black.
1304
+ if (!gradId) {
1305
+ const g = this.loadReferencedGradient(attr(p, 'fillColor'));
1306
+ if (g) gradId = emitGradient(g);
1307
+ }
1308
+
1309
+ const fillColor = attr(p, 'fillColor');
1310
+ const strokeColor = attr(p, 'strokeColor');
1311
+ if (gradId) {
1312
+ a += ` fill="url(#${gradId})"`;
1313
+ } else {
1314
+ const fill = this.paintAttrs(fillColor, 'fill', attr(p, 'fillAlpha'));
1315
+ if (fill) a += fill;
1316
+ else if (fillColor !== undefined) {
1317
+ // A fillColor attribute exists but cannot be resolved (mostly trimmed library resources). Use the default per the rules,
1318
+ // but it must be recorded, otherwise it renders black and nobody knows why.
1319
+ this.warnings.push(`${name}: fillColor ${fillColor} cannot be resolved, falling back to #000000`);
1320
+ this.counts.unresolvedPaint++;
1321
+ a += ' fill="#000000"';
1322
+ }
1323
+ else if (strokeColor !== undefined) a += ' fill="none"'; // stroke-only path: none must be explicit
1324
+ else a += ' fill="#000000"'; // both absent: platform default
1325
+ }
1326
+
1327
+ const stroke = this.paintAttrs(strokeColor, 'stroke', attr(p, 'strokeAlpha'));
1328
+ if (stroke) {
1329
+ a += stroke;
1330
+ const sw = attr(p, 'strokeWidth');
1331
+ if (sw) a += ` stroke-width="${svgNum(sw, 1)}"`;
1332
+ // In a decoded APK these enums are numbers; writing them directly yields an invalid stroke-linecap="2"
1333
+ const cap = attr(p, 'strokeLineCap');
1334
+ if (cap) a += ` stroke-linecap="${/^\d+$/.test(cap) ? STROKE_LINECAP[+cap] ?? 'butt' : cap}"`;
1335
+ const join = attr(p, 'strokeLineJoin');
1336
+ if (join) a += ` stroke-linejoin="${/^\d+$/.test(join) ? STROKE_LINEJOIN[+join] ?? 'miter' : join}"`;
1337
+ const miter = attr(p, 'strokeMiterLimit');
1338
+ if (miter) a += ` stroke-miterlimit="${svgNum(miter, 4)}"`;
1339
+ }
1340
+
1341
+ const ft = attr(p, 'fillType');
1342
+ if (ft !== undefined && (ft.toLowerCase() === 'evenodd' || ft === '1')) a += ' fill-rule="evenodd"';
1343
+
1344
+ // trimPath* has no static SVG equivalent; trimPathEnd=0 means this stroke is trimmed away entirely (invisible)
1345
+ const trimEnd = attr(p, 'trimPathEnd');
1346
+ if (trimEnd !== undefined && parseFloat(trimEnd) === 0) {
1347
+ this.warnings.push(`${name}: path trimPathEnd=0 (initially invisible on Android) has no SVG equivalent, emitted as visible`);
1348
+ }
1349
+ if (clipRef) a += ` clip-path="url(#${clipRef})"`;
1350
+ body.push(`${indent}<path d="${esc(d)}"${a}/>`);
1351
+ };
1352
+
1353
+ const walk = (node: XmlNode, inheritedClip: string | null, indent: string): void => {
1354
+ // Register this level's clip-path first, for paths in this level and child levels to reference
1355
+ let clipRef = inheritedClip;
1356
+ for (const c of node.children) {
1357
+ if (c.name !== 'clip-path') continue;
1358
+ const d = this.resolvePathData(attr(c, 'pathData'), name);
1359
+ if (!d) continue;
1360
+ const id = attr(c, 'name') ? `${name}_${attr(c, 'name')}` : `${name}_clip_${++clipSeq}`;
1361
+ defs.push(`<clipPath id="${id}"><path d="${esc(d)}"/></clipPath>`);
1362
+ clipRef = id;
1363
+ }
1364
+
1365
+ for (const c of node.children) {
1366
+ if (c.name === 'path') emitPath(c, clipRef, indent);
1367
+ else if (c.name === 'group') {
1368
+ const tx = svgNum(attr(c, 'translateX'), 0);
1369
+ const ty = svgNum(attr(c, 'translateY'), 0);
1370
+ const sx = svgNum(attr(c, 'scaleX'), 1);
1371
+ const sy = svgNum(attr(c, 'scaleY'), 1);
1372
+ const rot = svgNum(attr(c, 'rotation'), 0);
1373
+ const px = svgNum(attr(c, 'pivotX'), 0);
1374
+ const py = svgNum(attr(c, 'pivotY'), 0);
1375
+ const parts: string[] = [];
1376
+ if (tx !== 0 || ty !== 0) parts.push(`translate(${tx},${ty})`);
1377
+ if (sx !== 1 || sy !== 1) parts.push(`scale(${sx},${sy})`);
1378
+ if (rot !== 0) parts.push(`rotate(${rot},${px},${py})`);
1379
+ const t = parts.length > 0 ? ` transform="${parts.join(' ')}"` : '';
1380
+ body.push(`${indent}<g${t}>`);
1381
+ walk(c, clipRef, `${indent} `);
1382
+ body.push(`${indent}</g>`);
1383
+ }
1384
+ }
1385
+ };
1386
+
1387
+ walk(root, null, ' ');
1388
+
1389
+ const tint = attr(root, 'tint');
1390
+ if (tint) this.warnings.push(`${name}: android:tint has no direct SVG equivalent, ignored (tint with fillColor on the ArkUI side)`);
1391
+
1392
+ const op = alpha && parseFloat(alpha) < 0.999 ? ` opacity="${parseFloat(alpha)}"` : '';
1393
+ const defsBlock = defs.length > 0 ? ` <defs>${defs.join('')}</defs>\n` : '';
1394
+ const r3 = (v: number): number => Math.round(v * 1000) / 1000;
1395
+ const viewBox = adaptiveSafeZone
1396
+ ? `${r3(vw / 6)} ${r3(vh / 6)} ${r3((vw * 2) / 3)} ${r3((vh * 2) / 3)}`
1397
+ : `0 0 ${vw} ${vh}`;
1398
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="${viewBox}"${op}>\n${defsBlock}${body.join('\n')}\n</svg>\n`;
1399
+ }
1400
+
1401
+ /** `<shape>` → SVG. Rectangle / oval / line / ring. */
1402
+ shapeToSvg(root: XmlNode, name: string): string {
1403
+ const shape = (attr(root, 'shape') ?? 'rectangle').toLowerCase();
1404
+ const size = root.children.find((c) => c.name === 'size');
1405
+ const w = svgNum(size ? attr(size, 'width') : undefined, 24);
1406
+ const h = svgNum(size ? attr(size, 'height') : undefined, 24);
1407
+ if (!size) this.warnings.push(`${name}: <shape> has no <size>, emitted on the default 24x24 canvas`);
1408
+
1409
+ const solid = root.children.find((c) => c.name === 'solid');
1410
+ const strokeEl = root.children.find((c) => c.name === 'stroke');
1411
+ const corners = root.children.find((c) => c.name === 'corners');
1412
+ const gradEl = root.children.find((c) => c.name === 'gradient');
1413
+
1414
+ const defs: string[] = [];
1415
+ let fillAttr = ' fill="none"';
1416
+ if (gradEl) {
1417
+ const id = `${name}_grad`;
1418
+ const stops: string[] = [];
1419
+ for (const [c, off] of [[attr(gradEl, 'startColor'), 0], [attr(gradEl, 'centerColor'), 50], [attr(gradEl, 'endColor'), 100]] as Array<[string | undefined, number]>) {
1420
+ if (c === undefined) continue;
1421
+ const col = this.resolveColor(c);
1422
+ if (!col) continue;
1423
+ const p = androidColorToSvg(col)!;
1424
+ stops.push(`<stop offset="${off}%" stop-color="${p.color}"${p.opacity !== null ? ` stop-opacity="${p.opacity}"` : ''}/>`);
1425
+ }
1426
+ if (stops.length > 0) {
1427
+ const ang = svgNum(attr(gradEl, 'angle'), 0);
1428
+ const rad = (ang * Math.PI) / 180;
1429
+ defs.push(`<linearGradient id="${id}" x1="${Math.round(50 + 50 * Math.cos(rad + Math.PI))}%" y1="${Math.round(50 - 50 * Math.sin(rad + Math.PI))}%" x2="${Math.round(50 + 50 * Math.cos(rad))}%" y2="${Math.round(50 - 50 * Math.sin(rad))}%">${stops.join('')}</linearGradient>`);
1430
+ fillAttr = ` fill="url(#${id})"`;
1431
+ }
1432
+ } else if (solid) {
1433
+ fillAttr = this.paintAttrs(attr(solid, 'color'), 'fill') ?? ' fill="none"';
1434
+ }
1435
+
1436
+ let strokeAttr = '';
1437
+ let strokeW = 0;
1438
+ if (strokeEl) {
1439
+ const s = this.paintAttrs(attr(strokeEl, 'color'), 'stroke');
1440
+ if (s) {
1441
+ strokeW = svgNum(attr(strokeEl, 'width'), 1);
1442
+ strokeAttr = `${s} stroke-width="${strokeW}"`;
1443
+ const dw = attr(strokeEl, 'dashWidth');
1444
+ const dg = attr(strokeEl, 'dashGap');
1445
+ if (dw && dg) strokeAttr += ` stroke-dasharray="${svgNum(dw, 0)},${svgNum(dg, 0)}"`;
1446
+ }
1447
+ }
1448
+
1449
+ let el: string;
1450
+ if (shape === 'oval') {
1451
+ el = w === h
1452
+ ? `<circle cx="${w / 2}" cy="${h / 2}" r="${w / 2}"${fillAttr}${strokeAttr}/>`
1453
+ : `<ellipse cx="${w / 2}" cy="${h / 2}" rx="${w / 2}" ry="${h / 2}"${fillAttr}${strokeAttr}/>`;
1454
+ } else if (shape === 'line') {
1455
+ el = `<line x1="0" y1="${h / 2}" x2="${w}" y2="${h / 2}"${strokeAttr || ' stroke="#000000" stroke-width="1"'}/>`;
1456
+ } else if (shape === 'ring') {
1457
+ const innerR = attr(root, 'innerRadius')
1458
+ ? svgNum(attr(root, 'innerRadius'), 0)
1459
+ : w / (2 * svgNum(attr(root, 'innerRadiusRatio'), 3));
1460
+ const thickness = attr(root, 'thickness')
1461
+ ? svgNum(attr(root, 'thickness'), 0)
1462
+ : w / (2 * svgNum(attr(root, 'thicknessRatio'), 9));
1463
+ const ringPaint = solid ? (this.paintAttrs(attr(solid, 'color'), 'stroke') ?? ' stroke="#000000"') : ' stroke="#000000"';
1464
+ el = `<circle cx="${w / 2}" cy="${h / 2}" r="${innerR + thickness / 2}" fill="none"${ringPaint} stroke-width="${thickness}"/>`;
1465
+ } else {
1466
+ const r = corners ? svgNum(attr(corners, 'radius'), 0) : 0;
1467
+ const rr = r > 0 ? ` rx="${r}" ry="${r}"` : '';
1468
+ const inset = strokeW / 2;
1469
+ el = `<rect x="${inset}" y="${inset}" width="${w - strokeW}" height="${h - strokeW}"${rr}${fillAttr}${strokeAttr}/>`;
1470
+ }
1471
+
1472
+ const defsBlock = defs.length > 0 ? ` <defs>${defs.join('')}</defs>\n` : '';
1473
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">\n${defsBlock} ${el}\n</svg>\n`;
1474
+ }
1475
+
1476
+ /**
1477
+ * `<layer-list>` → a single SVG; `<item>`s are stacked bottom-up in document order, and insets become coordinate offsets.
1478
+ *
1479
+ * The canvas size must be derived from the content, never hard-coded: a layer-list often embeds a `<vector>` with a
1480
+ * viewport, and hard-coding 100x100 scales the whole icon relative to the source asset (the fidelity check reports
1481
+ * VIEWBOX_MISMATCH). Take the largest intrinsic size among all inner elements; fall back to 100x100 only when none has one.
1482
+ */
1483
+ layerListToSvg(root: XmlNode, name: string): string {
1484
+ const items = root.children.filter((c) => c.name === 'item');
1485
+
1486
+ let W = 0;
1487
+ let H = 0;
1488
+ for (const item of items) {
1489
+ for (const inner of item.children) {
1490
+ if (inner.name === 'vector') {
1491
+ W = Math.max(W, svgNum(attr(inner, 'viewportWidth'), 0));
1492
+ H = Math.max(H, svgNum(attr(inner, 'viewportHeight'), 0));
1493
+ } else if (inner.name === 'shape') {
1494
+ const size = inner.children.find((c) => c.name === 'size');
1495
+ if (size) {
1496
+ W = Math.max(W, svgNum(attr(size, 'width'), 0));
1497
+ H = Math.max(H, svgNum(attr(size, 'height'), 0));
1498
+ }
1499
+ }
1500
+ }
1501
+ }
1502
+ const derived = W > 0 && H > 0;
1503
+ if (!derived) {
1504
+ W = 100; H = 100;
1505
+ this.warnings.push(`${name}: layer-list inner layers have no intrinsic size, emitted on the default 100x100 canvas`);
1506
+ }
1507
+
1508
+ const layers: string[] = [];
1509
+ for (const item of items) {
1510
+ const l = svgNum(attr(item, 'left'), 0);
1511
+ const t = svgNum(attr(item, 'top'), 0);
1512
+ const r = svgNum(attr(item, 'right'), 0);
1513
+ const b = svgNum(attr(item, 'bottom'), 0);
1514
+
1515
+ // `<color>` item: a solid background block, filling the whole canvas
1516
+ const colorEl = item.children.find((c) => c.name === 'color');
1517
+ if (colorEl) {
1518
+ const paint = this.paintAttrs(attr(colorEl, 'color'), 'fill');
1519
+ if (paint) layers.push(` <rect x="0" y="0" width="${W}" height="${H}"${paint}/>`);
1520
+ else this.warnings.push(`${name}: layer-list <color> item color ${attr(colorEl, 'color')} cannot be resolved, layer skipped`);
1521
+ continue;
1522
+ }
1523
+
1524
+ const inner = item.children.find((c) => c.name === 'shape' || c.name === 'vector');
1525
+ if (!inner) {
1526
+ const ref = attr(item, 'drawable');
1527
+ this.warnings.push(`${name}: layer-list item references ${ref ?? '(unknown)'}, not inlined`);
1528
+ continue;
1529
+ }
1530
+ const sub = inner.name === 'shape'
1531
+ ? this.shapeToSvg(inner, `${name}_layer${layers.length}`)
1532
+ : this.vectorToSvg(inner, `${name}_layer${layers.length}`);
1533
+ const innerBody = sub.replace(/^<svg[^>]*>\n?/, '').replace(/<\/svg>\n?$/, '').trim();
1534
+
1535
+ // The inner element's own coordinate system size, used to turn insets into a scale
1536
+ const iw = inner.name === 'vector' ? svgNum(attr(inner, 'viewportWidth'), W) : W;
1537
+ const ih = inner.name === 'vector' ? svgNum(attr(inner, 'viewportHeight'), H) : H;
1538
+ const sw = W - l - r;
1539
+ const sh = H - t - b;
1540
+ const parts: string[] = [];
1541
+ if (l !== 0 || t !== 0) parts.push(`translate(${l},${t})`);
1542
+ if (sw !== iw || sh !== ih) {
1543
+ parts.push(`scale(${Math.round((sw / iw) * 10000) / 10000},${Math.round((sh / ih) * 10000) / 10000})`);
1544
+ }
1545
+ layers.push(parts.length > 0
1546
+ ? ` <g transform="${parts.join(' ')}">\n ${innerBody}\n </g>`
1547
+ : ` ${innerBody}`);
1548
+ }
1549
+
1550
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">\n${layers.join('\n')}\n</svg>\n`;
1551
+ }
1552
+
1553
+ /** `<selector>` → default-state SVG. Default state = the item without state_* attributes, otherwise the last item. */
1554
+ selectorDefault(root: XmlNode): XmlNode | null {
1555
+ const items = root.children.filter((c) => c.name === 'item');
1556
+ if (items.length === 0) return null;
1557
+ const noState = items.find((it) => !Object.keys(it.attrs).some((k) => k.includes('state_')));
1558
+ return noState ?? items[items.length - 1];
1559
+ }
1560
+
1561
+ /** Dispatch: reads the root element to decide how to convert. Returns null when unmappable. */
1562
+ xmlDrawableToSvg(root: XmlNode, name: string): { svg: string; kind: string; notes: string } | null {
1563
+ switch (root.name) {
1564
+ case 'vector':
1565
+ return { svg: this.vectorToSvg(root, name), kind: 'svg conversion', notes: '' };
1566
+ case 'shape':
1567
+ return { svg: this.shapeToSvg(root, name), kind: 'svg conversion', notes: '' };
1568
+ case 'layer-list':
1569
+ return { svg: this.layerListToSvg(root, name), kind: 'svg conversion', notes: 'layer-list flattened into stacked SVG groups' };
1570
+ case 'selector': {
1571
+ const def = this.selectorDefault(root);
1572
+ if (!def) return null;
1573
+ const states = root.children
1574
+ .filter((c) => c.name === 'item')
1575
+ .flatMap((it) => Object.keys(it.attrs).filter((k) => k.includes('state_')).map((k) => k.split(':').pop()!));
1576
+ const notes = `state variants dropped (${[...new Set(states)].join(', ') || 'none'}); implement state handling in ArkUI component code`;
1577
+ const inner = def.children.find((c) => c.name === 'shape' || c.name === 'vector');
1578
+ if (inner) {
1579
+ const out = this.xmlDrawableToSvg(inner, name);
1580
+ return out ? { ...out, notes } : null;
1581
+ }
1582
+ const ref = attr(def, 'drawable');
1583
+ this.warnings.push(`${name}: selector default item references ${ref ?? '(unknown)'}, not inlined`);
1584
+ return null;
1585
+ }
1586
+ case 'inset': {
1587
+ const inner = root.children.find((c) => c.name === 'shape' || c.name === 'vector' || c.name === 'selector');
1588
+ if (!inner) return null;
1589
+ const out = this.xmlDrawableToSvg(inner, name);
1590
+ return out ? { ...out, notes: 'inset wrapper flattened; inner drawable converted' } : null;
1591
+ }
1592
+ default:
1593
+ return null;
1594
+ }
1595
+ }
1596
+
1597
+ /**
1598
+ * What one adaptive icon layer is classified as (classify both layers first, then decide cropping and solid layer size; the two depend on each other).
1599
+ * - vector: drawable/mipmap reference, inline `<vector>`, `<bitmap src=@drawable/vector>` wrapper
1600
+ * - bitmap: references a bitmap (with the pixel sizes of each density copy, taking the largest)
1601
+ * - solid: `@color/` or a literal color
1602
+ * - inline: another inline drawable (shape / layer-list…), extracted into a separate SVG by the original logic
1603
+ * - ref: references a non-vector XML drawable or a missing file, kept as a verbatim `$media:` reference
1604
+ */
1605
+ classifyAdaptiveLayer(el: XmlNode): AdaptiveLayer {
1606
+ const ref = attr(el, 'drawable') ?? attr(el, 'color');
1607
+ if (!ref) {
1608
+ const child = el.children.find((c) => c.name);
1609
+ if (!child) return { kind: 'missing' };
1610
+ if (child.name === 'vector') return { kind: 'vector', vec: child, source: 'inline <vector>' };
1611
+ if (child.name === 'bitmap') {
1612
+ const src = attr(child, 'src');
1613
+ const m = src ? /^@(?:[a-zA-Z0-9._]+:)?(drawable|mipmap)\/(.+)$/.exec(src) : null;
1614
+ if (m) return this.classifyMediaRef(m[1], m[2]);
1615
+ }
1616
+ return { kind: 'inline', child };
1617
+ }
1618
+ const media = /^@(?:[a-zA-Z0-9._]+:)?(drawable|mipmap)\/(.+)$/.exec(ref);
1619
+ if (media) return this.classifyMediaRef(media[1], media[2]);
1620
+ const colorRef = /^@(?:[a-zA-Z0-9._]+:)?color\/(.+)$/.exec(ref);
1621
+ const literal = normalizeColor(ref);
1622
+ if (colorRef || literal) {
1623
+ return { kind: 'solid', ref, colorName: colorRef ? colorRef[1] : null, hex: literal ?? this.resolveColor(ref) };
1624
+ }
1625
+ return { kind: 'unknown', ref };
1626
+ }
1627
+
1628
+ /** `@drawable/x` / `@mipmap/x` are looked up only in **their own** type directory (a same-named mipmap cannot stand in for a drawable). */
1629
+ classifyMediaRef(type: string, resName: string): AdaptiveLayer {
1630
+ const vec = this.findResXml(type, resName, 'vector');
1631
+ if (vec) return { kind: 'vector', vec, source: `@${type}/${resName}`, resName };
1632
+ const variants = this.findBitmapVariants(type, resName);
1633
+ if (variants.length > 0) {
1634
+ const best = variants.reduce((a, b) => (b.w * b.h > a.w * a.h ? b : a));
1635
+ return { kind: 'bitmap', resName, w: best.w, h: best.h };
1636
+ }
1637
+ return { kind: 'ref', resName };
1638
+ }
1639
+
1640
+ /** `<adaptive-icon>` → layered-image JSON (+ solid layers when needed, safe-zone cropped copies of vector layers). */
1641
+ adaptiveIcon(root: XmlNode, name: string, qdir: string, androidPath: string): void {
1642
+ const out: Record<string, string> = {};
1643
+ const sourceCategory = this.sourceCategory(name);
1644
+ const extraTargets: Array<{ target: string; kind: string; notes: string }> = [];
1645
+
1646
+ const layers = (['background', 'foreground'] as const)
1647
+ .map((layer) => {
1648
+ const el = root.children.find((c) => c.name === layer);
1649
+ return el ? { layer, el, cls: this.classifyAdaptiveLayer(el) } : null;
1650
+ })
1651
+ .filter((x): x is { layer: 'background' | 'foreground'; el: XmlNode; cls: AdaptiveLayer } => x !== null);
1652
+
1653
+ // The HarmonyOS launcher composes layers at **their own size**, without stretching and without Android's 72/108 safe-zone cropping
1654
+ // (reproduced on device with WeatherApp 2026-10-22: a 108px solid PNG with a 1024 vector foreground → a small triangle in the top-left corner).
1655
+ // So all layers must share the same size and aspect ratio:
1656
+ // - With a bitmap layer, its pixel size rules; vector and solid layers are aligned to it. The bitmap's viewBox cannot be changed,
1657
+ // so it shows whole (HarmonyOS does not crop), and the vector layer is **not cropped** either, otherwise the two layers' relative scale deviates from Android.
1658
+ // - With only vector + solid, the vector layer is cropped to the middle 2/3 and the solid layer takes the first vector layer's size.
1659
+ // - When both layers are solid (or nothing to refer to), the solid layer takes 1024 (the DevEco template layer size).
1660
+ const bitmap = layers.find((l) => l.cls.kind === 'bitmap')?.cls as Extract<AdaptiveLayer, { kind: 'bitmap' }> | undefined;
1661
+ const firstVec = layers.find((l) => l.cls.kind === 'vector')?.cls as Extract<AdaptiveLayer, { kind: 'vector' }> | undefined;
1662
+ const crop = !bitmap;
1663
+ const target: { w: number; h: number } | null = bitmap
1664
+ ? { w: bitmap.w, h: bitmap.h }
1665
+ : firstVec
1666
+ ? {
1667
+ w: svgNum(attr(firstVec.vec, 'width'), svgNum(attr(firstVec.vec, 'viewportWidth'), 108)),
1668
+ h: svgNum(attr(firstVec.vec, 'height'), svgNum(attr(firstVec.vec, 'viewportHeight'), 108)),
1669
+ }
1670
+ : null;
1671
+ const solidFormat: 'svg' | 'png' = bitmap || !firstVec ? 'png' : 'svg';
1672
+ const solidSize = target ?? { w: 1024, h: 1024 };
1673
+
1674
+ for (const { layer, cls } of layers) {
1675
+ switch (cls.kind) {
1676
+ case 'missing':
1677
+ this.warnings.push(`${androidPath}: layered-image ${layer} layer has neither a drawable/color attribute nor an inline child, layer omitted`);
1678
+ break;
1679
+ case 'unknown':
1680
+ this.warnings.push(`${androidPath}: layered-image ${layer} reference ${cls.ref} not recognized`);
1681
+ break;
1682
+ case 'bitmap':
1683
+ case 'ref':
1684
+ out[layer] = `$media:${cls.resName}`;
1685
+ break;
1686
+ case 'inline':
1687
+ this.inlineAdaptiveLayer(cls.child, layer, name, qdir, androidPath, sourceCategory, out, extraTargets);
1688
+ break;
1689
+ case 'vector': {
1690
+ // Emit a separate SVG just for layered-image (cropped and/or size-aligned); the referenced original drawable is converted as usual,
1691
+ // since pages may reference it directly and it must not be touched. Inline vectors must be written separately anyway, so they go through here too.
1692
+ const layerName = `${name}_${layer}_layer`;
1693
+ const size = bitmap ? target! : undefined;
1694
+ this.write(path.join(qdir, 'media', `${layerName}.svg`),
1695
+ this.vectorToSvg(cls.vec, layerName, { adaptiveSafeZone: crop, size }));
1696
+ this.counts.safeZoneLayers++;
1697
+ out[layer] = `$media:${layerName}`;
1698
+ const how = [
1699
+ crop ? 'cropped to Android adaptive-icon 72/108 safe zone (HarmonyOS layered-image shows the full layer)' : '',
1700
+ size ? `sized ${size.w}x${size.h} to match bitmap layer @${bitmap!.resName}; not cropped because the bitmap layer cannot be` : '',
1701
+ ].filter(Boolean).join('; ');
1702
+ extraTargets.push({
1703
+ target: `resources/${qdir}/media/${layerName}.svg`,
1704
+ kind: 'svg conversion',
1705
+ notes: `layer vector ${cls.source} ${how}`,
1706
+ });
1707
+ break;
1708
+ }
1709
+ case 'solid': {
1710
+ if (!cls.hex) {
1711
+ const ph = cls.colorName ?? `${name}_${layer}`;
1712
+ this.warnings.push(`${androidPath}: layered-image ${layer} color ${cls.ref} cannot be resolved, using a placeholder reference`);
1713
+ out[layer] = `$media:${ph}_bg`;
1714
+ break;
1715
+ }
1716
+ out[layer] = `$media:${this.solidLayer(cls.colorName ?? `${name}_${layer}`, cls.hex, solidFormat, solidSize, qdir, extraTargets)}`;
1717
+ break;
1718
+ }
1719
+ }
1720
+ }
1721
+ if (bitmap) {
1722
+ this.counts.uncroppedBitmapIcons++;
1723
+ this.warnings.push(
1724
+ `${androidPath}: layered-image has a bitmap layer @${bitmap.resName} (${bitmap.w}x${bitmap.h}); HarmonyOS shows the whole layer without the 72/108 safe-zone crop, ` +
1725
+ 'so the icon content looks slightly smaller than on Android; to match, crop the bitmap to its center 2/3 and replace it');
1726
+ }
1727
+
1728
+ // monochrome does not go into the JSON, but the drawable it references is still a real resource and is handled as an ordinary drawable
1729
+ const mono = root.children.find((c) => c.name === 'monochrome');
1730
+ if (mono) {
1731
+ this.warnings.push(`${androidPath}: monochrome layer has no HarmonyOS layered-image equivalent, omitted from the JSON (its drawable is still converted as a normal resource)`);
1732
+ }
1733
+
1734
+ const jsonName = `${name}_layered_image.json`;
1735
+ this.write(path.join(qdir, 'media', jsonName), `${JSON.stringify({ 'layered-image': out }, null, 2)}\n`);
1736
+ this.counts.layeredImages++;
1737
+
1738
+ this.inv({
1739
+ androidResourcePath: androidPath, androidResourceName: name,
1740
+ function: 'Adaptive launcher icon', screens: 'Launcher', sourceCategory,
1741
+ typeCategory: 'mipmap', status: 'converted',
1742
+ });
1743
+ this.map({
1744
+ androidResourcePath: androidPath, androidScreens: 'Launcher',
1745
+ androidSourceCategory: sourceCategory, androidTypeCategory: 'mipmap',
1746
+ harmonyTarget: `resources/${qdir}/media/${jsonName}`, mappingKind: 'layered-image conversion',
1747
+ });
1748
+ for (const t of extraTargets) {
1749
+ this.map({
1750
+ androidResourcePath: androidPath, androidScreens: 'Launcher',
1751
+ androidSourceCategory: sourceCategory, androidTypeCategory: 'mipmap',
1752
+ harmonyTarget: t.target, mappingKind: t.kind, notes: t.notes,
1753
+ });
1754
+ }
1755
+ }
1756
+
1757
+ /**
1758
+ * Writes a solid layer and returns its `$media` name. `$media` names are globally unique within the module (independent of qdir),
1759
+ * so dedup is by "name → spec": same name and spec is reused; same name with a different spec (another icon pairs a layer of different color/size/format)
1760
+ * is renamed to `<name>_bg_<rgb>_<w>x<h>`, never reusing a file with a mismatched spec. Each qdir is written separately.
1761
+ */
1762
+ solidLayer(
1763
+ colorName: string, hex: string, format: 'svg' | 'png', size: { w: number; h: number },
1764
+ qdir: string, extraTargets: Array<{ target: string; kind: string; notes: string }>,
1765
+ ): string {
1766
+ const spec = `${format}:${size.w}x${size.h}:${hex}`;
1767
+ let media = `${colorName}_bg`;
1768
+ const prev = this.solidLayerSpecs.get(media);
1769
+ // The rename must carry every dimension of the spec (including color), otherwise two layers with the same name and size but different colors would collide on one file
1770
+ if (prev !== undefined && prev !== spec) {
1771
+ media = `${colorName}_bg_${hex.replace(/^#/, '').toLowerCase()}_${size.w}x${size.h}${format === 'svg' ? '_svg' : ''}`;
1772
+ }
1773
+ this.solidLayerSpecs.set(media, spec);
1774
+
1775
+ const file = `${media}.${format}`;
1776
+ const rel = path.join(qdir, 'media', file);
1777
+ if (this.writtenSolidLayers.has(rel)) return media;
1778
+ this.writtenSolidLayers.add(rel);
1779
+ // The converter writes straight into the project resources/ and does not clean old output. Old solid layers were always PNG, new ones may be SVG:
1780
+ // rerunning on an old project would leave both x.png and x.svg named $media:x. Delete the other-extension file left by the previous run;
1781
+ // files written by this run itself (a real same-name conflict) are left alone with only a warning.
1782
+ const other = path.join(qdir, 'media', `${media}.${format === 'svg' ? 'png' : 'svg'}`);
1783
+ const otherFull = path.join(this.outRoot, other);
1784
+ if (this.writtenThisRun.has(path.normalize(other))) {
1785
+ this.warnings.push(`${other}: same name as solid layer ${file} (same $media:${media}), resolve the name clash by hand`);
1786
+ } else if (!this.dryRun && fs.existsSync(otherFull)) {
1787
+ fs.rmSync(otherFull);
1788
+ this.warnings.push(`${other}: stale same-name solid layer from a previous conversion, deleted (this run produced ${file}; avoids a $media:${media} clash)`);
1789
+ }
1790
+ this.write(rel, format === 'svg' ? solidSvg(hex, size.w, size.h) : solidPng(hex, size.w, size.h));
1791
+ this.counts.solidLayersGenerated++;
1792
+ extraTargets.push({
1793
+ target: `resources/${qdir}/media/${file}`,
1794
+ kind: 'generated media',
1795
+ notes: `solid-color layer generated (${format.toUpperCase()} ${size.w}x${size.h}, matches the other layer) because layered-image accepts only $media references`,
1796
+ });
1797
+ return media;
1798
+ }
1799
+
1800
+ /**
1801
+ * Handling when a layer of `<adaptive-icon>` inlines a non-vector child drawable (shape / layer-list…).
1802
+ * The inline graphic is converted into a separate media file and referenced with `$media:`, the only form layered-image accepts.
1803
+ * Cases that cannot be converted are registered as unmappable; layers are never silently dropped.
1804
+ */
1805
+ inlineAdaptiveLayer(
1806
+ child: XmlNode,
1807
+ layer: 'background' | 'foreground',
1808
+ name: string,
1809
+ qdir: string,
1810
+ androidPath: string,
1811
+ sourceCategory: string,
1812
+ out: Record<string, string>,
1813
+ extraTargets: Array<{ target: string; kind: string; notes: string }>,
1814
+ ): void {
1815
+ const inlineName = `${name}_${layer}`;
1816
+ const conv = this.xmlDrawableToSvg(child, inlineName);
1817
+ if (!conv) {
1818
+ this.counts.unmappable++;
1819
+ this.warnings.push(`${androidPath}: layered-image ${layer} layer inlines <${child.name}>, which has no static SVG equivalent; no media file produced for it`);
1820
+ this.map({
1821
+ androidResourcePath: `${androidPath}#${layer}`, androidScreens: 'Launcher',
1822
+ androidSourceCategory: sourceCategory, androidTypeCategory: 'mipmap',
1823
+ harmonyTarget: 'N/A', mappingKind: 'unmappable',
1824
+ notes: `inline <${child.name}> in <${layer}> has no static SVG equivalent`,
1825
+ });
1826
+ return;
1827
+ }
1828
+
1829
+ this.write(path.join(qdir, 'media', `${inlineName}.svg`), conv.svg);
1830
+ this.counts.svgConverted++;
1831
+ out[layer] = `$media:${inlineName}`;
1832
+ extraTargets.push({
1833
+ target: `resources/${qdir}/media/${inlineName}.svg`,
1834
+ kind: conv.kind,
1835
+ notes: `inline <${child.name}> in <${layer}> extracted to its own media file; layered-image accepts only $media references${conv.notes ? `; ${conv.notes}` : ''}`,
1836
+ });
1837
+ }
1838
+
1839
+ // ── File resources ──
1840
+
1841
+ processFileResource(relFile: string, type: string, qdir: string): void {
1842
+ const base = path.basename(relFile);
1843
+ const ext = path.extname(base).toLowerCase();
1844
+ const androidPath = `res/${relFile}`;
1845
+ const resName = base.replace(/\.9\.png$/i, '').replace(/\.[^.]+$/, '');
1846
+ const sourceCategory = this.sourceCategory(resName);
1847
+
1848
+ const record = (target: string, kind: string, status: string, notes = '', fn = ''): void => {
1849
+ this.inv({
1850
+ androidResourcePath: androidPath, androidResourceName: resName,
1851
+ function: fn || `${type} resource`, sourceCategory, typeCategory: type,
1852
+ status, notes,
1853
+ });
1854
+ this.map({
1855
+ androidResourcePath: androidPath, androidSourceCategory: sourceCategory,
1856
+ androidTypeCategory: type, harmonyTarget: target, mappingKind: kind, notes,
1857
+ });
1858
+ };
1859
+
1860
+ if (type === 'font') {
1861
+ if (FONT_EXT.has(ext)) {
1862
+ const target = path.join('rawfile', 'fonts', base);
1863
+ this.write(target, fs.readFileSync(path.join(this.resDir, relFile)));
1864
+ this.counts.fontCopied++;
1865
+ record(`resources/${target.split(path.sep).join('/')}`, 'direct copy', 'converted', '', 'Font resource');
1866
+ } else {
1867
+ this.counts.unmappable++;
1868
+ record('N/A', 'unmappable', 'unmappable', 'font family XML has no HarmonyOS equivalent', 'Font family definition');
1869
+ }
1870
+ return;
1871
+ }
1872
+
1873
+ if (type === 'raw') {
1874
+ const target = path.join('rawfile', base);
1875
+ this.write(target, fs.readFileSync(path.join(this.resDir, relFile)));
1876
+ this.counts.rawCopied++;
1877
+ record(`resources/rawfile/${base}`, 'direct copy', 'converted', '', 'Raw file resource');
1878
+ return;
1879
+ }
1880
+
1881
+ if (type === 'xml') {
1882
+ const target = path.join(qdir, 'profile', base);
1883
+ this.write(target, fs.readFileSync(path.join(this.resDir, relFile)));
1884
+ this.counts.profileCopied++;
1885
+ record(`resources/${qdir}/profile/${base}`, 'direct copy', 'converted', '', 'Configuration XML');
1886
+ return;
1887
+ }
1888
+
1889
+ // drawable / mipmap
1890
+ if (/\.9\.png$/i.test(base)) {
1891
+ const renamed = base.replace(/\.9\.png$/i, '_9.png');
1892
+ const target = path.join(qdir, 'media', renamed);
1893
+ if (!this.claimTarget(target, relFile, androidPath, type)) return;
1894
+ this.write(target, fs.readFileSync(path.join(this.resDir, relFile)));
1895
+ this.counts.ninePatchRenamed++;
1896
+ this.counts.mediaCopied++;
1897
+ record(
1898
+ `resources/${qdir}/media/${renamed}`, 'rename', 'converted',
1899
+ 'nine-patch stretch behavior is lost; reimplement with a resizable Image in ArkUI',
1900
+ 'Nine-patch image',
1901
+ );
1902
+ return;
1903
+ }
1904
+
1905
+ if (IMAGE_EXT.has(ext)) {
1906
+ const target = path.join(qdir, 'media', base);
1907
+ if (!this.claimTarget(target, relFile, androidPath, type)) return;
1908
+ this.write(target, fs.readFileSync(path.join(this.resDir, relFile)));
1909
+ this.counts.mediaCopied++;
1910
+ record(`resources/${qdir}/media/${base}`, 'direct copy', 'converted', '', 'Image resource');
1911
+ return;
1912
+ }
1913
+
1914
+ if (ext === '.xml') {
1915
+ const root = parseXml(fs.readFileSync(path.join(this.resDir, relFile), 'utf8'));
1916
+
1917
+ if (root.name === 'adaptive-icon') {
1918
+ this.adaptiveIcon(root, resName, qdir, androidPath);
1919
+ return;
1920
+ }
1921
+
1922
+ const out = this.xmlDrawableToSvg(root, resName);
1923
+ if (!out) {
1924
+ this.counts.unmappable++;
1925
+ record(
1926
+ 'N/A', 'unmappable', 'unmappable',
1927
+ `<${root.name}> has no static SVG equivalent (runtime behavior)`,
1928
+ `${root.name} drawable`,
1929
+ );
1930
+ return;
1931
+ }
1932
+
1933
+ const target = path.join(qdir, 'media', `${resName}.svg`);
1934
+ if (!this.claimTarget(target, relFile, androidPath, type)) return;
1935
+ this.write(target, out.svg);
1936
+ this.counts.svgConverted++;
1937
+ record(`resources/${qdir}/media/${resName}.svg`, out.kind, 'converted', out.notes, `${root.name} drawable`);
1938
+ return;
1939
+ }
1940
+
1941
+ this.counts.unmappable++;
1942
+ record('N/A', 'unmappable', 'unmappable', `unhandled extension: ${ext}`);
1943
+ }
1944
+
1945
+ // ── Directory traversal ──
1946
+
1947
+ run(): void {
1948
+ const dirs = fs.readdirSync(this.resDir, { withFileTypes: true })
1949
+ .filter((d) => d.isDirectory())
1950
+ .map((d) => d.name)
1951
+ .sort();
1952
+
1953
+ // The first pass handles only values: SVG conversion needs the color / dimen lookup tables in place.
1954
+ // Lexicographic directory order puts drawable before values, so two passes are required.
1955
+ for (const dirName of dirs) {
1956
+ const { type, plan } = planQualifiers(dirName);
1957
+ if (type !== 'values' || plan.skip) continue;
1958
+ for (const f of fs.readdirSync(path.join(this.resDir, dirName)).sort()) {
1959
+ if (!f.endsWith('.xml')) continue;
1960
+ this.qualifierUse.push({ android: dirName, harmony: `${plan.dir}/element` });
1961
+ this.processValuesFile(`${dirName}/${f}`, plan.dir);
1962
+ }
1963
+ }
1964
+
1965
+ for (const dirName of dirs) {
1966
+ const { type, plan } = planQualifiers(dirName);
1967
+ const files = fs.readdirSync(path.join(this.resDir, dirName)).sort();
1968
+
1969
+ if (plan.skip) {
1970
+ this.counts.skippedQualifierDirs++;
1971
+ for (const f of files) {
1972
+ this.counts.unmappable++;
1973
+ this.inv({
1974
+ androidResourcePath: `res/${dirName}/${f}`, androidResourceName: f.replace(/\.[^.]+$/, ''),
1975
+ function: `${type} resource`, sourceCategory: this.sourceCategory(f),
1976
+ typeCategory: type, status: 'unmapped', notes: plan.skip,
1977
+ });
1978
+ this.map({
1979
+ androidResourcePath: `res/${dirName}/${f}`, androidTypeCategory: type,
1980
+ androidSourceCategory: this.sourceCategory(f),
1981
+ mappingKind: 'unmappable', notes: plan.skip,
1982
+ });
1983
+ }
1984
+ continue;
1985
+ }
1986
+
1987
+ if (type === 'values') continue; // already handled in the first pass
1988
+
1989
+ if (UNMAPPABLE_TYPES.has(type)) {
1990
+ for (const f of files) {
1991
+ const name = f.replace(/\.[^.]+$/, '');
1992
+ // Filter mode: only record resources in the allowlist
1993
+ if (this.filterSet && !this.filterSet.has(`${type}/${name}`)) continue;
1994
+ this.counts.unmappable++;
1995
+ this.inv({
1996
+ androidResourcePath: `res/${dirName}/${f}`, androidResourceName: name,
1997
+ function: `${type} resource`, sourceCategory: this.sourceCategory(name),
1998
+ typeCategory: type, status: 'unmappable',
1999
+ notes: `Android ${type} has no HarmonyOS equivalent (ArkUI is declarative)`,
2000
+ });
2001
+ this.map({
2002
+ androidResourcePath: `res/${dirName}/${f}`, androidTypeCategory: type,
2003
+ androidSourceCategory: this.sourceCategory(name), mappingKind: 'unmappable',
2004
+ notes: `Android ${type} has no HarmonyOS equivalent`,
2005
+ });
2006
+ }
2007
+ continue;
2008
+ }
2009
+
2010
+ for (const f of files) {
2011
+ const name = f.replace(/\.9\.png$/i, '').replace(/\.[^.]+$/, '');
2012
+ // Filter mode: only process resources in the allowlist
2013
+ if (this.filterSet && !this.filterSet.has(`${type}/${name}`)) continue;
2014
+ this.qualifierUse.push({ android: dirName, harmony: `${plan.dir}/media` });
2015
+ this.processFileResource(`${dirName}/${f}`, type, plan.dir);
2016
+ }
2017
+ }
2018
+
2019
+ this.resolveReferences();
2020
+ this.flushElements();
2021
+ }
2022
+ }
2023
+
2024
+ // ─────────────────────────────────────────────
2025
+ // Markdown generation
2026
+ // ─────────────────────────────────────────────
2027
+
2028
+ /** Markdown table cell escaping: `|` breaks the table, newlines break the row. */
2029
+ function cell(v: string): string {
2030
+ return (v ?? '').replace(/\|/g, '\\|').replace(/\r?\n/g, ' ').trim() || ' ';
2031
+ }
2032
+
2033
+ interface DocContext {
2034
+ apkPath: string;
2035
+ resSource: string;
2036
+ resDir: string;
2037
+ /** Android source project root (--android-project), a different path from resDir. */
2038
+ androidProjectDir: string;
2039
+ harmonyDir: string;
2040
+ appModule: string;
2041
+ androidCommit: string;
2042
+ iconSnapshotRef: string;
2043
+ buildResult: string;
2044
+ /** --json output of code_vector_icons.ts (optional) */
2045
+ icons: {
2046
+ counts?: Record<string, number>;
2047
+ icons?: Array<Record<string, unknown>>;
2048
+ ref?: string;
2049
+ /** The vast majority of dex references have no source origin ⇒ the whole material-icons-extended package was not shrunk by R8 */
2050
+ libraryLikelyUnshrunk?: boolean;
2051
+ } | null;
2052
+ /** --json output of svg_fidelity_check.ts (optional) */
2053
+ fidelity: { findings?: Array<Record<string, string>>; counts?: Record<string, number> } | null;
2054
+ /** --json output of app_identity.ts (optional) */
2055
+ appIdentity: {
2056
+ android?: { icon?: string; roundIcon?: string; label?: string };
2057
+ resolved?: {
2058
+ appIcon?: string | null;
2059
+ appLabel?: string | null;
2060
+ labelValue?: string | null;
2061
+ labelQualifiers?: string[];
2062
+ };
2063
+ warnings?: string[];
2064
+ } | null;
2065
+ }
2066
+
2067
+ /** `sourceCategory` of a third-party-library row when re-read from records JSON: the converter writes
2068
+ * the installed-language form, and records from either install are accepted. */
2069
+ const THIRD_PARTY_CATEGORY: readonly string[] = ['third-party-library', 'third-party-library'];
2070
+
2071
+ /** All the data document generation needs. Converter satisfies it structurally, and the records JSON deserializes into it too. */
2072
+ interface RecordsBundle {
2073
+ counts: Record<string, number>;
2074
+ warnings: string[];
2075
+ conflicts: string[];
2076
+ resolutions: ResolutionRecord[];
2077
+ inventory: InventoryRecord[];
2078
+ mappings: MappingRecord[];
2079
+ qualifierUse: Array<{ android: string; harmony: string }>;
2080
+ /** Lottie animations of an incremental run (extract_page_resources.ts → a2h_resource_incremental.ts); absent in full runs */
2081
+ lottie?: LottieDocRow[];
2082
+ }
2083
+
2084
+ /** One Lottie entry as lottie_refs.ts writes it; only the fields the documents show. */
2085
+ interface LottieDocRow {
2086
+ source: string;
2087
+ kind: 'asset' | 'raw' | 'remote' | 'dynamic';
2088
+ target: string | null;
2089
+ host: string;
2090
+ host_layout: string;
2091
+ suggested_page: string;
2092
+ refs: string[];
2093
+ images: Array<{ file: string | null; source?: string; declared: string; target: string }>;
2094
+ resolved: boolean;
2095
+ reason?: string;
2096
+ notes: string[];
2097
+ }
2098
+
2099
+ class DocWriter {
2100
+ conv: RecordsBundle;
2101
+ ctx: DocContext;
2102
+
2103
+ constructor(conv: RecordsBundle, ctx: DocContext) {
2104
+ this.conv = conv;
2105
+ this.ctx = ctx;
2106
+ }
2107
+
2108
+ private counts(): Record<string, number> {
2109
+ return this.conv.counts;
2110
+ }
2111
+
2112
+ /** Aggregated counts by a field, for the overview tables in the report. */
2113
+ private groupBy<T>(rows: T[], key: (r: T) => string): Array<[string, number]> {
2114
+ const m = new Map<string, number>();
2115
+ for (const r of rows) m.set(key(r), (m.get(r ? key(r) : '') ?? 0) + 1);
2116
+ return [...m].sort((a, b) => b[1] - a[1]);
2117
+ }
2118
+
2119
+ /**
2120
+ * Conversion report: meant for human reading, so it uses **aggregate** tables instead of listing 100k-scale resources one by one.
2121
+ * Per-entry auditing is the job of the resource_mapping document (which carries the hard "never omit" requirement).
2122
+ */
2123
+ report(): string {
2124
+ const c = this.counts();
2125
+ const o: string[] = [];
2126
+ const p = (s = ''): void => { o.push(s); };
2127
+
2128
+ p('# Android to HarmonyOS Resource Conversion Report');
2129
+ p();
2130
+ p('## Resource Source');
2131
+ p(`- APK: ${this.ctx.apkPath}`);
2132
+ p('- Decode result: Success');
2133
+ p(`- Resource source: ${this.ctx.resSource}`);
2134
+ p(`- Resource source path: ${this.ctx.resDir}`);
2135
+ p(`- Application module: ${this.ctx.appModule}`);
2136
+ p(`- Android final commit: ${this.ctx.androidCommit}`);
2137
+ p(`- Converter: scripts/a2h_resource_convert.ts (canonical implementation)`);
2138
+ p();
2139
+
2140
+ p('## Summary');
2141
+ p(`- Values entries converted: ${c.valuesEntries}`);
2142
+ p(`- Media files copied: ${c.mediaCopied} (nine-patch renamed: ${c.ninePatchRenamed})`);
2143
+ p(`- XML drawables converted to SVG: ${c.svgConverted}`);
2144
+ p(`- Adaptive icons converted to layered-image JSON: ${c.layeredImages}`);
2145
+ p(`- Adaptive-icon layer SVGs (safe-zone crop / size match): ${c.safeZoneLayers}; solid-color layers generated: ${c.solidLayersGenerated}`);
2146
+ if (c.uncroppedBitmapIcons > 0) {
2147
+ // The most common combination (bitmap foreground + solid background) lands exactly here; a single warning is easily drowned out, so it gets its own line in the summary
2148
+ p(`- **Known limitation** — adaptive icons with a bitmap layer, NOT cropped to the 72/108 safe zone: ${c.uncroppedBitmapIcons}. ` +
2149
+ 'They render ~1/3 smaller than on Android; crop the bitmap to its center 2/3 by hand if they must match.');
2150
+ }
2151
+ p(`- Raw / font / profile files: ${c.rawCopied} / ${c.fontCopied} / ${c.profileCopied}`);
2152
+ p(`- Unmappable (no HarmonyOS equivalent): ${c.unmappable}`);
2153
+ p(`- Directories skipped (unsupported qualifier): ${c.skippedQualifierDirs}`);
2154
+ p(`- References resolved: ${c.referencesResolved} (system resources: ${c.systemReferencesResolved})`);
2155
+ p(`- Fallback values applied: ${c.fallbacksApplied}`);
2156
+ p(`- SVG paint colors that could not be resolved: ${c.unresolvedPaint}`);
2157
+ p(`- HarmonyOS target collisions resolved: ${c.mediaTargetCollisions}`);
2158
+ p(`- Failed: ${c.failed}`);
2159
+ if (this.ctx.icons?.counts) {
2160
+ const ic = this.ctx.icons.counts;
2161
+ p(`- Code-defined icon references found (dex): ${ic.referencesFound ?? 0}`);
2162
+ p(`- Code-defined icons resolved / unresolved: ${ic.resolved ?? 0} / ${ic.unresolved ?? 0}`);
2163
+ p(`- Code-defined icon media files written: ${ic.mediaFilesWritten ?? 0}`);
2164
+ p(`- Code-defined icons screen-attributed / Unknown: ${ic.screenAttributed ?? 0} / ${ic.screenUnknown ?? 0}`);
2165
+ if (this.ctx.icons.libraryLikelyUnshrunk) {
2166
+ // The vast majority of references have no source origin ⇒ the whole material-icons-extended package was compiled into the dex (R8 did not shrink it).
2167
+ // The number of icons written then far exceeds what the app really uses; readers must know, otherwise they assume everything in media/ is a useful asset.
2168
+ p('- ⚠️ most icon references in the dex have no source origin, so the whole `material-icons-extended` package was not shrunk by R8: '
2169
+ + 'far more icons were written than the app uses; re-run with `--attributed-only` to keep only icons with a source attribution.');
2170
+ }
2171
+ p(`- Material Icons snapshot ref: ${this.ctx.icons.ref ?? this.ctx.iconSnapshotRef}`);
2172
+ } else {
2173
+ p('- Code-defined vector icons: not analysed (run scripts/code_vector_icons.ts)');
2174
+ }
2175
+ // App icon / app name.
2176
+ const idn = this.ctx.appIdentity;
2177
+ if (idn) {
2178
+ const r = idn.resolved ?? {};
2179
+ // The reason must be picked per field, not always warnings[0]: an icon warning attached to the app name row
2180
+ // would send readers investigating the wrong cause.
2181
+ const why = (re: RegExp): string => {
2182
+ const hit = (idn.warnings ?? []).find((w) => re.test(w));
2183
+ return hit ? `not rewritten (${hit})` : "not rewritten";
2184
+ };
2185
+ p(`- App icon: ${idn.android?.icon || '(none)'} → ${r.appIcon ?? why(/icon|launcher icon|app icon/i)}`);
2186
+ p(`- App name: ${idn.android?.label || '(none)'} → ${r.appLabel ?? why(/label|app name/i)}`
2187
+ + (r.labelValue != null ? ` = "${r.labelValue}"` : ''));
2188
+ p(`- App name locales written to AppScope: ${(r.labelQualifiers ?? []).join(', ') || '(none)'}`);
2189
+ p(`- App identity gate: ${r.appIcon && r.appLabel ? 'PASS' : "FAIL (app icon or app name not applied)"}`);
2190
+ } else {
2191
+ p('- App identity (launcher icon + app name): not run (run scripts/app_identity.ts)');
2192
+ }
2193
+ p();
2194
+
2195
+ p('## Conversion Details');
2196
+ p();
2197
+ p('### Converted Resources by Type');
2198
+ p('| Android Type | Mapping Kind | Count |');
2199
+ p('|---|---|---|');
2200
+ const conv = this.conv.mappings.filter((m) => m.mappingKind !== 'unmappable');
2201
+ for (const [k, n] of this.groupBy(conv, (m) => `${m.androidTypeCategory}|${m.mappingKind}`)) {
2202
+ const [t, kind] = k.split('|');
2203
+ p(`| ${cell(t)} | ${cell(kind)} | ${n} |`);
2204
+ }
2205
+ p();
2206
+
2207
+ p('### Qualifier Mappings Applied');
2208
+ p('| Android Qualifier Dir | HarmonyOS Target Dir | Files |');
2209
+ p('|---|---|---|');
2210
+ for (const [k, n] of this.groupBy(this.conv.qualifierUse, (q) => `${q.android}|${q.harmony}`)) {
2211
+ const [a, h] = k.split('|');
2212
+ p(`| ${cell(a)} | ${cell(h)} | ${n} |`);
2213
+ }
2214
+ p();
2215
+
2216
+ p('### Resource Reference Resolution');
2217
+ p('References resolved to concrete values. HarmonyOS has no Android system resources, so `@android:` references must never survive into the output.');
2218
+ p();
2219
+ p('| Resource File | Name | Reference | Resolved Value | Chain | Kind |');
2220
+ p('|---|---|---|---|---|---|');
2221
+ for (const r of this.conv.resolutions) {
2222
+ p(`| ${cell(r.file)} | ${cell(r.name)} | ${cell(r.reference)} | ${cell(r.resolved)} | ${cell(r.chain)} | ${r.kind} |`);
2223
+ }
2224
+ p();
2225
+
2226
+ p('### Unmappable Resources (by reason)');
2227
+ p('| Reason | Count |');
2228
+ p('|---|---|');
2229
+ for (const [k, n] of this.groupBy(this.conv.mappings.filter((m) => m.mappingKind === 'unmappable'), (m) => m.notes || '(unspecified)')) {
2230
+ p(`| ${cell(k)} | ${n} |`);
2231
+ }
2232
+ p();
2233
+
2234
+ if (this.ctx.fidelity) {
2235
+ const f = this.ctx.fidelity.findings ?? [];
2236
+ p('### Vector Fidelity Issues');
2237
+ if (f.length === 0) {
2238
+ p('`scripts/svg_fidelity_check.ts` reported no findings.');
2239
+ } else {
2240
+ p('| File | Rule | Severity | Android evidence | SVG evidence |');
2241
+ p('|---|---|---|---|---|');
2242
+ for (const x of f) {
2243
+ p(`| ${cell(x.name)} | ${x.rule} | ${x.severity} | ${cell(x.androidEvidence)} | ${cell(x.svgEvidence)} |`);
2244
+ }
2245
+ }
2246
+ p();
2247
+ }
2248
+
2249
+ if (this.ctx.icons?.icons) {
2250
+ p('### Code-Defined Vector Icons');
2251
+ p(`Artwork source: \`${this.ctx.icons.ref ?? this.ctx.iconSnapshotRef}\``);
2252
+ p();
2253
+ p('| Compose Reference | Material Name | Style | HarmonyOS Target | Host Screen(s) | Notes |');
2254
+ p('|---|---|---|---|---|---|');
2255
+ for (const i of this.ctx.icons.icons) {
2256
+ const screens = Array.isArray(i.screens) ? (i.screens as string[]).join(', ') : String(i.screens ?? 'Unknown');
2257
+ const notes = Array.isArray(i.notes) ? (i.notes as string[]).join('; ') : '';
2258
+ p(`| ${cell(String(i.compose))} | ${cell(String(i.material))} | ${cell(String(i.style))} | ${cell(i.resolved ? `base/media/${i.media}` : 'N/A')} | ${cell(screens)} | ${cell(notes || String(i.reason ?? ''))} |`);
2259
+ }
2260
+ p();
2261
+ }
2262
+
2263
+ // Warnings are grouped by "the pattern before the first colon" and shown in limited numbers: the report must be readable end to end;
2264
+ // the per-entry details are all in the warnings field of the records JSON, none missing.
2265
+ p('### Warnings');
2266
+ if (this.conv.warnings.length === 0) {
2267
+ p('None.');
2268
+ } else {
2269
+ const PER_KIND = 5;
2270
+ const byKind = new Map<string, string[]>();
2271
+ for (const w of this.conv.warnings) {
2272
+ const kind = w.includes(': ') ? w.slice(w.indexOf(': ') + 2).split(/[((]/)[0].trim() : w;
2273
+ const list = byKind.get(kind) ?? [];
2274
+ list.push(w);
2275
+ byKind.set(kind, list);
2276
+ }
2277
+ p(`${this.conv.warnings.length} in total, grouped by kind below; per-entry details are in the \`warnings\` field of the records JSON.`);
2278
+ p();
2279
+ for (const [kind, list] of [...byKind].sort((a, b) => b[1].length - a[1].length)) {
2280
+ p(`- **${cell(kind)}** — ${list.length}`);
2281
+ for (const w of list.slice(0, PER_KIND)) p(` - ${w}`);
2282
+ if (list.length > PER_KIND) p(` - …${list.length - PER_KIND} more in the records JSON`);
2283
+ }
2284
+ }
2285
+ p();
2286
+
2287
+ p('### Verification Results');
2288
+ p(`- All resources accounted for: Yes (${this.conv.inventory.length} inventory rows)`);
2289
+ p(`- Unresolved references remaining in output: 0 (fallbacks applied: ${c.fallbacksApplied}, all recorded above)`);
2290
+ p(`- Name conflicts (last definition wins): ${this.conv.conflicts.length}`);
2291
+ // `counts` only records rules/severities that occurred; when everything passes it is an empty object, so it cannot be used to infer "did not run".
2292
+ p(this.ctx.fidelity
2293
+ ? `- Vector fidelity errors: ${this.ctx.fidelity.counts?.error ?? 0} (warnings: ${this.ctx.fidelity.counts?.warn ?? 0})`
2294
+ : '- Vector fidelity errors: not run');
2295
+ p();
2296
+ return o.join('\n');
2297
+ }
2298
+
2299
+ /**
2300
+ * Resource mapping document (in the installed language). Hard requirement: **never silently omit any Android resource**,
2301
+ * and `values` must be entry level. So this document is naturally large (measured max about 23 MB),
2302
+ * with no sampling and no aggregation; that is the conversion report's job.
2303
+ */
2304
+ /** Inventory and mapping rows of the Lottie entries (and their image assets), in this document's language. */
2305
+ private lottieRows(): { inv: InventoryRecord[]; map: MappingRecord[]; superseded: Set<string> } {
2306
+ const inv: InventoryRecord[] = [];
2307
+ const map: MappingRecord[] = [];
2308
+ // a res/raw Lottie also went through the converter as a plain raw file (rawfile/<name>): its rows are replaced
2309
+ const superseded = new Set((this.conv.lottie ?? []).filter((l) => l.kind === 'raw' && l.resolved).map((l) => l.source));
2310
+ for (const l of this.conv.lottie ?? []) {
2311
+ if (l.kind === 'dynamic') continue; // no resource to list: the Lottie section carries it
2312
+ const remote = l.kind === 'remote';
2313
+ const category = remote ? 'runtime-remote' : 'app-own';
2314
+ const notes = [remote ? 'Lottie animation (remote URL)' : 'Lottie animation JSON', l.reason ?? '', ...l.notes].filter(Boolean).join('; ');
2315
+ const rows: Array<[string, string, string | null, string]> = [[l.source, l.source.split('/').pop() ?? l.source, l.target, notes]];
2316
+ for (const i of l.images) {
2317
+ rows.push([i.source ?? i.declared, i.declared.split('/').pop() ?? i.declared, i.file ? i.target : null, `image asset of ${l.source}${i.file ? '' : '; not found'}`]);
2318
+ }
2319
+ for (const [src, name, target, note] of rows) {
2320
+ inv.push({ androidResourcePath: src, androidResourceName: name, function: 'Lottie animation', screens: l.host,
2321
+ sourceCategory: category, typeCategory: 'raw', status: target ? 'converted' : 'unmappable', notes: note } as InventoryRecord);
2322
+ map.push({ androidResourcePath: src, androidScreens: l.host, androidSourceCategory: category, androidTypeCategory: 'raw',
2323
+ harmonyTarget: target ? `resources/${target}` : 'N/A',
2324
+ mappingKind: target ? 'direct copy' : remote ? 'remote resource (no local target)' : 'unmappable', notes: note } as MappingRecord);
2325
+ }
2326
+ }
2327
+ return { inv, map, superseded };
2328
+ }
2329
+
2330
+ mapping(): string {
2331
+ const c = this.counts();
2332
+ const lottie = this.lottieRows();
2333
+ const o: string[] = [];
2334
+ const p = (s = ''): void => { o.push(s); };
2335
+
2336
+ p("# Android Resources ↔ HarmonyOS Resources Mapping");
2337
+ p();
2338
+ p("## 1. Metadata");
2339
+ p(`- Android project directory: ${this.ctx.androidProjectDir}`);
2340
+ p(`- HarmonyOS project directory: ${this.ctx.harmonyDir}`);
2341
+ p(`- Resource source: ${this.ctx.resSource}`);
2342
+ p(`- Resource source path: ${this.ctx.resDir}`);
2343
+ p(`- APK: ${this.ctx.apkPath}`);
2344
+ p(`- Android final commit: ${this.ctx.androidCommit}`);
2345
+ p(`- Build result: ${this.ctx.buildResult}`);
2346
+ p("- Conversion implementation: scripts/a2h_resource_convert.ts (the canonical implementation; agents no longer write their own conversion scripts)");
2347
+ if (this.ctx.icons) p(`- Material Icons snapshot: ${this.ctx.icons.ref ?? this.ctx.iconSnapshotRef}`);
2348
+ p();
2349
+ p("### Record Granularity");
2350
+ p("- `values/*.xml` is recorded at **entry level**, with the path written as `file_path#tag/name`.");
2351
+ p("- File resources (drawable / mipmap / raw / font / xml) are recorded at **file level**.");
2352
+ p("- One-to-many conversions (e.g. an adaptive-icon producing a layered-image JSON plus generated solid-color PNGs) take one row per target.");
2353
+ p("- **No sampling, no aggregation**: the tables below list every resource one by one, with nothing omitted.");
2354
+ p();
2355
+
2356
+ p("## 2. Android Resource Inventory");
2357
+ p();
2358
+ p('| Android Resource Path | Resource Name | Function | Screen(s) | Source Category | Type Category | Status | Notes |');
2359
+ p('|---|---|---|---|---|---|---|---|');
2360
+ for (const r of [...this.conv.inventory.filter((x) => !lottie.superseded.has(x.androidResourcePath)), ...lottie.inv]) {
2361
+ p(`| ${cell(r.androidResourcePath)} | ${cell(r.androidResourceName)} | ${cell(r.function)} | ${cell(r.screens)} | ${cell(r.sourceCategory)} | ${cell(r.typeCategory)} | ${cell(r.status)} | ${cell(r.notes)} |`);
2362
+ }
2363
+ p();
2364
+
2365
+ p("## 3. Android → HarmonyOS Mapping Details");
2366
+ p();
2367
+ p('| Android Resource Path | Android Screen(s) | Android Source Category | Android Type Category | HarmonyOS Target | Mapping Kind | Notes |');
2368
+ p('|---|---|---|---|---|---|---|');
2369
+ for (const r of [...this.conv.mappings.filter((x) => !lottie.superseded.has(x.androidResourcePath)), ...lottie.map]) {
2370
+ p(`| ${cell(r.androidResourcePath)} | ${cell(r.androidScreens)} | ${cell(r.androidSourceCategory)} | ${cell(r.androidTypeCategory)} | ${cell(r.harmonyTarget)} | ${cell(r.mappingKind)} | ${cell(r.notes)} |`);
2371
+ }
2372
+ p();
2373
+
2374
+ p("## 4. Unmapped / Unmappable / System / Remote Summary");
2375
+ p();
2376
+ p("### 4.1 No Direct HarmonyOS Equivalent (by reason)");
2377
+ p("| Reason | Count |");
2378
+ p('|---|---|');
2379
+ for (const [k, n] of this.groupBy(this.conv.mappings.filter((m) => m.mappingKind === 'unmappable'), (m) => m.notes || "(unspecified)")) {
2380
+ p(`| ${cell(k)} | ${n} |`);
2381
+ }
2382
+ p();
2383
+ p("### 4.2 Android System Resources (resolved to concrete values; no `@android:` reference is kept in the output)");
2384
+ p("| Reference | Resolved Value | Location |");
2385
+ p('|---|---|---|');
2386
+ for (const r of this.conv.resolutions.filter((x) => x.kind === 'system')) {
2387
+ p(`| ${cell(r.reference)} | ${cell(r.resolved)} | ${cell(`${r.file}#${r.name}`)} |`);
2388
+ }
2389
+ p();
2390
+ p("### 4.3 Fallback Substitutions (unresolvable references)");
2391
+ if (c.fallbacksApplied === 0) p("None.");
2392
+ else {
2393
+ p("| Location | Original Reference | Fallback Value |");
2394
+ p('|---|---|---|');
2395
+ for (const r of this.conv.resolutions.filter((x) => x.kind === 'fallback' || x.kind === 'theme-attr')) {
2396
+ p(`| ${cell(`${r.file}#${r.name}`)} | ${cell(r.reference)} | ${cell(r.resolved)} |`);
2397
+ }
2398
+ }
2399
+ p();
2400
+ p("### 4.4 Runtime Remote Resources");
2401
+ const remoteLottie = (this.conv.lottie ?? []).filter((l) => l.kind === 'remote');
2402
+ if (remoteLottie.length === 0) {
2403
+ p("No runtime remote resources were detected in this conversion (no Lottie URL or server-delivered icon).");
2404
+ } else {
2405
+ p('| Reference | Host | Found at |');
2406
+ p('|---|---|---|');
2407
+ for (const l of remoteLottie) p(`| ${cell(l.source)} | ${cell(l.host)} | ${cell(l.refs.join('; '))} |`);
2408
+ }
2409
+ p();
2410
+ if (this.conv.lottie?.length) {
2411
+ // Heading and columns are the contract a2h-batch-ui-align Step 4.3 greps for (lottie-conversion-rules.md)
2412
+ p('### Lottie Animation Resources');
2413
+ p();
2414
+ p('| Android Source | Target Rawfile Path | Host Activity/Fragment | Host Layout / Loader | HarmonyOS Page (suggested) | Notes |');
2415
+ p('|---|---|---|---|---|---|');
2416
+ for (const l of this.conv.lottie) {
2417
+ const loader = l.kind === 'asset' || l.kind === 'raw' ? l.host_layout : l.refs.join('; ');
2418
+ const notes = [l.reason ?? '', ...l.notes, l.refs.length ? `refs: ${l.refs.join('; ')}` : ''].filter(Boolean).join('; ');
2419
+ p(`| ${cell(l.source)} | ${cell(l.target ?? 'N/A')} | ${cell(l.host)} | ${cell(loader)} | ${cell(l.suggested_page)} | ${cell(notes)} |`);
2420
+ }
2421
+ }
2422
+ p();
2423
+
2424
+ p("## 5. Code-Defined Vector Icons (Compose Material Icons)");
2425
+ if (!this.ctx.icons?.icons) {
2426
+ p("`scripts/code_vector_icons.ts` was not run this time, or the project has no code-defined icons.");
2427
+ p("If the Android side uses Jetpack Compose, that script **must** be run: these icons are not in `res/`, so this converter cannot see them.");
2428
+ p();
2429
+ } else {
2430
+ p("These icons are defined in code, not in `res/`, so a `res/` scan cannot see them. The list comes from `classes*.dex`; the artwork comes from a pinned Material Icons snapshot.");
2431
+ p();
2432
+ p("| Compose Reference | Material Name | Style | HarmonyOS Target | Screen(s) | Suggested Page | Notes |");
2433
+ p('|---|---|---|---|---|---|---|');
2434
+ for (const i of this.ctx.icons.icons) {
2435
+ const screens = Array.isArray(i.screens) ? (i.screens as string[]).join(', ') : String(i.screens ?? 'Unknown');
2436
+ const notes = Array.isArray(i.notes) ? (i.notes as string[]).join('; ') : '';
2437
+ p(`| ${cell(String(i.compose))} | ${cell(String(i.material))} | ${cell(String(i.style))} | ${cell(i.resolved ? `resources/base/media/${i.media}` : 'N/A')} | ${cell(screens)} | ${cell(String(i.suggestedPage ?? '—'))} | ${cell(notes || String(i.reason ?? ''))} |`);
2438
+ }
2439
+ p();
2440
+ }
2441
+
2442
+ p("## 6. Quick Findings");
2443
+ p(`- Launcher icons: ${c.layeredImages} adaptive-icon(s) detected and converted to layered-image JSON; HarmonyOS layered-image accepts only \`$media:\`, so color backgrounds were generated as solid-color PNGs.`);
2444
+ p(`- Nine-patch images: ${c.ninePatchRenamed} \`*.9.png\` renamed to \`*_9.png\`; the stretch behavior is lost and must be re-implemented on the ArkUI side with a resizable Image.`);
2445
+ p(`- Third-party library resources: ${this.conv.inventory.filter((r) => THIRD_PARTY_CATEGORY.includes(r.sourceCategory)).length} inventory entries inferred to come from third-party libraries by prefixes such as \`abc_*\` / \`mtrl_*\` / \`m3_*\`.`);
2446
+ if (c.mediaTargetCollisions > 0) {
2447
+ p(`- Target collisions: ${c.mediaTargetCollisions} case(s) of several Android sources landing on the same HarmonyOS target (e.g. \`drawable/\` and \`drawable-anydpi/\`); one was picked by "fewer qualifiers wins", and the losers are marked unmappable in the mapping table.`);
2448
+ }
2449
+ if (c.unresolvedPaint > 0) {
2450
+ p(`- SVG colors: ${c.unresolvedPaint} \`fillColor\` / \`strokeColor\` reference(s) missing from the merged resource table (mostly shrunk library resources) fell back to the platform default black, each with a warning.`);
2451
+ }
2452
+ p("- Styles and themes: `<style>` / `<attr>` / `<declare-styleable>` have no HarmonyOS equivalent; all are registered as unmappable and must be rebuilt in ArkUI component code.");
2453
+ p();
2454
+ return o.join('\n');
2455
+ }
2456
+ }
2457
+
2458
+ // ─────────────────────────────────────────────
2459
+ // Entry point
2460
+ // ─────────────────────────────────────────────
2461
+
2462
+ function parseArgs(argv: string[]): Record<string, string | boolean> {
2463
+ const args: Record<string, string | boolean> = {};
2464
+ for (let i = 0; i < argv.length; i++) {
2465
+ const a = argv[i];
2466
+ if (!a.startsWith('--')) fail(`unrecognized argument: ${a}`);
2467
+ const next = argv[i + 1];
2468
+ if (next && !next.startsWith('--')) { args[a.slice(2)] = next; i++; }
2469
+ else args[a.slice(2)] = true;
2470
+ }
2471
+ return args;
2472
+ }
2473
+
2474
+ function main(): void {
2475
+ const args = parseArgs(process.argv.slice(2));
2476
+ const resDir = typeof args.res === 'string' ? args.res : null;
2477
+ const harmony = typeof args.harmony === 'string' ? args.harmony : null;
2478
+ const dryRun = Boolean(args['dry-run']);
2479
+ const quiet = Boolean(args.quiet);
2480
+
2481
+ const docsOnly = Boolean(args['docs-only']);
2482
+ if (docsOnly) {
2483
+ if (typeof args.records !== 'string') fail('--docs-only needs --records <existing records JSON>');
2484
+ const bundle = JSON.parse(fs.readFileSync(args.records, 'utf8')) as RecordsBundle;
2485
+ emitDocs(bundle, args, resDir ?? '(from records)', harmony);
2486
+ process.exit(0);
2487
+ }
2488
+
2489
+ if (!resDir) fail('missing --res <decoded res dir>');
2490
+ if (!harmony && !dryRun) fail('missing --harmony <harmony project dir> (or use --dry-run)');
2491
+ if (!fs.existsSync(resDir)) fail(`--res path does not exist: ${resDir}`);
2492
+
2493
+ // Filter mode: read the JSON output of extract_project_resources.ts and build the type/name allowlist
2494
+ let filterSet: Set<string> | null = null;
2495
+ if (typeof args.filter === 'string') {
2496
+ if (!fs.existsSync(args.filter)) fail(`--filter path does not exist: ${args.filter}`);
2497
+ const filterJson = JSON.parse(fs.readFileSync(args.filter, 'utf8')) as {
2498
+ resources: Array<{ type: string; name: string }>;
2499
+ };
2500
+ filterSet = new Set<string>();
2501
+ // `<array>` / `<string-array>` / `<integer-array>` are three spellings of the same resource type:
2502
+ // aapt2 no longer distinguishes them after compilation, extract_project_resources.ts always records `array`, while this converter
2503
+ // normalizes by item content into string-array/integer-array (see normalizeArrayTag). The three spellings
2504
+ // register as aliases of each other, otherwise arrays in the allowlist would be silently dropped: neither converted nor recorded as an unmappable row.
2505
+ const ARRAY_TAGS = ['array', 'string-array', 'integer-array'];
2506
+ for (const r of filterJson.resources) {
2507
+ filterSet.add(`${r.type}/${r.name}`);
2508
+ if (ARRAY_TAGS.includes(r.type)) {
2509
+ for (const t of ARRAY_TAGS) filterSet.add(`${t}/${r.name}`);
2510
+ }
2511
+ }
2512
+ if (!quiet) console.log(`[a2h_resource_convert] filter mode: allowlist of ${filterSet.size} resources`);
2513
+ }
2514
+
2515
+ const uiModule = typeof args['ui-module'] === 'string' ? args['ui-module'] : 'entry';
2516
+ const conv = new Converter(resDir, harmony ?? '.', dryRun, uiModule, filterSet);
2517
+ conv.run();
2518
+
2519
+ emitDocs(conv, args, resDir, harmony);
2520
+
2521
+ if (typeof args.records === 'string') {
2522
+ fs.writeFileSync(args.records, `${JSON.stringify({
2523
+ counts: conv.counts,
2524
+ qualifierUse: conv.qualifierUse,
2525
+ warnings: conv.warnings,
2526
+ conflicts: conv.conflicts,
2527
+ resolutions: conv.resolutions,
2528
+ inventory: conv.inventory,
2529
+ mappings: conv.mappings,
2530
+ }, null, 1)}
2531
+ `, 'utf8');
2532
+ }
2533
+
2534
+ if (!quiet) {
2535
+ const c = conv.counts;
2536
+ console.log('[a2h_resource_convert]');
2537
+ console.log(` values entries : ${c.valuesEntries}`);
2538
+ console.log(` media files copied : ${c.mediaCopied} (nine-patch renamed: ${c.ninePatchRenamed})`);
2539
+ console.log(` raw / font / profile : ${c.rawCopied} / ${c.fontCopied} / ${c.profileCopied}`);
2540
+ console.log(` XML drawable → SVG : ${c.svgConverted}`);
2541
+ console.log(` layered-image JSON : ${c.layeredImages}`);
2542
+ console.log(` icon layer SVG/solid : ${c.safeZoneLayers} / ${c.solidLayersGenerated}`);
2543
+ console.log(` unmappable : ${c.unmappable}`);
2544
+ console.log(` skipped qualifier dirs: ${c.skippedQualifierDirs}`);
2545
+ console.log(` references resolved : ${c.referencesResolved} (system: ${c.systemReferencesResolved})`);
2546
+ console.log(` fallbacks applied : ${c.fallbacksApplied}`);
2547
+ console.log(` unresolved SVG colors: ${c.unresolvedPaint}`);
2548
+ console.log(` target collisions : ${c.mediaTargetCollisions}`);
2549
+ console.log(` failed : ${c.failed}`);
2550
+ console.log(` inventory / mapping rows: ${conv.inventory.length} / ${conv.mappings.length}`);
2551
+ if (conv.conflicts.length > 0) console.log(` same-name overrides : ${conv.conflicts.length}`);
2552
+ if (conv.warnings.length > 0) console.log(` warnings : ${conv.warnings.length}`);
2553
+ }
2554
+
2555
+ process.exit(conv.counts.failed > 0 ? 1 : 0);
2556
+ }
2557
+
2558
+ /** Generates both markdown documents. Extracted into a function so --docs-only can reuse it. */
2559
+ function emitDocs(
2560
+ bundle: RecordsBundle,
2561
+ args: Record<string, string | boolean>,
2562
+ resDir: string,
2563
+ harmony: string | null,
2564
+ ): void {
2565
+ if (typeof args.report !== 'string' && typeof args.mapping !== 'string') return;
2566
+ const readJson = (k: string): Record<string, unknown> | null => {
2567
+ const v = args[k];
2568
+ if (typeof v !== 'string') return null;
2569
+ try { return JSON.parse(fs.readFileSync(v, 'utf8')) as Record<string, unknown>; }
2570
+ catch (e) { fail(`--${k} could not be read: ${(e as Error).message}`); }
2571
+ };
2572
+
2573
+ {
2574
+ const doc = new DocWriter(bundle, {
2575
+ apkPath: typeof args.apk === 'string' ? args.apk : '(not provided)',
2576
+ resSource: 'decoded APK (complete merged resource set)',
2577
+ resDir,
2578
+ androidProjectDir: typeof args['android-project'] === 'string' ? args['android-project'] : '(not provided)',
2579
+ harmonyDir: harmony ?? '',
2580
+ appModule: typeof args['app-module'] === 'string' ? args['app-module'] : '(not provided)',
2581
+ androidCommit: typeof args['android-commit'] === 'string' ? args['android-commit'] : '(not provided)',
2582
+ iconSnapshotRef: '(not provided)',
2583
+ buildResult: typeof args['build-result'] === 'string' ? args['build-result'] : '(not run by this script)',
2584
+ icons: readJson('icons-json') as DocContext['icons'],
2585
+ fidelity: readJson('fidelity-json') as DocContext['fidelity'],
2586
+ appIdentity: readJson('app-identity-json') as DocContext['appIdentity'],
2587
+ });
2588
+ if (typeof args.report === 'string') fs.writeFileSync(args.report, `${doc.report()}
2589
+ `, 'utf8');
2590
+ if (typeof args.mapping === 'string') fs.writeFileSync(args.mapping, `${doc.mapping()}
2591
+ `, 'utf8');
2592
+ }
2593
+
2594
+ }
2595
+
2596
+ main();