@buaa_smat/hometrans 26.0.1 → 26.0.3

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 (1053) hide show
  1. package/README.md +14 -7
  2. package/agents/code-reviewer.md +25 -138
  3. package/dist/cli/index.js +4 -1
  4. package/dist/cli/init.js +131 -26
  5. package/dist/cli/uninstall.js +5 -5
  6. package/dist/platform/language.js +77 -0
  7. package/env-requirements.json +30 -5
  8. package/i18n/FILE-NAMES.md +9 -0
  9. package/i18n/agents/code-reviewer.md +364 -0
  10. package/i18n/agents/model-render-worker.md +38 -0
  11. package/i18n/agents/specgen-worker.md +18 -0
  12. package/i18n/commands/hometrans.md +17 -0
  13. package/i18n/skills/a2h-app-migrate/SKILL.md +198 -0
  14. package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -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 +1760 -0
  18. package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
  19. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1588 -0
  20. package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +657 -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 +131 -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 +698 -0
  28. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +89 -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 +219 -0
  33. package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +196 -0
  34. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
  35. package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +488 -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 +146 -0
  38. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +161 -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 +171 -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 +375 -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 +120 -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/references/ISSUES.md +9 -0
  72. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +192 -0
  73. package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +303 -0
  74. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
  75. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
  76. package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +587 -0
  77. package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  78. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  79. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  80. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  81. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  82. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  83. package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  84. package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +352 -0
  85. package/i18n/skills/a2h-batch-ui-align/SKILL.md +323 -0
  86. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +31 -0
  87. package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  88. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  89. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  90. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +80 -0
  91. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +22 -0
  92. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +87 -0
  93. package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  94. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  95. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +57 -0
  96. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +29 -0
  97. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +705 -0
  98. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +417 -0
  99. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
  100. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  101. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2549 -0
  102. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
  103. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +148 -0
  104. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +220 -0
  105. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
  106. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +216 -0
  107. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +203 -0
  108. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +210 -0
  109. package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
  110. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1748 -0
  111. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  112. package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  113. package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  114. package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1787 -0
  115. package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  116. package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  117. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1836 -0
  118. package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
  119. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1406 -0
  120. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1226 -0
  121. package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1220 -0
  122. package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +412 -0
  123. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  124. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
  125. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +173 -0
  126. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +629 -0
  127. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  128. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +67 -0
  129. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  130. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  131. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  132. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
  133. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  134. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
  135. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  136. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  137. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  138. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  139. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  140. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  141. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  142. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  143. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  144. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +551 -0
  145. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  146. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +374 -0
  147. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  148. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  149. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +119 -0
  150. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  151. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  152. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +80 -0
  153. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
  154. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  155. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  156. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  157. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +97 -0
  158. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  159. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -0
  160. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  161. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  162. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  163. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  164. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  165. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  166. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  167. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  168. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  169. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  170. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +123 -0
  171. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  172. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  173. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
  174. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  175. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  176. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  177. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  178. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +427 -0
  179. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  180. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  181. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  182. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  183. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  184. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +560 -0
  185. package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
  186. package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  187. package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  188. package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  189. package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  190. package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +324 -0
  191. package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  192. package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +325 -0
  193. package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +48 -0
  194. package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +387 -0
  195. package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  196. package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  197. package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  198. package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +59 -0
  199. package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
  200. package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
  201. package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  202. package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  203. package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  204. package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
  205. package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2048 -0
  206. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  207. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  208. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  209. package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  210. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  211. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  212. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
  213. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  214. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  215. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  216. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  217. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  218. package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  219. package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  220. package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
  221. package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  222. package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  223. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +227 -0
  224. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  225. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  226. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  227. package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  228. package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  229. package/i18n/skills/a2h-page-specgen/SKILL.md +136 -0
  230. package/i18n/skills/a2h-page-specgen/references/body-language.md +177 -0
  231. package/i18n/skills/a2h-page-specgen/references/gates.md +262 -0
  232. package/i18n/skills/a2h-page-specgen/references/page-inventory.md +173 -0
  233. package/i18n/skills/a2h-page-specgen/references/spec-template.md +207 -0
  234. package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1504 -0
  235. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1528 -0
  236. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +576 -0
  237. package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +138 -0
  238. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +262 -0
  239. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +176 -0
  240. package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +248 -0
  241. package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  242. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +506 -0
  243. package/i18n/skills/a2h-page-specgen/scripts/render.mjs +299 -0
  244. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +616 -0
  245. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +234 -0
  246. package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1166 -0
  247. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +74 -0
  248. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
  249. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
  250. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
  251. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  252. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +758 -0
  253. package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  254. package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +54 -0
  255. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +271 -0
  256. package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +54 -0
  257. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +171 -0
  258. package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +301 -0
  259. package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +83 -0
  260. package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +139 -0
  261. package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +774 -0
  262. package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1011 -0
  263. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +77 -0
  264. package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +419 -0
  265. package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  266. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +323 -0
  267. package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +546 -0
  268. package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +511 -0
  269. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +701 -0
  270. package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  271. package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1765 -0
  272. package/i18n/skills/a2h-resource-convert/SKILL.md +367 -0
  273. package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +335 -0
  274. package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
  275. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +219 -0
  276. package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
  277. package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
  278. package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  279. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2532 -0
  280. package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  281. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +278 -0
  282. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +260 -0
  283. package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +163 -0
  284. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +44 -0
  285. package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  286. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +589 -0
  287. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +506 -0
  288. package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
  289. package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
  290. package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  291. package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  292. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
  293. package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
  294. package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  295. package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  296. package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  297. package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
  298. package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  299. package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  300. package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  301. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
  302. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  303. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  304. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  305. package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
  306. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
  307. package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  308. package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  309. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
  310. package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
  311. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
  312. package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
  313. package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
  314. package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
  315. package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
  316. package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
  317. package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
  318. package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
  319. package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
  320. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  321. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  322. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  323. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  324. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
  325. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
  326. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
  327. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
  328. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  329. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
  330. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
  331. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
  332. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
  333. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
  334. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
  335. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  336. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
  337. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
  338. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
  339. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  340. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
  341. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  342. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  343. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  344. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  345. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  346. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  347. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
  348. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
  349. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
  350. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
  351. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  352. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  353. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  354. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  355. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  356. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  357. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  358. package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
  359. package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  360. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
  361. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
  362. package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
  363. package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  364. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  365. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  366. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  367. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  368. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  369. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  370. package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  371. package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  372. package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  373. package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  374. package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  375. package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  376. package/i18n/skills/a2h-utg-explorer/SKILL.md +120 -0
  377. package/i18n/skills/a2h-utg-explorer/references/architecture.md +279 -0
  378. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +918 -0
  379. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
  380. package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
  381. package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  382. package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
  383. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +380 -0
  384. package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  385. package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  386. package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  387. package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  388. package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  389. package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  390. package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  391. package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +492 -0
  392. package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +199 -0
  393. package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  394. package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  395. package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  396. package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  397. package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  398. package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  399. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  400. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  401. package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  402. package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  403. package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  404. package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  405. package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  406. package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  407. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1412 -0
  408. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2037 -0
  409. package/i18n/skills/a2h-utg-static/SKILL.md +368 -0
  410. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  411. package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
  412. package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2120 -0
  413. package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  414. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +609 -0
  415. package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
  416. package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
  417. package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  418. package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
  419. package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
  420. package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  421. package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +913 -0
  422. package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +517 -0
  423. package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  424. package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
  425. package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  426. package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  427. package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  428. package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  429. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
  430. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  431. package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  432. package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  433. package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  434. package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  435. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  436. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  437. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
  438. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  439. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  440. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  441. package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  442. package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
  443. package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  444. package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
  445. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  446. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  447. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  448. package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  449. package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  450. package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  451. package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  452. package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  453. package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  454. package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  455. package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  456. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  457. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  458. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
  459. package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  460. package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1351 -0
  461. package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  462. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  463. package/package.json +13 -160
  464. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  465. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  466. package/skills/a2h-app-migrate/SKILL.md +17 -6
  467. package/skills/a2h-app-migrate/references/config.example.json +1 -0
  468. package/skills/a2h-app-migrate/references/stage-map.md +3 -1
  469. package/skills/a2h-app-migrate/references/workflow.yaml +138 -47
  470. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +1 -2
  471. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +105 -39
  472. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +7 -8
  473. package/skills/a2h-app-migrate/scripts/ledger.mjs +17 -5
  474. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +43 -7
  475. package/skills/a2h-app-migrate/scripts/run_dir.mjs +127 -41
  476. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
  477. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
  478. package/skills/a2h-app-migrate/test/test_android_index.mjs +131 -0
  479. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  480. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  481. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  482. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  483. package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
  484. package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  485. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
  486. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +698 -0
  487. package/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
  488. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  489. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  490. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
  491. package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  492. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +91 -0
  493. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  494. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  495. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +111 -0
  496. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +53 -0
  497. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  498. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  499. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +219 -0
  500. package/skills/a2h-app-migrate/test/test_resume_summary.mjs +196 -0
  501. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
  502. package/skills/a2h-app-migrate/test/test_run_dir.mjs +488 -0
  503. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  504. package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
  505. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +147 -0
  506. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +146 -0
  507. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +161 -0
  508. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +344 -0
  509. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  510. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +53 -0
  511. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  512. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  513. package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  514. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
  515. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +178 -0
  516. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  517. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  518. package/skills/a2h-arch-generate/SKILL.md +1 -1
  519. package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
  520. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
  521. package/skills/a2h-arch-generate/references/homegraph-workflow.md +15 -6
  522. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
  523. package/skills/a2h-arch-generate/references/source-baseline.md +2 -2
  524. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
  525. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
  526. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
  527. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  528. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  529. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  530. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  531. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  532. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  533. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  534. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  535. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  536. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  537. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  538. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  539. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  540. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  541. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  542. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  543. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  544. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  545. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  546. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  547. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  548. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  549. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  550. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  551. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  552. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  553. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  554. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
  555. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +191 -0
  556. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  557. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  558. package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  559. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
  560. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
  561. package/skills/a2h-arkts-logic-coder/SKILL.md +21 -2
  562. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -0
  563. package/skills/a2h-arkts-logic-coder/references/code-generation.md +62 -0
  564. package/skills/a2h-arkts-logic-coder/references/spec-design.md +4 -0
  565. package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
  566. package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +583 -0
  567. package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
  568. package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  569. package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  570. package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  571. package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
  572. package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  573. package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  574. package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  575. package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +352 -0
  576. package/skills/a2h-batch-ui-align/SKILL.md +6 -4
  577. package/skills/a2h-batch-ui-align/references/cards/geometry.md +1 -1
  578. package/skills/a2h-batch-ui-align/references/cards/resources.md +4 -0
  579. package/skills/a2h-batch-ui-align/references/cards/widgets.md +22 -3
  580. package/skills/a2h-batch-ui-align/references/checker-rules.md +66 -3
  581. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +45 -8
  582. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +7 -5
  583. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
  584. package/skills/a2h-batch-ui-align/references/step4-prepare.md +4 -2
  585. package/skills/a2h-batch-ui-align/references/step5-convert.md +7 -5
  586. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
  587. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +84 -7
  588. package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  589. package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +229 -0
  590. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1 -2
  591. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
  592. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +88 -26
  593. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +305 -12
  594. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
  595. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +8 -9
  596. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +18 -5
  597. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +103 -3
  598. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
  599. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
  600. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +14 -8
  601. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
  602. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
  603. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
  604. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
  605. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
  606. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
  607. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  608. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
  609. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
  610. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +66 -2
  611. package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +119 -0
  612. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
  613. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  614. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +123 -0
  615. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
  616. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +6 -0
  617. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +217 -0
  618. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  619. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
  620. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  621. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  622. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  623. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  624. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +427 -0
  625. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  626. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  627. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +235 -0
  628. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  629. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  630. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
  631. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  632. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
  633. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  634. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +567 -0
  635. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +290 -0
  636. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +74 -0
  637. package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
  638. package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
  639. package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +420 -0
  640. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  641. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  642. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  643. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  644. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  645. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1628 -0
  646. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  647. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  648. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  649. package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  650. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +324 -0
  651. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  652. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +325 -0
  653. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +297 -0
  654. package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +48 -0
  655. package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +387 -0
  656. package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  657. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  658. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  659. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
  660. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
  661. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  662. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  663. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  664. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  665. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  666. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  667. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  668. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  669. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  670. package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
  671. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  672. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  673. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  674. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  675. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  676. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  677. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  678. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  679. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  680. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  681. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  682. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  683. package/skills/a2h-page-specgen/SKILL.md +136 -0
  684. package/skills/a2h-page-specgen/references/body-language.md +177 -0
  685. package/skills/a2h-page-specgen/references/evidence.md +70 -0
  686. package/skills/a2h-page-specgen/references/execution-model.md +255 -0
  687. package/skills/a2h-page-specgen/references/footprint-and-grouping.md +250 -0
  688. package/skills/a2h-page-specgen/references/gates.md +255 -0
  689. package/skills/a2h-page-specgen/references/page-inventory.md +173 -0
  690. package/skills/a2h-page-specgen/references/spec-template.md +207 -0
  691. package/skills/a2h-page-specgen/scripts/dispatch.mjs +209 -0
  692. package/skills/a2h-page-specgen/scripts/facts-build.mjs +1504 -0
  693. package/skills/a2h-page-specgen/scripts/finalize.mjs +422 -0
  694. package/skills/a2h-page-specgen/scripts/footprint.mjs +1528 -0
  695. package/skills/a2h-page-specgen/scripts/gate.mjs +558 -0
  696. package/skills/a2h-page-specgen/scripts/interactions.mjs +137 -0
  697. package/skills/a2h-page-specgen/scripts/inventory.mjs +269 -0
  698. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +255 -0
  699. package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
  700. package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +137 -0
  701. package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
  702. package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
  703. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +175 -0
  704. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +355 -0
  705. package/skills/a2h-page-specgen/scripts/lib/prose.mjs +234 -0
  706. package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  707. package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +391 -0
  708. package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
  709. package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
  710. package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
  711. package/skills/a2h-page-specgen/scripts/prepare.mjs +492 -0
  712. package/skills/a2h-page-specgen/scripts/render.mjs +317 -0
  713. package/skills/a2h-page-specgen/scripts/report.mjs +7 -0
  714. package/skills/a2h-page-specgen/scripts/submission.mjs +532 -0
  715. package/skills/a2h-page-specgen/scripts/submit.mjs +79 -0
  716. package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
  717. package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +590 -0
  718. package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
  719. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +207 -0
  720. package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
  721. package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1164 -0
  722. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +74 -0
  723. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
  724. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
  725. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
  726. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
  727. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
  728. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
  729. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
  730. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
  731. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
  732. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
  733. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
  734. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
  735. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
  736. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
  737. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
  738. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
  739. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
  740. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
  741. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
  742. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
  743. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
  744. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
  745. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
  746. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
  747. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
  748. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
  749. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
  750. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
  751. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
  752. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
  753. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
  754. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
  755. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
  756. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
  757. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
  758. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
  759. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
  760. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
  761. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
  762. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
  763. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
  764. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
  765. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
  766. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
  767. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
  768. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
  769. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
  770. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
  771. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
  772. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
  773. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
  774. package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
  775. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +94 -0
  776. package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
  777. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
  778. package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
  779. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  780. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
  781. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
  782. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +758 -0
  783. package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
  784. package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  785. package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +54 -0
  786. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +222 -0
  787. package/skills/a2h-page-specgen/scripts/test/helpers.mjs +54 -0
  788. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +171 -0
  789. package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +301 -0
  790. package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +45 -0
  791. package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +139 -0
  792. package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +774 -0
  793. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
  794. package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1011 -0
  795. package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +120 -0
  796. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +68 -0
  797. package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +390 -0
  798. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +167 -0
  799. package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  800. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +323 -0
  801. package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +546 -0
  802. package/skills/a2h-page-specgen/scripts/test/render.test.mjs +503 -0
  803. package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
  804. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +701 -0
  805. package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  806. package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
  807. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1765 -0
  808. package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1979 -0
  809. package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +313 -0
  810. package/skills/a2h-page-specgen/scripts/waker.mjs +1234 -0
  811. package/skills/a2h-page-specgen/scripts/watchdog.mjs +298 -0
  812. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +49 -51
  813. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  814. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  815. package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  816. package/skills/a2h-spec-design-pipeline/SKILL.md +79 -78
  817. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +51 -12
  818. package/skills/a2h-spec-design-pipeline/references/execution-model.md +24 -6
  819. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +3 -2
  820. package/skills/a2h-spec-design-pipeline/references/initialization.md +15 -4
  821. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +82 -41
  822. package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +61 -0
  823. package/skills/a2h-spec-design-pipeline/references/scripts.md +19 -10
  824. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +267 -0
  825. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +61 -8
  826. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +62 -13
  827. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +8 -0
  828. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +8 -0
  829. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-cn.md +55 -0
  830. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-en.md +60 -0
  831. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/HttpExtraDataEmptyStringCheck.js +488 -0
  832. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +11 -0
  833. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +17 -0
  834. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
  835. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +40 -5
  836. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +18 -0
  837. package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +74 -0
  838. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +1 -1
  839. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +1 -1
  840. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
  841. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +128 -5
  842. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +98 -35
  843. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +218 -37
  844. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
  845. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
  846. package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
  847. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +6 -7
  848. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
  849. package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +348 -0
  850. package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
  851. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +15 -5
  852. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +7 -2
  853. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +104 -1
  854. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +24 -0
  855. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +394 -0
  856. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +24 -1
  857. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +14 -0
  858. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +163 -5
  859. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +15 -7
  860. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
  861. package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +350 -0
  862. package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
  863. package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
  864. package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
  865. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +121 -0
  866. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
  867. package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
  868. package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
  869. package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
  870. package/skills/a2h-spec-generate/SKILL.md +87 -21
  871. package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
  872. package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  873. package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
  874. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  875. package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
  876. package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
  877. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
  878. package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
  879. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
  880. package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
  881. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
  882. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
  883. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
  884. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
  885. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
  886. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
  887. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
  888. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
  889. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
  890. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
  891. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
  892. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
  893. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  894. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
  895. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
  896. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
  897. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
  898. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
  899. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
  900. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
  901. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
  902. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
  903. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
  904. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
  905. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  906. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  907. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  908. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  909. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
  910. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
  911. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  912. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  913. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  914. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
  915. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  916. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
  917. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
  918. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
  919. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
  920. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
  921. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  922. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  923. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  924. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  925. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  926. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  927. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  928. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  929. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  930. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  931. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  932. package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
  933. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
  934. package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
  935. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
  936. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  937. package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
  938. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +230 -0
  939. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  940. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  941. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  942. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  943. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  944. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  945. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  946. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  947. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  948. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  949. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  950. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  951. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  952. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  953. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  954. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  955. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  956. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  957. package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  958. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
  959. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  960. package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  961. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  962. package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  963. package/skills/a2h-utg-explorer/references/architecture.md +4 -0
  964. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +64 -80
  965. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
  966. package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
  967. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
  968. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  969. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
  970. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  971. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  972. package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  973. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  974. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
  975. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
  976. package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
  977. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  978. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  979. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
  980. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  981. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  982. package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
  983. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  984. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  985. package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
  986. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +492 -0
  987. package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +199 -0
  988. package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
  989. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  990. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  991. package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  992. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  993. package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  994. package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  995. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  996. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  997. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  998. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  999. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  1000. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  1001. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +454 -0
  1002. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  1003. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  1004. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  1005. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  1006. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
  1007. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  1008. package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
  1009. package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
  1010. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  1011. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  1012. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  1013. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  1014. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  1015. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +13 -3
  1016. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +107 -65
  1017. package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +155 -0
  1018. package/skills/a2h-utg-static/scripts/assemble.mjs +28 -3
  1019. package/skills/a2h-utg-static/scripts/click_paths.mjs +19 -20
  1020. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +102 -2
  1021. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
  1022. package/skills/a2h-utg-static/scripts/nl_hints.mjs +2 -3
  1023. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
  1024. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
  1025. package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
  1026. package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
  1027. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
  1028. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
  1029. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
  1030. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
  1031. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
  1032. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
  1033. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
  1034. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
  1035. package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
  1036. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
  1037. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
  1038. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
  1039. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
  1040. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
  1041. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
  1042. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
  1043. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
  1044. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
  1045. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
  1046. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
  1047. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
  1048. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
  1049. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
  1050. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
  1051. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
  1052. package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
  1053. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
@@ -0,0 +1,1836 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Per-group source + resource pack: the files a conversion agent must read, found once.
4
+ *
5
+ * (Node >= 22.18, ESM, zero dependencies. Behaviour-identical port of
6
+ * group_pack.py: same args, exit codes, stdout and output files.)
7
+ *
8
+ * Measured on a 14-group run, an agent spent ~28% of its turns *discovering* inputs
9
+ * rather than converting: globbing for the Fragment/layout/style files of its own
10
+ * group (14%), and grepping color.json / string.json / media/ one name at a time to
11
+ * see whether a resource exists in the Harmony project (14%, one dump of a 51 KB
12
+ * string.json). Every one of those answers is a pure function of the Android tree,
13
+ * resource_mapping.md and the Harmony resources -- the same for every agent.
14
+ *
15
+ * This script resolves them per group and writes <out>/<GID>.md:
16
+ *
17
+ * * Source files, by relation: the member classes (meta.json `declared_at`), their
18
+ * base-class chain, the layouts / pref XMLs / menus they reference (R.layout.x,
19
+ * FooBinding, R.xml.x, R.menu.x, `<include>`), custom views used in those layouts,
20
+ * and their in-project UI imports (dialogs, adapters, views...). Absolute paths
21
+ * and line counts, so the agent issues one batched read.
22
+ * * Style references -> the file:line that defines them.
23
+ * * Resource table: every R.x.y / @x/y the group's files use -> its Harmony target
24
+ * from resource_mapping.md, whether it exists on disk, and its value (string /
25
+ * colour incl. dark / float), so no agent greps the resource JSON.
26
+ *
27
+ * Nothing here is a conclusion: it is a reading list plus lookups. The agent still
28
+ * reads the files and still owns every decision; a file the pack missed is read as
29
+ * before.
30
+ *
31
+ * group_pack.mjs build <harmony_dir> --android <android_dir> [--groups G001,G002]
32
+ * group_pack.mjs lookup <harmony_dir> --android <android_dir> string/foo color/bar ...
33
+ */
34
+
35
+ import * as fs from 'node:fs';
36
+ import * as path from 'node:path';
37
+ import { fileURLToPath, pathToFileURL } from 'node:url';
38
+
39
+ /** A doc heading / evidence name quoted the way the docs quote it: 「name」 in zh, "name" in en. */
40
+ const quoteName = (s) => (`"${s}"`);
41
+
42
+ const DOC = `Per-group source + resource pack: the files a conversion agent must read, found once.
43
+
44
+ Measured on a 14-group run, an agent spent ~28% of its turns *discovering* inputs
45
+ rather than converting: globbing for the Fragment/layout/style files of its own
46
+ group (14%), and grepping color.json / string.json / media/ one name at a time to
47
+ see whether a resource exists in the Harmony project (14%, one dump of a 51 KB
48
+ string.json). Every one of those answers is a pure function of the Android tree,
49
+ resource_mapping.md and the Harmony resources -- the same for every agent.
50
+
51
+ This script resolves them per group and writes <out>/<GID>.md:
52
+
53
+ * Source files, by relation: the member classes (meta.json \`declared_at\`), their
54
+ base-class chain, the layouts / pref XMLs / menus they reference (R.layout.x,
55
+ FooBinding, R.xml.x, R.menu.x, \`<include>\`), custom views used in those layouts,
56
+ and their in-project UI imports (dialogs, adapters, views...). Absolute paths
57
+ and line counts, so the agent issues one batched read.
58
+ * Style references -> the file:line that defines them.
59
+ * Resource table: every R.x.y / @x/y the group's files use -> its Harmony target
60
+ from resource_mapping.md, whether it exists on disk, and its value (string /
61
+ colour incl. dark / float), so no agent greps the resource JSON.
62
+
63
+ Nothing here is a conclusion: it is a reading list plus lookups. The agent still
64
+ reads the files and still owns every decision; a file the pack missed is read as
65
+ before.
66
+
67
+ group_pack.mjs build <harmony_dir> --android <android_dir> [--groups G001,G002]
68
+ group_pack.mjs lookup <harmony_dir> --android <android_dir> string/foo color/bar ...
69
+ `;
70
+
71
+ // ---------------------------------------------------------------- Python compat
72
+ // Outputs are a contract read by other scripts and agents: byte-identical to the
73
+ // Python version (json.dumps(indent=1, ensure_ascii=False), CRLF text writes on
74
+ // Windows, pathlib semantics, Python sort/regex semantics).
75
+
76
+ const IS_WIN = process.platform === 'win32';
77
+ const EOL = IS_WIN ? '\r\n' : '\n';
78
+
79
+ /** A float from json.loads: written back with Python repr. */
80
+ export class PyFloat {
81
+ constructor(value) { this.value = value; }
82
+ valueOf() { return this.value; }
83
+ }
84
+
85
+ const KEY_ORDER = Symbol('pyKeyOrder');
86
+ const INDEX_KEY = /^(?:0|[1-9][0-9]*)$/;
87
+
88
+ function floatRepr(x, json) {
89
+ if (!Number.isFinite(x)) {
90
+ if (Number.isNaN(x)) { return json ? 'NaN' : 'nan'; }
91
+ return x > 0 ? (json ? 'Infinity' : 'inf') : (json ? '-Infinity' : '-inf');
92
+ }
93
+ if (x === 0) { return Object.is(x, -0) ? '-0.0' : '0.0'; }
94
+ const [m, e] = Math.abs(x).toExponential().split('e');
95
+ const digits = m.replace('.', '');
96
+ const exp = Number(e);
97
+ let s;
98
+ if (exp >= -4 && exp < 16) {
99
+ if (exp >= 0) {
100
+ const ip = digits.slice(0, exp + 1).padEnd(exp + 1, '0');
101
+ s = ip + '.' + (digits.slice(exp + 1) || '0');
102
+ } else {
103
+ s = '0.' + '0'.repeat(-exp - 1) + digits;
104
+ }
105
+ } else {
106
+ s = digits[0] + (digits.length > 1 ? '.' + digits.slice(1) : '') + 'e' + (exp < 0 ? '-' : '+') +
107
+ String(Math.abs(exp)).padStart(2, '0');
108
+ }
109
+ return (x < 0 ? '-' : '') + s;
110
+ }
111
+
112
+ /** json.loads: floats -> PyFloat, unsafe ints -> BigInt, key order kept. */
113
+ function pyJsonLoads(text) {
114
+ let i = 0;
115
+ const n = text.length;
116
+ const fail = (msg) => { throw new SyntaxError(`${msg}: char ${i}`); };
117
+ const ws = () => {
118
+ while (i < n) {
119
+ const c = text.charCodeAt(i);
120
+ if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d) { i++; } else { break; }
121
+ }
122
+ };
123
+ const NUM = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/y;
124
+ const str = () => {
125
+ i++;
126
+ let out = '';
127
+ let start = i;
128
+ for (;;) {
129
+ if (i >= n) { fail('Unterminated string'); }
130
+ const c = text.charCodeAt(i);
131
+ if (c === 0x22) { out += text.slice(start, i); i++; return out; }
132
+ if (c < 0x20) { fail('Invalid control character'); }
133
+ if (c === 0x5c) {
134
+ out += text.slice(start, i);
135
+ const esc = text[i + 1];
136
+ const simple = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }[esc];
137
+ if (simple !== undefined) {
138
+ out += simple;
139
+ i += 2;
140
+ } else if (esc === 'u') {
141
+ const hex = text.slice(i + 2, i + 6);
142
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) { fail('Invalid \\uXXXX escape'); }
143
+ out += String.fromCharCode(parseInt(hex, 16));
144
+ i += 6;
145
+ } else {
146
+ fail('Invalid \\escape');
147
+ }
148
+ start = i;
149
+ continue;
150
+ }
151
+ i++;
152
+ }
153
+ };
154
+ const value = () => {
155
+ ws();
156
+ const c = text[i];
157
+ if (c === '{') {
158
+ i++;
159
+ const o = {};
160
+ const order = [];
161
+ let hasIndex = false;
162
+ ws();
163
+ if (text[i] === '}') { i++; return o; }
164
+ for (;;) {
165
+ ws();
166
+ if (text[i] !== '"') { fail('Expecting property name enclosed in double quotes'); }
167
+ const k = str();
168
+ ws();
169
+ if (text[i] !== ':') { fail("Expecting ':' delimiter"); }
170
+ i++;
171
+ const v = value();
172
+ if (!Object.hasOwn(o, k)) {
173
+ order.push(k);
174
+ if (INDEX_KEY.test(k)) { hasIndex = true; }
175
+ }
176
+ if (k === '__proto__') {
177
+ Object.defineProperty(o, k, { value: v, enumerable: true, writable: true, configurable: true });
178
+ } else {
179
+ o[k] = v;
180
+ }
181
+ ws();
182
+ if (text[i] === ',') { i++; continue; }
183
+ if (text[i] === '}') { i++; break; }
184
+ fail("Expecting ',' delimiter");
185
+ }
186
+ if (hasIndex) { o[KEY_ORDER] = order; }
187
+ return o;
188
+ }
189
+ if (c === '[') {
190
+ i++;
191
+ const a = [];
192
+ ws();
193
+ if (text[i] === ']') { i++; return a; }
194
+ for (;;) {
195
+ a.push(value());
196
+ ws();
197
+ if (text[i] === ',') { i++; continue; }
198
+ if (text[i] === ']') { i++; break; }
199
+ fail("Expecting ',' delimiter");
200
+ }
201
+ return a;
202
+ }
203
+ if (c === '"') { return str(); }
204
+ if (text.startsWith('null', i)) { i += 4; return null; }
205
+ if (text.startsWith('true', i)) { i += 4; return true; }
206
+ if (text.startsWith('false', i)) { i += 5; return false; }
207
+ if (text.startsWith('NaN', i)) { i += 3; return new PyFloat(NaN); }
208
+ if (text.startsWith('Infinity', i)) { i += 8; return new PyFloat(Infinity); }
209
+ if (text.startsWith('-Infinity', i)) { i += 9; return new PyFloat(-Infinity); }
210
+ NUM.lastIndex = i;
211
+ const m = NUM.exec(text);
212
+ if (!m) { fail('Expecting value'); }
213
+ i += m[0].length;
214
+ if (m[1] !== undefined || m[2] !== undefined) { return new PyFloat(Number(m[0])); }
215
+ const num = Number(m[0]);
216
+ return Number.isSafeInteger(num) ? (num === 0 ? 0 : num) : BigInt(m[0]);
217
+ };
218
+ const v = value();
219
+ ws();
220
+ if (i !== n) { fail('Extra data'); }
221
+ return v;
222
+ }
223
+
224
+ function keysOf(o) {
225
+ const ks = Object.keys(o);
226
+ const ord = o[KEY_ORDER];
227
+ if (!ord) { return ks; }
228
+ const present = new Set(ks);
229
+ const out = ord.filter((k) => present.has(k));
230
+ const seen = new Set(out);
231
+ for (const k of ks) { if (!seen.has(k)) { out.push(k); } }
232
+ return out;
233
+ }
234
+
235
+ /** json.dumps key coercion for a Map key (str / int / float / bool / None). */
236
+ function jsonKey(k) {
237
+ if (typeof k === 'string') { return k; }
238
+ if (k === null || k === undefined) { return 'null'; }
239
+ if (k === true) { return 'true'; }
240
+ if (k === false) { return 'false'; }
241
+ if (k instanceof PyFloat) { return floatRepr(k.value, true); }
242
+ if (typeof k === 'number' || typeof k === 'bigint') { return String(k); }
243
+ throw new TypeError(`keys must be str, int, float, bool or None, not ${pyType(k)}`);
244
+ }
245
+
246
+ /** json.dumps(v, ensure_ascii=False, indent=indent); a Map is a dict in insertion order. */
247
+ function pyJsonDumps(v, indent, level = 0) {
248
+ if (v === null || v === undefined) { return 'null'; }
249
+ if (v === true) { return 'true'; }
250
+ if (v === false) { return 'false'; }
251
+ if (typeof v === 'bigint') { return v.toString(); }
252
+ if (v instanceof PyFloat) { return floatRepr(v.value, true); }
253
+ if (typeof v === 'number') { return Number.isInteger(v) ? (Object.is(v, -0) ? '0' : String(v)) : floatRepr(v, true); }
254
+ if (typeof v === 'string') { return JSON.stringify(v); }
255
+ const pad = '\n' + ' '.repeat(indent * (level + 1));
256
+ const end = '\n' + ' '.repeat(indent * level);
257
+ if (Array.isArray(v)) {
258
+ if (v.length === 0) { return '[]'; }
259
+ return '[' + pad + v.map((x) => pyJsonDumps(x, indent, level + 1)).join(',' + pad) + end + ']';
260
+ }
261
+ const entries = v instanceof Map ? [...v].map(([k, x]) => [jsonKey(k), x]) : keysOf(v).map((k) => [k, v[k]]);
262
+ if (entries.length === 0) { return '{}'; }
263
+ return '{' + pad + entries.map(([k, x]) => JSON.stringify(k) + ': ' + pyJsonDumps(x, indent, level + 1))
264
+ .join(',' + pad) + end + '}';
265
+ }
266
+
267
+ function pyType(v) {
268
+ if (v === null || v === undefined) { return 'NoneType'; }
269
+ if (typeof v === 'boolean') { return 'bool'; }
270
+ if (typeof v === 'number') { return Number.isInteger(v) ? 'int' : 'float'; }
271
+ if (typeof v === 'bigint') { return 'int'; }
272
+ if (v instanceof PyFloat) { return 'float'; }
273
+ if (typeof v === 'string') { return 'str'; }
274
+ if (Array.isArray(v)) { return 'list'; }
275
+ return 'dict';
276
+ }
277
+
278
+ const isDict = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) && !(v instanceof PyFloat);
279
+
280
+ function truthy(v) {
281
+ if (v === null || v === undefined || v === false) { return false; }
282
+ if (v === true) { return true; }
283
+ if (typeof v === 'number') { return v !== 0; }
284
+ if (typeof v === 'bigint') { return v !== 0n; }
285
+ if (v instanceof PyFloat) { return v.value !== 0; }
286
+ if (typeof v === 'string' || Array.isArray(v)) { return v.length > 0; }
287
+ if (v instanceof Map || v instanceof Set) { return v.size > 0; }
288
+ return Object.keys(v).length > 0;
289
+ }
290
+
291
+ /** `a or b`. */
292
+ const or = (a, b) => (truthy(a) ? a : b);
293
+
294
+ /** d.get(k, default) on a json value: AttributeError unless it is a dict. */
295
+ function dget(d, k, dflt = null) {
296
+ if (!isDict(d)) { throw new TypeError(`'${pyType(d)}' object has no attribute 'get'`); }
297
+ return Object.hasOwn(d, k) ? d[k] : dflt;
298
+ }
299
+
300
+ /** d[k]. */
301
+ function dsub(d, k) {
302
+ if (typeof d === 'string' || Array.isArray(d)) { throw new TypeError(`${pyType(d)} indices must be integers`); }
303
+ if (!isDict(d)) { throw new TypeError(`'${pyType(d)}' object is not subscriptable`); }
304
+ if (!Object.hasOwn(d, k)) { throw new Error(`KeyError: '${k}'`); }
305
+ return d[k];
306
+ }
307
+
308
+ /** `for x in v` over a json value. */
309
+ function pyIter(v) {
310
+ if (Array.isArray(v)) { return v; }
311
+ if (typeof v === 'string') { return [...v]; }
312
+ if (isDict(v)) { return keysOf(v); }
313
+ throw new TypeError(`'${pyType(v)}' object is not iterable`);
314
+ }
315
+
316
+ function cmpStr(a, b) {
317
+ if (!/[\uD800-\uDFFF]/.test(a) && !/[\uD800-\uDFFF]/.test(b)) { return a < b ? -1 : a > b ? 1 : 0; }
318
+ const x = [...a];
319
+ const y = [...b];
320
+ for (let i = 0; i < Math.min(x.length, y.length); i++) {
321
+ const d = x[i].codePointAt(0) - y[i].codePointAt(0);
322
+ if (d !== 0) { return d < 0 ? -1 : 1; }
323
+ }
324
+ return x.length < y.length ? -1 : x.length > y.length ? 1 : 0;
325
+ }
326
+
327
+ /** Python `<` for sort keys: bool/int as numbers, str by code point, arrays element-wise. */
328
+ function pyCmp(a, b) {
329
+ const na = typeof a === 'boolean' ? Number(a) : a;
330
+ const nb = typeof b === 'boolean' ? Number(b) : b;
331
+ if (typeof na === 'number' && typeof nb === 'number') { return na < nb ? -1 : na > nb ? 1 : 0; }
332
+ if (typeof a === 'string' && typeof b === 'string') { return cmpStr(a, b); }
333
+ if (Array.isArray(a) && Array.isArray(b)) {
334
+ for (let i = 0; i < Math.min(a.length, b.length); i++) {
335
+ const c = pyCmp(a[i], b[i]);
336
+ if (c !== 0) { return c; }
337
+ }
338
+ return a.length < b.length ? -1 : a.length > b.length ? 1 : 0;
339
+ }
340
+ throw new TypeError(`'<' not supported between instances of '${pyType(a)}' and '${pyType(b)}'`);
341
+ }
342
+
343
+ /** sorted(items, key=key): stable. */
344
+ function sortedBy(items, key = (x) => x) {
345
+ const dec = [...items].map((v, i) => [key(v), i, v]);
346
+ dec.sort((p, q) => pyCmp(p[0], q[0]) || p[1] - q[1]);
347
+ return dec.map((d) => d[2]);
348
+ }
349
+
350
+ const NON_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
351
+
352
+ function strRepr(s) {
353
+ const q = s.includes("'") && !s.includes('"') ? '"' : "'";
354
+ let r = q;
355
+ for (const ch of s) {
356
+ const cp = ch.codePointAt(0);
357
+ if (ch === q || ch === '\\') { r += '\\' + ch; }
358
+ else if (ch === '\t') { r += '\\t'; }
359
+ else if (ch === '\n') { r += '\\n'; }
360
+ else if (ch === '\r') { r += '\\r'; }
361
+ else if (ch !== ' ' && NON_PRINTABLE.test(ch)) {
362
+ r += cp < 0x100 ? '\\x' + cp.toString(16).padStart(2, '0')
363
+ : cp < 0x10000 ? '\\u' + cp.toString(16).padStart(4, '0') : '\\U' + cp.toString(16).padStart(8, '0');
364
+ } else { r += ch; }
365
+ }
366
+ return r + q;
367
+ }
368
+
369
+ function pyRepr(v) {
370
+ if (v === null || v === undefined) { return 'None'; }
371
+ if (v === true) { return 'True'; }
372
+ if (v === false) { return 'False'; }
373
+ if (typeof v === 'bigint') { return v.toString(); }
374
+ if (v instanceof PyFloat) { return floatRepr(v.value, false); }
375
+ if (typeof v === 'number') { return Number.isInteger(v) ? String(v === 0 ? 0 : v) : floatRepr(v, false); }
376
+ if (typeof v === 'string') { return strRepr(v); }
377
+ if (Array.isArray(v)) { return '[' + v.map(pyRepr).join(', ') + ']'; }
378
+ return '{' + keysOf(v).map((k) => strRepr(k) + ': ' + pyRepr(v[k])).join(', ') + '}';
379
+ }
380
+
381
+ /** str(v) / f"{v}". */
382
+ const pyStr = (v) => (typeof v === 'string' ? v : pyRepr(v));
383
+
384
+ /** Python str.isspace() characters (for \s and strip()). */
385
+ const SP = '\\t\\n\\v\\f\\r\\x1c-\\x20\\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000';
386
+ const pyStrip = (s) => s.replace(new RegExp(`^[${SP}]+|[${SP}]+$`, 'gu'), '');
387
+
388
+ const LINE_BREAK = new RegExp('\\r\\n|[\\n\\r\\v\\f\\x1c\\x1d\\x1e\\x85\\u2028\\u2029]');
389
+
390
+ /** str.splitlines(). */
391
+ function splitlines(s) {
392
+ if (s === '') { return []; }
393
+ const parts = s.split(LINE_BREAK);
394
+ if (parts[parts.length - 1] === '') { parts.pop(); }
395
+ return parts;
396
+ }
397
+
398
+ const READ = new TextDecoder('utf-8', { fatal: false, ignoreBOM: true });
399
+ const STRICT = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
400
+
401
+ /** Path.read_text(encoding="utf-8", errors="replace"), "" on OSError. */
402
+ function _read(p) {
403
+ let buf;
404
+ try { buf = fs.readFileSync(p); } catch { return ''; }
405
+ return READ.decode(buf).replace(/\r\n?/g, '\n');
406
+ }
407
+
408
+ function _load(p, dflt = null) {
409
+ return isFile(p) ? pyJsonLoads(STRICT.decode(fs.readFileSync(p)).replace(/\r\n?/g, '\n')) : dflt;
410
+ }
411
+
412
+ function isFile(p) {
413
+ try { return fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false; } catch { return false; }
414
+ }
415
+ function isDir(p) {
416
+ try { return fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false; } catch { return false; }
417
+ }
418
+
419
+ // ---------------------------------------------------------------- paths (pathlib semantics)
420
+ // A path is a normalised string (str(Path(x))); equality / dict keys are case-folded on Windows.
421
+
422
+ const SEP = IS_WIN ? '\\' : '/';
423
+
424
+ function splitPath(p) {
425
+ if (IS_WIN) {
426
+ const s = String(p).replace(/\//g, '\\');
427
+ let drive = '';
428
+ let rest = s;
429
+ const unc = /^\\\\([^\\]+)\\([^\\]+)/.exec(s);
430
+ if (unc) { drive = unc[0]; rest = s.slice(drive.length); }
431
+ else if (/^[A-Za-z]:/.test(s)) { drive = s.slice(0, 2); rest = s.slice(2); }
432
+ const root = rest.startsWith('\\') ? '\\' : '';
433
+ return { drive, root, parts: rest.split('\\').filter((x) => x !== '' && x !== '.') };
434
+ }
435
+ const s = String(p);
436
+ const root = s.startsWith('//') && !s.startsWith('///') ? '//' : s.startsWith('/') ? '/' : '';
437
+ return { drive: '', root, parts: s.split('/').filter((x) => x !== '' && x !== '.') };
438
+ }
439
+
440
+ const fmt = ({ drive, root, parts }) => drive + root + parts.join(SEP) || '.';
441
+
442
+ /** str(Path(p)). */
443
+ export const pathStr = (p) => fmt(splitPath(p));
444
+
445
+ /** Path(a) / b / c ... */
446
+ function pJoin(a, ...segs) {
447
+ let cur = splitPath(a);
448
+ for (const s of segs) {
449
+ const n = splitPath(s);
450
+ if (n.root || (n.drive && n.drive.toLowerCase() !== cur.drive.toLowerCase())) {
451
+ cur = { drive: n.drive || cur.drive, root: n.root, parts: n.parts };
452
+ } else if (n.drive) {
453
+ cur = { drive: n.drive, root: cur.root, parts: [...cur.parts, ...n.parts] };
454
+ } else {
455
+ cur = { ...cur, parts: [...cur.parts, ...n.parts] };
456
+ }
457
+ }
458
+ return fmt(cur);
459
+ }
460
+
461
+ /** Path.parts. */
462
+ function pParts(p) {
463
+ const s = splitPath(p);
464
+ return s.drive || s.root ? [s.drive + s.root, ...s.parts] : s.parts;
465
+ }
466
+ const pName = (p) => { const s = splitPath(p).parts; return s.length ? s[s.length - 1] : ''; };
467
+ function pSuffix(p) {
468
+ const n = pName(p);
469
+ const i = n.lastIndexOf('.');
470
+ return i > 0 && i < n.length - 1 ? n.slice(i) : '';
471
+ }
472
+ const pStem = (p) => { const n = pName(p); const x = pSuffix(p); return x ? n.slice(0, -x.length) : n; };
473
+ function pParent(p) {
474
+ const s = splitPath(p);
475
+ return s.parts.length ? fmt({ ...s, parts: s.parts.slice(0, -1) }) : fmt(s);
476
+ }
477
+ /** Key for path equality / hashing. */
478
+ const pKey = (p) => (IS_WIN ? pathStr(p).toLowerCase() : pathStr(p));
479
+ /** PurePath `<` order. */
480
+ const pOrder = (p) => (IS_WIN ? pathStr(p).toLowerCase().split('\\') : pathStr(p).split('/'));
481
+
482
+ /** Entries of a directory in os.scandir order (no sort). Throws on OSError. */
483
+ function listDir(d) {
484
+ const names = [];
485
+ const h = fs.opendirSync(d);
486
+ try {
487
+ for (let e = h.readSync(); e !== null; e = h.readSync()) { names.push(e.name); }
488
+ } finally { h.closeSync(); }
489
+ return names.map((nm) => pJoin(d, nm));
490
+ }
491
+
492
+ /** Path(d).glob("*.<ext>"): scandir order, case-insensitive on Windows, [] when missing. */
493
+ function globExt(d, ext) {
494
+ let all;
495
+ try { all = listDir(d); } catch { return []; }
496
+ return all.filter((p) => (IS_WIN ? pName(p).toLowerCase().endsWith(ext.toLowerCase()) : pName(p).endsWith(ext)));
497
+ }
498
+
499
+ // ---------------------------------------------------------------- patterns
500
+ // Python `re` (str patterns) is Unicode-aware: \w = alnum + "_", \b is built on
501
+ // that \w, \s = str.isspace(), \d = Nd. Spelled out here so the 'u' JS regexes
502
+ // match exactly what the Python ones did. re.M `^`/`$` only treat "\n" as a line
503
+ // break (JS's 'm' also breaks on CR, LS and PS), hence the explicit anchors.
504
+
505
+ const W = '[\\p{L}\\p{N}_]';
506
+ const WC = '\\p{L}\\p{N}_';
507
+ const B = `(?:(?<=${W})(?!${W})|(?<!${W})(?=${W}))`;
508
+ const S = `[${SP}]`;
509
+ const NS = `[^${SP}]`;
510
+ const BOL = '(?<![^\\n])';
511
+ const EOLA = '(?![^\\n])';
512
+ const KINDS_R = 'layout|xml|menu|string|color|drawable|mipmap|dimen|style|plurals|array|integer|bool|font|raw|anim';
513
+
514
+ export const SKIP_DIRS = new Set(['build', '.git', '.gradle', '.idea', 'node_modules', '.cxx', 'intermediates']);
515
+ export const SRC_EXT = ['.java', '.kt'];
516
+ export const UI_SUFFIX = new RegExp('(Dialog|Fragment|Activity|View|Adapter|ViewHolder|Holder|Layout|' +
517
+ 'Preference|Sheet|Menu|Handler|Item|Row|Bar|Button|Widget)$', 'u');
518
+ export const R_REF = new RegExp(`${B}R\\.(${KINDS_R})\\.(${W}+)`, 'gu');
519
+ export const X_REF = new RegExp(`@(${KINDS_R})/([${WC}.]+)`, 'gu');
520
+ export const BINDING = new RegExp(`${B}([A-Z]${W}*?)Binding${B}`, 'gu');
521
+ export const IMPORT = new RegExp(`${BOL}${S}*import${S}+(?:static${S}+)?([${WC}.]+?)(?:\\.\\*)?${S}*;?${S}*${EOLA}`, 'gu');
522
+ export const EXTENDS_JAVA = new RegExp(`${B}class${S}+(${W}+)(?:<[^>{]*>)?${S}+extends${S}+([${WC}.]+)`, 'u');
523
+ export const EXTENDS_KT = new RegExp(`${B}class${S}+(${W}+)[^:{]*:${S}*([${WC}.]+)${S}*\\(`, 'u');
524
+ export const ASSET_LIT = new RegExp(`"([${WC}./-]+\\.(?:csv|json|txt|xml|html|md))"`, 'gu');
525
+ export const CLASS_TOKEN = new RegExp(`${B}([A-Z]${W}+)${B}`, 'gu');
526
+ export const CUSTOM_TAG = new RegExp(`<([a-z]${W}*(?:\\.${W}+)+)[${SP}>/]`, 'gu');
527
+ export const FILE_TYPES = new Set(['layout', 'xml', 'menu', 'drawable', 'mipmap', 'font', 'raw', 'anim']);
528
+ export const VALUE_JSON = new Map([['string', 'string'], ['color', 'color'], ['dimen', 'float'], ['integer', 'integer'],
529
+ ['bool', 'boolean'], ['plurals', 'plural']]);
530
+ export const TABLE_TYPES = ['string', 'plurals', 'color', 'dimen', 'integer', 'bool', 'drawable', 'mipmap',
531
+ 'array', 'font', 'raw'];
532
+ export const MAX_RELATED = 30;
533
+ export const MAPPINGS = path.join(path.dirname(path.dirname(fs.realpathSync.native(fileURLToPath(import.meta.url)))),
534
+ 'references', 'mappings');
535
+ export const CARDS = path.join(path.dirname(MAPPINGS), 'cards');
536
+ /** Knowledge cards every group reads (conversion-procedure.md Phase 3.1); `canvas` / `state-v1` are conditional. */
537
+ export const ALWAYS_CARDS = ['geometry', 'alignment', 'window', 'widgets', 'resources', 'dynamics', 'state', 'build'];
538
+ export const CUSTOM_DRAW = /\b(onDraw|dispatchDraw)\s*\(|\bCanvas\s*\(|\bdrawBehind\b|\bdrawWithContent\b|\bdrawWithCache\b|\bPath\s*\(\s*\)/;
539
+ export const XML_TAG = new RegExp(`<([A-Za-z][${WC}.]*)[${SP}>/]`, 'gu');
540
+ export const LISTENER = new RegExp(`${B}(?:set|add)?On(${W}+?)(?:Change)?Listener${B}`, 'gu');
541
+ export const HEADING = new RegExp(`^(#{2,4})${S}+(.*${NS})${S}*$`, 'u');
542
+ export const ASCII_WORD = /[A-Za-z][A-Za-z0-9]+/g;
543
+ // Heading words that name a category, not a widget: never a match on their own.
544
+ export const GENERIC = new Set(['Android', 'HarmonyOS', 'API', 'UI', 'Mapping', 'Reference', 'View', 'Layout', 'Text',
545
+ 'Image', 'Button', 'Event', 'Events', 'New', 'vs', 'and', 'or', 'the']);
546
+ const VIEW_CLASS = new RegExp(`class="([${WC}.$]+)"`, 'gu');
547
+ const EMBEDDED = new RegExp(`(?:android:name|android:fragment|app:fragment)="([${WC}.]+)"`, 'gu');
548
+ const R_LAYOUT = new RegExp(`${B}R\\.layout\\.(${W}+)`, 'gu');
549
+ const MAP_KEY = new RegExp(`#(${W}+)/(.+)$`, 'u');
550
+ const STRIP_LINE = /:\p{Nd}+(?=\n?$)/gu;
551
+ const UPPER = /^\p{Uppercase}$/u;
552
+
553
+ /** re.findall: the group (1 group) or the tuple of groups. */
554
+ function findall(re, text) {
555
+ return [...text.matchAll(re)].map((m) => (m.length === 2 ? m[1] : m.slice(1)));
556
+ }
557
+ /** set(xs) iterated: first-occurrence order. */
558
+ const uniq = (xs) => [...new Set(xs)];
559
+ const last = (xs) => xs[xs.length - 1];
560
+ const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, '\\$&');
561
+
562
+ export function mappingSections(root = MAPPINGS) {
563
+ // [(file, start, end, level, heading, words)] for every ##..#### heading.
564
+ const out = [];
565
+ for (const f of sortedBy(globExt(pathStr(root), '.md'), pOrder)) {
566
+ const lines = splitlines(_read(f));
567
+ const heads = [];
568
+ lines.forEach((l, i) => { const m = HEADING.exec(l); if (m) { heads.push([i + 1, m[1].length, m[2]]); } });
569
+ heads.forEach(([i, lvl, h], k) => {
570
+ const nx = heads.slice(k + 1).find(([, l2]) => l2 <= lvl);
571
+ const end = nx ? nx[0] - 1 : lines.length;
572
+ const words = new Set((h.split('→')[0].match(ASCII_WORD) || [])
573
+ .filter((w) => !GENERIC.has(w) && !(EN_PROSE.has(w) && !HAN.test(h))));
574
+ out.push([f, i, end, lvl, h, words]);
575
+ });
576
+ }
577
+ return out;
578
+ }
579
+
580
+ export function usedNames(pack, uiInfo, group) {
581
+ // Widget class short names (layout tags, captured view trees) and listener
582
+ // kinds (setOnClickListener -> Click) the group's own files use.
583
+ const names = new Set();
584
+ for (const [p, rel] of pack.files.values()) {
585
+ if (rel === 'related') { continue; }
586
+ const text = _read(p);
587
+ if (pSuffix(p) === '.xml') {
588
+ for (const t of findall(XML_TAG, text)) { names.add(last(t.split('.'))); }
589
+ } else {
590
+ for (const t of findall(LISTENER, text)) { names.add(t); }
591
+ for (const t of findall(CLASS_TOKEN, text)) {
592
+ if (['View', 'Layout', 'Bar', 'Sheet', 'Dialog', 'Pager'].some((x) => t.endsWith(x))) { names.add(t); }
593
+ }
594
+ }
595
+ }
596
+ for (const d of pyIter(or(dget(group, 'page_dirs'), []))) {
597
+ const vx = pJoin(uiInfo, d, 'view.xml');
598
+ if (isFile(vx)) {
599
+ for (const c of findall(VIEW_CLASS, _read(vx))) { names.add(last(c.split('.'))); }
600
+ }
601
+ }
602
+ return names;
603
+ }
604
+
605
+ // The interaction reference titles its sections in Chinese ("Click Gesture", "Swipe Gesture"), its i18n/ copy
606
+ // in English ("Click Gesture", "Swipe Gesture"): an Android signal -> the heading words [zh, en]
607
+ // that name it (i18n/terms.json, area batch-ui-align).
608
+ const SW = {
609
+ click: ['Click', 'Click'], longPress: ['Long Press', 'Long Press'], touch: ['Touch', 'Touch'], swipe: ['Swipe', 'Swipe'],
610
+ drag: ['Drag', 'Drag'], swipeDelete: ['Swipe to Delete', 'Swipe to Delete'], anim: ['Animation', 'Animation'],
611
+ propAnim: ['Property Animation', 'Property Animation'], animListener: ['Animation Listener', 'Animation Listener'],
612
+ focus: ['Focus', 'Focus'], keyboard: ['Keyboard', 'Keyboard'],
613
+ };
614
+ export const SIGNAL_WORDS = new Map(Object.entries({
615
+ Click: SW.click, ItemClick: SW.click, LongClick: SW.longPress, ItemLongClick: SW.longPress,
616
+ Touch: SW.touch, Scroll: SW.swipe, Fling: SW.swipe, Swipe: SW.swipe, Drag: SW.drag, Refresh: SW.swipe,
617
+ SwipeRefreshLayout: SW.swipe, MotionLayout: SW.anim, ItemTouchHelper: SW.swipeDelete,
618
+ ObjectAnimator: SW.propAnim, ValueAnimator: SW.propAnim, AnimatorListener: SW.animListener,
619
+ FocusChange: SW.focus, Key: SW.keyboard, EditorAction: SW.keyboard,
620
+ }));
621
+ // In an English heading (no Han: the i18n/ copy) these are translated prose, not widget names: the
622
+ // zh original writes them as Click / Focus / Page / Refresh ..., which never match a used name as a heading
623
+ // word. Dropping them keeps the en copy's index equal to the zh one (signal words still match the
624
+ // interaction sections through SIGNAL_WORDS). `Page` / `Refresh` collide with listener kinds
625
+ // (OnPageChangeListener, OnRefreshListener) in "Page Lifecycle" / "Refresh Layout".
626
+ const EN_PROSE = new Set([...Object.values(SW).flatMap(([, en]) => en.match(ASCII_WORD)), 'Page', 'Refresh']);
627
+ const HAN = /\p{Script=Han}/u;
628
+ export const WHOLE_FILE_BELOW = 12_000; // a reference this small is listed whole
629
+
630
+ const secKey = (s) => [pKey(s[0]), s[1], s[2], s[3], s[4]].join('\u0000');
631
+
632
+ export function mappingIndex(names, sections = null) {
633
+ // Deepest matching section per (file, name): the agent reads exactly those
634
+ // line ranges instead of paging through a 175 KB reference.
635
+ sections = sections ?? mappingSections();
636
+ names = new Set(names);
637
+ const picked = new Map(); // (file, word) -> {f, w, sec}
638
+ for (const [f, a, b, lvl, h, words] of sections) {
639
+ const hit = new Set([...words].filter((w) => names.has(w)));
640
+ if (pName(f).includes('interaction')) {
641
+ // Chinese signal words name interaction sections only; elsewhere
642
+ // "Animation" also titles unrelated sections (Compose animation APIs).
643
+ for (const n of names) { const sw = SIGNAL_WORDS.get(n); if (sw && sw.some((x) => h.includes(x))) { hit.add(n); } }
644
+ }
645
+ for (const w of sortedBy(hit)) {
646
+ const k = pKey(f) + '\u0000' + w;
647
+ const cur = picked.get(k)?.sec;
648
+ if (cur === undefined || lvl > cur[3] || (lvl === cur[3] && a < cur[1])) {
649
+ picked.set(k, { f, w, sec: [f, a, b, lvl, h] });
650
+ }
651
+ }
652
+ }
653
+ const rows = new Map(); // sec -> {sec, ws}
654
+ for (const { w, sec } of picked.values()) {
655
+ const k = secKey(sec);
656
+ if (!rows.has(k)) { rows.set(k, { sec, ws: new Set() }); }
657
+ rows.get(k).ws.add(w);
658
+ }
659
+ // A used class with no section of its own but named in a table row: point
660
+ // at those lines (MotionLayout is a row of the ConstraintLayout tables).
661
+ const files = new Map();
662
+ for (const s of sections) { if (!files.has(pKey(s[0]))) { files.set(pKey(s[0]), s[0]); } }
663
+ for (const f of sortedBy(files.values(), pOrder)) {
664
+ if (fs.statSync(f).size < WHOLE_FILE_BELOW || pName(f).includes('interaction')) { continue; }
665
+ const covered = new Set([...picked.values()].filter((x) => pKey(x.f) === pKey(f)).map((x) => x.w));
666
+ const lines = splitlines(_read(f));
667
+ for (const w of sortedBy([...names].filter((x) => !covered.has(x) && !GENERIC.has(x)))) {
668
+ const cps = [...w];
669
+ if (!(cps.length > 5 && UPPER.test(cps[0]) && cps.slice(1).some((c) => UPPER.test(c)))) {
670
+ continue; // CamelCase class names only, not prose words
671
+ }
672
+ const re = new RegExp(`${B}${reEscape(w)}${B}`, 'u');
673
+ const hits = [];
674
+ lines.forEach((l, i) => { if (re.test(l)) { hits.push(i + 1); } });
675
+ if (hits.length) {
676
+ const sec = [f, hits[0], hits[0], 9, `rows naming ${w}: lines ${hits.slice(0, 6).join(', ')}`];
677
+ rows.set(secKey(sec), { sec, ws: new Set([w]) });
678
+ }
679
+ }
680
+ }
681
+ for (const f of files.values()) {
682
+ if (fs.statSync(f).size < WHOLE_FILE_BELOW) {
683
+ const n = splitlines(_read(f)).length;
684
+ for (const [k, v] of [...rows]) { if (pKey(v.sec[0]) === pKey(f)) { rows.delete(k); } }
685
+ const sec = [f, 1, n, 1, '(whole file — small)'];
686
+ rows.set(secKey(sec), { sec, ws: new Set(['all']) });
687
+ }
688
+ }
689
+ return sortedBy([...rows.values()].map(({ sec, ws }) => [sec, sortedBy(ws)]), (r) => [pathStr(r[0][0]), r[0][1]]);
690
+ }
691
+
692
+ export function snake(camel) {
693
+ return camel.replace(/(?<!^)(?=[A-Z])/g, '_').toLowerCase();
694
+ }
695
+
696
+ // ---------------------------------------------------------------- Android index
697
+
698
+ /** Name -> files for sources and resources, excluding build outputs. */
699
+ export class AndroidIndex {
700
+ constructor(root) {
701
+ this.root = pathStr(root);
702
+ this.by_class = new Map(); // stem -> [path]
703
+ this.by_fqcn = new Map(); // fqcn -> path
704
+ this.res = new Map(); // "kind\0name" -> [path]
705
+ this.values = [];
706
+ this.assets = new Map(); // name -> [path]
707
+ this._defs = new Map();
708
+ for (const p of this._walk(this.root)) {
709
+ const parts = pParts(p);
710
+ const suf = pSuffix(p);
711
+ if (SRC_EXT.includes(suf) && (parts.includes('java') || parts.includes('kotlin'))) {
712
+ if (!this.by_class.has(pStem(p))) { this.by_class.set(pStem(p), []); }
713
+ this.by_class.get(pStem(p)).push(p);
714
+ const k = parts.includes('java') ? 'java' : 'kotlin';
715
+ const rel = parts.slice(parts.lastIndexOf(k) + 1);
716
+ this.by_fqcn.set(rel.join('.').slice(0, -suf.length), p);
717
+ } else if (parts.includes('assets') && parts.includes('src')) {
718
+ if (!this.assets.has(pName(p))) { this.assets.set(pName(p), []); }
719
+ this.assets.get(pName(p)).push(p);
720
+ } else if (parts.length >= 3 && parts[parts.length - 3] === 'res') {
721
+ const kind = parts[parts.length - 2].split('-')[0];
722
+ if (kind === 'values') {
723
+ if (suf === '.xml') { this.values.push(p); }
724
+ } else {
725
+ const key = kind + '\u0000' + pStem(p).split('.')[0];
726
+ if (!this.res.has(key)) { this.res.set(key, []); }
727
+ this.res.get(key).push(p);
728
+ }
729
+ }
730
+ }
731
+ }
732
+
733
+ * _walk(d) {
734
+ let entries;
735
+ try { entries = listDir(d); } catch { return; }
736
+ for (const e of entries) {
737
+ if (isDir(e)) {
738
+ const nm = pName(e);
739
+ if (!SKIP_DIRS.has(nm) && !nm.startsWith('.')) { yield* this._walk(e); }
740
+ } else {
741
+ yield e;
742
+ }
743
+ }
744
+ }
745
+
746
+ /** Prefer src/main and unqualified resource dirs. */
747
+ static _rank(p) {
748
+ const s = pathStr(p).replace(/\\/g, '/');
749
+ return [!s.includes('/src/main/'), pName(pParent(p)).includes('-'), [...s].length];
750
+ }
751
+
752
+ res_file(kind, name) {
753
+ const hits = this.res.get(kind + '\u0000' + name) || [];
754
+ return hits.length ? sortedBy(hits, AndroidIndex._rank)[0] : null;
755
+ }
756
+
757
+ cls(name, imports = [], near = null) {
758
+ if (typeof name !== 'string') { throw new TypeError(`argument of type '${pyType(name)}' is not iterable`); }
759
+ if (name.includes('.') && this.by_fqcn.has(name)) { return this.by_fqcn.get(name); }
760
+ const simple = last(name.split('.'));
761
+ for (const imp of imports) {
762
+ if (imp.endsWith('.' + simple) && this.by_fqcn.has(imp)) { return this.by_fqcn.get(imp); }
763
+ }
764
+ const hits = this.by_class.get(simple) || [];
765
+ if (near !== null) {
766
+ const same = hits.filter((h) => pKey(pParent(h)) === pKey(pParent(near)));
767
+ if (same.length) { return same[0]; }
768
+ }
769
+ return hits.length >= 1 ? sortedBy(hits, AndroidIndex._rank)[0] : null;
770
+ }
771
+
772
+ /** name -> [file, line] of the first `<tag name="...">` in values/*.xml. */
773
+ value_defs(tag) {
774
+ if (!this._defs.has(tag)) {
775
+ const pat = new RegExp(`<${tag}${S}+name="([^"]+)"`, 'u');
776
+ const found = new Map();
777
+ for (const p of sortedBy(this.values, AndroidIndex._rank)) {
778
+ splitlines(_read(p)).forEach((line, i) => {
779
+ const m = pat.exec(line);
780
+ if (m && !found.has(m[1])) { found.set(m[1], [p, i + 1]); }
781
+ });
782
+ }
783
+ this._defs.set(tag, found);
784
+ }
785
+ return this._defs.get(tag);
786
+ }
787
+ }
788
+
789
+ // ---------------------------------------------------------------- Harmony resources
790
+
791
+ /** Key of a (qual, kind, name) value: name keeps its json type (1 != "1"). */
792
+ function valKey(qual, kind, name) {
793
+ if (Array.isArray(name) || isDict(name)) { throw new TypeError(`unhashable type: '${pyType(name)}'`); }
794
+ return [qual, kind, typeof name === 'string' ? 's:' + name : 'o:' + pyRepr(name)].join('\u0000');
795
+ }
796
+
797
+ export class HarmonyRes {
798
+ constructor(harmonyDir, module = 'entry') {
799
+ this.base = pJoin(harmonyDir, module, 'src', 'main', 'resources');
800
+ this.mapping = new Map(); // "kind\0name" -> [[target, kind]]
801
+ const mp = pJoin(harmonyDir, '.hometrans', 'resource_mapping.md');
802
+ if (isFile(mp)) { this._parse_mapping(mp); }
803
+ this.values = new Map();
804
+ for (const qual of ['base', 'zh_CN', 'dark']) {
805
+ for (const f of globExt(pJoin(this.base, qual, 'element'), '.json')) {
806
+ const data = or(_load(f, {}), {});
807
+ if (!isDict(data)) { throw new TypeError(`'${pyType(data)}' object has no attribute 'items'`); }
808
+ for (const kind of keysOf(data)) {
809
+ const rows = data[kind];
810
+ for (const r of Array.isArray(rows) ? rows : []) {
811
+ if (isDict(r) && Object.hasOwn(r, 'name')) {
812
+ this.values.set(valKey(qual, kind, r.name), Object.hasOwn(r, 'value') ? r.value : null);
813
+ }
814
+ }
815
+ }
816
+ }
817
+ }
818
+ }
819
+
820
+ _parse_mapping(p) {
821
+ let inDetail = false;
822
+ for (const line of splitlines(_read(p))) {
823
+ if (line.startsWith('## ')) {
824
+ inDetail = line.includes('Mapping Details') || line.includes('Mapping Details');
825
+ continue;
826
+ }
827
+ if (!inDetail || !line.startsWith('| res/')) { continue; }
828
+ const t = pyStrip(line).replace(/^\|+|\|+$/g, '');
829
+ const cols = t.split('|').map(pyStrip);
830
+ if (cols.length < 6) { continue; }
831
+ const [src, target, kind] = [cols[0], cols[4], cols[5]];
832
+ let key;
833
+ if (src.includes('#')) {
834
+ const m = MAP_KEY.exec(src);
835
+ key = m ? [m[1], m[2]] : null;
836
+ } else {
837
+ key = [pName(pParent(src)).split('-')[0], pStem(src).split('.')[0]];
838
+ }
839
+ if (key) {
840
+ const k = key.join('\u0000');
841
+ if (!this.mapping.has(k)) { this.mapping.set(k, []); }
842
+ this.mapping.get(k).push([target, kind]);
843
+ }
844
+ }
845
+ }
846
+
847
+ value(kind, name) {
848
+ const jk = VALUE_JSON.get(kind);
849
+ if (!jk) { return null; }
850
+ const out = {};
851
+ for (const qual of ['base', 'zh_CN', 'dark']) {
852
+ const v = this.values.get(valKey(qual, jk, name));
853
+ if (v !== undefined && v !== null) { out[qual] = v; }
854
+ }
855
+ return Object.keys(out).length ? out : null;
856
+ }
857
+
858
+ row(kind, name) {
859
+ const targets = this.mapping.get(kind + '\u0000' + name) || [];
860
+ const t0 = targets.find(([t]) => t && t !== 'N/A');
861
+ const tgt = t0 ? t0[0] : null;
862
+ const status = targets.length ? targets[0][1] : 'not in mapping';
863
+ let exists = null;
864
+ if (tgt) {
865
+ const f = tgt.split('#')[0];
866
+ const p = f.startsWith('resources/') ? pJoin(pParent(this.base), f) : pJoin(this.base, f);
867
+ exists = isFile(p) && (!tgt.includes('#') || this.value(kind, name) !== null || !VALUE_JSON.has(kind));
868
+ }
869
+ const hname = tgt && tgt.includes('#') ? last(tgt.split('#')) : (tgt ? pStem(tgt) : null);
870
+ let ref = null;
871
+ if (tgt && tgt.includes('#')) {
872
+ ref = `app.${pStem(tgt.split('#')[0])}.${hname}`; // element/string.json#x
873
+ } else if (tgt && tgt.includes('/media/')) {
874
+ ref = `app.media.${hname}`;
875
+ } else if (tgt && tgt.includes('/rawfile/')) {
876
+ ref = 'rawfile ' + tgt.slice(tgt.indexOf('/rawfile/') + '/rawfile/'.length);
877
+ }
878
+ return { android: `${kind}/${name}`, harmony: tgt, ref: ref || tgt,
879
+ status, exists, value: this.value(kind, hname || name) };
880
+ }
881
+ }
882
+
883
+ // ---------------------------------------------------------------- pack
884
+
885
+ export class Pack {
886
+ constructor(idx) {
887
+ this.idx = idx;
888
+ this.files = new Map(); // pKey -> [path, relation, reason]
889
+ this.refs = new Map(); // "kind\0name" -> [kind, name]
890
+ this.styles = new Set();
891
+ this.arrays = new Set();
892
+ this.assets = new Map(); // pKey -> path
893
+ }
894
+
895
+ has(p) { return this.files.has(pKey(p)); }
896
+
897
+ add(p, relation, why) {
898
+ if (p === null || p === undefined) { return false; }
899
+ p = pathStr(p);
900
+ if (this.files.has(pKey(p))) { return false; }
901
+ this.files.set(pKey(p), [p, relation, why]);
902
+ return true;
903
+ }
904
+
905
+ /** A host Activity contributes its window chrome: itself, its base chain and its own
906
+ * layouts -- not every screen it can show (its R.xml.* are sibling pref screens). */
907
+ scan_host(p, label) {
908
+ if (!this.add(p, 'host', `host activity of ${pyStr(label)}`)) { return; }
909
+ const text = _read(p);
910
+ const names = [...findall(BINDING, text).map(snake), ...findall(R_LAYOUT, text)];
911
+ for (const name of sortedBy(uniq(names))) {
912
+ const lay = this.idx.res_file('layout', name);
913
+ if (lay && this.add(lay, 'host', `layout of ${pName(p)}`)) { this.scan_xml(lay, 'host'); }
914
+ }
915
+ const m = EXTENDS_JAVA.exec(text) || EXTENDS_KT.exec(text);
916
+ const base = m ? this.idx.cls(m[2], findall(IMPORT, text), p) : null;
917
+ if (base !== null && !this.has(base)) { this.scan_host(base, label); }
918
+ }
919
+
920
+ scan_source(p, relation, followBase = true) {
921
+ const text = _read(p);
922
+ const imports = findall(IMPORT, text);
923
+ for (const lit of uniq(findall(ASSET_LIT, text))) {
924
+ for (const a of (this.idx.assets.get(last(lit.split('/'))) || []).slice(0, 1)) {
925
+ if (!this.assets.has(pKey(a))) { this.assets.set(pKey(a), a); }
926
+ }
927
+ }
928
+ for (const [kind, name] of findall(R_REF, text)) { this._ref(kind, name, p, relation); }
929
+ for (const b of uniq(findall(BINDING, text))) {
930
+ const lay = this.idx.res_file('layout', snake(b));
931
+ if (lay && this.add(lay, relation, `${b}Binding in ${pName(p)}`)) { this.scan_xml(lay, relation); }
932
+ }
933
+ if (followBase) {
934
+ const m = EXTENDS_JAVA.exec(text) || EXTENDS_KT.exec(text);
935
+ if (m) {
936
+ const base = this.idx.cls(m[2], imports, p);
937
+ if (base && this.add(base, 'base', `base of ${m[1]}`)) { this.scan_source(base, 'base', true); }
938
+ }
939
+ }
940
+ return imports;
941
+ }
942
+
943
+ _addRef(kind, name) {
944
+ const k = kind + '\u0000' + name;
945
+ if (!this.refs.has(k)) { this.refs.set(k, [kind, name]); }
946
+ }
947
+
948
+ _ref(kind, name, src, relation) {
949
+ if (['layout', 'xml', 'menu'].includes(kind)) {
950
+ const f = this.idx.res_file(kind, name);
951
+ if (f && this.add(f, relation, `R.${kind}.${name} in ${pName(src)}`)) { this.scan_xml(f, relation); }
952
+ } else if (kind === 'style') {
953
+ this.styles.add(name.replace(/_/g, '.'));
954
+ } else {
955
+ if (kind === 'array') { this.arrays.add(name); }
956
+ this._addRef(kind, name);
957
+ }
958
+ }
959
+
960
+ scan_xml(p, relation) {
961
+ const text = _read(p);
962
+ for (const [kind, name] of findall(X_REF, text)) {
963
+ if (['layout', 'xml', 'menu'].includes(kind)) {
964
+ const f = this.idx.res_file(kind, name);
965
+ if (f && this.add(f, relation, `@${kind}/${name} in ${pName(p)}`)) { this.scan_xml(f, relation); }
966
+ } else if (kind === 'style') {
967
+ this.styles.add(name);
968
+ } else {
969
+ if (kind === 'array') { this.arrays.add(name); }
970
+ this._addRef(kind, name);
971
+ }
972
+ }
973
+ for (const tag of uniq(findall(CUSTOM_TAG, text))) {
974
+ if (['android.', 'androidx.', 'com.google.'].some((x) => tag.startsWith(x))) { continue; }
975
+ const c = this.idx.cls(tag);
976
+ if (c && this.add(c, 'custom-view', `<${last(tag.split('.'))}> in ${pName(p)}`)) {
977
+ this.scan_source(c, 'custom-view', false);
978
+ }
979
+ }
980
+ // fragments embedded by layout: <fragment android:name>, FragmentContainerView, prefs
981
+ for (const m of text.matchAll(EMBEDDED)) {
982
+ const c = m[1].includes('.') ? this.idx.cls(m[1]) : null;
983
+ if (c && this.add(c, relation, `embedded fragment in ${pName(p)}`)) { this.scan_source(c, relation, false); }
984
+ }
985
+ }
986
+ }
987
+
988
+ /** pages.json rows by page dir name -> their attached_nodes (where a captured page lists them). */
989
+ function _attachedRows(uiInfo) {
990
+ return new Map(pyIter(or(dget(or(_load(pJoin(uiInfo, 'pages.json'), {}), {}), 'pages'), []))
991
+ .map((p) => [pName(pyStr(dget(p, 'page_dir'))), or(dget(p, 'attached_nodes'), [])]));
992
+ }
993
+
994
+ /** A page dir's attached nodes: in meta.json for a source-only page, in its pages.json row for a captured one. */
995
+ function _attachedOf(meta, rows, dir) {
996
+ return [...pyIter(or(dget(meta, 'attached_nodes'), [])), ...pyIter(rows.get(pName(dir)) ?? [])];
997
+ }
998
+
999
+ function _memberClasses(meta, idx, android, attached = null) {
1000
+ // A page's own sources: its class (declared_at; the activity class when declared_at
1001
+ // is only the manifest), its attached nodes (their classes, layouts and base classes),
1002
+ // its layouts, its extends_base.
1003
+ const out = [];
1004
+ const att = attached ?? pyIter(or(dget(meta, 'attached_nodes'), []));
1005
+ const locs = [dget(meta, 'declared_at'), ...att.map((a) => dget(a, 'declared_at'))];
1006
+ for (const loc of locs) {
1007
+ if (!truthy(loc)) { continue; }
1008
+ if (typeof loc !== 'string') { throw new TypeError('expected string or bytes-like object'); }
1009
+ let p = pJoin(android, loc.replace(STRIP_LINE, ''));
1010
+ if (pName(p) === 'AndroidManifest.xml') {
1011
+ const act = or(dget(or(dget(meta, 'activity_info'), {}), 'activity'), dget(meta, 'label'));
1012
+ p = truthy(act) ? idx.cls(act) : null;
1013
+ } else if (!isFile(p) && SRC_EXT.includes(pSuffix(p))) {
1014
+ p = idx.cls(pStem(p)); // static UTG recorded the class in another module
1015
+ }
1016
+ if (p !== null && isFile(p)) { out.push(p); }
1017
+ }
1018
+ for (const hints of [or(dget(meta, 'source_hints'), {}), ...att]) {
1019
+ for (const lf of pyIter(or(dget(hints, 'layout_files'), []))) {
1020
+ const p = pJoin(android, lf);
1021
+ if (isFile(p)) { out.push(p); }
1022
+ }
1023
+ if (truthy(dget(hints, 'extends_base'))) {
1024
+ const c = idx.cls(dsub(hints, 'extends_base'));
1025
+ if (c) { out.push(c); }
1026
+ }
1027
+ }
1028
+ return out;
1029
+ }
1030
+
1031
+ export function buildGroup(group, uiInfo, idx, hres, android) {
1032
+ const pack = new Pack(idx);
1033
+ const hosts = [];
1034
+ const rows = _attachedRows(uiInfo);
1035
+ for (const d of pyIter(or(dget(group, 'page_dirs'), []))) {
1036
+ const meta = or(_load(pJoin(uiInfo, d, 'meta.json'), {}), {});
1037
+ const label = dget(meta, 'label', d);
1038
+ const members = _memberClasses(meta, idx, android, _attachedOf(meta, rows, pyStr(d)));
1039
+ for (const p of members) {
1040
+ if (pSuffix(p) === '.xml') {
1041
+ if (pack.add(p, 'member', `layout of ${pyStr(label)}`)) { pack.scan_xml(p, 'member'); }
1042
+ } else if (pack.add(p, 'member', `class of ${pyStr(label)}`)) {
1043
+ pack.scan_source(p, 'member');
1044
+ }
1045
+ }
1046
+ // the Activity hosting a fragment/dialog owns its toolbar and window chrome
1047
+ const act = dget(or(dget(meta, 'activity_info'), {}), 'activity');
1048
+ const h = truthy(act) ? idx.cls(act) : null;
1049
+ if (h !== null && !members.some((m) => pKey(m) === pKey(h))) { hosts.push([h, label]); }
1050
+ }
1051
+ for (const [h, label] of hosts) { pack.scan_host(h, label); }
1052
+ // one level of related classes from member/base sources: same-package types the
1053
+ // code names (no import line), and in-project imports that look like UI classes
1054
+ let related = 0;
1055
+ for (const [p, rel] of [...pack.files.values()]) {
1056
+ if (!['member', 'base'].includes(rel) || !SRC_EXT.includes(pSuffix(p))) { continue; }
1057
+ const text = _read(p);
1058
+ const cands = [];
1059
+ for (const tok of sortedBy(uniq(findall(CLASS_TOKEN, text)))) {
1060
+ for (const h of idx.by_class.get(tok) || []) {
1061
+ if (pKey(pParent(h)) === pKey(pParent(p)) && pKey(h) !== pKey(p)) { cands.push([h, `same package, used by ${pName(p)}`]); }
1062
+ }
1063
+ }
1064
+ for (const imp of findall(IMPORT, text)) {
1065
+ if (idx.by_fqcn.has(imp) && UI_SUFFIX.test(last(imp.split('.')))) {
1066
+ cands.push([idx.by_fqcn.get(imp), `imported by ${pName(p)}`]);
1067
+ }
1068
+ }
1069
+ for (const [c, why] of cands) {
1070
+ if (related >= MAX_RELATED) { break; }
1071
+ if (pack.add(c, 'related', why)) {
1072
+ pack.scan_source(c, 'related', false);
1073
+ related += 1;
1074
+ }
1075
+ }
1076
+ }
1077
+ return pack;
1078
+ }
1079
+
1080
+ /**
1081
+ * Inline budget (characters): measured on AntennaPod 10-15 (54 conversion agents), an agent
1082
+ * made a median 52 read/grep calls, about half of its ~52 turns at ~25 s each, and 26% of
1083
+ * its reads re-read a file it had read already. The pack listed most of what it read
1084
+ * (592 of 722 Android reads, 224 slices of the mapping reference) but made the agent fetch
1085
+ * each one. Inlined, the member / base / custom-view sources, the mapping sections and the
1086
+ * style blocks arrive with the pack in one read. Bigger files stay listed: a pack past the
1087
+ * host's read size is read in pages, which costs the turns it was meant to save.
1088
+ */
1089
+ /**
1090
+ * The whole pack must come back from ONE read: opencode / DevEco cap a read at 50 KB
1091
+ * (2000 lines, 2000 chars a line), so a pack past that is read in pages. `pack` bytes
1092
+ * is the cap for the finished file; the inline part gets what the list leaves of it.
1093
+ */
1094
+ export const INLINE = { file: 9000, lines: 220, pack: 48 * 1024, rels: ['member', 'base', 'custom-view'] };
1095
+
1096
+ const fence = (p) => (pSuffix(p) === '.xml' ? 'xml' : pSuffix(p) === '.kt' ? 'kotlin' : 'java');
1097
+
1098
+ /** `text` with line numbers, as the read tool shows it, so citations (`file:line`) still work. */
1099
+ function numbered(text, from = 1) {
1100
+ return splitlines(text).map((l, i) => `${String(from + i).padStart(5)} ${l}`).join('\n');
1101
+ }
1102
+
1103
+ /** Lines a..b (1-based, inclusive) of a file. */
1104
+ function slice(p, a, b) {
1105
+ return splitlines(_read(p)).slice(a - 1, b);
1106
+ }
1107
+
1108
+ /**
1109
+ * The inlined part of a pack: member sources first (they are read anyway), then mapping
1110
+ * sections and style blocks, then base / custom-view sources, until `room` bytes. Returns
1111
+ * {lines, inlined: Set of pKey, chars}; whatever did not fit stays a listed path.
1112
+ */
1113
+ export function inlineBlock(pack, idxRows, styles, room, budget = INLINE) {
1114
+ const inlined = new Set(); let used = 0;
1115
+ const bytes = (s) => Buffer.byteLength(s, 'utf8') + (s.match(/\n/g)?.length ?? 0); // CRLF on disk
1116
+ const take = (chunk) => {
1117
+ const n = bytes(chunk);
1118
+ if (used + n > room) return false;
1119
+ used += n; return true;
1120
+ };
1121
+ const files = [...pack.files.values()].filter(([, r]) => budget.rels.includes(r))
1122
+ .sort((x, y) => budget.rels.indexOf(x[1]) - budget.rels.indexOf(y[1]) || cmpStr(pathStr(x[0]), pathStr(y[0])));
1123
+ const src = [];
1124
+ const addSources = (rels) => {
1125
+ for (const [p, rel] of files) {
1126
+ if (!rels.includes(rel)) continue;
1127
+ const text = _read(p);
1128
+ if (text.length > budget.file || splitlines(text).length > budget.lines) continue;
1129
+ const chunk = `### ${rel}: \`${p}\`\n\n\`\`\`${fence(p)}\n${numbered(text)}\n\`\`\`\n`;
1130
+ if (take(chunk)) { inlined.add(pKey(p)); src.push(chunk); }
1131
+ }
1132
+ };
1133
+ addSources(['member']);
1134
+ const maps = [];
1135
+ for (const [[f, a, b, , h]] of idxRows) {
1136
+ if (b - a + 1 > budget.lines) continue;
1137
+ const chunk = `### ${h} — \`${pName(f)}\` lines ${a}-${b}\n\n${slice(f, a, b).join('\n')}\n`;
1138
+ if (take(chunk)) { inlined.add(`${pKey(f)}#${a}`); maps.push(chunk); }
1139
+ }
1140
+ const sty = [];
1141
+ for (const [name, hit] of styles) {
1142
+ const lines = splitlines(_read(hit[0]));
1143
+ let end = hit[1];
1144
+ while (end < lines.length && end - hit[1] < 40 && !/<\/style>/.test(lines[end - 1])) end += 1;
1145
+ const chunk = `- \`${name}\` (\`${pName(hit[0])}:${hit[1]}\`)\n\n\`\`\`xml\n${numbered(lines.slice(hit[1] - 1, end).join('\n'), hit[1])}\n\`\`\`\n`;
1146
+ if (take(chunk)) { inlined.add(`${pKey(hit[0])}#${hit[1]}`); sty.push(chunk); }
1147
+ }
1148
+ addSources(budget.rels.filter((r) => r !== 'member'));
1149
+ const lines = [];
1150
+ if (src.length) lines.push('## Inlined sources (already read for you — do not read these files again)', '', ...src);
1151
+ if (maps.length) lines.push('## Inlined mapping-reference sections', '', ...maps);
1152
+ if (sty.length) lines.push('## Inlined style definitions', '', ...sty);
1153
+ return { lines, inlined, chars: used };
1154
+ }
1155
+
1156
+ /**
1157
+ * The source hints of an uncaptured attached node, handed to the agent: the SOURCE_HINTS fields that
1158
+ * conversion-procedure.md §source-only reads (Phase 4.1 layouts / base class, 4.2 state / login gate).
1159
+ */
1160
+ const UNCAPTURED_HINTS = ['declared_at', 'layout_files', 'extends_base', 'widgets', 'launch_hint', 'required_state',
1161
+ 'content_state_evidence', 'layout_hidden_ids', 'login_interceptor'];
1162
+ /** Widgets listed per uncaptured node before the rest are counted. */
1163
+ const UNCAPTURED_WIDGETS = 12;
1164
+ /** The conversion-procedure.md section uncaptured nodes follow, as its heading reads in this language. */
1165
+ const SOURCE_ONLY_SECTION = quoteName('source-only tier');
1166
+
1167
+ /**
1168
+ * build_conversion_set hintsOf's isEmptyish (null, empty array, empty object), restated rather than imported:
1169
+ * this file has no local imports, so its i18n/ copy runs from a directory without build_conversion_set's deps.
1170
+ */
1171
+ const isEmptyish = (v) => v === null || v === undefined || (Array.isArray(v) && v.length === 0) ||
1172
+ (typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length === 0);
1173
+
1174
+ /**
1175
+ * Every frame of every state the group converts against, labelled by the static node it shows.
1176
+ *
1177
+ * A group's `page_dirs` are its members' own dirs plus the captured dirs of nodes attached to
1178
+ * them (build_conversion_set folds a captured ui-state / panel / menu into its host's group).
1179
+ * One dir = one state; inside it `view.xml` + `view_scroll_N.xml` are frames
1180
+ * of that state, each with its screenshot unless FLAG_SECURE blocked it. Handing an agent only
1181
+ * `meta.screenshot` lost every other frame and every attached state: captured states were then
1182
+ * converted from source branches as if never seen.
1183
+ *
1184
+ * -> {entries: [{page_dir, node, relation, tier, label, frames: [{view_xml, screenshot,
1185
+ * blocked, pre_data?: [text]}], missing: [path], measure_summary}], uncaptured: [{node, kind, label, host,
1186
+ * declared_at?, layout_files?, extends_base?, widgets?, launch_hint?, required_state?, content_state_evidence?,
1187
+ * layout_hidden_ids?, login_interceptor?}]}
1188
+ * The optional uncaptured fields are the static UTG's source hints (build_conversion_set hintsOf), passed
1189
+ * on so the agent starts from the node's own source branch instead of searching the host for it.
1190
+ * `pre_data` = the frame was captured before the page's data arrived (meta.content_loading).
1191
+ * Paths are absolute. `missing` = a declared file that does not exist (Step 4.1 fails the page).
1192
+ */
1193
+ export function referenceEvidence(group, uiInfo) {
1194
+ const relation = new Map(pyIter(or(dget(group, 'members'), [])).map((m) => [dget(m, 'node'), dget(m, 'relation')]));
1195
+ const dirs = pyIter(or(dget(group, 'page_dirs'), [])).map(pyStr);
1196
+ const rows = _attachedRows(uiInfo);
1197
+ const entries = [];
1198
+ const attached = new Map();
1199
+ for (const d of dirs) {
1200
+ const dir = pJoin(uiInfo, d);
1201
+ const meta = or(_load(pJoin(dir, 'meta.json'), {}), {});
1202
+ const node = pyStr(or(dget(meta, 'static_node'), d));
1203
+ const abs = (rel) => pathStr(pJoin(uiInfo, rel));
1204
+ const shots = new Set(pyIter(or(dget(meta, 'screenshots'), [])).map(pyStr));
1205
+ const blocked = new Map(pyIter(or(dget(meta, 'screenshots_blocked'), [])).map((b) => [pyStr(dget(b, 'view_xml')), pyStr(dget(b, 'reason'))]));
1206
+ const frames = []; const missing = [];
1207
+ // views export_ui_info found captured before the data arrived (unformatted `%1$s` text)
1208
+ const preData = new Map(pyIter(or(dget(or(dget(meta, 'content_loading'), {}), 'views'), []))
1209
+ .map((v) => [pyStr(dget(v, 'view_xml')), pyIter(or(dget(v, 'texts'), [])).map(pyStr)]));
1210
+ for (const vx of pyIter(or(dget(meta, 'view_xmls'), [])).map(pyStr)) {
1211
+ // view.xml <-> screenshot.png, view_scroll_2.xml <-> screenshot_scroll_2.png
1212
+ const shot = vx.replace(/\/view(_[^/]*)?\.xml$/, (_, t) => `/screenshot${t || ''}.png`);
1213
+ const frame = { view_xml: abs(vx), screenshot: shots.has(shot) ? abs(shot) : null, blocked: blocked.get(vx) ?? null,
1214
+ ...(preData.has(vx) ? { pre_data: preData.get(vx) } : {}) };
1215
+ if (!isFile(frame.view_xml)) { missing.push(frame.view_xml); }
1216
+ if (frame.screenshot && !isFile(frame.screenshot)) { missing.push(frame.screenshot); }
1217
+ frames.push(frame);
1218
+ }
1219
+ const summary = pJoin(dir, 'measure_summary.txt');
1220
+ const density = Number(dget(dget(or(_load(pJoin(dir, 'measure_pack.json'), {}), {}), 'density') ?? {}, 'value')) ||
1221
+ Number(dget(dget(meta, 'device_info') ?? {}, 'density')) || 0;
1222
+ entries.push({ page_dir: pathStr(dir), node, relation: relation.get(node) ?? 'attached',
1223
+ tier: pyStr(or(dget(meta, 'evidence_tier'), 'captured')), label: pyStr(or(dget(meta, 'label'), node)),
1224
+ frames, missing, measure_summary: isFile(summary) ? pathStr(summary) : null, density });
1225
+ for (const a of _attachedOf(meta, rows, d)) {
1226
+ attached.set(pyStr(dget(a, 'id')), [a, node]);
1227
+ }
1228
+ }
1229
+ // Attached nodes no dir of this group shows: converted from their source branch alone.
1230
+ const shown = new Set(entries.map((e) => e.node));
1231
+ const uncaptured = [...attached].filter(([id]) => !shown.has(id)).map(([id, [a, host]]) => {
1232
+ const u = { node: id, kind: pyStr(or(dget(a, 'kind'), '')), label: pyStr(or(dget(a, 'label'), id)), host };
1233
+ for (const k of UNCAPTURED_HINTS) {
1234
+ const v = dget(a, k);
1235
+ if (!isEmptyish(v)) { u[k] = v; }
1236
+ }
1237
+ return u;
1238
+ });
1239
+ return { entries, uncaptured: sortedBy(uncaptured, (u) => u.node) };
1240
+ }
1241
+
1242
+ /**
1243
+ * Container geometry of a uiautomator view tree in dp: every node with children that is at least
1244
+ * 40% of the root's width, with its insets from its parent and whether it spans the parent's
1245
+ * content column (`full`: same width as the widest sibling container, or parent width minus equal
1246
+ * insets). Measured on where2study5 settings (FLAG_SECURE, tree-only): the agent read the cards'
1247
+ * inner text start (x=94px) as the content edge and guessed a tablet mode; the card box itself
1248
+ * ([52..1028]) said full width. Computing the insets removes that reading step. `density` 0 = px.
1249
+ */
1250
+ export function treeGeometry(viewXml, density, limit = 40) {
1251
+ let xml = '';
1252
+ try { xml = fs.readFileSync(viewXml, 'utf8'); } catch { return []; }
1253
+ const d = density > 0 ? density : 1;
1254
+ const round = (v) => Math.round((v / d) * 10) / 10;
1255
+ const nodes = [];
1256
+ const stack = [];
1257
+ const re = /<node\b([^>]*?)(\/?)>|<\/node>/g;
1258
+ let m;
1259
+ while ((m = re.exec(xml)) !== null) {
1260
+ if (m[0] === '</node>') { stack.pop(); continue; }
1261
+ const attr = (k) => (new RegExp(`\\b${k}="([^"]*)"`).exec(m[1]) ?? [])[1] ?? '';
1262
+ const b = /\[(-?\d+),(-?\d+)\]\[(-?\d+),(-?\d+)\]/.exec(attr('bounds'));
1263
+ const parent = stack.length ? stack[stack.length - 1] : null;
1264
+ const n = { idx: nodes.length, cls: attr('class').split('.').pop(), text: attr('text').slice(0, 24),
1265
+ b: b ? b.slice(1).map(Number) : null, parent, kids: 0 };
1266
+ nodes.push(n);
1267
+ if (parent) parent.kids++;
1268
+ if (m[2] !== '/') stack.push(n);
1269
+ }
1270
+ const root = nodes.find((n) => n.b);
1271
+ if (!root) return [];
1272
+ const rootW = root.b[2] - root.b[0];
1273
+ const out = [];
1274
+ for (const n of nodes) {
1275
+ if (!n.b || !n.parent || !n.parent.b || n.kids === 0) continue;
1276
+ const w = n.b[2] - n.b[0];
1277
+ if (w < rootW * 0.4) continue;
1278
+ const p = n.parent.b;
1279
+ const insetL = n.b[0] - p[0];
1280
+ const insetR = p[2] - n.b[2];
1281
+ const sibs = nodes.filter((s) => s.parent === n.parent && s.b && s.kids > 0);
1282
+ const widest = Math.max(...sibs.map((s) => s.b[2] - s.b[0]));
1283
+ const full = Math.abs(insetL - insetR) <= 2 * d && (w >= widest - 2 * d);
1284
+ out.push({ idx: n.idx, cls: n.cls, x: round(n.b[0]), w: round(w), insetL: round(insetL), insetR: round(insetR), full, text: n.text });
1285
+ if (out.length >= limit) break;
1286
+ }
1287
+ return out;
1288
+ }
1289
+
1290
+ /**
1291
+ * Text drawn on a Canvas by the group's Android sources: `drawText` calls and the Paint text sizes
1292
+ * they use. Custom-view text has no node in the view tree and no measurement, so nothing else hands
1293
+ * these sizes to the agent. Measured on where2study5's teaching calendar: the agent copied
1294
+ * `sp(9f)` / `sp(17f)` / `sp(8f)` as Canvas `'9px'` / `'bold 17px'` / `'8px'`, about 1/2.6 of the
1295
+ * Android size (GATE canvas-font-px-literal now catches the unit; this list is what to check against).
1296
+ */
1297
+ export function canvasTextInventory(files, limit = 40) {
1298
+ const out = [];
1299
+ for (const p of files) {
1300
+ if (!/\.(kt|java)$/.test(p)) continue;
1301
+ const text = _read(p);
1302
+ // only custom views: a TextView's `textSize = 12f` is already sp and has a view-tree node
1303
+ if (!/\bdrawText\s*\(/.test(text) || !/\bonDraw\s*\(/.test(text)) continue;
1304
+ splitlines(text).forEach((line, i) => {
1305
+ if (out.length >= limit) return;
1306
+ if (/^\s*(import|\/\/|\*)/.test(line)) return;
1307
+ // Paint sizes are px, so the source converts them: sp(…) / dp(…) / applyDimension / * density
1308
+ const paintSize = /\btextSize\s*=|\bsetTextSize\s*\(/.test(line) &&
1309
+ /\b(sp|dp|spToPx|dpToPx)\s*\(|applyDimension|density|scaledDensity|getDimension/.test(line);
1310
+ if (paintSize || /\bdrawText\s*\(/.test(line)) {
1311
+ out.push(`- \`${p}:${i + 1}\` — \`${line.trim().slice(0, 140)}\``);
1312
+ }
1313
+ });
1314
+ }
1315
+ return out;
1316
+ }
1317
+
1318
+ /**
1319
+ * The knowledge cards this group must read: the always set, plus `canvas` when a source file
1320
+ * custom-draws (`onDraw`, Compose `Canvas` / `drawBehind`, `Path()`). Returns [[card, why], ...].
1321
+ * `state-v1` depends on PARADIGM, which the prompt states; it is listed as conditional text, not here.
1322
+ */
1323
+ export function knowledgeCards(files) {
1324
+ const out = ALWAYS_CARDS.map((c) => [c, 'always']);
1325
+ const hit = files.find((p) => /\.(kt|java)$/.test(p) && CUSTOM_DRAW.test(maskKotlin(_read(p))));
1326
+ if (hit) out.push(['canvas', `custom drawing in \`${hit}\``]);
1327
+ return out;
1328
+ }
1329
+
1330
+ export function renderCards(files) {
1331
+ const cards = knowledgeCards(files);
1332
+ const lines = ['## Knowledge cards (conversion-procedure.md Phase 3.1)', '',
1333
+ 'Read every card listed here in one batched turn before writing code. Each one ends with its own ' +
1334
+ quoteName("Common Mistranslations") + ' table; walk those tables again before the Phase 5 report. `state-v1.md` is required as ' +
1335
+ 'well when the prompt says `PARADIGM = V1`.' +
1336
+ (cards.some(([c]) => c === 'canvas') ? '' : ' No custom drawing was found in this group\'s sources, so ' +
1337
+ '`canvas.md` is not listed; read it if you port an `onDraw` / `Canvas` the pack did not list.'), ''];
1338
+ for (const [c, why] of cards) lines.push(`- \`${path.join(CARDS, `${c}.md`)}\`${why === 'always' ? '' : ` — ${why}`}`);
1339
+ lines.push('');
1340
+ return lines;
1341
+ }
1342
+
1343
+ /** Kotlin source with comments and string literals blanked to spaces (offsets and newlines kept). */
1344
+ function maskKotlin(text) {
1345
+ return text.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"""[\s\S]*?"""|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g,
1346
+ (m) => m.replace(/[^\n]/g, ' '));
1347
+ }
1348
+
1349
+ /** index of the bracket closing the one at `open`, or -1 */
1350
+ function matchBracket(s, open) {
1351
+ const o = s[open];
1352
+ const c = o === '(' ? ')' : '}';
1353
+ let depth = 0;
1354
+ for (let i = open; i < s.length; i++) {
1355
+ if (s[i] === o) depth++;
1356
+ else if (s[i] === c && --depth === 0) return i;
1357
+ }
1358
+ return -1;
1359
+ }
1360
+
1361
+ const BOX_ALIGN = 'TopStart|TopCenter|TopEnd|CenterStart|Center|CenterEnd|BottomStart|BottomCenter|BottomEnd';
1362
+
1363
+ /**
1364
+ * Compose Box children that position themselves with `Modifier.align(X)` where X differs from the
1365
+ * Box's `contentAlignment` (default TopStart). ArkUI `Stack` has no per-child alignment, so this
1366
+ * alignment is easy to drop: only the `.padding` after it survives as a one-sided margin and the
1367
+ * child sits in the middle on top of its siblings. Measured on ydweather's observe cards:
1368
+ * `Box(contentAlignment = Center)` + label `Modifier.align(BottomCenter).padding(bottom = 5.dp)`
1369
+ * became `Stack({ alignContent: Center })` + `.margin({ bottom: 5 })`, and "UV" / "Comfortable" / "hPa"
1370
+ * overlapped the number or icon above them. Only the 2-D `Alignment` values are BoxScope's; Row /
1371
+ * Column scopes take `Alignment.Top` / `CenterVertically` / `Start` …, which are not listed.
1372
+ */
1373
+ export function boxAlignInventory(files, limit = 40) {
1374
+ const out = [];
1375
+ for (const p of files) {
1376
+ if (out.length >= limit) break;
1377
+ if (!/\.kt$/.test(p)) continue;
1378
+ const text = _read(p);
1379
+ if (!/\.align\s*\(\s*Alignment\./.test(text)) continue;
1380
+ const code = maskKotlin(text);
1381
+ const lines = splitlines(text);
1382
+ const lineAt = (i) => code.slice(0, i).split('\n').length;
1383
+ const boxes = [];
1384
+ for (const m of code.matchAll(/\b(?:Box|BoxWithConstraints)\s*(?=[({])/g)) {
1385
+ let i = m.index + m[0].length;
1386
+ let args = '';
1387
+ if (code[i] === '(') {
1388
+ const close = matchBracket(code, i);
1389
+ if (close < 0) continue;
1390
+ args = text.slice(i, close + 1);
1391
+ i = close + 1;
1392
+ while (/\s/.test(code[i] ?? '')) i++;
1393
+ }
1394
+ if (code[i] !== '{') continue;
1395
+ const end = matchBracket(code, i);
1396
+ if (end < 0) continue;
1397
+ const ca = /contentAlignment\s*=\s*Alignment\.(\w+)/.exec(args);
1398
+ boxes.push({ start: i, end, align: ca ? ca[1] : 'TopStart', line: lineAt(m.index) });
1399
+ }
1400
+ const re = new RegExp(`\\.align\\s*\\(\\s*Alignment\\.(${BOX_ALIGN})\\s*\\)`, 'g');
1401
+ for (const m of code.matchAll(re)) {
1402
+ if (out.length >= limit) break;
1403
+ // innermost Box whose lambda holds the call; none = a BoxScope extension called from elsewhere
1404
+ const box = boxes.filter((b) => b.start < m.index && m.index < b.end).sort((a, b) => b.start - a.start)[0];
1405
+ if (box && box.align === m[1]) continue;
1406
+ const ln = lineAt(m.index);
1407
+ const host = box ? `Box(contentAlignment = ${box.align}) at :${box.line}` : 'BoxScope (enclosing Box not in this file)';
1408
+ out.push(`- \`${p}:${ln}\` — child \`align(${m[1]})\` in ${host} — \`${lines[ln - 1].trim().slice(0, 120)}\``);
1409
+ }
1410
+ }
1411
+ return out;
1412
+ }
1413
+
1414
+ /** Markdown of referenceEvidence: what REFERENCE_SCREENSHOTS / REFERENCE_VIEW_TREES carry. */
1415
+ export function renderEvidence(ev) {
1416
+ const lines = ['## Reference evidence — one state per directory, every frame',
1417
+ '',
1418
+ 'Each `###` is one state of this group (the member page, or a node attached to it) with ' +
1419
+ 'every captured frame of that state. Read **all** of them: scroll frames are ' +
1420
+ 'the same state at other offsets; an attached state is converted against its own frames, ' +
1421
+ 'not from source branches. A `blocked` frame has a view tree but no screenshot (the app ' +
1422
+ 'forbids screen capture): bounds from the tree, colours from source/theme.',
1423
+ ''];
1424
+ for (const e of ev.entries) {
1425
+ const treeOnly = e.frames.length > 0 && e.frames.every((f) => !f.screenshot && f.blocked);
1426
+ lines.push(`### ${e.node} — ${e.label} (${e.relation}, ${e.tier}${treeOnly ? ', **tree-only**' : ''})`, '');
1427
+ if (treeOnly) {
1428
+ lines.push('**Tree-only state: no frame has pixels** (all FLAG_SECURE-blocked). Nothing downstream ' +
1429
+ 'can compare your output with a picture, so geometry must come from the table below, not from ' +
1430
+ 'your own reading of `bounds`: a card is the container whose box spans the column, its text sits ' +
1431
+ 'one padding further in. Every container marked `full` is `.width(\'100%\')` (or a weight) in ' +
1432
+ 'ArkUI; colours, borders and corner radii come from the Android source, never from the tree.', '');
1433
+ const geo = treeGeometry(e.frames[0].view_xml, e.density);
1434
+ if (geo.length) {
1435
+ lines.push('| node | class | x dp | width dp | inset from parent L/R dp | |', '|---|---|---|---|---|---|');
1436
+ for (const g of geo) {
1437
+ lines.push(`| ${g.idx} | ${g.cls} | ${g.x} | ${g.w} | ${g.insetL} / ${g.insetR} | ${g.full ? 'full' : ''}${g.text ? ` "${g.text}"` : ''} |`);
1438
+ }
1439
+ lines.push('');
1440
+ }
1441
+ }
1442
+ if (!e.frames.length) { lines.push('- no capture (source-only)'); }
1443
+ const pre = e.frames.filter((f) => f.pre_data);
1444
+ if (pre.length) {
1445
+ const loaded = e.frames.filter((f) => !f.pre_data);
1446
+ lines.push(`**${pre.length} frame(s) below are PRE-DATA** — captured before the page's data arrived; their texts ` +
1447
+ '(e.g. `' + pre[0].pre_data.slice(0, 3).join('`, `') + '`) are the layout\'s android:text defaults, not what the page shows. ' +
1448
+ (loaded.length ? 'Take texts, values, icons and row counts from the frames not marked PRE-DATA. '
1449
+ : 'No frame has the data: derive the populated look from the source binding code and say so in the report. ') +
1450
+ 'Never write an unformatted `%1$s`-style string into ArkTS text, and never skip data binding because a frame shows the default. ' +
1451
+ 'Geometry (bounds) of PRE-DATA frames is still valid (conversion-procedure.md §4.1).', '');
1452
+ }
1453
+ for (const f of e.frames) {
1454
+ const shot = f.screenshot ? `\`${f.screenshot}\`` : (f.blocked ? `no screenshot (blocked: ${f.blocked})` : 'no screenshot');
1455
+ lines.push(`- view tree \`${f.view_xml}\` — screenshot ${shot}${f.pre_data ? ' — **PRE-DATA**' : ''}`);
1456
+ }
1457
+ if (e.measure_summary) { lines.push(`- MEASUREMENT_PACK: \`${e.measure_summary}\``); }
1458
+ for (const m of e.missing) { lines.push(`- **MISSING** \`${m}\` (Step 4.1: page failed)`); }
1459
+ lines.push('');
1460
+ }
1461
+ if (ev.uncaptured.length) {
1462
+ lines.push('### Attached states with no capture — convert from their source branch', '',
1463
+ `Each one follows conversion-procedure.md §${SOURCE_ONLY_SECTION} for that node only. Paths are relative to \`android_project_dir\`.`, '');
1464
+ const code = (x) => `\`${typeof x === 'string' ? x : JSON.stringify(x)}\``;
1465
+ const show = (v) => (Array.isArray(v) ? v : [v]).map(code).join(', ');
1466
+ // a widget as `<widget>#<view_id> @ <file:line>`: where its layout or code lives
1467
+ const widget = (w) => `\`${[dget(w, 'widget') ?? dget(w, 'kind') ?? '?', dget(w, 'view_id') && `#${dget(w, 'view_id')}`]
1468
+ .filter(Boolean).join('')}${dget(w, 'at') ? ` @ ${dget(w, 'at')}` : ''}\``;
1469
+ for (const u of ev.uncaptured) {
1470
+ lines.push(`- ${u.node} — ${u.label} (${u.kind}, on ${u.host})`);
1471
+ for (const k of UNCAPTURED_HINTS) {
1472
+ if (u[k] === undefined) { continue; }
1473
+ if (k === 'widgets') {
1474
+ const ws = pyIter(u[k]);
1475
+ const more = ws.length > UNCAPTURED_WIDGETS ? ` (+${ws.length - UNCAPTURED_WIDGETS} more)` : '';
1476
+ lines.push(` - widgets: ${ws.slice(0, UNCAPTURED_WIDGETS).map(widget).join(', ')}${more}`);
1477
+ } else {
1478
+ lines.push(` - ${k}: ${show(u[k])}`);
1479
+ }
1480
+ }
1481
+ if (u.declared_at === undefined && u.layout_files === undefined && u.widgets === undefined) {
1482
+ lines.push(' - no source location recorded: if this run\'s pages.json / meta.json predate source hints, ' +
1483
+ 'rerun build_conversion_set.mjs; otherwise find the branch in the host source that shows it');
1484
+ }
1485
+ }
1486
+ lines.push('');
1487
+ }
1488
+ return lines;
1489
+ }
1490
+
1491
+ export function render(group, pack, idx, hres, android, uiInfo = null, { inline = false } = {}) {
1492
+ const relOrder = ['member', 'base', 'host', 'custom-view', 'related'];
1493
+ const lines = [`# Source pack — ${pyStr(dsub(group, 'id'))}`,
1494
+ '',
1495
+ 'Reading list resolved by `group_pack.mjs` from meta.json `declared_at`, R.* / @* ' +
1496
+ 'references, base classes, the host Activity and same-package / UI imports. **Read the ' +
1497
+ '`member` and `base` files in one batched turn**; `host` (toolbar / window chrome) and ' +
1498
+ '`related` ones in the next batch, as the conversion needs them. ' +
1499
+ 'A file missing here is read as before — this list is a starting point, not a limit.',
1500
+ ''];
1501
+ if (uiInfo !== null) { lines.push(...renderEvidence(referenceEvidence(group, uiInfo))); }
1502
+ lines.push(...renderCards([...pack.files.values()].map(([p]) => pathStr(p))));
1503
+ const idxRows = uiInfo !== null ? mappingIndex(usedNames(pack, uiInfo, group)) : [];
1504
+ const styles = idx.value_defs('style');
1505
+ const styleHits = sortedBy([...pack.styles]).filter((x) => styles.get(x)).map((x) => [x, styles.get(x)]);
1506
+ let inl = { lines: [], inlined: new Set() };
1507
+ if (inline) {
1508
+ // room = the one-read cap less the list itself (rendered once without inlining) and the
1509
+ // ' — **inlined**' marks and header line inlining adds
1510
+ const plain = render(group, pack, idx, hres, android, uiInfo, { inline: false });
1511
+ const room = INLINE.pack - Buffer.byteLength(plain, 'utf8') - (plain.match(/\n/g)?.length ?? 0) - 4096;
1512
+ if (room > 2048) inl = inlineBlock(pack, idxRows, styleHits, room);
1513
+ }
1514
+ const mark = (k) => (inl.inlined.has(k) ? ' — **inlined**' : '');
1515
+ if (inl.inlined.size) {
1516
+ lines.push('Entries marked **inlined** are reproduced at the end of this pack with their line numbers: ' +
1517
+ 'cite them as `file:line` and do not read them again.', '');
1518
+ }
1519
+ for (const r of relOrder) {
1520
+ const rows = [...pack.files.values()].filter(([, rr]) => rr === r).map(([p, , why]) => [p, why]);
1521
+ if (!rows.length) { continue; }
1522
+ lines.push(`## ${r} (${rows.length})`, '');
1523
+ for (const [p, why] of sortedBy(rows, (x) => [pSuffix(x[0]) !== '.java' && pSuffix(x[0]) !== '.kt', pathStr(x[0])])) {
1524
+ const n = splitlines(_read(p)).length;
1525
+ lines.push(`- \`${p}\` — ${n} lines — ${why}${mark(pKey(p))}`);
1526
+ }
1527
+ lines.push('');
1528
+ }
1529
+ const canvasText = canvasTextInventory([...pack.files.values()].map(([p]) => pathStr(p)));
1530
+ if (canvasText.length) {
1531
+ lines.push('## Canvas-drawn text (no view-tree node, no measurement)', '',
1532
+ 'Every `drawText` and Paint text size in this group\'s custom views. Port each size with its ' +
1533
+ 'unit: Android `sp(N)` → Canvas `font` `\'Nvp\'` (or `fp2px(N)` + `px` to follow the font scale); ' +
1534
+ 'a Canvas `px` is a physical pixel (GATE `canvas-font-px-literal`). Geometry is vp by default: ' +
1535
+ '`new CanvasRenderingContext2D(settings)` draws coordinates, `lineWidth` and `measureText` in vp, so ' +
1536
+ 'Android `dp(N)` is plain `N` — never multiply by `vp2px(1)` (GATE `canvas-coord-density-scaled`); ' +
1537
+ 'physical px only via the constructor\'s `LengthMetricsUnit.PX`. There is no `ctx.units` / `CanvasUnit`.',
1538
+ '', ...canvasText, '');
1539
+ }
1540
+ const boxAlign = boxAlignInventory([...pack.files.values()].map(([p]) => pathStr(p)));
1541
+ if (boxAlign.length) {
1542
+ lines.push('## Box children with their own alignment (Compose `Modifier.align`)', '',
1543
+ 'Every Compose `Box` child aligned differently from its Box\'s `contentAlignment`. ArkUI `Stack` ' +
1544
+ 'has no per-child alignment and a child `.align()` only arranges its own content, so each row ' +
1545
+ 'needs its own form: wrap the child in a container the Stack\'s size that places it ' +
1546
+ '(`Column().width(\'100%\').height(\'100%\').justifyContent(FlexAlign.End).padding({ bottom: 5 })` for ' +
1547
+ '`BottomCenter` + `padding(bottom = 5.dp)`), or `.position` / `.markAnchor`. Keeping only the ' +
1548
+ 'padding as a one-sided margin leaves the child centred on top of its siblings ' +
1549
+ '(GATE `stack-overlay-default-center`). Cite the ArkTS `file:line` of each row in Phase 5 ' +
1550
+ quoteName("Text Alignment Evidence") + '.', '', ...boxAlign, '');
1551
+ }
1552
+ if (idxRows.length) {
1553
+ lines.push('## Mapping-reference sections for the widgets and listeners used here', '',
1554
+ 'The sections of `references/mappings/*.md` whose heading names a widget class or ' +
1555
+ "listener this group's files and captured view trees use. Read them by line range " +
1556
+ '(`offset` = start, `limit` = end - start + 1) in one batched turn instead of paging ' +
1557
+ 'through the whole reference. A widget with no row here has no dedicated section: ' +
1558
+ 'search the reference as before.', '');
1559
+ for (const [[f, a, b, , h], ws] of idxRows) { lines.push(`- \`${f}\` lines ${a}-${b} — ${h} — for ${ws.join(', ')}${mark(`${pKey(f)}#${a}`)}`); }
1560
+ lines.push('');
1561
+ }
1562
+ if (pack.styles.size) {
1563
+ lines.push('## Style definitions', '');
1564
+ for (const s of sortedBy(pack.styles)) {
1565
+ const hit = styles.get(s);
1566
+ lines.push(hit ? `- \`${s}\` → \`${hit[0]}:${hit[1]}\`${mark(`${pKey(hit[0])}#${hit[1]}`)}`
1567
+ : `- \`${s}\` → (not in project values; library/platform style)`);
1568
+ }
1569
+ lines.push('');
1570
+ }
1571
+ if (pack.arrays.size || pack.assets.size) {
1572
+ const arrays = idx.value_defs('(?:string-|integer-)?array');
1573
+ lines.push('## Arrays and assets', '');
1574
+ for (const a of sortedBy(pack.arrays)) {
1575
+ const hit = arrays.get(a);
1576
+ lines.push(hit ? `- array \`${a}\` → \`${hit[0]}:${hit[1]}\`` : `- array \`${a}\` → (not found)`);
1577
+ }
1578
+ for (const a of sortedBy(pack.assets.values(), pathStr)) {
1579
+ lines.push(`- asset \`${a}\` — ${splitlines(_read(a)).length} lines`);
1580
+ }
1581
+ lines.push('');
1582
+ }
1583
+ const refs = sortedBy([...pack.refs.values()].filter((r) => TABLE_TYPES.includes(r[0])));
1584
+ if (refs.length) {
1585
+ lines.push('## Resources referenced by these files → Harmony',
1586
+ '',
1587
+ 'From resource_mapping.md + the Harmony resource files. `exists` = present on disk ' +
1588
+ "now; `ref` goes into `$r('...')`; values shown for base / zh_CN / dark. Rows with " +
1589
+ '`exists`=NO or ref N/A need the resource-fidelity handling of conversion-procedure.md.',
1590
+ '',
1591
+ '| Android | ref | status | exists | value |',
1592
+ '|---|---|---|---|---|');
1593
+ for (const [kind, name] of refs) {
1594
+ const r = hres.row(kind, name);
1595
+ const v = r.value;
1596
+ let vs = v ? Object.entries(v).map(([q, x]) => `${q}=${[...pyStr(x)].slice(0, 60).join('')}`).join('; ') : '';
1597
+ vs = vs.replace(/\|/g, '\\|').replace(/\n/g, ' ');
1598
+ const ex = r.exists === true ? 'yes' : r.exists === false ? 'NO' : '-';
1599
+ lines.push(`| ${kind}/${name} | ${r.ref || 'N/A'} | ${r.status} | ${ex} | ${vs} |`);
1600
+ }
1601
+ lines.push('');
1602
+ }
1603
+ if (inl.lines.length) lines.push(...inl.lines);
1604
+ return lines.join('\n');
1605
+ }
1606
+
1607
+ export function _ctx(hp, android) {
1608
+ const meta = pJoin(hp, '.hometrans');
1609
+ const progress = or(_load(pJoin(meta, 'batch_progress.json'), {}), {});
1610
+ const uiInfo = pathStr(or(dget(progress, 'ui_info_root'), pJoin(meta, 'ui_info')));
1611
+ const module = or(dget(progress, 'ui_module'), 'entry');
1612
+ const plan = dget(or(_load(pJoin(uiInfo, 'conversion_set.json'), {}), {}), 'plan', {});
1613
+ return [uiInfo, dget(plan, 'groups', []), new AndroidIndex(android), new HarmonyRes(hp, module)];
1614
+ }
1615
+
1616
+ export function build(hp, android, out = null, only = null, { inline = true } = {}) {
1617
+ const [uiInfo, groups, idx, hres] = _ctx(hp, android);
1618
+ out = pathStr(or(out, pJoin(hp, '.hometrans', 'work', 'group_packs')));
1619
+ if (isFile(out)) { throw new Error(`FileExistsError: ${out}`); }
1620
+ fs.mkdirSync(out, { recursive: true });
1621
+ const report = new Map();
1622
+ for (const g of pyIter(groups)) {
1623
+ if (only && !only.has(dsub(g, 'id'))) { continue; }
1624
+ const pack = buildGroup(g, uiInfo, idx, hres, android);
1625
+ const text = render(g, pack, idx, hres, android, uiInfo, { inline });
1626
+ const gid = dsub(g, 'id');
1627
+ const file = pJoin(out, `${pyStr(gid)}.md`);
1628
+ fs.writeFileSync(file, IS_WIN ? text.replace(/\n/g, '\r\n') : text, 'utf8');
1629
+ // the same evidence as data: the parent builds REFERENCE_* and runs measure_pack from it
1630
+ fs.writeFileSync(pJoin(out, `${pyStr(gid)}.evidence.json`), JSON.stringify(referenceEvidence(g, uiInfo), null, 1), 'utf8');
1631
+ const k = typeof gid === 'string' ? gid : jsonKey(gid);
1632
+ report.set(k, new Map([['files', pack.files.size], ['resources', pack.refs.size],
1633
+ ['styles', pack.styles.size], ['mapping_sections', text.split(' — for ').length - 1]]));
1634
+ }
1635
+ return new Map([['out', out], ['groups', report]]);
1636
+ }
1637
+
1638
+ export function lookup(hp, android, names) {
1639
+ const hres = new HarmonyRes(hp, or(dget(or(_load(pJoin(hp, '.hometrans', 'batch_progress.json'), {}), {}),
1640
+ 'ui_module'), 'entry'));
1641
+ const rows = [];
1642
+ for (const n of names) {
1643
+ const s = n.replaceAll('R.', '').replaceAll('@', '').replace('.', '/');
1644
+ const i = s.indexOf('/');
1645
+ const [kind, name] = i < 0 ? [s, ''] : [s.slice(0, i), s.slice(i + 1)];
1646
+ rows.push(hres.row(kind, name));
1647
+ }
1648
+ return rows;
1649
+ }
1650
+
1651
+ // ---------------------------------------------------------------- argparse equivalent
1652
+ // Mirrors this CLI's argparse (Python 3.13) behaviour: unique long-option prefixes,
1653
+ // `--opt=value`, `--`, interleaved positionals (mode, harmony_dir, names*),
1654
+ // usage/help layout (width = terminal columns - 2), errors -> usage + exit 2.
1655
+
1656
+ function termColumns() {
1657
+ const env = Number.parseInt(process.env.COLUMNS ?? '', 10);
1658
+ if (env > 0) { return env; }
1659
+ return process.stdout.isTTY && process.stdout.columns ? process.stdout.columns : 80;
1660
+ }
1661
+
1662
+ function usage(prog) {
1663
+ const width = termColumns() - 2;
1664
+ const opt = ['[-h]', '--android ANDROID', '[--groups GROUPS]', '[--out OUT]'];
1665
+ const pos = ['{build,lookup}', 'harmony_dir', '[names ...]'];
1666
+ const full = [prog, ...opt, ...pos].join(' ');
1667
+ if ('usage: '.length + full.length <= width) { return 'usage: ' + full; }
1668
+ const getLines = (parts, indent, prefix) => {
1669
+ const lines = [];
1670
+ let line = [];
1671
+ let len = prefix !== undefined ? prefix.length - 1 : indent.length - 1;
1672
+ for (const part of parts) {
1673
+ if (len + 1 + part.length > width && line.length) {
1674
+ lines.push(indent + line.join(' '));
1675
+ line = [];
1676
+ len = indent.length - 1;
1677
+ }
1678
+ line.push(part);
1679
+ len += part.length + 1;
1680
+ }
1681
+ if (line.length) { lines.push(indent + line.join(' ')); }
1682
+ if (prefix !== undefined) { lines[0] = lines[0].slice(indent.length); }
1683
+ return lines;
1684
+ };
1685
+ let lines;
1686
+ if ('usage: '.length + prog.length <= 0.75 * width) {
1687
+ const indent = ' '.repeat('usage: '.length + prog.length + 1);
1688
+ lines = getLines([prog, ...opt], indent, prog);
1689
+ if (pos.length) { lines.push(...getLines(pos, indent)); }
1690
+ } else {
1691
+ const indent = ' '.repeat('usage: '.length);
1692
+ lines = getLines([...opt, ...pos], indent);
1693
+ if (lines.length > 1) { lines = [...getLines(opt, indent), ...getLines(pos, indent)]; }
1694
+ lines = [prog, ...lines];
1695
+ }
1696
+ return 'usage: ' + lines.join('\n');
1697
+ }
1698
+
1699
+ function helpText(prog) {
1700
+ const rows = [
1701
+ ['{build,lookup}', null], ['harmony_dir', null], ['names', 'lookup: type/name ... (e.g. string/foo R.color.bar)'],
1702
+ ];
1703
+ const opts = [['-h, --help', 'show this help message and exit'], ['--android ANDROID', 'android_project_dir'],
1704
+ ['--groups GROUPS', 'build: comma-separated ids (default: all)'],
1705
+ ['--out OUT', 'build: output dir (default .hometrans/work/group_packs)']];
1706
+ const width = termColumns() - 2;
1707
+ const maxPos = Math.min(24, Math.max(width - 20, 4));
1708
+ const longest = Math.max(...[...rows, ...opts].map(([inv]) => inv.length + 2));
1709
+ const helpPos = Math.min(longest + 2, maxPos);
1710
+ const item = ([inv, help]) => {
1711
+ if (!help) { return [' ' + inv]; }
1712
+ if (inv.length + 2 <= helpPos - 2) { return [' ' + inv.padEnd(helpPos - 4) + ' ' + help]; }
1713
+ return [' ' + inv, ' '.repeat(helpPos) + help];
1714
+ };
1715
+ return [usage(prog), '', DOC.trimEnd(), '', 'positional arguments:', ...rows.flatMap(item), '',
1716
+ 'options:', ...opts.flatMap(item)].join('\n') + '\n';
1717
+ }
1718
+
1719
+ function parseArgs(argv, prog) {
1720
+ const fail = (msg) => {
1721
+ process.stderr.write((usage(prog) + '\n' + `${prog}: error: ${msg}\n`).replace(/\n/g, EOL));
1722
+ process.exit(2);
1723
+ };
1724
+ const LONG = ['--help', '--android', '--groups', '--out'];
1725
+ // classify: 'O' option, 'A' argument; the first '--' ends options and is dropped
1726
+ const kinds = [];
1727
+ const args = [];
1728
+ let rest = false;
1729
+ for (const s of argv) {
1730
+ if (!rest && s === '--') { rest = true; continue; }
1731
+ let k = 'A';
1732
+ if (!rest && s.startsWith('-') && s !== '-') {
1733
+ if (/^-\d+$|^-\d*\.\d+$/.test(s)) { k = 'A'; }
1734
+ else if (s.includes(' ') && !LONG.includes(s.split('=')[0]) && s.split('=')[0] !== '-h') { k = 'A'; }
1735
+ else { k = 'O'; }
1736
+ }
1737
+ kinds.push(k);
1738
+ args.push(s);
1739
+ }
1740
+ const res = { mode: null, harmony_dir: null, names: null, android: null, groups: '', out: null };
1741
+ const seen = new Set();
1742
+ const extras = [];
1743
+ const posActs = ['mode', 'harmony_dir', 'names'];
1744
+ let pi = 0; // next positional action
1745
+ const take = (act, vals) => {
1746
+ if (act === 'mode') {
1747
+ if (!['build', 'lookup'].includes(vals[0])) {
1748
+ fail(`argument mode: invalid choice: ${pyRepr(vals[0])} (choose from build, lookup)`);
1749
+ }
1750
+ res.mode = vals[0];
1751
+ } else if (act === 'harmony_dir') { res.harmony_dir = vals[0]; }
1752
+ else { res.names = vals; }
1753
+ seen.add(act);
1754
+ };
1755
+ // consume a run of 'A' args with the remaining positionals (greedy, names = '*')
1756
+ const consumePos = (start, end, more) => {
1757
+ let n = end - start;
1758
+ let i = start;
1759
+ const need = posActs.slice(pi);
1760
+ // how many fixed (exactly-one) actions can be satisfied
1761
+ const fixed = need.filter((a) => a !== 'names');
1762
+ let use = Math.min(n, fixed.length);
1763
+ for (let k = 0; k < use; k++) { take(fixed[k], [args[i]]); i++; pi++; }
1764
+ if (pi === 2 && use === fixed.length) {
1765
+ const left = end - i;
1766
+ if (left > 0 || !more) { take('names', args.slice(i, end)); i = end; pi++; }
1767
+ }
1768
+ return i;
1769
+ };
1770
+ let i = 0;
1771
+ while (i < args.length) {
1772
+ if (kinds[i] === 'A') {
1773
+ let j = i;
1774
+ while (j < args.length && kinds[j] === 'A') { j++; }
1775
+ const stop = consumePos(i, j, j < args.length);
1776
+ extras.push(...args.slice(stop, j));
1777
+ i = j;
1778
+ continue;
1779
+ }
1780
+ const s = args[i];
1781
+ const eq = s.startsWith('--') ? s.indexOf('=') : -1;
1782
+ const key = eq >= 0 ? s.slice(0, eq) : s;
1783
+ let opt = null;
1784
+ let explicit = eq >= 0 ? s.slice(eq + 1) : null;
1785
+ if (key === '-h' || LONG.includes(key)) { opt = key === '-h' ? '--help' : key; }
1786
+ else if (key.startsWith('--')) {
1787
+ const hits = LONG.filter((o) => o.startsWith(key));
1788
+ if (hits.length === 1) { opt = hits[0]; }
1789
+ } else if (s.startsWith('-h') && !s.startsWith('--')) {
1790
+ opt = '--help';
1791
+ explicit = s.slice(2);
1792
+ }
1793
+ if (!opt) { extras.push(s); i++; continue; }
1794
+ if (opt === '--help') {
1795
+ if (explicit !== null && explicit !== '') {
1796
+ fail(`argument -h/--help: ignored explicit argument ${pyRepr(explicit.replace(/^=/, ''))}`);
1797
+ }
1798
+ process.stdout.write(helpText(prog).replace(/\n/g, EOL));
1799
+ process.exit(0);
1800
+ }
1801
+ const dest = opt.slice(2);
1802
+ if (explicit !== null) { res[dest] = explicit; i++; }
1803
+ else if (i + 1 < args.length && kinds[i + 1] === 'A') { res[dest] = args[i + 1]; i += 2; }
1804
+ else { fail(`argument ${opt}: expected one argument`); }
1805
+ seen.add(dest);
1806
+ }
1807
+ if (pi === 2) { take('names', []); pi++; }
1808
+ const missing = [];
1809
+ if (!seen.has('mode')) { missing.push('mode'); }
1810
+ if (!seen.has('harmony_dir')) { missing.push('harmony_dir'); }
1811
+ if (!seen.has('android')) { missing.push('--android'); }
1812
+ if (missing.length) { fail(`the following arguments are required: ${missing.join(', ')}`); }
1813
+ if (extras.length) { fail(`unrecognized arguments: ${extras.join(' ')}`); }
1814
+ if (res.names === null) { res.names = []; }
1815
+ return res;
1816
+ }
1817
+
1818
+ export function main(argv = process.argv.slice(2)) {
1819
+ const prog = path.basename(process.argv[1] || 'group_pack.mjs');
1820
+ const a = parseArgs(argv, prog);
1821
+ let res;
1822
+ if (a.mode === 'build') {
1823
+ const only = new Set(a.groups.split(',').map(pyStrip).filter((g) => g));
1824
+ // inlining is on unless GROUP_PACK_INLINE=0 (a host whose read tool truncates large files)
1825
+ res = build(a.harmony_dir, a.android, a.out, only.size ? only : null,
1826
+ { inline: process.env.GROUP_PACK_INLINE !== '0' });
1827
+ } else {
1828
+ res = lookup(a.harmony_dir, a.android, a.names);
1829
+ }
1830
+ process.stdout.write((pyJsonDumps(res, 1) + '\n').replace(/\n/g, EOL));
1831
+ return 0;
1832
+ }
1833
+
1834
+ if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
1835
+ process.exitCode = main();
1836
+ }