@buaa_smat/hometrans 26.0.2 → 26.0.4

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 (1471) hide show
  1. package/README.md +8 -7
  2. package/agents/code-reviewer.md +111 -154
  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 +436 -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 +206 -0
  14. package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
  15. package/i18n/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  16. package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
  17. package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
  18. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +2007 -0
  19. package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +187 -0
  20. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1656 -0
  21. package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +728 -0
  22. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
  23. package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  24. package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  25. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  26. package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  27. package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  28. package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  29. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  30. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  31. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  32. package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  33. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  34. package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  35. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  36. package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  37. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  38. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  39. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  40. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  41. package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  42. package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  43. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +207 -0
  44. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  45. package/i18n/skills/a2h-arch-generate/SKILL.md +378 -0
  46. package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  47. package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  48. package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
  49. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  50. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  51. package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  52. package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  53. package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  54. package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  55. package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  56. package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +131 -0
  57. package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  58. package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
  59. package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
  60. package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  61. package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
  62. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  63. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  64. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  65. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  66. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  67. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  68. package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
  69. package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  70. package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
  71. package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
  72. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +304 -0
  73. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +10 -0
  74. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +249 -0
  75. package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +344 -0
  76. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
  77. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
  78. package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +877 -0
  79. package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  80. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  81. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  82. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  83. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  84. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  85. package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  86. package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +597 -0
  87. package/i18n/skills/a2h-batch-ui-align/SKILL.md +372 -0
  88. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +35 -0
  89. package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  90. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  91. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  92. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +85 -0
  93. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +23 -0
  94. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +89 -0
  95. package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  96. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  97. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +62 -0
  98. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +30 -0
  99. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +930 -0
  100. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +420 -0
  101. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +158 -0
  102. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  103. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2552 -0
  104. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
  105. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +175 -0
  106. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +251 -0
  107. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
  108. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +232 -0
  109. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +206 -0
  110. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +232 -0
  111. package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
  112. package/i18n/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  113. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +2118 -0
  114. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  115. package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  116. package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  117. package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1805 -0
  118. package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  119. package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  120. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1959 -0
  121. package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  122. package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
  123. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1632 -0
  124. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1300 -0
  125. package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1234 -0
  126. package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +417 -0
  127. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  128. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
  129. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +216 -0
  130. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +615 -0
  131. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  132. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +49 -0
  133. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  134. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  135. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  136. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
  137. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  138. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
  139. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  140. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  141. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  142. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  143. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  144. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  145. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  146. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  147. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  148. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  149. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  150. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  151. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  152. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  153. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +780 -0
  154. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  155. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  156. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +408 -0
  157. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  158. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  159. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  160. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  161. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  162. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  163. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  164. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +81 -0
  165. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
  166. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  167. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  168. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  169. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  170. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +147 -0
  171. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  172. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  173. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +127 -0
  174. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  175. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  176. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  177. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  178. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  179. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  180. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  181. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  182. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  183. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  184. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  185. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  186. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  187. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  188. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  189. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
  190. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  191. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  192. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  193. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  194. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  195. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  196. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  197. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  198. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  199. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  200. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  201. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  202. package/i18n/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  203. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  204. package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
  205. package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  206. package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  207. package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  208. package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  209. package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  210. package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  211. package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  212. package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  213. package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  214. package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  215. package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  216. package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  217. package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +62 -0
  218. package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
  219. package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
  220. package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  221. package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  222. package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  223. package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
  224. package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2050 -0
  225. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  226. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  227. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  228. package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  229. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  230. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  231. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
  232. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  233. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  234. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  235. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  236. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  237. package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  238. package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  239. package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
  240. package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  241. package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  242. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +265 -0
  243. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  244. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  245. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  246. package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  247. package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  248. package/i18n/skills/a2h-page-specgen/SKILL.md +239 -0
  249. package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +1174 -0
  250. package/i18n/skills/a2h-page-specgen/references/body-language.md +179 -0
  251. package/i18n/skills/a2h-page-specgen/references/gates.md +329 -0
  252. package/i18n/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  253. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +274 -0
  254. package/i18n/skills/a2h-page-specgen/references/spec-example.md +312 -0
  255. package/i18n/skills/a2h-page-specgen/references/spec-template.md +210 -0
  256. package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  257. package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  258. package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  259. package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  260. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  261. package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  262. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  263. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +864 -0
  264. package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +346 -0
  265. package/i18n/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  266. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  267. package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  268. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +684 -0
  269. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  270. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  271. package/i18n/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  272. package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +252 -0
  273. package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  274. package/i18n/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  275. package/i18n/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  276. package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  277. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +864 -0
  278. package/i18n/skills/a2h-page-specgen/scripts/render.mjs +276 -0
  279. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +897 -0
  280. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +25 -0
  281. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +373 -0
  282. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +300 -0
  283. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +47 -0
  284. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +373 -0
  285. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +300 -0
  286. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  287. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  288. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  289. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +373 -0
  290. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  291. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +267 -0
  292. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +57 -0
  293. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +373 -0
  294. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +300 -0
  295. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  296. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  297. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  298. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  299. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  300. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +553 -0
  301. package/i18n/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  302. package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  303. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +546 -0
  304. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +655 -0
  305. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1234 -0
  306. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +520 -0
  307. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1516 -0
  308. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +759 -0
  309. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +630 -0
  310. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +118 -0
  311. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +798 -0
  312. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +886 -0
  313. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  314. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  315. package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1205 -0
  316. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +271 -0
  317. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
  318. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
  319. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
  320. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  321. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  322. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  323. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  324. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  325. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  326. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  327. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  328. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  329. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  330. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  331. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  332. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  333. package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  334. package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  335. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1121 -0
  336. package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  337. package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  338. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  339. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  340. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  341. package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  342. package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +348 -0
  343. package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  344. package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  345. package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  346. package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  347. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  348. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  349. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  350. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +240 -0
  351. package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +427 -0
  352. package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  353. package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  354. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  355. package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  356. package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +536 -0
  357. package/i18n/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  358. package/i18n/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  359. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1239 -0
  360. package/i18n/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  361. package/i18n/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  362. package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  363. package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  364. package/i18n/skills/a2h-resource-convert/SKILL.md +375 -0
  365. package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +336 -0
  366. package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +272 -0
  367. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +226 -0
  368. package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
  369. package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +251 -0
  370. package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  371. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2596 -0
  372. package/i18n/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  373. package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  374. package/i18n/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  375. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +238 -0
  376. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +358 -0
  377. package/i18n/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +307 -0
  378. package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +103 -0
  379. package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +266 -0
  380. package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  381. package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +71 -0
  382. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +55 -0
  383. package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  384. package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +246 -0
  385. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +752 -0
  386. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +661 -0
  387. package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
  388. package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
  389. package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  390. package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  391. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
  392. package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
  393. package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  394. package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  395. package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  396. package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
  397. package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  398. package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  399. package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  400. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
  401. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  402. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  403. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  404. package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
  405. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
  406. package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  407. package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  408. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
  409. package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
  410. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
  411. package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
  412. package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
  413. package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
  414. package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
  415. package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
  416. package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
  417. package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
  418. package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
  419. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  420. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  421. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  422. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  423. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
  424. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
  425. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
  426. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
  427. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  428. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
  429. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
  430. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
  431. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
  432. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
  433. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
  434. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  435. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
  436. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
  437. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
  438. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  439. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
  440. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  441. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  442. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  443. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  444. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  445. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  446. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
  447. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
  448. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
  449. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
  450. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  451. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  452. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  453. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  454. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  455. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  456. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  457. package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
  458. package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  459. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
  460. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
  461. package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
  462. package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  463. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  464. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  465. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  466. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  467. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  468. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  469. package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  470. package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  471. package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  472. package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  473. package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  474. package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  475. package/i18n/skills/a2h-utg-explorer/SKILL.md +126 -0
  476. package/i18n/skills/a2h-utg-explorer/references/architecture.md +282 -0
  477. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +908 -0
  478. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
  479. package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
  480. package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  481. package/i18n/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  482. package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
  483. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +647 -0
  484. package/i18n/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  485. package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  486. package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  487. package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  488. package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +252 -0
  489. package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  490. package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  491. package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  492. package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  493. package/i18n/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  494. package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  495. package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  496. package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  497. package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  498. package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  499. package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  500. package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  501. package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  502. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  503. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  504. package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  505. package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  506. package/i18n/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  507. package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  508. package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  509. package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  510. package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  511. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  512. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  513. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1562 -0
  514. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  515. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2714 -0
  516. package/i18n/skills/a2h-utg-static/SKILL.md +372 -0
  517. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  518. package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
  519. package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2190 -0
  520. package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  521. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +720 -0
  522. package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
  523. package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
  524. package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  525. package/i18n/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  526. package/i18n/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  527. package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
  528. package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +705 -0
  529. package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  530. package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +958 -0
  531. package/i18n/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  532. package/i18n/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  533. package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +545 -0
  534. package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  535. package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
  536. package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  537. package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  538. package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  539. package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  540. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +125 -0
  541. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  542. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  543. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +113 -0
  544. package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  545. package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  546. package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  547. package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  548. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  549. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  550. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  551. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +457 -0
  552. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  553. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  554. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  555. package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  556. package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
  557. package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  558. package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +78 -0
  559. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  560. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  561. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  562. package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  563. package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  564. package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  565. package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  566. package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  567. package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  568. package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  569. package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  570. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  571. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  572. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  573. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +330 -0
  574. package/i18n/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  575. package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  576. package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1394 -0
  577. package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  578. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  579. package/package.json +11 -161
  580. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  581. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  582. package/skills/a2h-app-migrate/SKILL.md +31 -12
  583. package/skills/a2h-app-migrate/references/config.example.json +1 -0
  584. package/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  585. package/skills/a2h-app-migrate/references/stage-map.md +4 -2
  586. package/skills/a2h-app-migrate/references/workflow.yaml +427 -103
  587. package/skills/a2h-app-migrate/scripts/android_index.mjs +35 -8
  588. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +39 -1
  589. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -6
  590. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +144 -9
  591. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +14 -1
  592. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +46 -5
  593. package/skills/a2h-app-migrate/scripts/diagnose.mjs +162 -0
  594. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +178 -44
  595. package/skills/a2h-app-migrate/scripts/feature_scope.mjs +347 -0
  596. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +81 -11
  597. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +17 -1
  598. package/skills/a2h-app-migrate/scripts/ledger.mjs +80 -10
  599. package/skills/a2h-app-migrate/scripts/migration_manifest.mjs +351 -0
  600. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +9 -23
  601. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +72 -12
  602. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +33 -1
  603. package/skills/a2h-app-migrate/scripts/run_dir.mjs +137 -41
  604. package/skills/a2h-app-migrate/scripts/scope_model.mjs +255 -0
  605. package/skills/a2h-app-migrate/scripts/scope_report.mjs +128 -0
  606. package/skills/a2h-app-migrate/scripts/source_fp.mjs +120 -0
  607. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
  608. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
  609. package/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  610. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  611. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  612. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  613. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  614. package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
  615. package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  616. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
  617. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  618. package/skills/a2h-app-migrate/test/test_feature_scope.mjs +217 -0
  619. package/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  620. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  621. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  622. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
  623. package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  624. package/skills/a2h-app-migrate/test/test_incremental_acceptance.mjs +145 -0
  625. package/skills/a2h-app-migrate/test/test_incremental_phase2.mjs +223 -0
  626. package/skills/a2h-app-migrate/test/test_incremental_phase2_acceptance.mjs +157 -0
  627. package/skills/a2h-app-migrate/test/test_incremental_profile.mjs +84 -0
  628. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +101 -0
  629. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  630. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  631. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +150 -0
  632. package/skills/a2h-app-migrate/test/test_migration_manifest.mjs +225 -0
  633. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +86 -0
  634. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  635. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  636. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  637. package/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  638. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  639. package/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  640. package/skills/a2h-app-migrate/test/test_scope_model.mjs +172 -0
  641. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  642. package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
  643. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +155 -0
  644. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  645. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  646. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +511 -0
  647. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  648. package/skills/a2h-app-migrate/test/test_ui_batch_capture_audit.mjs +106 -0
  649. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +65 -0
  650. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  651. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  652. package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  653. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
  654. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +214 -0
  655. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  656. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  657. package/skills/a2h-arch-generate/SKILL.md +20 -17
  658. package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
  659. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
  660. package/skills/a2h-arch-generate/references/homegraph-workflow.md +25 -14
  661. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
  662. package/skills/a2h-arch-generate/references/source-baseline.md +4 -4
  663. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +34 -3
  664. package/skills/a2h-arch-generate/scripts/create_project.mjs +24 -1
  665. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
  666. package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +29 -5
  667. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
  668. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
  669. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  670. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  671. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  672. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  673. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  674. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  675. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  676. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  677. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  678. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  679. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  680. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  681. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  682. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  683. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  684. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  685. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  686. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  687. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  688. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  689. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  690. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  691. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  692. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  693. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  694. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  695. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  696. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
  697. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +208 -0
  698. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  699. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  700. package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  701. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +164 -0
  702. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
  703. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +4 -2
  704. package/skills/a2h-arkts-logic-coder/SKILL.md +163 -15
  705. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +3 -1
  706. package/skills/a2h-arkts-logic-coder/references/code-generation.md +120 -1
  707. package/skills/a2h-arkts-logic-coder/references/spec-design.md +46 -11
  708. package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
  709. package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +873 -0
  710. package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
  711. package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  712. package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  713. package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  714. package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
  715. package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  716. package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  717. package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  718. package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +596 -0
  719. package/skills/a2h-batch-ui-align/SKILL.md +78 -26
  720. package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +16 -2
  721. package/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
  722. package/skills/a2h-batch-ui-align/references/cards/geometry.md +6 -1
  723. package/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
  724. package/skills/a2h-batch-ui-align/references/cards/resources.md +9 -3
  725. package/skills/a2h-batch-ui-align/references/cards/widgets.md +27 -3
  726. package/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
  727. package/skills/a2h-batch-ui-align/references/checker-rules.md +301 -13
  728. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +53 -13
  729. package/skills/a2h-batch-ui-align/references/host-dispatch.md +2 -0
  730. package/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
  731. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +14 -9
  732. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
  733. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
  734. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +30 -0
  735. package/skills/a2h-batch-ui-align/references/step3-capture.md +25 -6
  736. package/skills/a2h-batch-ui-align/references/step4-prepare.md +7 -2
  737. package/skills/a2h-batch-ui-align/references/step5-convert.md +33 -9
  738. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
  739. package/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  740. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +463 -22
  741. package/skills/a2h-batch-ui-align/scripts/capture_audit.mjs +474 -0
  742. package/skills/a2h-batch-ui-align/scripts/capture_fast.mjs +665 -0
  743. package/skills/a2h-batch-ui-align/scripts/capture_verify.mjs +552 -0
  744. package/skills/a2h-batch-ui-align/scripts/detach.mjs +5 -2
  745. package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  746. package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +263 -0
  747. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +20 -3
  748. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
  749. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +220 -35
  750. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +517 -41
  751. package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  752. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
  753. package/skills/a2h-batch-ui-align/scripts/list_existing.mjs +141 -0
  754. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +239 -14
  755. package/skills/a2h-batch-ui-align/scripts/page_gap.mjs +210 -0
  756. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +98 -11
  757. package/skills/a2h-batch-ui-align/scripts/progress_identity.mjs +208 -0
  758. package/skills/a2h-batch-ui-align/scripts/scroll_verdict.mjs +62 -0
  759. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +118 -4
  760. package/skills/a2h-batch-ui-align/scripts/shell_requests.mjs +273 -0
  761. package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
  762. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
  763. package/skills/a2h-batch-ui-align/scripts/static_check/core/baseline.ts +79 -0
  764. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
  765. package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +90 -2
  766. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +44 -0
  767. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +61 -12
  768. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +32 -0
  769. package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
  770. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
  771. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
  772. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
  773. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
  774. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
  775. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
  776. package/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  777. package/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  778. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  779. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
  780. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  781. package/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  782. package/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  783. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
  784. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  785. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
  786. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +110 -12
  787. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  788. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  789. package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  790. package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
  791. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
  792. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  793. package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
  794. package/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  795. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
  796. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  797. package/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  798. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  799. package/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  800. package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
  801. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
  802. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +30 -2
  803. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +231 -0
  804. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  805. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
  806. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_baseline.test.mjs +129 -0
  807. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  808. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  809. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  810. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_runtime2.test.mjs +697 -0
  811. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  812. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +298 -0
  813. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  814. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  815. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  816. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  817. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  818. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +269 -0
  819. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  820. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +346 -0
  821. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  822. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
  823. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  824. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
  825. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme_runtime.test.mjs +95 -0
  826. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  827. package/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  828. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  829. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +291 -0
  830. package/skills/a2h-batch-ui-align/scripts/tests/capture_audit.test.mjs +179 -0
  831. package/skills/a2h-batch-ui-align/scripts/tests/capture_fast.test.mjs +56 -0
  832. package/skills/a2h-batch-ui-align/scripts/tests/capture_gate.test.mjs +197 -0
  833. package/skills/a2h-batch-ui-align/scripts/tests/capture_review_fixes.test.mjs +322 -0
  834. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +93 -0
  835. package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
  836. package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
  837. package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +435 -0
  838. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  839. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  840. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/SearchMenuDialog.buggy.ets +95 -0
  841. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/meta.json +21 -0
  842. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/screenshot.png +0 -0
  843. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/view.xml +35 -0
  844. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  845. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  846. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  847. package/skills/a2h-batch-ui-align/scripts/tests/group_pack_evidence.test.mjs +95 -0
  848. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1782 -0
  849. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  850. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  851. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  852. package/skills/a2h-batch-ui-align/scripts/tests/icon_coverage.test.mjs +314 -0
  853. package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  854. package/skills/a2h-batch-ui-align/scripts/tests/list_existing.test.mjs +157 -0
  855. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  856. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  857. package/skills/a2h-batch-ui-align/scripts/tests/page_gap.test.mjs +115 -0
  858. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  859. package/skills/a2h-batch-ui-align/scripts/tests/progress_identity.test.mjs +174 -0
  860. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +302 -0
  861. package/skills/a2h-batch-ui-align/scripts/tests/shell_requests.test.mjs +158 -0
  862. package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  863. package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  864. package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  865. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  866. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  867. package/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
  868. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
  869. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
  870. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  871. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  872. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  873. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  874. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  875. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  876. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  877. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  878. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  879. package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
  880. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  881. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  882. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  883. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  884. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  885. package/skills/a2h-dashboard-render/test/test_device_locale_dialogs.mjs +17 -0
  886. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  887. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  888. package/skills/a2h-module-semantic-docs/SKILL.md +51 -13
  889. package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +66 -11
  890. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  891. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  892. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  893. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  894. package/skills/a2h-module-semantic-docs/test/test_incremental_fingerprint.mjs +94 -0
  895. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  896. package/skills/a2h-page-specgen/SKILL.md +240 -0
  897. package/skills/a2h-page-specgen/references/behavior-ledger.md +1170 -0
  898. package/skills/a2h-page-specgen/references/body-language.md +179 -0
  899. package/skills/a2h-page-specgen/references/evidence.md +105 -0
  900. package/skills/a2h-page-specgen/references/execution-model.md +364 -0
  901. package/skills/a2h-page-specgen/references/footprint-and-grouping.md +255 -0
  902. package/skills/a2h-page-specgen/references/gates.md +323 -0
  903. package/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  904. package/skills/a2h-page-specgen/references/scenario-authoring.md +272 -0
  905. package/skills/a2h-page-specgen/references/spec-example.md +312 -0
  906. package/skills/a2h-page-specgen/references/spec-template.md +210 -0
  907. package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  908. package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  909. package/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  910. package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  911. package/skills/a2h-page-specgen/scripts/dispatch.mjs +212 -0
  912. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  913. package/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  914. package/skills/a2h-page-specgen/scripts/finalize.mjs +825 -0
  915. package/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  916. package/skills/a2h-page-specgen/scripts/gate.mjs +848 -0
  917. package/skills/a2h-page-specgen/scripts/interactions.mjs +344 -0
  918. package/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  919. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  920. package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
  921. package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +229 -0
  922. package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
  923. package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
  924. package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  925. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +683 -0
  926. package/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  927. package/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  928. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +478 -0
  929. package/skills/a2h-page-specgen/scripts/lib/main-module.mjs +24 -0
  930. package/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  931. package/skills/a2h-page-specgen/scripts/lib/prose.mjs +238 -0
  932. package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  933. package/skills/a2h-page-specgen/scripts/lib/recovery-policy.mjs +28 -0
  934. package/skills/a2h-page-specgen/scripts/lib/scope.mjs +355 -0
  935. package/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  936. package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  937. package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
  938. package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
  939. package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
  940. package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  941. package/skills/a2h-page-specgen/scripts/prepare.mjs +840 -0
  942. package/skills/a2h-page-specgen/scripts/render.mjs +294 -0
  943. package/skills/a2h-page-specgen/scripts/report.mjs +340 -0
  944. package/skills/a2h-page-specgen/scripts/submission.mjs +697 -0
  945. package/skills/a2h-page-specgen/scripts/submit.mjs +85 -0
  946. package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
  947. package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +871 -0
  948. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.java +15 -0
  949. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +26 -0
  950. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +347 -0
  951. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +298 -0
  952. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.java +36 -0
  953. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +43 -0
  954. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +347 -0
  955. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +298 -0
  956. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  957. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  958. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  959. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +347 -0
  960. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  961. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +265 -0
  962. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.java +47 -0
  963. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +54 -0
  964. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +347 -0
  965. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +298 -0
  966. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  967. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  968. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  969. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  970. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  971. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +515 -0
  972. package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
  973. package/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  974. package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  975. package/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +543 -0
  976. package/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +652 -0
  977. package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1231 -0
  978. package/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +494 -0
  979. package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1513 -0
  980. package/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +758 -0
  981. package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +623 -0
  982. package/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +116 -0
  983. package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +795 -0
  984. package/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +883 -0
  985. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  986. package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
  987. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  988. package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1203 -0
  989. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +243 -0
  990. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
  991. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
  992. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
  993. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
  994. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
  995. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
  996. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
  997. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
  998. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
  999. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
  1000. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
  1001. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
  1002. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
  1003. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
  1004. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
  1005. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
  1006. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
  1007. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
  1008. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
  1009. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
  1010. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
  1011. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
  1012. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
  1013. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
  1014. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
  1015. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
  1016. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
  1017. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
  1018. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
  1019. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
  1020. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
  1021. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
  1022. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
  1023. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
  1024. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
  1025. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
  1026. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
  1027. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
  1028. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
  1029. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
  1030. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
  1031. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
  1032. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
  1033. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
  1034. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
  1035. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
  1036. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
  1037. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
  1038. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
  1039. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
  1040. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
  1041. package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
  1042. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +112 -0
  1043. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.java +14 -0
  1044. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.kt +14 -0
  1045. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanelsKotlinForms.kt +12 -0
  1046. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ChildContent.java +6 -0
  1047. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ComposeLifecycle.kt +26 -0
  1048. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleCallAndOverride.java +10 -0
  1049. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleHooks.kt +31 -0
  1050. package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
  1051. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyLifecycleHooks.kt +12 -0
  1052. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
  1053. package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
  1054. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshOnResume.java +7 -0
  1055. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshResultNoise.kt +36 -0
  1056. package/skills/a2h-page-specgen/scripts/test/fixtures/src/SelectionView.java +5 -0
  1057. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ShowPage.vue +12 -0
  1058. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ThirdPartyLifecycle.kt +25 -0
  1059. package/skills/a2h-page-specgen/scripts/test/fixtures/src/fragment_detail.xml +1 -0
  1060. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  1061. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  1062. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  1063. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  1064. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  1065. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  1066. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  1067. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  1068. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  1069. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  1070. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  1071. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  1072. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
  1073. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
  1074. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  1075. package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
  1076. package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  1077. package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  1078. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1078 -0
  1079. package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  1080. package/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  1081. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  1082. package/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  1083. package/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  1084. package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  1085. package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +310 -0
  1086. package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  1087. package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  1088. package/skills/a2h-page-specgen/scripts/test/ledger-lock.test.mjs +77 -0
  1089. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
  1090. package/skills/a2h-page-specgen/scripts/test/main-module.test.mjs +43 -0
  1091. package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  1092. package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  1093. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  1094. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  1095. package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +160 -0
  1096. package/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  1097. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +236 -0
  1098. package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +398 -0
  1099. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  1100. package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  1101. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  1102. package/skills/a2h-page-specgen/scripts/test/recovery-policy.test.mjs +14 -0
  1103. package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  1104. package/skills/a2h-page-specgen/scripts/test/render.test.mjs +546 -0
  1105. package/skills/a2h-page-specgen/scripts/test/report.test.mjs +296 -0
  1106. package/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  1107. package/skills/a2h-page-specgen/scripts/test/scope.test.mjs +292 -0
  1108. package/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  1109. package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
  1110. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1231 -0
  1111. package/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  1112. package/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  1113. package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  1114. package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
  1115. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  1116. package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1993 -0
  1117. package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +342 -0
  1118. package/skills/a2h-page-specgen/scripts/waker.mjs +1301 -0
  1119. package/skills/a2h-page-specgen/scripts/watchdog.mjs +299 -0
  1120. package/skills/a2h-resource-convert/SKILL.md +9 -1
  1121. package/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
  1122. package/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
  1123. package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
  1124. package/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
  1125. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +115 -53
  1126. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +68 -0
  1127. package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +45 -3
  1128. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +42 -5
  1129. package/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  1130. package/skills/a2h-resource-convert/scripts/lottie_refs.ts +398 -0
  1131. package/skills/a2h-resource-convert/scripts/merge_mapping.ts +316 -0
  1132. package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +2 -1
  1133. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  1134. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  1135. package/skills/a2h-resource-convert/scripts/tests/code_vector_guard.test.mjs +75 -0
  1136. package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  1137. package/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  1138. package/skills/a2h-resource-convert/scripts/tests/lottie_incremental.test.mjs +178 -0
  1139. package/skills/a2h-resource-convert/scripts/tests/merge_mapping.test.mjs +201 -0
  1140. package/skills/a2h-spec-design-pipeline/SKILL.md +98 -121
  1141. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +170 -45
  1142. package/skills/a2h-spec-design-pipeline/references/execution-model.md +62 -12
  1143. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -4
  1144. package/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +229 -0
  1145. package/skills/a2h-spec-design-pipeline/references/initialization.md +49 -6
  1146. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +198 -54
  1147. package/skills/a2h-spec-design-pipeline/references/permission-index.json +206 -0
  1148. package/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  1149. package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +67 -0
  1150. package/skills/a2h-spec-design-pipeline/references/review-loop.md +46 -0
  1151. package/skills/a2h-spec-design-pipeline/references/scripts.md +47 -14
  1152. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +390 -0
  1153. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +148 -29
  1154. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +104 -24
  1155. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +18 -0
  1156. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +16 -0
  1157. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +47 -0
  1158. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +31 -0
  1159. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +698 -0
  1160. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +96 -0
  1161. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +103 -0
  1162. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +124 -0
  1163. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +138 -0
  1164. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +106 -0
  1165. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +113 -0
  1166. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +705 -0
  1167. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +1063 -0
  1168. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +473 -0
  1169. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/platform/ExtraDataSubCheck.js +485 -0
  1170. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +13 -0
  1171. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +18 -0
  1172. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
  1173. package/skills/a2h-spec-design-pipeline/scripts/check_design_map.ts +108 -0
  1174. package/skills/a2h-spec-design-pipeline/scripts/check_permissions.ts +420 -0
  1175. package/skills/a2h-spec-design-pipeline/scripts/check_review_evidence.ts +45 -0
  1176. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +95 -7
  1177. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +156 -7
  1178. package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +71 -0
  1179. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +22 -3
  1180. package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +63 -4
  1181. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +33 -3
  1182. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
  1183. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +232 -13
  1184. package/skills/a2h-spec-design-pipeline/scripts/ensure_index.ts +866 -0
  1185. package/skills/a2h-spec-design-pipeline/scripts/fixtures/homecheck-stub.cjs +47 -0
  1186. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +220 -44
  1187. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
  1188. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
  1189. package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
  1190. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +178 -14
  1191. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
  1192. package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +368 -0
  1193. package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
  1194. package/skills/a2h-spec-design-pipeline/scripts/sync_permission_index.ts +340 -0
  1195. package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +281 -0
  1196. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +690 -0
  1197. package/skills/a2h-spec-design-pipeline/scripts/test_check_design_map.ts +46 -0
  1198. package/skills/a2h-spec-design-pipeline/scripts/test_check_permissions.ts +201 -0
  1199. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +42 -8
  1200. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +27 -9
  1201. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +242 -9
  1202. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +192 -7
  1203. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +531 -0
  1204. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +49 -1
  1205. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +92 -4
  1206. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +51 -0
  1207. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index.ts +572 -0
  1208. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index_real.ts +56 -0
  1209. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +17 -10
  1210. package/skills/a2h-spec-design-pipeline/scripts/test_homegraph_docs.ts +217 -0
  1211. package/skills/a2h-spec-design-pipeline/scripts/test_permission_index.ts +214 -0
  1212. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
  1213. package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +308 -0
  1214. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
  1215. package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +401 -0
  1216. package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
  1217. package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
  1218. package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
  1219. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +165 -0
  1220. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
  1221. package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
  1222. package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
  1223. package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
  1224. package/skills/a2h-spec-generate/SKILL.md +89 -23
  1225. package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
  1226. package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  1227. package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
  1228. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  1229. package/skills/a2h-spec-generate/references/specs.schema.json +24 -11
  1230. package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
  1231. package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
  1232. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
  1233. package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
  1234. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
  1235. package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
  1236. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +1 -2
  1237. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
  1238. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
  1239. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
  1240. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
  1241. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
  1242. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
  1243. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
  1244. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
  1245. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
  1246. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
  1247. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
  1248. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
  1249. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  1250. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
  1251. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
  1252. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
  1253. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
  1254. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
  1255. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
  1256. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
  1257. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
  1258. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
  1259. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
  1260. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
  1261. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  1262. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  1263. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  1264. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  1265. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
  1266. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
  1267. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  1268. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  1269. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  1270. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
  1271. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  1272. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
  1273. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
  1274. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
  1275. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
  1276. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
  1277. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  1278. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  1279. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  1280. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  1281. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  1282. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  1283. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  1284. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  1285. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  1286. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  1287. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  1288. package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
  1289. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
  1290. package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
  1291. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
  1292. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  1293. package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
  1294. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +229 -0
  1295. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  1296. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  1297. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  1298. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  1299. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  1300. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  1301. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  1302. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  1303. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  1304. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  1305. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  1306. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  1307. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  1308. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  1309. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  1310. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  1311. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  1312. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  1313. package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  1314. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
  1315. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  1316. package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  1317. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  1318. package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  1319. package/skills/a2h-utg-explorer/SKILL.md +9 -3
  1320. package/skills/a2h-utg-explorer/references/architecture.md +7 -0
  1321. package/skills/a2h-utg-explorer/scripts/audit.mjs +8 -2
  1322. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +120 -85
  1323. package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +47 -2
  1324. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
  1325. package/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  1326. package/skills/a2h-utg-explorer/scripts/plan.mjs +8 -0
  1327. package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
  1328. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
  1329. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
  1330. package/skills/a2h-utg-explorer/scripts/report.mjs +89 -0
  1331. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +67 -10
  1332. package/skills/a2h-utg-explorer/scripts/run_device.mjs +10 -2
  1333. package/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  1334. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  1335. package/skills/a2h-utg-explorer/scripts/tests/blank_wait.test.mjs +126 -0
  1336. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
  1337. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  1338. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  1339. package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  1340. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  1341. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
  1342. package/skills/a2h-utg-explorer/scripts/tests/default_override.test.mjs +109 -0
  1343. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
  1344. package/skills/a2h-utg-explorer/scripts/tests/device_locale_dialogs.test.mjs +29 -0
  1345. package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
  1346. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  1347. package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +254 -0
  1348. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  1349. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
  1350. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  1351. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  1352. package/skills/a2h-utg-explorer/scripts/tests/foreground_spelling.test.mjs +155 -0
  1353. package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
  1354. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  1355. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  1356. package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
  1357. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +120 -0
  1358. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  1359. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  1360. package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  1361. package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
  1362. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  1363. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  1364. package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  1365. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  1366. package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  1367. package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  1368. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  1369. package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +218 -0
  1370. package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +292 -0
  1371. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  1372. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  1373. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  1374. package/skills/a2h-utg-explorer/scripts/tests/recover_d_grounding.test.mjs +164 -0
  1375. package/skills/a2h-utg-explorer/scripts/tests/replay_reroute.test.mjs +143 -0
  1376. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  1377. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  1378. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +458 -0
  1379. package/skills/a2h-utg-explorer/scripts/tests/run_cycle_follow.test.mjs +35 -0
  1380. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  1381. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  1382. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  1383. package/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  1384. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  1385. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
  1386. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  1387. package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
  1388. package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
  1389. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  1390. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  1391. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  1392. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  1393. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  1394. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +135 -7
  1395. package/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  1396. package/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  1397. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +245 -69
  1398. package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  1399. package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +164 -0
  1400. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +718 -42
  1401. package/skills/a2h-utg-explorer/scripts/variant.mjs +57 -11
  1402. package/skills/a2h-utg-static/SKILL.md +6 -2
  1403. package/skills/a2h-utg-static/scripts/assemble.mjs +93 -3
  1404. package/skills/a2h-utg-static/scripts/click_paths.mjs +135 -25
  1405. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
  1406. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +110 -3
  1407. package/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
  1408. package/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
  1409. package/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  1410. package/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  1411. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
  1412. package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +46 -1
  1413. package/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
  1414. package/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  1415. package/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  1416. package/skills/a2h-utg-static/scripts/menu_nav.mjs +1 -1
  1417. package/skills/a2h-utg-static/scripts/nl_hints.mjs +34 -7
  1418. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
  1419. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
  1420. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +86 -4
  1421. package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
  1422. package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
  1423. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +30 -0
  1424. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +18 -0
  1425. package/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  1426. package/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +114 -0
  1427. package/skills/a2h-utg-static/scripts/tests/test_guard_kinds_locale.mjs +12 -0
  1428. package/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  1429. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +165 -1
  1430. package/skills/a2h-utg-static/scripts/tests/test_library_activity.mjs +45 -0
  1431. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
  1432. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
  1433. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_default_override.mjs +50 -0
  1434. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +21 -0
  1435. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +172 -0
  1436. package/skills/a2h-utg-static/scripts/tests/test_redirect_path_cost.mjs +136 -0
  1437. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
  1438. package/skills/a2h-utg-static/scripts/tests/test_uniapp_route_jump.mjs +175 -0
  1439. package/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  1440. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +99 -0
  1441. package/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  1442. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +21 -0
  1443. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +112 -69
  1444. package/skills/a2h-utg-static/scripts/vm_nav.mjs +9 -1
  1445. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
  1446. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
  1447. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
  1448. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
  1449. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
  1450. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
  1451. package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
  1452. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
  1453. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
  1454. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
  1455. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
  1456. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
  1457. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
  1458. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +0 -885
  1459. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
  1460. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
  1461. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +0 -856
  1462. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
  1463. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
  1464. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
  1465. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
  1466. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
  1467. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
  1468. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
  1469. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
  1470. package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
  1471. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
@@ -0,0 +1,2118 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * build_conversion_set.mjs — make the static UTG, not the capture, decide what
4
+ * gets converted.
5
+ *
6
+ * node build_conversion_set.mjs <utg_static_ws> --ui-info <ui_info_root>
7
+ *
8
+ * (Node >= 22.18, ESM, zero dependencies. Behaviour-identical port of
9
+ * build_conversion_set.py: same args, exit codes, stdout and output files.)
10
+ *
11
+ * Run AFTER export_ui_info.mjs. Every static node gets exactly one role:
12
+ *
13
+ * page converted on its own. Tier `captured` when export_ui_info wrote
14
+ * a snapshot for it, else tier `source-only`: a page_NNNN_<Name>/
15
+ * directory is created with a meta.json that carries source hints
16
+ * (declared_at, layout files, ids, widgets, edges) and no screenshot.
17
+ * attach a menu / ui-state / mode / panel / embedded fragment. Converted as
18
+ * part of its host page's unit, never as a page of its own.
19
+ * skip not an app screen (out of scope, container, UI-less shell,
20
+ * unreachable). Listed with its reason, never silently dropped.
21
+ *
22
+ * Input : <ws>/utg.json, <ws>/click_paths.json,
23
+ * <ui_info>/export_manifest.json, <ui_info>/pages.json (both optional:
24
+ * without them every page is source-only).
25
+ * Output: <ui_info>/page_NNNN_<Name>/meta.json (source-only pages)
26
+ * <ui_info>/pages.json (captured first, then source-only)
27
+ * <ui_info>/conversion_set.json (every node's role, tier, reason;
28
+ * `plan`: the Step 4.2 groups, their
29
+ * predicted writes, class, lane, stage,
30
+ * `after` / `reuse_from` dependencies)
31
+ *
32
+ * Re-runnable: a source-only directory whose node has since been captured is
33
+ * removed, so it is not converted twice. Everything else is stable across
34
+ * re-runs: a source-only page keeps its directory and a group keeps its id
35
+ * (keyed by anchor; `--renumber` resets), so the builder can run after every
36
+ * explorer step while group_queue.mjs is already converting (`--exploring` holds
37
+ * source-only groups until the final run without it).
38
+ *
39
+ * Incremental mode (`--scope <json>`, the user-confirmed SCOPE of
40
+ * references/incremental-scope.md I4): only the scope's pages are converted. Every
41
+ * other page becomes `skip` (`out-of-incremental-scope`), and its source-only
42
+ * directory, if an earlier run made one, is left alone. The entry node is still
43
+ * inferred over the whole graph, so a group mounted on the existing launch page
44
+ * keeps `ENTRY_PAGE`. `--existing <json>` lists the .ets files the Harmony
45
+ * project already has (I3, relative to the ETS root): a group predicted to write
46
+ * one is `host-chain` with `existing_writes`. With no entry group in scope, the
47
+ * first host-chain group (else the first group) becomes stage 0: it reads the
48
+ * existing conventions before anything else converts.
49
+ */
50
+
51
+ import { createHash } from 'node:crypto';
52
+ import * as fs from 'node:fs';
53
+ import * as path from 'node:path';
54
+ import { pathToFileURL } from 'node:url';
55
+ import { _replace } from './group_watch.mjs';
56
+ import { scrollableContainers, sourceDeclaresScroll, sourceFileFor } from './capture_audit.mjs';
57
+ import { scrollVerdict } from './scroll_verdict.mjs';
58
+
59
+ // ---------------------------------------------------------------- Python compatibility layer
60
+ // These outputs are a contract read by other scripts and the agent and must match the original Python version byte for byte:
61
+ // JSON in json.dumps(indent=2, ensure_ascii=False) format (floats written by repr,
62
+ // big integers without precision loss, object keys in insertion order), text written with \r\n on Windows,
63
+ // sorting by Python comparison rules (strings by code point, tuples item by item, None not comparable).
64
+
65
+ const IS_WIN = process.platform === 'win32';
66
+ const EOL = IS_WIN ? '\r\n' : '\n';
67
+
68
+ /** A float read by json.loads: keeps the fact "it is a float" and is written back as Python repr. */
69
+ export class PyFloat {
70
+ constructor(value) { this.value = value; }
71
+ valueOf() { return this.value; }
72
+ }
73
+
74
+ // If a parsed object has integer-like keys ("0", "12"), plain JS objects move them first; record the original key order.
75
+ const KEY_ORDER = Symbol('pyKeyOrder');
76
+ const INDEX_KEY = /^(?:0|[1-9][0-9]*)$/;
77
+
78
+ function floatRepr(x, json) {
79
+ if (!Number.isFinite(x)) {
80
+ if (Number.isNaN(x)) { return json ? 'NaN' : 'nan'; }
81
+ return x > 0 ? (json ? 'Infinity' : 'inf') : (json ? '-Infinity' : '-inf');
82
+ }
83
+ if (x === 0) { return Object.is(x, -0) ? '-0.0' : '0.0'; }
84
+ const [m, e] = Math.abs(x).toExponential().split('e');
85
+ const digits = m.replace('.', '');
86
+ const exp = Number(e);
87
+ let s;
88
+ if (exp >= -4 && exp < 16) {
89
+ if (exp >= 0) {
90
+ const ip = digits.slice(0, exp + 1).padEnd(exp + 1, '0');
91
+ s = ip + '.' + (digits.slice(exp + 1) || '0');
92
+ } else {
93
+ s = '0.' + '0'.repeat(-exp - 1) + digits;
94
+ }
95
+ } else {
96
+ s = digits[0] + (digits.length > 1 ? '.' + digits.slice(1) : '') + 'e' + (exp < 0 ? '-' : '+') +
97
+ String(Math.abs(exp)).padStart(2, '0');
98
+ }
99
+ return (x < 0 ? '-' : '') + s;
100
+ }
101
+
102
+ /** json.loads: float → PyFloat, integers beyond the safe range → BigInt, otherwise same as JSON.parse. */
103
+ function pyJsonLoads(text) {
104
+ let i = 0;
105
+ const n = text.length;
106
+ const fail = (msg) => { throw new SyntaxError(`${msg}: char ${i}`); };
107
+ const ws = () => {
108
+ while (i < n) {
109
+ const c = text.charCodeAt(i);
110
+ if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d) { i++; } else { break; }
111
+ }
112
+ };
113
+ const NUM = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/y;
114
+ const str = () => {
115
+ i++;
116
+ let out = '';
117
+ let start = i;
118
+ for (;;) {
119
+ if (i >= n) { fail('Unterminated string'); }
120
+ const c = text.charCodeAt(i);
121
+ if (c === 0x22) { out += text.slice(start, i); i++; return out; }
122
+ if (c < 0x20) { fail('Invalid control character'); }
123
+ if (c === 0x5c) {
124
+ out += text.slice(start, i);
125
+ const esc = text[i + 1];
126
+ const simple = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }[esc];
127
+ if (simple !== undefined) {
128
+ out += simple;
129
+ i += 2;
130
+ } else if (esc === 'u') {
131
+ const hex = text.slice(i + 2, i + 6);
132
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) { fail('Invalid \\uXXXX escape'); }
133
+ out += String.fromCharCode(parseInt(hex, 16));
134
+ i += 6;
135
+ } else {
136
+ fail('Invalid \\escape');
137
+ }
138
+ start = i;
139
+ continue;
140
+ }
141
+ i++;
142
+ }
143
+ };
144
+ const value = () => {
145
+ ws();
146
+ const c = text[i];
147
+ if (c === '{') {
148
+ i++;
149
+ const o = {};
150
+ const order = [];
151
+ let hasIndex = false;
152
+ ws();
153
+ if (text[i] === '}') { i++; return o; }
154
+ for (;;) {
155
+ ws();
156
+ if (text[i] !== '"') { fail('Expecting property name enclosed in double quotes'); }
157
+ const k = str();
158
+ ws();
159
+ if (text[i] !== ':') { fail("Expecting ':' delimiter"); }
160
+ i++;
161
+ const v = value();
162
+ if (!Object.hasOwn(o, k)) {
163
+ order.push(k);
164
+ if (INDEX_KEY.test(k)) { hasIndex = true; }
165
+ }
166
+ if (k === '__proto__') {
167
+ Object.defineProperty(o, k, { value: v, enumerable: true, writable: true, configurable: true });
168
+ } else {
169
+ o[k] = v;
170
+ }
171
+ ws();
172
+ if (text[i] === ',') { i++; continue; }
173
+ if (text[i] === '}') { i++; break; }
174
+ fail("Expecting ',' delimiter");
175
+ }
176
+ if (hasIndex) { o[KEY_ORDER] = order; }
177
+ return o;
178
+ }
179
+ if (c === '[') {
180
+ i++;
181
+ const a = [];
182
+ ws();
183
+ if (text[i] === ']') { i++; return a; }
184
+ for (;;) {
185
+ a.push(value());
186
+ ws();
187
+ if (text[i] === ',') { i++; continue; }
188
+ if (text[i] === ']') { i++; break; }
189
+ fail("Expecting ',' delimiter");
190
+ }
191
+ return a;
192
+ }
193
+ if (c === '"') { return str(); }
194
+ if (text.startsWith('null', i)) { i += 4; return null; }
195
+ if (text.startsWith('true', i)) { i += 4; return true; }
196
+ if (text.startsWith('false', i)) { i += 5; return false; }
197
+ if (text.startsWith('NaN', i)) { i += 3; return new PyFloat(NaN); }
198
+ if (text.startsWith('Infinity', i)) { i += 8; return new PyFloat(Infinity); }
199
+ if (text.startsWith('-Infinity', i)) { i += 9; return new PyFloat(-Infinity); }
200
+ NUM.lastIndex = i;
201
+ const m = NUM.exec(text);
202
+ if (!m) { fail('Expecting value'); }
203
+ i += m[0].length;
204
+ if (m[1] !== undefined || m[2] !== undefined) { return new PyFloat(Number(m[0])); }
205
+ const num = Number(m[0]);
206
+ return Number.isSafeInteger(num) ? (num === 0 ? 0 : num) : BigInt(m[0]);
207
+ };
208
+ const v = value();
209
+ ws();
210
+ if (i !== n) { fail('Extra data'); }
211
+ return v;
212
+ }
213
+
214
+ function keysOf(o) {
215
+ const ks = Object.keys(o);
216
+ const ord = o[KEY_ORDER];
217
+ if (!ord) { return ks; }
218
+ const present = new Set(ks);
219
+ const out = ord.filter((k) => present.has(k));
220
+ const seen = new Set(out);
221
+ for (const k of ks) { if (!seen.has(k)) { out.push(k); } }
222
+ return out;
223
+ }
224
+
225
+ /** json.dumps(v, ensure_ascii=False, indent=indent). undefined is treated as None (matches dict.get default). */
226
+ function pyJsonDumps(v, indent, level = 0) {
227
+ if (v === null || v === undefined) { return 'null'; }
228
+ if (v === true) { return 'true'; }
229
+ if (v === false) { return 'false'; }
230
+ if (typeof v === 'bigint') { return v.toString(); }
231
+ if (v instanceof PyFloat) { return floatRepr(v.value, true); }
232
+ if (typeof v === 'number') { return Number.isInteger(v) ? (Object.is(v, -0) ? '0' : String(v)) : floatRepr(v, true); }
233
+ if (typeof v === 'string') { return JSON.stringify(v); }
234
+ const pad = '\n' + ' '.repeat(indent * (level + 1));
235
+ const end = '\n' + ' '.repeat(indent * level);
236
+ if (Array.isArray(v)) {
237
+ if (v.length === 0) { return '[]'; }
238
+ return '[' + pad + v.map((x) => pyJsonDumps(x, indent, level + 1)).join(',' + pad) + end + ']';
239
+ }
240
+ const ks = keysOf(v);
241
+ if (ks.length === 0) { return '{}'; }
242
+ return '{' + pad + ks.map((k) => JSON.stringify(k) + ': ' + pyJsonDumps(v[k], indent, level + 1)).join(',' + pad) +
243
+ end + '}';
244
+ }
245
+
246
+ const UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
247
+
248
+ /** Path.read_text(encoding="utf-8"): strict decoding, BOM kept, universal newlines. */
249
+ function readText(p) {
250
+ return UTF8.decode(fs.readFileSync(p)).replace(/\r\n?/g, '\n');
251
+ }
252
+
253
+
254
+ function out(s = '') { process.stdout.write(s + EOL); }
255
+ function err(s = '') { process.stderr.write(s + EOL); }
256
+
257
+ function isFile(p) {
258
+ try { return fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false; } catch { return false; }
259
+ }
260
+ function isDir(p) {
261
+ try { return fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false; } catch { return false; }
262
+ }
263
+ function exists(p) {
264
+ try { return fs.statSync(p, { throwIfNoEntry: false }) !== undefined; } catch { return false; }
265
+ }
266
+
267
+ /** dict.get(k, d): the default is used only when the key is missing; a null value is still returned as null. */
268
+ function get(o, k, d = undefined) {
269
+ return o !== null && typeof o === 'object' && !Array.isArray(o) && Object.hasOwn(o, k) ? o[k] : d;
270
+ }
271
+
272
+ function truthy(v) {
273
+ if (v === null || v === undefined || v === false) { return false; }
274
+ if (v === true) { return true; }
275
+ if (typeof v === 'number') { return v !== 0; }
276
+ if (typeof v === 'bigint') { return v !== 0n; }
277
+ if (v instanceof PyFloat) { return v.value !== 0; }
278
+ if (typeof v === 'string' || Array.isArray(v)) { return v.length > 0; }
279
+ if (v instanceof Map || v instanceof Set) { return v.size > 0; }
280
+ return Object.keys(v).length > 0;
281
+ }
282
+
283
+ /** Python's `a or b`. */
284
+ function or(a, b) { return truthy(a) ? a : b; }
285
+
286
+ function pyLen(v) {
287
+ if (typeof v === 'string') { return [...v].length; }
288
+ if (Array.isArray(v)) { return v.length; }
289
+ if (v !== null && typeof v === 'object' && !(v instanceof PyFloat)) { return Object.keys(v).length; }
290
+ throw new TypeError(`object of type '${pyType(v)}' has no len()`);
291
+ }
292
+
293
+ function pyType(v) {
294
+ if (v === null || v === undefined) { return 'NoneType'; }
295
+ if (typeof v === 'boolean') { return 'bool'; }
296
+ if (typeof v === 'number') { return Number.isInteger(v) ? 'int' : 'float'; }
297
+ if (typeof v === 'bigint') { return 'int'; }
298
+ if (v instanceof PyFloat) { return 'float'; }
299
+ if (typeof v === 'string') { return 'str'; }
300
+ if (Array.isArray(v)) { return 'list'; }
301
+ return 'dict';
302
+ }
303
+
304
+ /** Python's `x in container` (list by equality, str by substring, dict by key). */
305
+ function pyIn(x, c) {
306
+ if (typeof c === 'string') { return typeof x === 'string' && c.includes(x); }
307
+ if (Array.isArray(c)) { return c.some((y) => pyEq(x, y)); }
308
+ if (c !== null && typeof c === 'object') { return typeof x === 'string' && Object.hasOwn(c, x); }
309
+ throw new TypeError(`argument of type '${pyType(c)}' is not iterable`);
310
+ }
311
+
312
+ function numOf(v) {
313
+ if (typeof v === 'boolean') { return v ? 1 : 0; }
314
+ if (v instanceof PyFloat) { return v.value; }
315
+ if (typeof v === 'number' || typeof v === 'bigint') { return v; }
316
+ return undefined;
317
+ }
318
+
319
+ function pyEq(a, b) {
320
+ if (a === undefined) { a = null; }
321
+ if (b === undefined) { b = null; }
322
+ const na = numOf(a);
323
+ const nb = numOf(b);
324
+ if (na !== undefined && nb !== undefined) { return na == nb; } // eslint-disable-line eqeqeq
325
+ if (na !== undefined || nb !== undefined) { return false; }
326
+ if (a === null || b === null || typeof a === 'string' || typeof b === 'string') { return a === b; }
327
+ if (Array.isArray(a) || Array.isArray(b)) {
328
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((x, i) => pyEq(x, b[i]));
329
+ }
330
+ const ka = Object.keys(a);
331
+ return ka.length === Object.keys(b).length && ka.every((k) => Object.hasOwn(b, k) && pyEq(a[k], b[k]));
332
+ }
333
+
334
+ const SURROGATE = /[\uD800-\uDFFF]/;
335
+
336
+ function cmpStr(a, b) {
337
+ if (!SURROGATE.test(a) && !SURROGATE.test(b)) { return a < b ? -1 : a > b ? 1 : 0; }
338
+ const x = [...a];
339
+ const y = [...b];
340
+ for (let i = 0; i < Math.min(x.length, y.length); i++) {
341
+ const d = x[i].codePointAt(0) - y[i].codePointAt(0);
342
+ if (d !== 0) { return d < 0 ? -1 : 1; }
343
+ }
344
+ return x.length - y.length < 0 ? -1 : x.length > y.length ? 1 : 0;
345
+ }
346
+
347
+ /** Python `<` comparison (for sorted keys): numbers compare with each other, str by code point, tuple/list item by item; other combinations throw TypeError. */
348
+ function pyCmp(a, b) {
349
+ const na = numOf(a);
350
+ const nb = numOf(b);
351
+ if (na !== undefined && nb !== undefined) { return na < nb ? -1 : na > nb ? 1 : 0; }
352
+ if (typeof a === 'string' && typeof b === 'string') { return cmpStr(a, b); }
353
+ if (Array.isArray(a) && Array.isArray(b)) {
354
+ for (let i = 0; i < Math.min(a.length, b.length); i++) {
355
+ if (!pyEq(a[i], b[i])) { return pyCmp(a[i], b[i]); }
356
+ }
357
+ return a.length < b.length ? -1 : a.length > b.length ? 1 : 0;
358
+ }
359
+ throw new TypeError(`'<' not supported between instances of '${pyType(a)}' and '${pyType(b)}'`);
360
+ }
361
+
362
+ /** sorted(items, key=key, reverse=reverse): stable sort. */
363
+ function sortedBy(items, key = (x) => x, reverse = false) {
364
+ const dec = [...items].map((v, i) => [key(v), i, v]);
365
+ dec.sort((p, q) => (reverse ? pyCmp(q[0], p[0]) : pyCmp(p[0], q[0])) || p[1] - q[1]);
366
+ return dec.map((d) => d[2]);
367
+ }
368
+
369
+ const NON_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
370
+
371
+ function strRepr(s) {
372
+ const q = s.includes("'") && !s.includes('"') ? '"' : "'";
373
+ let r = q;
374
+ for (const ch of s) {
375
+ const cp = ch.codePointAt(0);
376
+ if (ch === q || ch === '\\') { r += '\\' + ch; }
377
+ else if (ch === '\t') { r += '\\t'; }
378
+ else if (ch === '\n') { r += '\\n'; }
379
+ else if (ch === '\r') { r += '\\r'; }
380
+ else if (ch !== ' ' && NON_PRINTABLE.test(ch)) {
381
+ r += cp < 0x100 ? '\\x' + cp.toString(16).padStart(2, '0')
382
+ : cp < 0x10000 ? '\\u' + cp.toString(16).padStart(4, '0') : '\\U' + cp.toString(16).padStart(8, '0');
383
+ } else { r += ch; }
384
+ }
385
+ return r + q;
386
+ }
387
+
388
+ /** repr(v). */
389
+ function pyRepr(v) {
390
+ if (v === null || v === undefined) { return 'None'; }
391
+ if (v === true) { return 'True'; }
392
+ if (v === false) { return 'False'; }
393
+ if (typeof v === 'bigint') { return v.toString(); }
394
+ if (v instanceof PyFloat) { return floatRepr(v.value, false); }
395
+ if (typeof v === 'number') { return Number.isInteger(v) ? String(v === 0 ? 0 : v) : floatRepr(v, false); }
396
+ if (typeof v === 'string') { return strRepr(v); }
397
+ if (Array.isArray(v)) { return '[' + v.map(pyRepr).join(', ') + ']'; }
398
+ return '{' + keysOf(v).map((k) => strRepr(k) + ': ' + pyRepr(v[k])).join(', ') + '}';
399
+ }
400
+
401
+ /** str(v) / f"{v}". */
402
+ function pyStr(v) { return typeof v === 'string' ? v : pyRepr(v); }
403
+
404
+ /** int() of a re `\d+` match (Unicode decimal digits: each Nd run is aligned blocks of ten). */
405
+ function pyInt(digits) {
406
+ let s = '';
407
+ for (const ch of digits) {
408
+ let cp = ch.codePointAt(0);
409
+ let k = 0;
410
+ while (/\p{Nd}/u.test(String.fromCodePoint(cp - 1))) { cp--; k++; }
411
+ s += String(k % 10);
412
+ }
413
+ const n = Number(s);
414
+ return Number.isSafeInteger(n) ? n : BigInt(s);
415
+ }
416
+
417
+ function setdefault(m, k, d) {
418
+ if (!m.has(k)) { m.set(k, d); }
419
+ return m.get(k);
420
+ }
421
+
422
+ // ---------------------------------------------------------------- paths (pathlib semantics)
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
+ /** str(Path(p)). */
441
+ function pathStr(p) {
442
+ const { drive, root, parts } = splitPath(p);
443
+ const s = drive + root + parts.join(IS_WIN ? '\\' : '/');
444
+ return s || '.';
445
+ }
446
+
447
+ /** Path(p).name. */
448
+ function pathName(p) {
449
+ const { parts } = splitPath(p);
450
+ return parts.length ? parts[parts.length - 1] : '';
451
+ }
452
+
453
+ /** Path(p).resolve(): realpath on the longest existing prefix, the rest copied as is. */
454
+ function pathResolve(p) {
455
+ let abs = path.resolve(String(p));
456
+ const tail = [];
457
+ for (;;) {
458
+ try {
459
+ const real = fs.realpathSync.native(abs);
460
+ return tail.length ? path.join(real, ...tail.reverse()) : real;
461
+ } catch {
462
+ const parent = path.dirname(abs);
463
+ if (parent === abs) { return path.resolve(String(p)); }
464
+ tail.push(path.basename(abs));
465
+ abs = parent;
466
+ }
467
+ }
468
+ }
469
+
470
+ /** Path(p).absolute(): only prepends cwd, does not normalize `..`. */
471
+ function pathAbsolute(p) {
472
+ const { drive, root, parts } = splitPath(p);
473
+ const sep = IS_WIN ? '\\' : '/';
474
+ if (IS_WIN ? (drive && root) || /^\\\\/.test(drive) : root) { return pathStr(p); }
475
+ const cwd = process.cwd();
476
+ if (root) { return splitPath(cwd).drive + root + parts.join(sep); }
477
+ const base = drive ? path.resolve(drive) : cwd;
478
+ return [base.replace(/[\\/]+$/, ''), ...parts].join(sep) || base;
479
+ }
480
+
481
+ /** Path(dir).glob(prefix + '*'): raw file-system order (os.scandir), case-insensitive on Windows. */
482
+ function globPrefix(dir, prefix) {
483
+ const names = [];
484
+ let d;
485
+ try { d = fs.opendirSync(dir); } catch { return names; }
486
+ try {
487
+ for (let e = d.readSync(); e !== null; e = d.readSync()) {
488
+ const nm = e.name;
489
+ if (IS_WIN ? nm.toLowerCase().startsWith(prefix.toLowerCase()) : nm.startsWith(prefix)) { names.push(nm); }
490
+ }
491
+ } finally { d.closeSync(); }
492
+ return names.map((nm) => path.join(String(dir), nm));
493
+ }
494
+
495
+ // ---------------------------------------------------------------- argparse equivalent
496
+ // Replicates argparse's observable behavior: unique long-option prefixes, `--opt=value`, `--`,
497
+ // `-h/--help` layout (width = terminal columns - 2), on error prints usage to stderr and exits 2.
498
+
499
+ function termColumns() {
500
+ const env = Number.parseInt(process.env.COLUMNS ?? '', 10);
501
+ if (env > 0) { return env; }
502
+ // shutil.get_terminal_size(): COLUMNS, else the stdout tty, else 80.
503
+ return process.stdout.isTTY && process.stdout.columns ? process.stdout.columns : 80;
504
+ }
505
+
506
+ /** Common subset of textwrap.wrap(width): break at whitespace, hard-split overlong words. */
507
+ function wrapText(text, width) {
508
+ const words = text.split(' ').filter((w) => w !== '');
509
+ const lines = [];
510
+ let cur = '';
511
+ for (let w of words) {
512
+ while (w.length > width && cur === '') { lines.push(w.slice(0, width)); w = w.slice(width); }
513
+ if (cur === '') { cur = w; }
514
+ else if (cur.length + 1 + w.length <= width) { cur += ' ' + w; }
515
+ else {
516
+ lines.push(cur);
517
+ cur = '';
518
+ while (w.length > width) { lines.push(w.slice(0, width)); w = w.slice(width); }
519
+ cur = w;
520
+ }
521
+ }
522
+ if (cur !== '') { lines.push(cur); }
523
+ return lines;
524
+ }
525
+
526
+ /**
527
+ * spec: { prog, description, args: [{ name, positional?, metavar?, help?, required?, type?: 'int', def? }] }
528
+ * Returns { dest: value } (dest = leading `--` removed, `-` replaced with `_`).
529
+ */
530
+ function parseArgs(spec, argv) {
531
+ const width = termColumns() - 2;
532
+ const actions = [{ name: '-h', alias: '--help', help: 'show this help message and exit', flag: true }, ...spec.args];
533
+ const dest = (a) => a.name.replace(/^-+/, '').replace(/-/g, '_');
534
+ const metavar = (a) => a.metavar ?? dest(a).toUpperCase();
535
+ const invocation = (a) => (a.positional ? a.name : a.flag ? `${a.name}, ${a.alias}` : a.bool ? a.name : `${a.name} ${metavar(a)}`);
536
+ const usagePart = (a) => {
537
+ if (a.positional) { return a.name; }
538
+ const s = a.flag || a.bool ? a.name : `${a.name} ${metavar(a)}`;
539
+ return a.required ? s : `[${s}]`;
540
+ };
541
+ const opts = actions.filter((a) => !a.positional);
542
+ const poss = actions.filter((a) => a.positional);
543
+
544
+ const formatUsage = () => {
545
+ const prefix = 'usage: ';
546
+ const prog = spec.prog;
547
+ const optParts = opts.map(usagePart);
548
+ const posParts = poss.map(usagePart);
549
+ let usage = [prog, ...optParts, ...posParts].join(' ');
550
+ if (prefix.length + usage.length > width) {
551
+ const getLines = (parts, indent, pfx) => {
552
+ const lines = [];
553
+ let line = [];
554
+ let len = pfx !== undefined ? pfx.length - 1 : indent.length - 1;
555
+ for (const part of parts) {
556
+ if (len + 1 + part.length > width && line.length) {
557
+ lines.push(indent + line.join(' '));
558
+ line = [];
559
+ len = indent.length - 1;
560
+ }
561
+ line.push(part);
562
+ len += part.length + 1;
563
+ }
564
+ if (line.length) { lines.push(indent + line.join(' ')); }
565
+ if (pfx !== undefined) { lines[0] = lines[0].slice(indent.length); }
566
+ return lines;
567
+ };
568
+ let lines;
569
+ if (prefix.length + prog.length <= 0.75 * width) {
570
+ const indent = ' '.repeat(prefix.length + prog.length + 1);
571
+ lines = getLines([prog, ...optParts], indent, prefix);
572
+ lines.push(...getLines(posParts, indent));
573
+ } else {
574
+ const indent = ' '.repeat(prefix.length);
575
+ lines = getLines([...optParts, ...posParts], indent);
576
+ if (lines.length > 1) { lines = [...getLines(optParts, indent), ...getLines(posParts, indent)]; }
577
+ lines = [prog, ...lines];
578
+ }
579
+ usage = lines.join('\n');
580
+ }
581
+ return prefix + usage;
582
+ };
583
+
584
+ const formatHelp = () => {
585
+ const maxHelpPos = Math.min(24, Math.max(width - 20, 4));
586
+ const maxLen = Math.max(...actions.map((a) => invocation(a).length + 2));
587
+ const helpPos = Math.min(maxLen + 2, maxHelpPos);
588
+ const helpWidth = Math.max(width - helpPos, 11);
589
+ const actionWidth = helpPos - 2 - 2;
590
+ const item = (a) => {
591
+ const inv = invocation(a);
592
+ const rows = [];
593
+ let first;
594
+ if (!a.help) { rows.push(' ' + inv); return rows; }
595
+ if (inv.length <= actionWidth) { first = ' ' + inv.padEnd(actionWidth) + ' '; }
596
+ else { rows.push(' ' + inv); first = ' '.repeat(helpPos); }
597
+ const hl = wrapText(a.help.replace(/\s+/g, ' ').trim(), helpWidth);
598
+ rows.push(first + hl[0]);
599
+ for (const l of hl.slice(1)) { rows.push(' '.repeat(helpPos) + l); }
600
+ return rows;
601
+ };
602
+ const parts = [formatUsage(), ''];
603
+ if (spec.description) { parts.push(...wrapText(spec.description.replace(/\s+/g, ' ').trim(), width), ''); }
604
+ if (poss.length) { parts.push('positional arguments:', ...poss.flatMap(item), ''); }
605
+ parts.push('options:', ...opts.flatMap(item));
606
+ return parts.join('\n');
607
+ };
608
+
609
+ const fail = (msg) => {
610
+ err(formatUsage());
611
+ err(`${spec.prog}: error: ${msg}`);
612
+ process.exit(2);
613
+ };
614
+
615
+ const result = {};
616
+ for (const a of spec.args) { result[dest(a)] = a.bool ? false : (a.def ?? null); }
617
+ const seen = new Set();
618
+ const positionals = [];
619
+ const extras = [];
620
+ const longNames = opts.flatMap((a) => (a.alias ? [[a.name, a], [a.alias, a]] : [[a.name, a]]));
621
+ const looksNegative = (s) => /^-\d+$|^-\d*\.\d+$/.test(s);
622
+ const isOptionLike = (s) => s.startsWith('-') && s !== '-' && !looksNegative(s) && !(s.includes(' ') && !findOpt(s));
623
+ function findOpt(s) {
624
+ const [k] = s.split('=', 1);
625
+ const exact = longNames.find(([n]) => n === k);
626
+ if (exact) { return exact[1]; }
627
+ if (!k.startsWith('--')) { return null; }
628
+ const hits = longNames.filter(([n]) => n.startsWith(k));
629
+ const uniq = [...new Set(hits.map((h) => h[1]))];
630
+ if (uniq.length > 1) { fail(`ambiguous option: ${k} could match ${hits.map((h) => h[0]).join(', ')}`); }
631
+ return uniq[0] ?? null;
632
+ }
633
+ let i = 0;
634
+ let rest = false;
635
+ while (i < argv.length) {
636
+ const s = argv[i];
637
+ if (!rest && s === '--') { rest = true; i++; continue; }
638
+ if (rest || !isOptionLike(s)) { positionals.push(s); i++; continue; }
639
+ const a = findOpt(s);
640
+ if (!a) { extras.push(s); i++; continue; }
641
+ const eq = s.indexOf('=');
642
+ const name = a.name;
643
+ if (a.flag) {
644
+ if (eq >= 0) { fail(`argument -h/--help: ignored explicit argument '${s.slice(eq + 1)}'`); }
645
+ process.stdout.write((formatHelp() + '\n').replace(/\n/g, EOL));
646
+ process.exit(0);
647
+ }
648
+ if (a.bool) {
649
+ if (eq >= 0) { fail(`argument ${name}: ignored explicit argument '${s.slice(eq + 1)}'`); }
650
+ result[dest(a)] = true;
651
+ seen.add(a);
652
+ i++;
653
+ continue;
654
+ }
655
+ let val;
656
+ if (eq >= 0 && s.startsWith('--')) { val = s.slice(eq + 1); i++; }
657
+ else if (i + 1 < argv.length && !(argv[i + 1] === '--' || isOptionLike(argv[i + 1]))) { val = argv[i + 1]; i += 2; }
658
+ else { fail(`argument ${name}: expected one argument`); }
659
+ if (a.type === 'int') {
660
+ const t = val.trim();
661
+ if (!/^[+-]?\p{Nd}+(?:_\p{Nd}+)*$/u.test(t)) { fail(`argument ${name}: invalid int value: ${pyRepr(val)}`); }
662
+ val = Number(pyInt(t.replace(/^[+-]|_/g, ''))) * (t.startsWith('-') ? -1 : 1);
663
+ }
664
+ result[dest(a)] = val;
665
+ seen.add(a);
666
+ }
667
+ poss.forEach((a, k) => { if (k < positionals.length) { result[dest(a)] = positionals[k]; seen.add(a); } });
668
+ extras.push(...positionals.slice(poss.length));
669
+ const missing = actions.filter((a) => (a.positional || a.required) && !seen.has(a)).map((a) => a.name);
670
+ if (missing.length) { fail(`the following arguments are required: ${missing.join(', ')}`); }
671
+ if (extras.length) { fail(`unrecognized arguments: ${extras.join(' ')}`); }
672
+ return result;
673
+ }
674
+
675
+ // ---------------------------------------------------------------- roles
676
+
677
+ // Same container kinds export_ui_info refuses to export, minus the ones
678
+ // that are UI attached to a host (they become `attach`, not `skip`).
679
+ export const SKIP_KINDS = new Set(['host-activity', 'sentinel', 'media-browse', 'media-player', 'unknown', 'hybrid']);
680
+ export const ATTACH_KINDS = new Set(['menu', 'ui-state', 'mode', 'panel']);
681
+ export const PAGE_PREFIXES = ['activity:', 'fragment:', 'dialog:', 'pref-dialog:', 'overlay:'];
682
+ export const ARROW = ' → ';
683
+ export const MAX_TEMPLATES = 3;
684
+ export const GENERIC_BASES = new Set(['Fragment', 'DialogFragment', 'AppCompatDialogFragment', 'BottomSheetDialogFragment',
685
+ 'Activity', 'AppCompatActivity', 'FragmentActivity', 'PreferenceFragmentCompat']);
686
+
687
+ const startsWithAny = (s, prefixes) => prefixes.some((p) => s.startsWith(p));
688
+
689
+ export function readJson(p, dflt = null) {
690
+ if (!isFile(p)) { return dflt; }
691
+ // BOM-tolerant: PowerShell writes one by default and an agent editing a JSON by hand adds it.
692
+ return pyJsonLoads(readText(p).replace(/^\uFEFF/, ''));
693
+ }
694
+
695
+ /**
696
+ * Atomic (tmp + rename, Windows EPERM retried: group_watch._replace): group_queue / group_watch
697
+ * read these files while a refresh rewrites them, and an in-place write showed them half a file.
698
+ */
699
+ export function writeJson(p, data) {
700
+ _replace(p, pyJsonDumps(data, 2));
701
+ }
702
+
703
+ export function safeName(node) {
704
+ // str(node.get("id", "")).split(":", 1)[-1]
705
+ const sid = pyStr(get(node, 'id', ''));
706
+ const colon = sid.indexOf(':');
707
+ const raw = or(get(node, 'name'), or(colon < 0 ? sid : sid.slice(colon + 1), 'Page'));
708
+ const name = raw.replace(/[^A-Za-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
709
+ return name || 'Page';
710
+ }
711
+
712
+ /** `res/layout/x.xml:22` → `res/layout/x.xml`. */
713
+ export function stripLine(loc) {
714
+ if (!truthy(loc)) { return null; }
715
+ return pyStr(loc).replace(/:\p{Nd}+(?=\n?$)/u, '');
716
+ }
717
+
718
+ export function layoutFiles(node) {
719
+ const files = [];
720
+ for (const w of or(get(node, 'widgets'), [])) {
721
+ for (const loc of [get(w, 'via'), get(w, 'at')]) {
722
+ const f = stripLine(loc);
723
+ if (f && f.endsWith('.xml') && !files.includes(f)) { files.push(f); }
724
+ }
725
+ }
726
+ return files;
727
+ }
728
+
729
+ export function shortName(nodeId) {
730
+ const parts = nodeId.split(':');
731
+ const at = parts[parts.length - 1].split('@');
732
+ return at[at.length - 1].split('#')[0];
733
+ }
734
+
735
+ /**
736
+ * The base a page's HarmonyOS files are named after: pages/<base>Page.ets, viewmodel/<base>ViewModel.ets,
737
+ * components/<base>Dialog|Component.ets. Exported so the feature-scope mapping predicts the same files.
738
+ */
739
+ export function pageBaseName(nid) {
740
+ const name = shortName(nid);
741
+ return name.replace(/(Fragment|Activity|DialogFragment|Dialog)(?=\n?$)/, '') || name;
742
+ }
743
+
744
+ export class Graph {
745
+ constructor(utg) {
746
+ this.nodes = new Map(get(utg, 'nodes', []).map((n) => [n.id, n]));
747
+ this.inbound = new Map();
748
+ this.outbound = new Map();
749
+ for (const e of get(utg, 'links', get(utg, 'edges', []))) {
750
+ const s = get(e, 'source');
751
+ const t = get(e, 'target');
752
+ if (this.nodes.has(s) && this.nodes.has(t)) {
753
+ setdefault(this.inbound, t, []).push(e);
754
+ setdefault(this.outbound, s, []).push(e);
755
+ }
756
+ }
757
+ this.byShort = new Map();
758
+ for (const nid of this.nodes.keys()) {
759
+ if (startsWithAny(nid, PAGE_PREFIXES)) { setdefault(this.byShort, shortName(nid), nid); }
760
+ }
761
+ }
762
+
763
+ /** Where an attachable node lives. None when the node is page-level. */
764
+ directHost(node) {
765
+ for (const key of ['embedded_in', 'host_node']) {
766
+ const h = get(node, key);
767
+ if (this.nodes.has(h)) { return h; }
768
+ }
769
+ if (!ATTACH_KINDS.has(get(node, 'kind'))) { return null; }
770
+ const nid = node.id;
771
+ if (nid.includes('@')) { // menu:queue@QueueFragment
772
+ const h = this.byShort.get(nid.slice(nid.lastIndexOf('@') + 1));
773
+ if (truthy(h)) { return h; }
774
+ }
775
+ for (const e of this.inbound.get(nid) ?? []) { // mode entered from a menu, etc.
776
+ if (e.source !== nid) { return e.source; }
777
+ }
778
+ return null;
779
+ }
780
+ }
781
+
782
+ /** (role, reason) before host resolution; role in page|attach|skip. */
783
+ export function classify(g, node) {
784
+ if (get(node, 'status') === 'unreachable') {
785
+ return ['skip', 'unreachable' + (truthy(get(node, 'unreachable_reason')) ? `: ${pyStr(node.unreachable_reason)}` : '')];
786
+ }
787
+ if (truthy(get(node, 'out_of_scope'))) { return ['skip', `out-of-scope: ${pyStr(node.out_of_scope)}`]; }
788
+ if (truthy(get(node, 'ui_less_shell'))) { return ['skip', 'ui-less-shell']; }
789
+ if (SKIP_KINDS.has(get(node, 'kind'))) {
790
+ return ['skip', `kind:${pyStr(get(node, 'kind'))} (container, its pages are converted individually)`];
791
+ }
792
+ if (truthy(g.directHost(node))) { return ['attach', null]; }
793
+ if (ATTACH_KINDS.has(get(node, 'kind'))) { return ['skip', 'attachable node with no resolvable host']; }
794
+ if (get(node, 'denominator') === false) { return ['skip', 'denominator:false (static stage marked it not-a-page)']; }
795
+ return ['page', null];
796
+ }
797
+
798
+ export function resolveRoles(g) {
799
+ const roles = new Map([...g.nodes].map(([nid, n]) => [nid, classify(g, n)]));
800
+ const roleOf = (x) => (roles.has(x) ? roles.get(x)[0] : 'skip');
801
+ const res = new Map();
802
+ for (const [nid, [role, reason]] of roles) {
803
+ if (role !== 'attach') {
804
+ res.set(nid, { role, reason });
805
+ continue;
806
+ }
807
+ // Walk up until a page; a host chain may pass through other attach nodes.
808
+ let cur = nid;
809
+ const seen = new Set();
810
+ while (truthy(cur) && roleOf(cur) === 'attach' && !seen.has(cur)) {
811
+ seen.add(cur);
812
+ cur = g.directHost(g.nodes.get(cur));
813
+ }
814
+ if (truthy(cur) && roleOf(cur) === 'page') {
815
+ res.set(nid, { role: 'attach', host: cur });
816
+ } else {
817
+ res.set(nid, { role: 'skip', reason: `attachable node whose host chain ends at ${pyStr(or(cur, 'nothing'))}` });
818
+ }
819
+ }
820
+ return res;
821
+ }
822
+
823
+ export function templateKeys(node) {
824
+ const keys = [];
825
+ if (truthy(get(node, 'extends_base'))) { keys.push(['base', node.extends_base]); }
826
+ for (const f of layoutFiles(node)) { keys.push(['layout', f]); }
827
+ if (node.id.startsWith('pref-dialog:')) { keys.push(['family', 'pref-dialog']); }
828
+ // `fragment;base:ItemFilterDialog` names a real shared base; `base:Fragment`
829
+ // names the framework class every page shares, which is no template at all.
830
+ const m = /base:([A-Za-z0-9_]+)/.exec(pyStr(or(get(node, 'launch_hint'), '')));
831
+ if (m && !GENERIC_BASES.has(m[1])) { keys.push(['base', m[1]]); }
832
+ return keys;
833
+ }
834
+
835
+ const tkey = (k) => pyRepr(k[0]) + '\u0000' + pyRepr(k[1]);
836
+
837
+ export function edgeView(e, end) {
838
+ return { [end]: e[end], mechanism: get(e, 'mechanism'), trigger: get(e, 'trigger') };
839
+ }
840
+
841
+ const isEmptyish = (v) => v === null || v === undefined || (Array.isArray(v) && v.length === 0) ||
842
+ (typeof v === 'object' && !Array.isArray(v) && !(v instanceof PyFloat) && Object.keys(v).length === 0);
843
+
844
+ export function hintsOf(node) {
845
+ const widgets = (or(get(node, 'widgets'), [])).map((w) => {
846
+ const o = {};
847
+ for (const k of ['widget', 'kind', 'view_id', 'text', 'placeholder', 'preference_type', 'at']) {
848
+ const v = get(w, k);
849
+ if (v !== null && v !== undefined) { o[k] = w[k]; }
850
+ }
851
+ return o;
852
+ });
853
+ const h = {
854
+ declared_at: get(node, 'declared_at'), layout_files: layoutFiles(node),
855
+ layout_ids: or(get(node, 'layout_ids'), []), layout_hidden_ids: or(get(node, 'layout_hidden_ids'), []),
856
+ widgets, extends_base: get(node, 'extends_base'), launch_hint: get(node, 'launch_hint'),
857
+ required_state: or(get(node, 'required_state'), []),
858
+ content_state_evidence: get(node, 'content_state_evidence'),
859
+ login_interceptor: get(node, 'login_interceptor'),
860
+ observable: get(node, 'observable'), expected: get(node, 'expected'),
861
+ };
862
+ const res = {};
863
+ for (const [k, v] of Object.entries(h)) { if (!isEmptyish(v)) { res[k] = v; } }
864
+ return res;
865
+ }
866
+
867
+ // ---------------------------------------------------------------- grouping
868
+ // A group is the unit one sub-agent converts. It is built around an *anchor*
869
+ // page; a member joins its anchor only when splitting them would make two
870
+ // agents write one file: an embedded child is instantiated inside the
871
+ // parent's build(), and a single-host overlay is mounted in its host page.
872
+ // A routed child (tap → pushUrl) gets its own group — the Step 5.5 wiring
873
+ // sub-agent registers the route, so nothing is shared.
874
+
875
+ export const OVERLAY_PREFIXES = ['dialog:', 'pref-dialog:', 'overlay:'];
876
+ export const EMBED_VIA = ['pager-', 'child-fragment', 'layout-inflate'];
877
+ export const MOUNT_VIA = ['drawer-panel', 'bottom-sheet'];
878
+ export const MAX_GROUP = 8;
879
+
880
+ const BIG = 10 ** 6;
881
+
882
+ /**
883
+ * A node shown over a host page. Kind `screen` is a page whatever its id: a2h-utg-static
884
+ * activityGates emits a full-screen gate (a landing splash setContent shows instead of the NavHost)
885
+ * as `overlay:<Name>`, and as an overlay it would be converted to `components/<Name>Dialog.ets`.
886
+ */
887
+ export function isOverlay(node) {
888
+ if (get(node, 'kind') === 'screen') { return false; }
889
+ return pyIn(get(node, 'kind'), ['dialog', 'panel', 'window']) || startsWithAny(node.id, OVERLAY_PREFIXES);
890
+ }
891
+
892
+ export function edgeArgs(e) {
893
+ return or(get(e, 'args'), {});
894
+ }
895
+
896
+ export function isMount(e) {
897
+ return MOUNT_VIA.includes(pyStr(get(edgeArgs(e), 'via')));
898
+ }
899
+
900
+ /** The edge renders the target inside the source, with no navigation. */
901
+ export function isEmbed(e) {
902
+ const a = edgeArgs(e);
903
+ const via = pyStr(get(a, 'via'));
904
+ const scope = pyStr(get(a, 'commit_scope'));
905
+ const action = get(a, 'action');
906
+ if (get(e, 'mechanism') === 'fragment-embed' || startsWithAny(via, EMBED_VIA)) { return true; }
907
+ const auto = via === 'auto-load' || pyIn('auto-load', or(get(a, 'also_via'), []));
908
+ if (auto && scope.startsWith('lifecycle-fn')) { return true; }
909
+ if (via === 'instantiation' && scope.startsWith('lifecycle-fn') && pyIn(action ?? null, [null, 'default'])) { return true; }
910
+ // A section a host dispatches into its own layout: no gesture on the edge.
911
+ return via === 'dispatch-table' && (action === null || action === undefined) && get(e, 'mechanism') === 'fragment-transaction';
912
+ }
913
+
914
+ /**
915
+ * roles: Map nid → role row; rows: Map nid → conversion_set node row;
916
+ * pageOrder: Map page-dir name → pages.json index; ranked: click-path order.
917
+ */
918
+ export function planGroups(g, roles, rows, pageOrder, ranked, entryOverride = null, prevIds = null, fullRoles = null) {
919
+ const roleOf = (nid) => (roles.get(nid) ?? {}).role; // roles.get(nid, {}).get("role")
920
+ const pageIds = [...roles].filter(([, r]) => r.role === 'page').map(([nid]) => nid);
921
+
922
+ const pindex = (nid) => {
923
+ let best = BIG;
924
+ for (const d of get(rows.get(nid), 'page_dirs', [])) {
925
+ const v = pageOrder.has(d) ? pageOrder.get(d) : BIG;
926
+ if (v < best) { best = v; }
927
+ }
928
+ return best;
929
+ };
930
+
931
+ // Launcher host = the first host-activity on a click path; entry = its
932
+ // first page in pages.json order that it reaches without a mount/embed.
933
+ const rank = new Map(ranked.map((nid, i) => [nid, i]));
934
+ const hosts = sortedBy([...g.nodes].filter(([nid, n]) => get(n, 'kind') === 'host-activity' && rank.has(nid))
935
+ .map(([nid]) => nid), (nid) => rank.get(nid));
936
+ const launcher = hosts.length ? hosts[0] : null;
937
+ let entry = entryOverride ?? null;
938
+ let how = truthy(entry) ? '--entry' : '';
939
+ if (!truthy(entry) && truthy(launcher)) {
940
+ let cands = (g.outbound.get(launcher) ?? []).filter((e) => roleOf(e.target) === 'page' && !isMount(e) &&
941
+ !isEmbed(e) && !isOverlay(g.nodes.get(e.target))).map((e) => e.target);
942
+ // Key is total (ends with the id), so set order does not matter.
943
+ cands = sortedBy([...new Set(cands)], (n) => [pindex(n), rank.has(n) ? rank.get(n) : BIG, n]);
944
+ if (cands.length) {
945
+ entry = cands[0];
946
+ how = `first page of launcher host ${launcher} in pages.json order`;
947
+ } else {
948
+ entry = null;
949
+ how = '';
950
+ }
951
+ }
952
+ // No host-activity (e.g. a single-Activity app whose launcher Activity is
953
+ // itself a page): fall back to the manifest launcher. Without it the entry
954
+ // stays null and no group is placed in the entry lane.
955
+ if (!truthy(entry)) {
956
+ const isLauncher = (n) => get(n, 'is_launcher') === true || get(n, 'entry_kind') === 'launcher' ||
957
+ get(or(get(n, 'launch_hint'), {}), 'is_launcher') === true;
958
+ const asPage = (nid) => {
959
+ const r = roles.get(nid) ?? {};
960
+ if (r.role === 'page') { return nid; }
961
+ if (r.role === 'attach' && (roles.get(r.host) ?? {}).role === 'page') { return r.host; }
962
+ return null;
963
+ };
964
+ const launchers = sortedBy([...g.nodes].filter(([nid, n]) => isLauncher(n) && truthy(asPage(nid)))
965
+ .map(([nid]) => nid), (nid) => [rank.has(nid) ? rank.get(nid) : BIG, nid]);
966
+ if (launchers.length) {
967
+ entry = asPage(launchers[0]);
968
+ how = `manifest launcher ${launchers[0]}`;
969
+ }
970
+ }
971
+
972
+ const defaultPage = (host) => {
973
+ if (host === launcher) { return entry; }
974
+ for (const e of g.outbound.get(host) ?? []) {
975
+ const a = edgeArgs(e);
976
+ if ((pyIn('auto-load', or(get(a, 'also_via'), [])) || get(a, 'via') === 'auto-load') &&
977
+ pyStr(get(a, 'commit_scope')).startsWith('lifecycle-fn') && roleOf(e.target) === 'page') {
978
+ return e.target;
979
+ }
980
+ }
981
+ return null;
982
+ };
983
+
984
+ /** An edge source as a page id: attach → its host, host-activity → its default page. */
985
+ const resolve = (src) => {
986
+ const r = roles.get(src) ?? {};
987
+ if (r.role === 'attach') { return r.host; }
988
+ if (r.role === 'page') { return src; }
989
+ if (get(g.nodes.get(src) ?? {}, 'kind') === 'host-activity') { return defaultPage(src); }
990
+ return null;
991
+ };
992
+ // What a member is mounted on, over the whole app: an incremental scope leaves the existing
993
+ // launch page outside, and a drawer mounted on it still writes into it (ENTRY_PAGE).
994
+ const mountHost = (src) => {
995
+ const own = resolve(src);
996
+ if (truthy(own) || !fullRoles) { return own; }
997
+ const r = fullRoles.get(src) ?? {};
998
+ if (r.role === 'attach') { return r.host; }
999
+ if (r.role === 'page') { return src; }
1000
+ if (src === launcher) { return entry; }
1001
+ return null;
1002
+ };
1003
+
1004
+ const parent = new Map();
1005
+ const rel = new Map();
1006
+ const mountedOn = new Map();
1007
+ for (const nid of pageIds) {
1008
+ const node = g.nodes.get(nid);
1009
+ const inbound = (g.inbound.get(nid) ?? []).filter((e) => e.source !== nid);
1010
+ for (const e of inbound) {
1011
+ if (isMount(e) && truthy(mountHost(e.source))) { mountedOn.set(nid, mountHost(e.source)); }
1012
+ }
1013
+ // Only its size and (when size 1) its single element are used: order-free.
1014
+ const srcs = new Set(inbound.map((e) => resolve(e.source)).filter((s) => truthy(s) && s !== nid));
1015
+ const explicit = or(get(node, 'embedded_in'), get(node, 'host_node'));
1016
+ if (roles.has(explicit) && roles.get(explicit).role === 'page') {
1017
+ parent.set(nid, explicit);
1018
+ rel.set(nid, 'embedded');
1019
+ } else if (isOverlay(node)) {
1020
+ if (srcs.size === 1) {
1021
+ parent.set(nid, [...srcs][0]);
1022
+ rel.set(nid, 'overlay');
1023
+ }
1024
+ } else if (srcs.size === 1 && inbound.length && inbound.every(isEmbed) && !mountedOn.has(nid)) {
1025
+ parent.set(nid, [...srcs][0]);
1026
+ rel.set(nid, 'embedded');
1027
+ }
1028
+ }
1029
+
1030
+ const anchor = (nid) => {
1031
+ const seen = [];
1032
+ while (parent.has(nid) && !seen.includes(nid)) {
1033
+ seen.push(nid);
1034
+ nid = parent.get(nid);
1035
+ }
1036
+ return nid;
1037
+ };
1038
+
1039
+ const members = new Map();
1040
+ for (const nid of pageIds) { setdefault(members, anchor(nid), []).push(nid); }
1041
+
1042
+ const base = pageBaseName;
1043
+ // One class mounted as several destinations (`view-page:InformationQueryPage#courses` / `#query`,
1044
+ // instantiated twice with different modes) gives anchors with the same base name. They are separate
1045
+ // pages, not a host and its default child: without the instance suffix both predicted the same files,
1046
+ // the later group became verify_only and its destination was never converted (where2study 11-11:
1047
+ // the 查询 tab mounted the 课程 page). The same holds when the instances are embedded members (two
1048
+ // pager tabs of one class) rather than anchors. Only non-overlay page nodes that all carry a
1049
+ // `#instance` qualify; a collision with an unqualified node (MainActivity / MainFragment) keeps the
1050
+ // shared name and verify_only.
1051
+ const instanceOf = (nid) => {
1052
+ const last = nid.split(':').pop().split('@').pop();
1053
+ const at = last.indexOf('#');
1054
+ // everything after the first `#`: `X#tab#a` / `X#tab#b` are two instances, not one
1055
+ return at < 0 ? '' : last.slice(at + 1);
1056
+ };
1057
+ const pascal = (s) => s.split(/[^A-Za-z0-9]+/).filter(Boolean).map((p) => p[0].toUpperCase() + p.slice(1)).join('');
1058
+ const peersByBase = new Map();
1059
+ for (const nid of pageIds) {
1060
+ if (!isOverlay(g.nodes.get(nid))) { setdefault(peersByBase, base(nid), []).push(nid); }
1061
+ }
1062
+ // A suffix per instance, unique within its base: the PascalCase instance name, or `I<n>` when that is
1063
+ // empty or shared — `#课程` / `#查询` and `#my-tab` / `#my_tab` would otherwise collapse to one file and
1064
+ // bring the bug back. n counts up past every suffix already taken (`#i2` keeps `I2`).
1065
+ const suffixOf = new Map();
1066
+ for (const peers of peersByBase.values()) {
1067
+ const insts = sortedBy([...new Set(peers.map(instanceOf))]);
1068
+ if (insts.length < 2 || insts.includes('')) { continue; }
1069
+ const named = new Map(insts.map((i) => [i, pascal(i)]));
1070
+ const counts = new Map();
1071
+ for (const v of named.values()) { counts.set(v, (counts.get(v) ?? 0) + 1); }
1072
+ const chosen = new Map();
1073
+ const taken = new Set();
1074
+ for (const i of insts) {
1075
+ const v = named.get(i);
1076
+ if (v && counts.get(v) === 1) { chosen.set(i, v); taken.add(v); }
1077
+ }
1078
+ let n = 0;
1079
+ for (const i of insts) {
1080
+ if (chosen.has(i)) { continue; }
1081
+ do { n += 1; } while (taken.has(`I${n}`));
1082
+ chosen.set(i, `I${n}`);
1083
+ taken.add(`I${n}`);
1084
+ }
1085
+ for (const p of peers) { suffixOf.set(p, chosen.get(instanceOf(p))); }
1086
+ }
1087
+ const pageBase = (nid) => `${base(nid)}${suffixOf.get(nid) ?? ''}`;
1088
+
1089
+ let groups = [];
1090
+ for (let [anc, mem] of members) {
1091
+ mem = sortedBy(mem, (n) => [n !== anc, pindex(n), n]);
1092
+ const tiers = new Set(mem.map((n) => rows.get(n).tier));
1093
+ const writes = new Set();
1094
+ const aNode = g.nodes.get(anc);
1095
+ if (isOverlay(aNode)) {
1096
+ writes.add(`components/${base(anc)}Dialog.ets`);
1097
+ } else {
1098
+ writes.add(`pages/${pageBase(anc)}Page.ets`);
1099
+ writes.add(`viewmodel/${pageBase(anc)}ViewModel.ets`);
1100
+ }
1101
+ for (const n of mem.slice(1)) {
1102
+ writes.add(`components/${pageBase(n)}${isOverlay(g.nodes.get(n)) ? 'Dialog' : 'Component'}.ets`);
1103
+ }
1104
+ // The shared name each per-instance write had before the split: an incremental run on a project
1105
+ // converted before it finds its files under that name (applyIncremental).
1106
+ const legacy = {};
1107
+ for (const n of mem) {
1108
+ if (!suffixOf.has(n)) { continue; }
1109
+ if (n === anc && !isOverlay(aNode)) {
1110
+ legacy[`pages/${pageBase(n)}Page.ets`] = `pages/${base(n)}Page.ets`;
1111
+ legacy[`viewmodel/${pageBase(n)}ViewModel.ets`] = `viewmodel/${base(n)}ViewModel.ets`;
1112
+ } else if (n !== anc) {
1113
+ const kind = isOverlay(g.nodes.get(n)) ? 'Dialog' : 'Component';
1114
+ legacy[`components/${pageBase(n)}${kind}.ets`] = `components/${base(n)}${kind}.ets`;
1115
+ }
1116
+ }
1117
+ // With no entry, an unmounted member used to compare equal to it (null ===
1118
+ // null), making every group an entry hit and the whole plan one serial lane.
1119
+ const entryHit = truthy(entry) &&
1120
+ (mem.includes(entry) || mem.some((n) => mountedOn.has(n) && mountedOn.get(n) === entry));
1121
+ if (entryHit) { writes.add('ENTRY_PAGE'); }
1122
+ const fam = new Set();
1123
+ for (const n of mem) {
1124
+ for (const k of templateKeys(g.nodes.get(n))) { fam.add(`${pyStr(k[0])}:${pyStr(k[1])}`); }
1125
+ }
1126
+ groups.push({
1127
+ anchor: anc,
1128
+ members: mem.map((n) => ({ node: n, tier: rows.get(n).tier, relation: n === anc ? 'anchor' : (rel.get(n) ?? 'embedded') })),
1129
+ page_dirs: mem.flatMap((n) => get(rows.get(n), 'page_dirs', [])),
1130
+ tier: tiers.has('captured') ? 'captured' : 'source-only',
1131
+ mixed_tier: tiers.size > 1,
1132
+ predicted_writes: sortedBy([...writes]),
1133
+ ...(Object.keys(legacy).length ? { legacy_writes: legacy } : {}),
1134
+ _fam: fam, _entry: entryHit, _is_entry: mem.includes(entry),
1135
+ _order: Math.min(...mem.map(pindex)),
1136
+ });
1137
+ }
1138
+
1139
+ // Captured attach nodes (a menu or panel that was screenshotted as its own
1140
+ // page dir) are evidence for their host's group, never a group of their own.
1141
+ const byMember = new Map();
1142
+ for (const gr of groups) { for (const m of gr.members) { byMember.set(m.node, gr); } }
1143
+ for (const [nid, r] of roles) {
1144
+ if (r.role === 'attach' && truthy(get(rows.get(nid), 'page_dirs')) && byMember.has(r.host)) {
1145
+ const gr = byMember.get(r.host);
1146
+ gr.members.push({ node: nid, tier: 'captured', relation: 'attached' });
1147
+ gr.page_dirs.push(...rows.get(nid).page_dirs);
1148
+ gr._order = Math.min(gr._order, pindex(nid));
1149
+ const tiers = new Set(gr.members.map((m) => m.tier));
1150
+ gr.tier = tiers.has('captured') ? 'captured' : 'source-only';
1151
+ gr.mixed_tier = tiers.size > 1;
1152
+ }
1153
+ }
1154
+
1155
+ // Stage: 0 = the entry group alone (it sets the conventions), 1 = groups
1156
+ // with a capture, 2 = source-only. Within a stage, pages.json order.
1157
+ for (const gr of groups) { gr.stage = gr._is_entry ? 0 : (gr.tier === 'captured' ? 1 : 2); }
1158
+ groups = sortedBy(groups, (gr) => [gr.stage, gr._order, gr.anchor]);
1159
+ // Stable ids across re-runs: a re-export during exploration must not
1160
+ // renumber groups whose prompts, queue state and reports already exist.
1161
+ // A known anchor keeps its id (its stage may change); a new one numbers on.
1162
+ const known = prevIds ?? new Map();
1163
+ let nxt = 0;
1164
+ for (const v of known.values()) {
1165
+ const m = /^G(\d+)$/.exec(v);
1166
+ if (m) nxt = Math.max(nxt, Number(m[1]));
1167
+ }
1168
+ for (const gr of groups) {
1169
+ if (known.has(gr.anchor)) gr.id = known.get(gr.anchor);
1170
+ else { nxt += 1; gr.id = `G${String(nxt).padStart(3, '0')}`; }
1171
+ }
1172
+
1173
+ // Lanes: groups sharing a predicted write run serially; ENTRY_PAGE is the
1174
+ // host chain. Union-find over write tokens.
1175
+ const owner = new Map();
1176
+ const laneOf = new Map();
1177
+ for (const gr of groups) { laneOf.set(gr.id, gr.id); }
1178
+ const find = (x) => {
1179
+ while (laneOf.get(x) !== x) {
1180
+ laneOf.set(x, laneOf.get(laneOf.get(x)));
1181
+ x = laneOf.get(x);
1182
+ }
1183
+ return x;
1184
+ };
1185
+ for (const gr of groups) {
1186
+ for (const w of gr.predicted_writes) {
1187
+ if (owner.has(w)) {
1188
+ // Python evaluates the right-hand side first, then the subscript.
1189
+ const rhs = find(owner.get(w));
1190
+ laneOf.set(find(gr.id), rhs);
1191
+ } else {
1192
+ owner.set(w, gr.id);
1193
+ }
1194
+ }
1195
+ }
1196
+ const lanes = new Map();
1197
+ for (const gr of groups) { setdefault(lanes, find(gr.id), []).push(gr.id); }
1198
+ // A group whose every predicted write is owned by an earlier group of its
1199
+ // lane converts nothing of its own: a source-only host Activity whose
1200
+ // name collides with its default child (MainActivity -> MainPage.ets,
1201
+ // written by the MainFragment group). It verifies the host shell and
1202
+ // reports. Its files exist before it is dispatched, so "nothing written"
1203
+ // is its normal outcome, not a failure to redispatch.
1204
+ for (const gr of groups) {
1205
+ const ws = gr.predicted_writes.filter((w) => w !== 'ENTRY_PAGE');
1206
+ gr.verify_only = ws.length > 0 && ws.every((w) => owner.has(w) && owner.get(w) !== gr.id);
1207
+ }
1208
+ // The queue serialises only groups whose lane NAMES are equal (Step 5.3 rule c),
1209
+ // so a lane is named once for all its peers. A lane holding an entry group is the
1210
+ // host chain: its peers write the entry group's files and must carry 'entry' too.
1211
+ // Measured (WeatherApp 11-10): MainActivity (entry) got 'entry', MainFragment,
1212
+ // sharing MainPage.ets / MainViewModel.ets with it, got 'lane-G001'; with a shell
1213
+ // contract the two ran at once on the same files.
1214
+ const isEntry = new Map(groups.map((gr) => [gr.id, Boolean(gr._entry)]));
1215
+ for (const gr of groups) {
1216
+ const peers = lanes.get(find(gr.id));
1217
+ if (gr._entry || peers.some((id) => isEntry.get(id))) {
1218
+ gr.class = 'host-chain';
1219
+ gr.lane = 'entry';
1220
+ } else if (peers.length > 1) {
1221
+ gr.class = 'serial';
1222
+ gr.lane = `lane-${peers[0]}`;
1223
+ } else {
1224
+ gr.class = 'self-contained';
1225
+ gr.lane = null;
1226
+ }
1227
+ }
1228
+
1229
+ // Families: a shared base class / layout / pref-dialog family. The first
1230
+ // group to convert one builds the shared component; later groups reuse it
1231
+ // (read-only) and, inside the same stage, wait for it.
1232
+ const leader = new Map();
1233
+ for (const gr of groups) {
1234
+ const reuse = [];
1235
+ const after = [];
1236
+ for (const f of sortedBy([...gr._fam])) {
1237
+ const holders = groups.filter((o) => o._fam.has(f));
1238
+ if (holders.length < 2) { continue; }
1239
+ const lead = setdefault(leader, f, gr);
1240
+ if (lead !== gr) {
1241
+ reuse.push({ family: f, from: lead.id });
1242
+ if (lead.stage === gr.stage && !after.includes(lead.id)) { after.push(lead.id); }
1243
+ }
1244
+ }
1245
+ gr.reuse_from = reuse;
1246
+ gr.after = after;
1247
+ if (gr.members.length > MAX_GROUP) {
1248
+ gr.warning = `${gr.members.length} members > ${MAX_GROUP}: review in Step 4.2, split routed-looking members`;
1249
+ }
1250
+ }
1251
+ // An overlay a member opens but another group owns (a shared overlay gets its own group): the host group
1252
+ // must import that group's file, never write its own copy. Measured (CoolMall 11-19): SmsLogin and Register
1253
+ // both open overlay:ImageCaptchaDialog, which was G033's; G029 was never told, wrote
1254
+ // components/34ImageCaptchaDialog.ets in parallel, and Step 5.5 later kept the wrong copy.
1255
+ const groupOf = new Map();
1256
+ for (const gr of groups) { for (const m of gr.members) { groupOf.set(m.node, gr); } }
1257
+ for (const gr of groups) {
1258
+ const mine = new Set(gr.members.map((m) => m.node));
1259
+ const owned = new Map();
1260
+ for (const m of gr.members) {
1261
+ for (const e of g.outbound.get(m.node) ?? []) {
1262
+ const t = e.target;
1263
+ if (mine.has(t) || !isOverlay(g.nodes.get(t))) { continue; }
1264
+ const og = groupOf.get(t);
1265
+ if (og === undefined || og === gr || owned.has(t)) { continue; }
1266
+ // the overlay's own file (same naming as the writes above), not the owner group's first component:
1267
+ // an owner anchored on a page writes several components
1268
+ const own = og.anchor === t ? `components/${base(t)}Dialog.ets` : `components/${pageBase(t)}Dialog.ets`;
1269
+ owned.set(t, { node: t, group: og.id, file: og.predicted_writes.includes(own) ? own : null });
1270
+ }
1271
+ }
1272
+ if (owned.size) { gr.overlays_owned_elsewhere = sortedBy([...owned.values()], (o) => o.node); }
1273
+ }
1274
+ // The host waits for the overlay's group: in one stage through `after` (unless that would close a wait
1275
+ // cycle: the overlay group already waits, through family `after`, on the host); on a lower stage through
1276
+ // `waits_for`, which group_queue._deps honours whatever overlap_entry / stage-2 filtering would drop. An owner
1277
+ // on a later stage cannot be waited for without inverting the stages: the host imports the predicted file
1278
+ // anyway (the owner writes it before Step 6), per step5-convert.md OVERLAYS_OWNED_ELSEWHERE.
1279
+ const byGid = new Map(groups.map((gr) => [gr.id, gr]));
1280
+ for (const gr of groups) {
1281
+ for (const o of gr.overlays_owned_elsewhere ?? []) {
1282
+ if (byGid.get(o.group).stage < gr.stage) { addWait(gr, o.group); }
1283
+ }
1284
+ }
1285
+ const waitsOn = (from, to) => {
1286
+ const stack = [from];
1287
+ const seen = new Set();
1288
+ while (stack.length) {
1289
+ const x = stack.pop();
1290
+ if (x === to) { return true; }
1291
+ if (seen.has(x)) { continue; }
1292
+ seen.add(x);
1293
+ stack.push(...(byGid.get(x)?.after ?? []));
1294
+ }
1295
+ return false;
1296
+ };
1297
+ for (const gr of groups) {
1298
+ for (const o of gr.overlays_owned_elsewhere ?? []) {
1299
+ const og = byGid.get(o.group);
1300
+ if (og.stage !== gr.stage || gr.after.includes(o.group) || waitsOn(o.group, gr.id)) { continue; }
1301
+ gr.after.push(o.group);
1302
+ }
1303
+ }
1304
+ for (const gr of groups) {
1305
+ for (const k of ['_fam', '_entry', '_is_entry', '_order']) { delete gr[k]; }
1306
+ }
1307
+ return { entry_node: entry, entry_chosen_by: how, launcher_host: launcher, groups };
1308
+ }
1309
+
1310
+ // ---------------------------------------------------------------- build
1311
+
1312
+ /**
1313
+ * Remove source-only dirs whose node is now captured (or no longer a page);
1314
+ * return [removed, Map node -> slug] of the ones kept, so a re-run reuses the
1315
+ * same directory name for a group that may already be converting it.
1316
+ */
1317
+ /** Record that `gr` must wait for group `id` to finish although `id` is on a lower stage (group_queue._deps). */
1318
+ export function addWait(gr, id) {
1319
+ if (id === gr.id) { return; }
1320
+ gr.waits_for = sortedBy([...new Set([...(gr.waits_for ?? []), id])]);
1321
+ }
1322
+
1323
+ /**
1324
+ * Mark the groups whose pages live inside a shell host (shell_contract.json `shell_hosts`:
1325
+ * an Activity that swaps Fragments or Views inside a persistent chrome). Such a group is content the
1326
+ * shell mounts, not a routed page: no @Entry, no chrome of its own, and it is reached through
1327
+ * the shell rather than router.pushUrl. The entry group writes the shell itself.
1328
+ *
1329
+ * Adds `host_activity` + `presentation` (`shell` | `shell-content`) to those groups only.
1330
+ * Without shell_hosts (no shell_contract.json yet, or an app with no such Activity) nothing is
1331
+ * added, so the plan is identical to the one written before this existed.
1332
+ *
1333
+ * A host's reach is its own fragment-transaction / view-swap targets plus, transitively, the
1334
+ * fragments / view-pages those swap in: all of them render inside the host's container. Whether a given one is a chrome tab or a
1335
+ * pushed child is the host's dispatch code and the shell's business, not the plan's.
1336
+ */
1337
+ export function annotateShellContent(g, plan, contract) {
1338
+ // A user-picked theme colour (contract theme.runtime_slots) lives in theme.state_module, which the
1339
+ // stage-0 entry group creates; every later group imports it, so it waits for stage 0 even when
1340
+ // overlap_entry would start stage 1 beside the entry group (group_queue._deps honours waits_for).
1341
+ const slots = get(get(or(contract, {}), 'theme', {}) ?? {}, 'runtime_slots', []);
1342
+ if (Array.isArray(slots) && slots.length) {
1343
+ const entryIds = plan.groups.filter((gr) => gr.stage === 0).map((gr) => gr.id);
1344
+ for (const gr of plan.groups) {
1345
+ if (gr.stage === 0) { continue; }
1346
+ for (const id of entryIds) { addWait(gr, id); }
1347
+ }
1348
+ }
1349
+ const hosts = get(or(contract, {}), 'shell_hosts', null);
1350
+ if (!truthy(hosts)) { return; }
1351
+ const hostOf = new Map();
1352
+ for (const hid of keysOf(hosts)) {
1353
+ const queue = [...get(hosts[hid], 'host_destinations', [])];
1354
+ while (queue.length) {
1355
+ const nid = queue.shift();
1356
+ if (hostOf.has(nid)) { continue; }
1357
+ hostOf.set(nid, hid);
1358
+ for (const e of g.outbound.get(nid) ?? []) {
1359
+ const mech = get(e, 'mechanism');
1360
+ const t = pyStr(get(e, 'target'));
1361
+ if ((mech === 'fragment-transaction' && t.startsWith('fragment:')) ||
1362
+ (mech === 'view-swap' && t.startsWith('view-page:'))) {
1363
+ queue.push(e.target);
1364
+ }
1365
+ }
1366
+ }
1367
+ }
1368
+ for (const gr of plan.groups) {
1369
+ const hid = hostOf.get(gr.anchor);
1370
+ if (!hid) { continue; }
1371
+ gr.host_activity = hid;
1372
+ gr.presentation = gr.anchor === plan.entry_node ? 'shell' : 'shell-content';
1373
+ }
1374
+ }
1375
+
1376
+ export function clearPrevious(uiInfo, keep = new Set(), protect = new Set(), capturedDirs = new Set()) {
1377
+ let n = 0;
1378
+ const kept = new Map();
1379
+ for (const d of sortedBy(globPrefix(uiInfo, 'page_'))) {
1380
+ const meta = isDir(d) ? readJson(path.join(d, 'meta.json'), {}) : {};
1381
+ if (get(meta, 'evidence_tier') !== 'source-only') continue;
1382
+ // A capture demoted for a blank frame (and one the manifest lists) is evidence, not a stale
1383
+ // source-only unit: deleting it lost the frames and turned the node back into "captured".
1384
+ if (get(meta, 'degraded_from') === 'capture' || capturedDirs.has(pathName(d))) continue;
1385
+ const nid = get(meta, 'static_node');
1386
+ if (protect.has(nid)) continue; // outside an incremental scope: not this run's to judge
1387
+ if (keep.has(nid) && !kept.has(nid)) kept.set(nid, pathName(d));
1388
+ else {
1389
+ fs.rmSync(d, { recursive: true });
1390
+ n += 1;
1391
+ }
1392
+ }
1393
+ return [n, kept];
1394
+ }
1395
+
1396
+ /** Stable digest of a scope member list (order and duplicates do not matter): `inc-<n>-<sha256/12>`. */
1397
+ export function scopeIdOf(ids) {
1398
+ const set = [...new Set(ids.map(String))].sort();
1399
+ if (!set.length) { throw new Error('scope holds no node id'); }
1400
+ return `inc-${set.length}-${createHash('sha256').update(set.join('\n'), 'utf8').digest('hex').slice(0, 12)}`;
1401
+ }
1402
+
1403
+ /**
1404
+ * A scope file -> { ids, scope_id }. v1 ({"scope": [...]}, a bare list, {"nodes": [...]}) digests its ids; v2 (the
1405
+ * feature scope a2h-app-migrate scope_model.mjs writes: {"version": 2, "scope_id", "features", "pages"}) takes the
1406
+ * pages it derived and the scope_id it carries, so every lane of one run agrees on the id even when two feature
1407
+ * scopes cover the same pages.
1408
+ */
1409
+ export function scopeOf(p) {
1410
+ const ids = readList(p, ['scope', 'nodes', 'pages']);
1411
+ // the UI lane has nothing to convert (a v2 scope of LOGIC work only derives no page): same refusal as a bad file
1412
+ if (!ids.length) { throw new Error(`${pathStr(p)}: expected a JSON list of scoped node ids, and it holds no page`); }
1413
+ const doc = readJson(p, null);
1414
+ const declared = get(doc, 'version') === 2 && typeof get(doc, 'scope_id') === 'string' && get(doc, 'scope_id') ? doc.scope_id : null;
1415
+ return { ids, scope_id: declared ?? scopeIdOf(ids), doc: get(doc, 'version') === 2 ? doc : null };
1416
+ }
1417
+
1418
+ /** --scope / --existing file: a JSON list, or an object holding it under one of `keys`. */
1419
+ export function readList(p, keys) {
1420
+ const v = readJson(p, null);
1421
+ let xs = Array.isArray(v) ? v : null;
1422
+ for (const k of keys) { if (xs === null && Array.isArray(get(v, k))) { xs = v[k]; } }
1423
+ if (xs === null) { throw new Error(`${pathStr(p)}: expected a JSON list, or an object with ${keys.map((k) => `"${k}"`).join(' / ')}`); }
1424
+ return xs.map((x) => (typeof x === 'string' ? x : or(get(x, 'node'), get(x, 'id')))).filter(truthy);
1425
+ }
1426
+
1427
+ /** An existing .ets path as a predicted write: relative to the ETS root, forward slashes. */
1428
+ export function etsRel(p) {
1429
+ const s = pyStr(p).replace(/\\/g, '/');
1430
+ const i = s.lastIndexOf('/src/main/ets/');
1431
+ const rel = i >= 0 ? s.slice(i + '/src/main/ets/'.length) : s.startsWith('src/main/ets/') ? s.slice('src/main/ets/'.length) : s;
1432
+ return rel.replace(/^\.\//, '');
1433
+ }
1434
+
1435
+ /**
1436
+ * Restrict roles to an incremental scope: a page outside it, and a node attached to such a
1437
+ * page, become `skip`. Throws on ids the graph does not have (a typo would scope to nothing).
1438
+ */
1439
+ export function scopeRoles(g, roles, scopeIds) {
1440
+ const unknown = sortedBy([...new Set(scopeIds.filter((x) => !g.nodes.has(x)))]);
1441
+ if (unknown.length) { throw new Error(`--scope names nodes the static UTG does not have: ${unknown.join(', ')}`); }
1442
+ const want = new Set(scopeIds);
1443
+ const res = new Map();
1444
+ for (const [nid, r] of roles) {
1445
+ // an attach node lives in its host's group: named without its host, there is no group for it
1446
+ if (r.role === 'attach' && want.has(nid) && !want.has(r.host)) {
1447
+ res.set(nid, { role: 'skip', reason: `out-of-incremental-scope: its host ${pyStr(r.host)} is not in the scope` });
1448
+ continue;
1449
+ }
1450
+ const inScope = r.role === 'page' ? want.has(nid) : r.role === 'attach' ? want.has(r.host) : true;
1451
+ res.set(nid, inScope ? r : { role: 'skip', reason: 'out-of-incremental-scope' });
1452
+ }
1453
+ if (![...res.values()].some((r) => r.role === 'page')) {
1454
+ throw new Error('--scope holds no convertible page (every id is a container, skipped or attached elsewhere)');
1455
+ }
1456
+ return res;
1457
+ }
1458
+
1459
+ /**
1460
+ * Feature scope (v2): a page whose work is SUP (supplement) or CHG (changed behavior) already exists and lacks part
1461
+ * of the Android page. Its group gets `supplement` — per page, the missing list page_gap.mjs computed (SUP) or the
1462
+ * change (CHG) — and group_pack.mjs tells the converter to add only that, editing the existing file in place.
1463
+ * A v1 scope, or a page with NEW work, is untouched.
1464
+ */
1465
+ export function applySupplement(plan, scopeDoc) {
1466
+ const byPage = new Map();
1467
+ for (const f of (scopeDoc && Array.isArray(scopeDoc.features)) ? scopeDoc.features : []) {
1468
+ for (const w of Array.isArray(f.work) ? f.work : []) {
1469
+ if ((w.type !== 'SUP' && w.type !== 'CHG') || !w.page) { continue; }
1470
+ const list = byPage.get(w.page) ?? [];
1471
+ list.push({ feature: f.id, type: w.type, ...(w.missing ? { missing: w.missing } : {}), ...(w.change ? { change: w.change } : {}) });
1472
+ byPage.set(w.page, list);
1473
+ }
1474
+ }
1475
+ if (!byPage.size) { return; }
1476
+ for (const gr of plan.groups) {
1477
+ // the anchor is also listed among the members
1478
+ const nodes = [...new Set([gr.anchor, ...(gr.members ?? []).map((m) => m.node)])];
1479
+ const rows = nodes.filter((n) => byPage.has(n)).map((n) => ({ page: n, items: byPage.get(n) }));
1480
+ if (rows.length) { gr.supplement = rows; }
1481
+ }
1482
+ }
1483
+
1484
+ /** Incremental: mark groups that write existing files, and make sure one group goes first. */
1485
+ export function applyIncremental(plan, existing) {
1486
+ const have = new Set([...existing].map(etsRel));
1487
+ for (const gr of plan.groups) {
1488
+ // A per-instance write that does not exist yet, while the shared name it replaced does: the project
1489
+ // was converted before the split, so the group edits that file (and shares it, serialised, with the
1490
+ // other instances) instead of creating a parallel one next to it.
1491
+ const legacy = gr.legacy_writes ?? {};
1492
+ gr.predicted_writes = sortedBy([...new Set(gr.predicted_writes.map((w) =>
1493
+ (!have.has(w) && legacy[w] !== undefined && have.has(legacy[w]) ? legacy[w] : w)))]);
1494
+ const hits = gr.predicted_writes.filter((w) => have.has(w));
1495
+ if (!hits.length) { continue; }
1496
+ gr.existing_writes = hits;
1497
+ if (gr.class === 'host-chain') { continue; }
1498
+ // its lane serialises shared writes: move the whole lane, or a peer left behind
1499
+ // would run alongside it on the same file
1500
+ const peers = truthy(gr.lane) ? plan.groups.filter((o) => o.lane === gr.lane) : [gr];
1501
+ for (const o of peers) {
1502
+ o.class = 'host-chain';
1503
+ o.lane = 'entry';
1504
+ }
1505
+ }
1506
+ // an overlay owned elsewhere follows its owner's write onto the legacy name it now edits
1507
+ const ownerOf = new Map(plan.groups.map((gr) => [gr.id, gr]));
1508
+ for (const gr of plan.groups) {
1509
+ for (const o of gr.overlays_owned_elsewhere ?? []) {
1510
+ const og = ownerOf.get(o.group);
1511
+ const legacy = og?.legacy_writes ?? {};
1512
+ if (o.file !== null && !og.predicted_writes.includes(o.file) && legacy[o.file] !== undefined) { o.file = legacy[o.file]; }
1513
+ }
1514
+ }
1515
+ if (plan.groups.some((gr) => gr.stage === 0)) { return; }
1516
+ // What a group builds on: the family leaders it reuses a component from and the captured
1517
+ // groups it borrows measurements from. Promoted alone, such a group would convert before
1518
+ // them while they wait (stage >= 1) for stage 0: the dependency inverted.
1519
+ const needs = (gr) => [...new Set([...(gr.reuse_from ?? []).map((r) => r.from), ...(gr.template_groups ?? [])])]
1520
+ .filter((id) => id !== gr.id);
1521
+ const hosts = plan.groups.filter((gr) => gr.class === 'host-chain');
1522
+ const first = hosts.find((gr) => !needs(gr).length) ?? hosts[0]
1523
+ ?? plan.groups.find((gr) => !needs(gr).length) ?? plan.groups[0];
1524
+ if (!first) { return; }
1525
+ // stage 0 = the chosen group and, transitively, everything it builds on
1526
+ const byId = new Map(plan.groups.map((gr) => [gr.id, gr]));
1527
+ const pulled = [first];
1528
+ for (let i = 0; i < pulled.length; i += 1) {
1529
+ for (const id of needs(pulled[i])) {
1530
+ const o = byId.get(id);
1531
+ if (o && !pulled.includes(o)) { pulled.push(o); }
1532
+ }
1533
+ }
1534
+ // `after` is same-stage only: inside stage 0 each pulled group waits for what it builds on.
1535
+ // reuse_from points at a family's first holder in plan order, so those waits never cycle;
1536
+ // a measurement borrow can point back (leader L borrows from its own reuser P), and a wait
1537
+ // that would close a cycle is dropped, or group_queue would never find either ready.
1538
+ const inPulled = new Set(pulled.map((gr) => gr.id));
1539
+ const waits = new Map(pulled.map((gr) => [gr.id,
1540
+ [...new Set((gr.reuse_from ?? []).map((r) => r.from))].filter((id) => id !== gr.id && inPulled.has(id))]));
1541
+ const reaches = (from, to) => {
1542
+ const stack = [from];
1543
+ const seen = new Set();
1544
+ while (stack.length) {
1545
+ const x = stack.pop();
1546
+ if (x === to) { return true; }
1547
+ if (seen.has(x)) { continue; }
1548
+ seen.add(x);
1549
+ stack.push(...(waits.get(x) ?? []));
1550
+ }
1551
+ return false;
1552
+ };
1553
+ for (const gr of pulled) {
1554
+ for (const id of gr.template_groups ?? []) {
1555
+ const w = waits.get(gr.id);
1556
+ if (id !== gr.id && inPulled.has(id) && !w.includes(id) && !reaches(id, gr.id)) { w.push(id); }
1557
+ }
1558
+ }
1559
+ for (const gr of pulled) {
1560
+ gr.stage = 0;
1561
+ gr.after = waits.get(gr.id);
1562
+ }
1563
+ plan.stage0_chosen_by = (first.class === 'host-chain'
1564
+ ? 'incremental: first host-chain group (the launch page is outside the scope)'
1565
+ : 'incremental: first group (no group touches the existing shared surface)')
1566
+ + (pulled.length > 1 ? `; with ${pulled.slice(1).map((gr) => gr.id).join(', ')} it builds on` : '');
1567
+ // the groups it builds on first, in dependency order (`waits` is acyclic)
1568
+ const head = [];
1569
+ const visit = (gr) => {
1570
+ if (head.includes(gr)) { return; }
1571
+ for (const id of waits.get(gr.id)) { visit(byId.get(id)); }
1572
+ head.push(gr);
1573
+ };
1574
+ for (const gr of [...pulled].reverse()) { visit(gr); }
1575
+ plan.groups = [...head, ...plan.groups.filter((gr) => !head.includes(gr))];
1576
+ }
1577
+
1578
+ /**
1579
+ * True when the capture directory has view trees but no screenshot at all because every frame was
1580
+ * FLAG_SECURE-blocked (export_ui_info writes `screenshots_blocked` and drops the black PNGs).
1581
+ * Such a page stays `captured` (the tree is real device evidence) but nothing can check pixels.
1582
+ */
1583
+ export function pixelsBlocked(uiInfo, dir) {
1584
+ const meta = readJson(path.join(uiInfo, pathName(String(dir)), 'meta.json'));
1585
+ if (!meta || typeof meta !== 'object') return false;
1586
+ const shots = Array.isArray(meta.screenshots) ? meta.screenshots.filter(Boolean) : [];
1587
+ const blocked = Array.isArray(meta.screenshots_blocked) ? meta.screenshots_blocked : [];
1588
+ return blocked.length > 0 && shots.length === 0 && !meta.screenshot;
1589
+ }
1590
+
1591
+ /**
1592
+ * The Gate E verdict of a page dir (meta.capture_quality, written by export_ui_info's pixel gate).
1593
+ * `null` = never verified (a capture made before this gate existed, or by another tool).
1594
+ */
1595
+ export function captureQuality(uiInfo, dir) {
1596
+ const meta = readJson(path.join(uiInfo, pathName(String(dir)), 'meta.json'));
1597
+ const q = get(meta ?? {}, 'capture_quality', null);
1598
+ if (!q || typeof q !== 'object') return null;
1599
+ return { verdict: get(q, 'verdict'), level: get(q, 'level'), reasons: get(q, 'reasons', []) };
1600
+ }
1601
+
1602
+ /**
1603
+ * True when every directory of a node holds a frame that shows nothing. Such a page is NOT captured
1604
+ * evidence: no screenshot, no view tree (one WebView node), no measurable layout. Measured
1605
+ * (app_uni 2026-11-20): 26 of 149 exported pages were blank and 8 groups had one as their only
1606
+ * reference look — the converter then rebuilt a page from a white rectangle. The directory is kept
1607
+ * (audit trail, re-export in place) but the page converts from source.
1608
+ */
1609
+ export function captureRejected(uiInfo, dirs) {
1610
+ const list = (dirs ?? []).filter(truthy);
1611
+ if (!list.length) return null;
1612
+ const qs = list.map((d) => captureQuality(uiInfo, d));
1613
+ if (!qs.length || qs.some((q) => !q)) return null; // unverified: leave the tier alone
1614
+ const rejected = qs.filter((q) => q.verdict === 'rejected');
1615
+ if (rejected.length !== qs.length) return null;
1616
+ return rejected.flatMap((q) => q.reasons ?? []).filter(Boolean);
1617
+ }
1618
+
1619
+ /** True when a captured page has no pixel verdict at all (a hand-rolled capture that skipped Gate E). */
1620
+ export function captureUnverified(uiInfo, dirs) {
1621
+ const list = (dirs ?? []).filter(truthy);
1622
+ return list.length > 0 && list.every((d) => !captureQuality(uiInfo, d));
1623
+ }
1624
+
1625
+ /**
1626
+ * The scroll evidence of a captured page: frames on disk, the manifest/meta verdict, and whether
1627
+ * the page has a vertical scroller a converter would need to see. `gap` means the page scrolls but
1628
+ * no capture proves the below-fold content.
1629
+ *
1630
+ * This is deliberately independent of export_manifest.json: a hand-rolled capture can forget the
1631
+ * manifest, and the view tree still proves the scroller exists.
1632
+ */
1633
+ export function pageScroll(uiInfo, dirs, source = null) {
1634
+ let frames = 0; let completeness = null; let scrollers = 0; let probe = null; let sourceScroll = false;
1635
+ for (const d of (dirs ?? []).filter(truthy)) {
1636
+ const dir = path.join(uiInfo, pathName(String(d)));
1637
+ const meta = readJson(path.join(dir, 'meta.json'), {});
1638
+ const trees = Array.isArray(meta?.view_xmls) && meta.view_xmls.length ? meta.view_xmls
1639
+ : (meta?.view_xml ? [meta.view_xml] : []);
1640
+ // same count as capture_audit: the trees on record, or meta.scroll_frames when it says more
1641
+ const treeFrames = trees.filter((v) => /[\\/]view_scroll_\d+\.xml$/i.test(String(v))).length;
1642
+ frames += Math.max(treeFrames, Number(meta?.scroll_frames ?? meta?.scroll?.frames ?? 0) || 0);
1643
+ completeness = completeness ?? meta?.scroll_completeness ?? meta?.scroll?.completeness ?? null;
1644
+ scrollers += scrollableContainers(dir, meta ?? {}, { uiInfo }).length;
1645
+ if (!sourceScroll && source) {
1646
+ const sf = sourceFileFor(meta ?? {}, source);
1647
+ if (sf) { sourceScroll = sourceDeclaresScroll(fs.readFileSync(sf, 'utf8')); }
1648
+ }
1649
+ if (!probe && meta?.scroll_probe && typeof meta.scroll_probe === 'object') { probe = meta.scroll_probe; }
1650
+ }
1651
+ scrollers += sourceScroll && scrollers === 0 ? 1 : 0;
1652
+ // scroll_verdict.mjs is the one rule (capture_audit and group_pack apply it too): `gap` is fake
1653
+ // completion only and holds the group; `degraded` is an honest partial sweep and does not.
1654
+ const v = scrollVerdict({ scrollable: scrollers > 0, completeness, frames, probe });
1655
+ const gap = v.status === 'gap';
1656
+ return { frames, completeness, scrollers, gap, verdict: v.status, ...(v.code ? { code: v.code } : {}),
1657
+ ...(probe ? { probe: { overflow: probe.overflow ?? null, scroll_height: probe.scroll_height ?? null, client_height: probe.client_height ?? null } } : {}) };
1658
+ }
1659
+
1660
+ export function build(ws, uiInfo, entry = null, renumber = false, exploring = false,
1661
+ { scope = null, existing = null, source = null } = {}) {
1662
+ const g = new Graph(readJson(path.join(ws, 'utg.json')));
1663
+ const prevSet = or(readJson(path.join(uiInfo, 'conversion_set.json'), {}), {});
1664
+ const rawPaths = get(or(readJson(path.join(ws, 'click_paths.json'), {}), {}), 'paths', {});
1665
+ // Map, not a plain object: node ids are keys and insertion order is the contract.
1666
+ const paths = new Map(Array.isArray(rawPaths) ? rawPaths : keysOf(rawPaths).map((k) => [k, rawPaths[k]]));
1667
+ const ranked = sortedBy([...paths.keys()],
1668
+ (k) => [pyLen(get(paths.get(k), 'steps', [])), get(paths.get(k), 'clicks', 0)]);
1669
+ const order = new Map(ranked.map((nid, i) => [nid, i]));
1670
+
1671
+ const manifest = or(readJson(path.join(uiInfo, 'export_manifest.json'), {}), {});
1672
+ const scopeDoc = truthy(scope) ? scopeOf(scope) : null;
1673
+ const scopeIds = scopeDoc ? scopeDoc.ids : null;
1674
+ // Incremental: each scope explores in a new campaign, and its export rewrites the manifest.
1675
+ // export_ui_info carries an earlier campaign's pages over as `earlier`; a node this campaign
1676
+ // did not capture again keeps that capture instead of turning source-only.
1677
+ const manifestPages = [...get(manifest, 'pages', [])];
1678
+ const listed = new Set(manifestPages.map((p) => p.static_node));
1679
+ for (const p of scopeIds ? get(manifest, 'earlier', []) : []) {
1680
+ if (!listed.has(p.static_node) && isDir(path.join(uiInfo, pathName(p.page_dir)))) { manifestPages.push(p); }
1681
+ }
1682
+ const captured = new Map();
1683
+ for (const p of manifestPages) { setdefault(captured, p.static_node, []).push(p.page_dir); }
1684
+
1685
+ const fullRoles = resolveRoles(g);
1686
+ const roles = scopeIds ? scopeRoles(g, fullRoles, scopeIds) : fullRoles;
1687
+ const keepIds = new Set([...roles].filter(([nid, r]) => r.role === 'page' && !captured.has(nid)).map(([nid]) => nid));
1688
+ const protect = new Set(scopeIds ? [...fullRoles].filter(([nid, r]) => r.role === 'page' && roles.get(nid).role === 'skip')
1689
+ .map(([nid]) => nid) : []);
1690
+ const attached = new Map();
1691
+ for (const [nid, r] of roles) {
1692
+ if (r.role === 'attach') { setdefault(attached, r.host, []).push(nid); }
1693
+ }
1694
+
1695
+ const tmplIndex = new Map();
1696
+ for (const [nid, dirs] of captured) {
1697
+ if (g.nodes.has(nid)) {
1698
+ for (const k of templateKeys(g.nodes.get(nid))) { setdefault(tmplIndex, tkey(k), []).push(...dirs); }
1699
+ }
1700
+ }
1701
+
1702
+ const attachedView = (host) => sortedBy(attached.get(host) ?? []).map((a) => ({
1703
+ id: a, kind: get(g.nodes.get(a), 'kind'), label: get(g.nodes.get(a), 'label'),
1704
+ captured_page_dirs: captured.get(a) ?? [], ...hintsOf(g.nodes.get(a)),
1705
+ }));
1706
+
1707
+ // Captured entries keep export_ui_info's order; drop stale source-only rows.
1708
+ // A scoped run writes only its scope to pages.json; pages_captured.json keeps every
1709
+ // capture, so a later run (another scope, or none) without export_ui_info still sees them.
1710
+ // The bare-list form (`[ {...} ]`) is accepted too: a capture pass written by another tool (the
1711
+ // measured one wrote exactly that) would otherwise parse as "0 entries" and every page dir would be
1712
+ // dropped from the page table.
1713
+ const pagesOf = (file) => {
1714
+ const doc = or(readJson(path.join(uiInfo, file), {}), {});
1715
+ return Array.isArray(doc) ? doc : get(doc, 'pages', []);
1716
+ };
1717
+ const old = [];
1718
+ const oldNames = new Set();
1719
+ const inPages = new Set(pagesOf('pages.json').map((e) => pathName(e.page_dir)));
1720
+ for (const f of ['pages.json', 'pages_captured.json']) {
1721
+ for (const e of pagesOf(f)) {
1722
+ if (!oldNames.has(pathName(e.page_dir))) { oldNames.add(pathName(e.page_dir)); old.push(e); }
1723
+ }
1724
+ }
1725
+ const pages = [];
1726
+ const allCaptured = [];
1727
+ const slugNode = new Map(manifestPages.map((p) => [p.page_dir, p.static_node]));
1728
+ // an earlier campaign's capture no pages file lists any more (a full run deleted
1729
+ // pages_captured.json, then this campaign's export rewrote pages.json)
1730
+ for (const p of manifestPages.slice(get(manifest, 'pages', []).length)) {
1731
+ if (!oldNames.has(pathName(p.page_dir))) {
1732
+ oldNames.add(pathName(p.page_dir));
1733
+ old.push({ page_dir: p.page_dir, ui_sequence: or(get(p, 'ui_sequence'), "Root page") });
1734
+ }
1735
+ }
1736
+ for (let e of old) {
1737
+ // Rebase onto this ui_info: a copied project still holds the original's
1738
+ // absolute page_dir, which would silently point every page at the source.
1739
+ const pdir = path.join(uiInfo, pathName(e.page_dir));
1740
+ // a demoted capture's row says source-only but is still a capture: the demotion below re-marks it
1741
+ if ((get(e, 'evidence_tier') === 'source-only' && get(e, 'degraded_from') !== 'capture') || !isDir(pdir)) { continue; }
1742
+ if (get(e, 'degraded_from') === 'capture') {
1743
+ e = { ...e };
1744
+ delete e.degraded_from;
1745
+ }
1746
+ const nodeId = slugNode.get(pathName(pdir));
1747
+ // a remembered capture the current export no longer lists is stale
1748
+ if (!truthy(nodeId) && slugNode.size && !inPages.has(pathName(pdir))) { continue; }
1749
+ allCaptured.push({ ...e, page_dir: pathResolve(pdir), evidence_tier: 'captured' });
1750
+ // incremental: a capture of a node outside the scope stays on disk, out of pages.json
1751
+ if (scopeIds && (!truthy(nodeId) || get(roles.get(nodeId), 'role', 'skip') === 'skip')) { continue; }
1752
+ e = { ...e, page_dir: pathResolve(pdir), evidence_tier: 'captured' };
1753
+ if (truthy(nodeId) && truthy(attached.get(nodeId))) { e.attached_nodes = attachedView(nodeId); }
1754
+ pages.push(e);
1755
+ }
1756
+ // The manifest is a capture source of truth too. A build that ran while pages.json was empty
1757
+ // (or a custom capture that wrote pages.json after the build) used to write `{pages: []}` and
1758
+ // drop every captured row. Keep the union, never shrink: a row present in the manifest and on
1759
+ // disk is a captured page even when pages.json forgot it.
1760
+ {
1761
+ const present = new Set(pages.map((p) => pathName(p.page_dir)));
1762
+ const allPresent = new Set(allCaptured.map((p) => pathName(p.page_dir)));
1763
+ const manifestByDir = new Map(manifestPages.map((p) => [pathName(p.page_dir), p]));
1764
+ for (const p of pages) {
1765
+ const m = manifestByDir.get(pathName(p.page_dir));
1766
+ if (!m) { continue; }
1767
+ if (m.scroll_frames !== undefined) { p.scroll_frames = m.scroll_frames; }
1768
+ if (m.scroll_completeness !== undefined) { p.scroll_completeness = m.scroll_completeness; }
1769
+ }
1770
+ // In a scoped run pages.json must hold only the scope; an out-of-scope capture stays in
1771
+ // pages_captured.json (the scope contract). A full run keeps every capture.
1772
+ if (!scopeIds) {
1773
+ for (const m of manifestPages) {
1774
+ const name = pathName(m.page_dir);
1775
+ if (!truthy(name) || present.has(name)) { continue; }
1776
+ const pdir = path.join(uiInfo, name);
1777
+ if (!isDir(pdir)) { continue; }
1778
+ const nodeId = slugNode.get(name);
1779
+ const row = { page_dir: pathResolve(pdir), ui_sequence: or(get(m, 'ui_sequence'), '根页面'),
1780
+ static_node: nodeId ?? get(m, 'static_node'), evidence_tier: 'captured',
1781
+ scroll_frames: get(m, 'scroll_frames'), scroll_completeness: get(m, 'scroll_completeness') };
1782
+ pages.push(row);
1783
+ if (!allPresent.has(name)) { allCaptured.push(row); allPresent.add(name); }
1784
+ present.add(name);
1785
+ }
1786
+ }
1787
+ }
1788
+
1789
+ // Never shrink the page table, and refuse before anything is written: a resume / review would see
1790
+ // 0 pages, and the old order (write pages.json, then refuse) already lost the table.
1791
+ const pageRoles = [...roles].filter(([, r]) => r.role === 'page');
1792
+ const capturedInPlan = pageRoles.filter(([nid]) => captured.has(nid)).length;
1793
+ if (capturedInPlan > 0 && pages.length === 0 && pageRoles.every(([nid]) => captured.has(nid))) {
1794
+ return { refused_shrink: true, pages_captured: capturedInPlan, page_dirs_total: 0 };
1795
+ }
1796
+ fs.mkdirSync(uiInfo, { recursive: true });
1797
+ const capturedDirs = new Set([...get(manifest, 'pages', []), ...get(manifest, 'earlier', [])]
1798
+ .map((p) => pathName(String(get(p, 'page_dir') ?? ''))).filter(truthy));
1799
+ const [removed, prevUnit] = clearPrevious(uiInfo, keepIds, protect, capturedDirs);
1800
+
1801
+ const nums = [];
1802
+ for (const d of globPrefix(uiInfo, 'page_')) {
1803
+ const m = /^page_(\p{Nd}+)_/u.exec(pathName(d));
1804
+ if (m) { nums.push(pyInt(m[1])); }
1805
+ }
1806
+ let seq = nums.reduce((a, b) => (b > a ? b : a), 0);
1807
+ const todo = sortedBy([...roles].filter(([nid, r]) => r.role === 'page' && !captured.has(nid)).map(([nid]) => nid),
1808
+ (nid) => [order.has(nid) ? order.get(nid) : order.size, nid]);
1809
+ const units = new Map();
1810
+ const tmplOf = new Map();
1811
+ for (const nid of todo) {
1812
+ const node = g.nodes.get(nid);
1813
+ let slug = prevUnit.get(nid);
1814
+ if (!slug) {
1815
+ seq += 1;
1816
+ slug = `page_${String(seq).padStart(4, '0')}_${safeName(node)}`;
1817
+ }
1818
+ const pdir = path.join(uiInfo, slug);
1819
+ fs.mkdirSync(pdir, { recursive: true });
1820
+ const templates = [];
1821
+ for (const k of templateKeys(node)) {
1822
+ for (const d of tmplIndex.get(tkey(k)) ?? []) {
1823
+ if (!pyIn(d, templates)) { templates.push(d); }
1824
+ }
1825
+ }
1826
+ const p = or(paths.get(nid), {});
1827
+ const labels = get(p, 'steps', []).map((s) => get(s, 'label')).filter(truthy);
1828
+ const route = or(get(p, 'nl_path_text'), get(p, 'path_text'));
1829
+ const meta = {
1830
+ page_id: slug, static_node: nid, kind: get(node, 'kind'), label: get(node, 'label'),
1831
+ declared_at: get(node, 'declared_at'),
1832
+ evidence_tier: 'source-only',
1833
+ // Deliberately empty: there is no capture. Step 4.1 must not treat
1834
+ // this as a failed read, and no agent may invent one.
1835
+ screenshots: [], view_xmls: [],
1836
+ source_hints: hintsOf(node),
1837
+ attached_nodes: attachedView(nid),
1838
+ reached_from: (g.inbound.get(nid) ?? []).map((e) => edgeView(e, 'source')),
1839
+ navigates_to: (g.outbound.get(nid) ?? []).map((e) => edgeView(e, 'target')),
1840
+ template_pages: templates.slice(0, MAX_TEMPLATES),
1841
+ click_path: get(p, 'steps', []),
1842
+ breadcrumb: labels.join(' > '),
1843
+ click_path_text: or(route, ''),
1844
+ source: { backend: 'a2h-utg-static', builder: 'build_conversion_set.mjs' },
1845
+ };
1846
+ writeJson(path.join(pdir, 'meta.json'), meta);
1847
+ pages.push({
1848
+ page_dir: pathResolve(pdir),
1849
+ ui_sequence: ["Root page", ...(truthy(route) ? [route] : labels)].join(ARROW),
1850
+ evidence_tier: 'source-only',
1851
+ });
1852
+ units.set(nid, slug);
1853
+ tmplOf.set(nid, templates.slice(0, MAX_TEMPLATES));
1854
+ }
1855
+
1856
+ const nodesOut = [];
1857
+ const demoted = new Map(); // node id -> rejection reasons (blank capture, converted from source)
1858
+ for (const nid of sortedBy([...g.nodes.keys()])) {
1859
+ const r = roles.get(nid);
1860
+ const row = { node: nid, kind: get(g.nodes.get(nid), 'kind'), role: r.role };
1861
+ if (r.role === 'page') {
1862
+ const dirs = or(captured.get(nid), [units.get(nid)]);
1863
+ const blank = captured.has(nid) ? captureRejected(uiInfo, dirs) : null;
1864
+ if (blank) { demoted.set(nid, blank); }
1865
+ row.tier = captured.has(nid) && !blank ? 'captured' : 'source-only';
1866
+ row.page_dirs = dirs;
1867
+ // captured but every frame FLAG_SECURE-blocked: view tree only, no pixel verification possible
1868
+ if (row.tier === 'captured' && row.page_dirs.every((d) => pixelsBlocked(uiInfo, d))) { row.pixels = 'blocked'; }
1869
+ if (blank) { row.pixels = 'rejected'; row.capture_rejected = blank; }
1870
+ if (row.tier === 'captured') {
1871
+ row.scroll = pageScroll(uiInfo, row.page_dirs, source);
1872
+ if (row.scroll.gap) { row.scroll_gap = true; }
1873
+ else if (row.scroll.verdict === 'degraded') { row.scroll_degraded = true; }
1874
+ if (!row.pixels && captureUnverified(uiInfo, row.page_dirs)) { row.pixels = 'unverified'; }
1875
+ }
1876
+ } else if (r.role === 'attach') {
1877
+ row.host = r.host;
1878
+ if (captured.has(nid)) { row.page_dirs = captured.get(nid); }
1879
+ } else {
1880
+ row.reason = r.reason;
1881
+ if (captured.has(nid)) { row.page_dirs = captured.get(nid); }
1882
+ }
1883
+ nodesOut.push(row);
1884
+ }
1885
+ // A demoted page keeps its directory (and its frames, for audit) but must be converted from source.
1886
+ // meta.evidence_tier stays as the capture wrote it: `degraded_from: "capture"` is the marker, and
1887
+ // the effective tier (group_pack, evidence_gate, capture_audit) is source-only while it is set.
1888
+ // Overwriting evidence_tier made the next build's clearPrevious delete the directory as a stale
1889
+ // source-only unit. A capture that passes Gate E again (re-captured) loses the marker.
1890
+ const writeDemotion = (d, reasons) => {
1891
+ const file = path.join(uiInfo, pathName(String(d)), 'meta.json');
1892
+ const meta = or(readJson(file), null);
1893
+ if (!meta) { return; }
1894
+ const want = reasons ? (reasons.join('; ') || 'blank frame') : null;
1895
+ if (reasons ? (meta.degraded_from === 'capture' && meta.degraded_reason === want) : meta.degraded_from !== 'capture') { return; }
1896
+ // lift the marker only on a fresh, non-rejected verdict (a re-capture), never on a lost one
1897
+ if (!reasons) {
1898
+ const q = captureQuality(uiInfo, d);
1899
+ if (!q || q.verdict === 'rejected') { return; }
1900
+ }
1901
+ if (reasons) {
1902
+ meta.degraded_from = 'capture';
1903
+ meta.degraded_reason = want;
1904
+ } else {
1905
+ delete meta.degraded_from;
1906
+ delete meta.degraded_reason;
1907
+ }
1908
+ writeJson(file, meta);
1909
+ };
1910
+ for (const [nid, dirs] of captured) {
1911
+ if (get(roles.get(nid), 'role') !== 'page') { continue; }
1912
+ for (const d of dirs ?? []) { writeDemotion(d, demoted.get(nid) ?? null); }
1913
+ }
1914
+ // pages.json rows feed Step 4.1 and group_queue: a demoted page must not read "captured" there.
1915
+ if (demoted.size) {
1916
+ const demotedDirs = new Set();
1917
+ for (const nid of demoted.keys()) { for (const d of captured.get(nid) ?? []) { demotedDirs.add(pathName(String(d))); } }
1918
+ for (const p of pages) {
1919
+ if (!demotedDirs.has(pathName(p.page_dir))) { continue; }
1920
+ p.evidence_tier = 'source-only';
1921
+ p.degraded_from = 'capture';
1922
+ }
1923
+ }
1924
+
1925
+ const count = (pred) => nodesOut.filter(pred).length;
1926
+ const summary = {
1927
+ static_nodes: nodesOut.length,
1928
+ pages_captured: count((r) => r.tier === 'captured'),
1929
+ pages_tree_only: count((r) => r.pixels === 'blocked'),
1930
+ pages_capture_rejected: count((r) => r.pixels === 'rejected'),
1931
+ pages_capture_unverified: count((r) => r.tier === 'captured' && r.pixels === 'unverified'),
1932
+ pages_scroll_gap: count((r) => r.tier === 'captured' && r.scroll_gap),
1933
+ pages_scroll_degraded: count((r) => r.tier === 'captured' && r.scroll_degraded),
1934
+ pages_source_only: count((r) => r.tier === 'source-only'),
1935
+ attached: count((r) => r.role === 'attach'),
1936
+ skipped: count((r) => r.role === 'skip'),
1937
+ page_dirs_total: pages.length,
1938
+ stale_source_only_removed: removed,
1939
+ ...(scopeIds ? { out_of_scope: [...roles.values()].filter((r) => pyStr(r.reason).startsWith('out-of-incremental-scope')).length,
1940
+ scoped_without_host: sortedBy([...roles].filter(([, r]) => / its host .* is not in the scope$/.test(pyStr(r.reason))).map(([nid]) => nid)) } : {}),
1941
+ };
1942
+ const pageOrder = new Map(pages.map((p, i) => [pathName(p.page_dir), i]));
1943
+ let prevPlan = renumber ? {} : or(get(prevSet, 'plan'), {});
1944
+ if (truthy(entry) && truthy(prevPlan) && entry !== get(prevPlan, 'entry_node')) {
1945
+ prevPlan = {}; // a new entry reshapes the plan: done before the queue starts
1946
+ }
1947
+ const prevIds = new Map(get(prevPlan, 'groups', []).map((gr) => [gr.anchor, gr.id]));
1948
+ // Keep the entry chosen last time (often an --entry override): an early,
1949
+ // partial export would otherwise re-infer it on every re-run.
1950
+ entry = or(entry, get(prevPlan, 'entry_node') ?? null);
1951
+ if (scopeIds && !truthy(entry)) {
1952
+ // the launch page exists already and is usually outside the scope: infer it over the whole app
1953
+ const full = new Map([...fullRoles].filter(([, r]) => r.role === 'page')
1954
+ .map(([nid]) => [nid, { tier: captured.has(nid) ? 'captured' : 'source-only', page_dirs: captured.get(nid) ?? [] }]));
1955
+ // ordered by the unfiltered pages.json: the scoped one dropped the captures outside the scope
1956
+ const fullOrder = new Map(old.map((p, i) => [pathName(p.page_dir), i]));
1957
+ entry = planGroups(g, fullRoles, full, fullOrder, ranked, null, null).entry_node;
1958
+ }
1959
+ const plan = planGroups(g, roles, new Map(nodesOut.map((r) => [r.node, r])), pageOrder, ranked, entry, prevIds,
1960
+ scopeIds ? fullRoles : null);
1961
+ const gs = plan.groups;
1962
+ // Carry the hard scroll gap (fake completion) onto the group so group_queue can hold it; a
1963
+ // degraded sweep is listed as scroll_degraded (group_pack's SINGLE VIEWPORT banner), not held.
1964
+ const dirsOf = (pred) => new Set(nodesOut.filter(pred)
1965
+ .flatMap((r) => r.page_dirs ?? []).map((d) => pathName(String(d))));
1966
+ const gapDirs = dirsOf((r) => truthy(r.scroll_gap));
1967
+ const degradedDirs = dirsOf((r) => truthy(r.scroll_degraded));
1968
+ if (gapDirs.size || degradedDirs.size) {
1969
+ for (const gr of gs) {
1970
+ const gap = (gr.page_dirs ?? []).filter((d) => gapDirs.has(pathName(String(d))));
1971
+ if (gap.length) { gr.scroll_gap = gap; }
1972
+ const deg = (gr.page_dirs ?? []).filter((d) => degradedDirs.has(pathName(String(d))));
1973
+ if (deg.length) { gr.scroll_degraded = deg; }
1974
+ }
1975
+ }
1976
+ // The captured groups a source-only group borrows measurements from: it
1977
+ // waits for exactly those (group_queue), not for every captured group.
1978
+ const owner = new Map();
1979
+ for (const gr of gs) for (const d of gr.page_dirs) owner.set(d, gr.id);
1980
+ for (const gr of gs) {
1981
+ const tg = new Set();
1982
+ for (const m of gr.members) {
1983
+ for (const d of tmplOf.get(m.node) ?? []) {
1984
+ const o = owner.get(pathName(d));
1985
+ if (o && o !== gr.id) tg.add(o);
1986
+ }
1987
+ }
1988
+ gr.template_groups = sortedBy([...tg]);
1989
+ }
1990
+ // Exploration still running: captured groups may start, source-only ones
1991
+ // are held -- their tier is not final until the explorer settles.
1992
+ if (scopeIds) {
1993
+ applyIncremental(plan, truthy(existing) ? readList(existing, ['existing', 'files']) : []);
1994
+ applySupplement(plan, scopeDoc.doc);
1995
+ plan.mode = 'incremental';
1996
+ plan.scope = sortedBy([...new Set(scopeIds)]);
1997
+ // the resume identity of batch_progress.json (progress_identity.mjs computes the same digest)
1998
+ plan.scope_id = scopeDoc.scope_id;
1999
+ }
2000
+ annotateShellContent(g, plan, readJson(path.join(path.dirname(path.resolve(ws)), 'shell_contract.json'), null));
2001
+ plan.exploring = truthy(exploring);
2002
+ // The captures this plan's tiers reflect, and how it was built: group_queue.mjs
2003
+ // rebuilds the plan the same way when the campaign's captures have moved on.
2004
+ plan.capture_digest = manifest.capture_digest ?? null;
2005
+ plan.built_from = { static_ws: pathStr(ws), entry: entry ?? null,
2006
+ ...(scopeIds ? { scope: pathStr(pathResolve(scope)), existing: truthy(existing) ? pathStr(pathResolve(existing)) : null } : {}) };
2007
+ const byClass = {};
2008
+ for (const c of ['host-chain', 'serial', 'self-contained']) { byClass[c] = gs.filter((x) => x.class === c).length; }
2009
+ const byStage = {};
2010
+ for (const st of [0, 1, 2]) { byStage[String(st)] = gs.filter((x) => x.stage === st).length; }
2011
+ Object.assign(summary, {
2012
+ groups: gs.length, entry_node: plan.entry_node,
2013
+ groups_by_class: byClass,
2014
+ groups_by_stage: byStage,
2015
+ group_warnings: gs.filter((x) => truthy(x.warning)).length,
2016
+ // incremental without --existing: no group can be marked as writing an existing file, so a
2017
+ // hand-written page or ViewModel of a predicted name is written over (list_existing.mjs makes the list)
2018
+ ...(scopeIds ? { existing_listed: truthy(existing) } : {}),
2019
+ });
2020
+ writeJson(path.join(uiInfo, 'pages.json'), { pages });
2021
+ if (scopeIds) {
2022
+ writeJson(path.join(uiInfo, 'pages_captured.json'), { pages: allCaptured });
2023
+ } else {
2024
+ fs.rmSync(path.join(uiInfo, 'pages_captured.json'), { force: true }); // pages.json holds them all again
2025
+ }
2026
+ writeJson(path.join(uiInfo, 'conversion_set.json'), { summary, nodes: nodesOut, plan });
2027
+ return summary;
2028
+ }
2029
+
2030
+ const DESCRIPTION = 'build_conversion_set.mjs — make the static UTG, not the capture, decide what\ngets converted.';
2031
+
2032
+ export function main(argv = process.argv.slice(2)) {
2033
+ const a = parseArgs({
2034
+ prog: 'build_conversion_set.mjs', description: DESCRIPTION,
2035
+ args: [
2036
+ { name: 'static_ws', positional: true, help: 'a2h-utg-static workspace (utg.json, click_paths.json)' },
2037
+ { name: '--ui-info', required: true, help: 'ui_info_root (export_ui_info.mjs output)' },
2038
+ { name: '--entry', help: "static node rendered by the app's launch page (default: inferred, see plan.entry_chosen_by)" },
2039
+ { name: '--exploring', bool: true, help: 'explorer still running: mark the plan so group_queue holds source-only groups' },
2040
+ { name: '--renumber', bool: true, help: "assign group ids afresh instead of keeping the previous run's ids per anchor" },
2041
+ { name: '--scope', help: 'incremental: JSON list of the static node ids to convert (the confirmed SCOPE); every other page is skipped' },
2042
+ { name: '--existing', help: 'incremental: JSON list of the .ets files the Harmony project already has (relative to the ETS root)' },
2043
+ { name: '--source', help: 'Android/UniApp source root; lets a hybrid page whose tree has no scroller still be detected as scrollable' },
2044
+ ],
2045
+ }, argv);
2046
+ if (!isFile(path.join(a.static_ws, 'utg.json'))) {
2047
+ err(`[ERR] ${pathStr(a.static_ws)}/utg.json missing — run Step 3.1 first`);
2048
+ return 2;
2049
+ }
2050
+ if (a.existing && !a.scope) {
2051
+ err('[ERR] --existing needs --scope');
2052
+ return 2;
2053
+ }
2054
+ for (const k of ['scope', 'existing']) {
2055
+ if (a[k] && !isFile(a[k])) {
2056
+ err(`[ERR] --${k} ${pathStr(a[k])}: no such file`);
2057
+ return 2;
2058
+ }
2059
+ }
2060
+ let s;
2061
+ try {
2062
+ s = build(pathResolve(a.static_ws), pathResolve(a.ui_info), a.entry, a.renumber, a.exploring,
2063
+ { scope: a.scope, existing: a.existing, source: a.source ? pathResolve(a.source) : null });
2064
+ } catch (e) {
2065
+ if (!a.scope || !/^--scope|: expected a JSON list/.test(e.message)) { throw e; }
2066
+ err(`[ERR] ${e.message}`);
2067
+ return 2;
2068
+ }
2069
+ if (s.refused_shrink) {
2070
+ err(`[ERR] the plan has ${s.pages_captured} captured page(s) but pages.json would be empty: refusing to shrink the ` +
2071
+ 'page table (a resume / review would see 0 pages); nothing was written. Check export_manifest.json, ' +
2072
+ 'pages.json and pages_captured.json, then rerun; capture_audit.mjs reports the same gap as pages_json_gap.');
2073
+ return 2;
2074
+ }
2075
+ out(`static nodes ${s.static_nodes}: pages ${s.pages_captured} captured + ` +
2076
+ `${s.pages_source_only} source-only, ${s.attached} attached to a host, ${s.skipped} skipped` +
2077
+ (s.out_of_scope !== undefined ? ` (${s.out_of_scope} outside the incremental scope)` : '') + '; ' +
2078
+ `pages.json has ${s.page_dirs_total} entries`);
2079
+ out(`groups ${s.groups} (entry ${pyStr(s.entry_node)}): ${pyRepr(s.groups_by_class)}, by stage ${pyRepr(s.groups_by_stage)}` +
2080
+ (s.group_warnings ? `; ${s.group_warnings} oversized — review` : ''));
2081
+ if (s.existing_listed === false) {
2082
+ err('[WARN] --scope without --existing: no group is marked as writing an existing HarmonyOS file, so ' +
2083
+ 'hand-written pages / ViewModels of a predicted name would be written over — run ' +
2084
+ 'list_existing.mjs <harmony_project_dir> --out <existing.json> and pass --existing');
2085
+ }
2086
+ if (!truthy(s.entry_node)) {
2087
+ err('[WARN] no entry page inferred (no launcher host-activity, no manifest launcher page): ' +
2088
+ 'no group carries ENTRY_PAGE — re-run with --entry <static node of the launch page>');
2089
+ }
2090
+ if (truthy(s.scoped_without_host)) {
2091
+ err(`[WARN] --scope names ${s.scoped_without_host.join(', ')} without its host page: not converted — ` +
2092
+ 'add the host page to the scope (an attached node is converted inside its host group)');
2093
+ }
2094
+ if (s.pages_captured === 0) {
2095
+ err('[WARN] no captured page: every page would be source-only and no project token ' +
2096
+ "(colour, density, spacing) can be measured — see Step 3.3's gate");
2097
+ }
2098
+ if (s.pages_scroll_gap > 0) {
2099
+ err(`[WARN] ${s.pages_scroll_gap} captured page(s) have a scroll container and a fake or missing scroll ` +
2100
+ 'verdict (complete with 0 frames, or no verdict at all): their group is held by group_queue.mjs until ' +
2101
+ 'the frames are captured (capture_fast.mjs for hybrid pages, the explorer sweep otherwise). A ' +
2102
+ 'capture_waivers.json entry cannot release it. See capture_audit.mjs.');
2103
+ }
2104
+ if (s.pages_scroll_degraded > 0) {
2105
+ err(`[WARN] ${s.pages_scroll_degraded} captured page(s) have a partial scroll record (truncated / not-swept / ` +
2106
+ 'no-effect / aborted / unreached): converted with a SINGLE VIEWPORT warning, the below-fold part from source. ' +
2107
+ 'Not held; re-capture to improve, or record the decision with capture_audit.mjs --allow-degraded.');
2108
+ }
2109
+ if (s.pages_capture_unverified > 0) {
2110
+ err(`[WARN] ${s.pages_capture_unverified} captured page(s) have no pixel verdict: run ` +
2111
+ 'capture_verify.mjs <ui_info> --write (a blank frame must be demoted, not converted as captured).');
2112
+ }
2113
+ return 0;
2114
+ }
2115
+
2116
+ if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
2117
+ process.exitCode = main();
2118
+ }