@buaa_smat/hometrans 26.0.5 → 26.0.6

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 (472) hide show
  1. package/README.md +249 -279
  2. package/agents/code-reviewer.md +1 -1
  3. package/dist/cli/editors.json +20 -0
  4. package/dist/platform/registry.js +1 -0
  5. package/dist/platform/validate.js +2 -1
  6. package/i18n/agents/code-reviewer.md +1 -1
  7. package/i18n/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  8. package/i18n/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  9. package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  10. package/i18n/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  11. package/i18n/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  12. package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  13. package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
  14. package/i18n/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  15. package/i18n/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  16. package/i18n/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  17. package/i18n/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  18. package/i18n/skills/a2h-app-migrate/SKILL.md +32 -15
  19. package/i18n/skills/a2h-app-migrate/references/stage-map.md +4 -2
  20. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +148 -89
  21. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
  22. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
  23. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +1 -1
  24. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
  25. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
  26. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
  27. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
  28. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +9 -3
  29. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
  30. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
  31. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
  32. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
  33. package/i18n/skills/a2h-batch-ui-align/SKILL.md +14 -12
  34. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
  35. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
  36. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
  37. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
  38. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
  39. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
  40. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
  41. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
  42. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
  43. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
  44. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
  45. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
  46. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
  47. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
  48. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
  49. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +1 -1
  50. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
  51. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
  52. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
  53. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
  54. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
  55. package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
  56. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
  57. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
  58. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
  59. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
  60. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
  61. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
  62. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
  63. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
  64. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
  65. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
  66. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
  67. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
  68. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
  69. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
  70. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
  71. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
  72. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
  73. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
  74. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
  75. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
  76. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
  77. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
  78. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
  79. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
  80. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
  81. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
  82. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +3 -2
  83. package/i18n/skills/a2h-page-specgen/SKILL.md +36 -5
  84. package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +89 -21
  85. package/i18n/skills/a2h-page-specgen/references/gates.md +33 -7
  86. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
  87. package/i18n/skills/a2h-page-specgen/references/spec-example.md +166 -32
  88. package/i18n/skills/a2h-page-specgen/references/spec-template.md +8 -5
  89. package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +37 -1
  90. package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
  91. package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
  92. package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +32 -0
  93. package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
  94. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
  95. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +19 -10
  96. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +62 -3
  97. package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
  98. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +116 -6
  99. package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
  100. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +26 -14
  101. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +118 -25
  102. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +104 -19
  103. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +118 -25
  104. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +104 -19
  105. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +216 -216
  106. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
  107. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
  108. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +118 -25
  109. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +100 -15
  110. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +118 -25
  111. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +104 -19
  112. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +155 -3
  113. package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
  114. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
  115. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
  116. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
  117. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
  118. package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
  119. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +75 -3
  120. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
  121. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +124 -0
  122. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
  123. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +106 -1
  124. package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
  125. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +12 -0
  126. package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
  127. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +11 -3
  128. package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
  129. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
  130. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
  131. package/i18n/skills/a2h-resource-convert/SKILL.md +1 -1
  132. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
  133. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
  134. package/i18n/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
  135. package/i18n/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
  136. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +15 -12
  137. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
  138. package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
  139. package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
  140. package/i18n/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
  141. package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
  142. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +5 -3
  143. package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
  144. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
  145. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
  146. package/i18n/skills/a2h-spec-generate/references/input-formats.md +1 -1
  147. package/i18n/skills/a2h-utg-explorer/SKILL.md +11 -5
  148. package/i18n/skills/a2h-utg-explorer/references/architecture.md +37 -19
  149. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +48 -3
  150. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
  151. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
  152. package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
  153. package/i18n/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
  154. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
  155. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +143 -14
  156. package/i18n/skills/a2h-utg-static/SKILL.md +3 -3
  157. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
  158. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
  159. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
  160. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
  161. package/package.json +2 -1
  162. package/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  163. package/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  164. package/platforms/codebuddy/agents/build-fixer.frontmatter.md +5 -0
  165. package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +5 -0
  166. package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +5 -0
  167. package/platforms/codebuddy/agents/model-worker.frontmatter.md +5 -0
  168. package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +5 -0
  169. package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  170. package/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  171. package/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  172. package/platforms/deveco/agents/build-fixer.frontmatter.md +2 -0
  173. package/platforms/deveco/agents/code-reviewer.frontmatter.md +2 -0
  174. package/platforms/deveco/agents/model-render-worker.frontmatter.md +2 -0
  175. package/platforms/deveco/agents/model-worker.frontmatter.md +2 -0
  176. package/platforms/deveco/agents/specgen-worker.frontmatter.md +2 -0
  177. package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  178. package/platforms/opencode/agents/build-fixer.frontmatter.md +2 -0
  179. package/platforms/opencode/agents/code-reviewer.frontmatter.md +2 -0
  180. package/platforms/opencode/agents/model-render-worker.frontmatter.md +2 -0
  181. package/platforms/opencode/agents/model-worker.frontmatter.md +2 -0
  182. package/platforms/opencode/agents/specgen-worker.frontmatter.md +2 -0
  183. package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
  184. package/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  185. package/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  186. package/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  187. package/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  188. package/skills/a2h-app-migrate/SKILL.md +31 -14
  189. package/skills/a2h-app-migrate/references/stage-map.md +4 -2
  190. package/skills/a2h-app-migrate/references/workflow.yaml +152 -89
  191. package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +1 -1
  192. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +28 -11
  193. package/skills/a2h-app-migrate/scripts/dag_action_catalog.mjs +76 -0
  194. package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +60 -5
  195. package/skills/a2h-app-migrate/scripts/dag_runner.mjs +184 -4
  196. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
  197. package/skills/a2h-app-migrate/scripts/ledger.mjs +2 -2
  198. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -3
  199. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
  200. package/skills/a2h-app-migrate/test/test_dag_blocked_guard.mjs +291 -0
  201. package/skills/a2h-app-migrate/test/test_dag_production.mjs +40 -0
  202. package/skills/a2h-app-migrate/test/test_dag_runner.mjs +4 -3
  203. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +1 -1
  204. package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
  205. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
  206. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
  207. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +1 -1
  208. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
  209. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +36 -0
  210. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +19 -6
  211. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
  212. package/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
  213. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
  214. package/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
  215. package/skills/a2h-batch-ui-align/SKILL.md +14 -12
  216. package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
  217. package/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
  218. package/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
  219. package/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
  220. package/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
  221. package/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
  222. package/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
  223. package/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
  224. package/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
  225. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
  226. package/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
  227. package/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
  228. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
  229. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
  230. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
  231. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
  232. package/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
  233. package/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
  234. package/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
  235. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
  236. package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +6 -1
  237. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
  238. package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +270 -0
  239. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +134 -16
  240. package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +39 -8
  241. package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
  242. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
  243. package/skills/a2h-batch-ui-align/scripts/module_placement.mjs +189 -0
  244. package/skills/a2h-batch-ui-align/scripts/overlay_effects.mjs +205 -0
  245. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
  246. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
  247. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +28 -0
  248. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
  249. package/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
  250. package/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
  251. package/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
  252. package/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
  253. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
  254. package/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
  255. package/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
  256. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
  257. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
  258. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
  259. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
  260. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
  261. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
  262. package/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
  263. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
  264. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
  265. package/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
  266. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
  267. package/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
  268. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +28 -0
  269. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_chrome_defaults.test.mjs +328 -0
  270. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_click_handler.test.mjs +127 -0
  271. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_compose_semantics.test.mjs +150 -0
  272. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +117 -0
  273. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
  274. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
  275. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +413 -0
  276. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +159 -0
  277. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_sheet_builder.test.mjs +192 -0
  278. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +4 -2
  279. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
  280. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_compose.test.mjs +106 -0
  281. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +15 -0
  282. package/skills/a2h-batch-ui-align/scripts/tests/group_pass.test.mjs +150 -0
  283. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +125 -0
  284. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +56 -0
  285. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack_icon_leaf.test.mjs +143 -0
  286. package/skills/a2h-batch-ui-align/scripts/tests/module_placement.test.mjs +248 -0
  287. package/skills/a2h-batch-ui-align/scripts/tests/overlay_effects.test.mjs +214 -0
  288. package/skills/a2h-fix-build-errors/references/known-patterns.md +5 -5
  289. package/skills/a2h-module-semantic-docs/SKILL.md +3 -2
  290. package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +10 -0
  291. package/skills/a2h-module-semantic-docs/scripts/design_baseline.mjs +158 -0
  292. package/skills/a2h-module-semantic-docs/test/test_design_baseline.mjs +128 -0
  293. package/skills/a2h-page-specgen/SKILL.md +36 -5
  294. package/skills/a2h-page-specgen/references/behavior-ledger.md +88 -21
  295. package/skills/a2h-page-specgen/references/evidence.md +2 -1
  296. package/skills/a2h-page-specgen/references/execution-model.md +13 -5
  297. package/skills/a2h-page-specgen/references/gates.md +33 -7
  298. package/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
  299. package/skills/a2h-page-specgen/references/spec-example.md +166 -32
  300. package/skills/a2h-page-specgen/references/spec-template.md +8 -5
  301. package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +40 -2
  302. package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
  303. package/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
  304. package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +35 -2
  305. package/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
  306. package/skills/a2h-page-specgen/scripts/finalize.mjs +55 -2
  307. package/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
  308. package/skills/a2h-page-specgen/scripts/gate.mjs +20 -11
  309. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +56 -3
  310. package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
  311. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +114 -5
  312. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +20 -3
  313. package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
  314. package/skills/a2h-page-specgen/scripts/prepare.mjs +25 -14
  315. package/skills/a2h-page-specgen/scripts/report.mjs +26 -5
  316. package/skills/a2h-page-specgen/scripts/submission.mjs +69 -2
  317. package/skills/a2h-page-specgen/scripts/submit.mjs +105 -4
  318. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +110 -18
  319. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +97 -12
  320. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +110 -18
  321. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +97 -12
  322. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +224 -224
  323. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
  324. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
  325. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +110 -18
  326. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +97 -12
  327. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +110 -18
  328. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +97 -12
  329. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +153 -3
  330. package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
  331. package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
  332. package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
  333. package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
  334. package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
  335. package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
  336. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +82 -3
  337. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
  338. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +11 -0
  339. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
  340. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +94 -1
  341. package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
  342. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +14 -0
  343. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +49 -1
  344. package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
  345. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +12 -4
  346. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
  347. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
  348. package/skills/a2h-page-specgen/scripts/test/report.test.mjs +80 -1
  349. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
  350. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +23 -0
  351. package/skills/a2h-page-specgen/scripts/waker.mjs +8 -1
  352. package/skills/a2h-resource-convert/SKILL.md +1 -1
  353. package/skills/a2h-resource-convert/data/framework-strings/NOTICE +10 -0
  354. package/skills/a2h-resource-convert/data/framework-strings/manifest.json +90 -0
  355. package/skills/a2h-resource-convert/data/framework-strings/strings.json +382 -0
  356. package/skills/a2h-resource-convert/references/conversion-rules.md +7 -1
  357. package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
  358. package/skills/a2h-resource-convert/references/step5-reference-resolution.md +16 -0
  359. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
  360. package/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
  361. package/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
  362. package/skills/a2h-spec-design-pipeline/SKILL.md +14 -11
  363. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
  364. package/skills/a2h-spec-design-pipeline/references/execution-model.md +3 -0
  365. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -3
  366. package/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
  367. package/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
  368. package/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
  369. package/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
  370. package/skills/a2h-spec-design-pipeline/references/scripts.md +4 -3
  371. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +24 -19
  372. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
  373. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +12 -5
  374. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
  375. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
  376. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +27 -3
  377. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +46 -1
  378. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +2511 -295
  379. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +27 -72
  380. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +39 -83
  381. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +132 -101
  382. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +158 -115
  383. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +60 -93
  384. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +73 -100
  385. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-cn.md +52 -0
  386. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-en.md +59 -0
  387. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +57 -8
  388. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +475 -18
  389. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +472 -4
  390. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/RoutePageSideEffectImportCheck.js +570 -0
  391. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/arkui/RouteParamCarrierSubCheck.js +1053 -0
  392. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/sql/SqlIdentifierAnalysis.js +427 -0
  393. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +7 -1
  394. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
  395. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
  396. package/skills/a2h-spec-design-pipeline/scripts/settle.ts +785 -0
  397. package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +286 -0
  398. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +166 -2
  399. package/skills/a2h-spec-design-pipeline/scripts/test_docs_refresh_contract.ts +40 -0
  400. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
  401. package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +350 -7
  402. package/skills/a2h-spec-design-pipeline/scripts/test_route_page_side_effect_import.ts +185 -0
  403. package/skills/a2h-spec-design-pipeline/scripts/test_route_param_carrier.ts +341 -0
  404. package/skills/a2h-spec-design-pipeline/scripts/test_settle.ts +593 -0
  405. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +92 -1
  406. package/skills/a2h-spec-design-pipeline/scripts/test_sql_identifier_analysis.ts +137 -0
  407. package/skills/a2h-spec-generate/references/input-formats.md +1 -1
  408. package/skills/a2h-utg-explorer/SKILL.md +11 -5
  409. package/skills/a2h-utg-explorer/references/architecture.md +37 -19
  410. package/skills/a2h-utg-explorer/scripts/audit.mjs +6 -2
  411. package/skills/a2h-utg-explorer/scripts/close_phases.mjs +8 -5
  412. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +95 -19
  413. package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +192 -4
  414. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
  415. package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +1 -1
  416. package/skills/a2h-utg-explorer/scripts/plan.mjs +16 -1
  417. package/skills/a2h-utg-explorer/scripts/predicates.mjs +270 -0
  418. package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +2 -0
  419. package/skills/a2h-utg-explorer/scripts/recover.mjs +4 -3
  420. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
  421. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +4 -3
  422. package/skills/a2h-utg-explorer/scripts/report.mjs +32 -2
  423. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +103 -36
  424. package/skills/a2h-utg-explorer/scripts/run_device.mjs +3 -8
  425. package/skills/a2h-utg-explorer/scripts/schedule_states.mjs +189 -0
  426. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +9 -0
  427. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +11 -0
  428. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +31 -2
  429. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +1 -1
  430. package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
  431. package/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
  432. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +4 -1
  433. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +6 -28
  434. package/skills/a2h-utg-explorer/scripts/tests/in_route_surface.test.mjs +125 -0
  435. package/skills/a2h-utg-explorer/scripts/tests/list_probe_target_wait.test.mjs +86 -0
  436. package/skills/a2h-utg-explorer/scripts/tests/multi_host.test.mjs +167 -0
  437. package/skills/a2h-utg-explorer/scripts/tests/nested_list.test.mjs +58 -0
  438. package/skills/a2h-utg-explorer/scripts/tests/overlay_opener.test.mjs +100 -0
  439. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +8 -1
  440. package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +1 -0
  441. package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +2 -31
  442. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +1 -1
  443. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +56 -7
  444. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +117 -6
  445. package/skills/a2h-utg-explorer/scripts/tests/state_inventory.test.mjs +414 -0
  446. package/skills/a2h-utg-explorer/scripts/tests/tree_unreliable.test.mjs +197 -0
  447. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +196 -30
  448. package/skills/a2h-utg-explorer/scripts/utg_explorer/hosts.mjs +146 -0
  449. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
  450. package/skills/a2h-utg-explorer/scripts/utg_explorer/states.mjs +286 -0
  451. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +197 -19
  452. package/skills/a2h-utg-static/SKILL.md +3 -3
  453. package/skills/a2h-utg-static/references/extractors.md +7 -0
  454. package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
  455. package/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
  456. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +642 -22
  457. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
  458. package/skills/a2h-utg-static/scripts/tests/test_in_route_surface.mjs +123 -0
  459. package/skills/a2h-utg-static/scripts/tests/test_overlay_host_effects.mjs +239 -0
  460. package/skills/a2h-utg-static/scripts/tests/test_shared_host_depths.mjs +48 -0
  461. package/skills/a2h-utg-static/scripts/utg_html.mjs +2 -0
  462. package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
  463. package/i18n/skills/a2h-app-migrate/references/specs.example.json +0 -19
  464. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
  465. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
  466. package/resource/convert_pipeline_process.svg +0 -114
  467. package/resource/project_architecture.svg +0 -120
  468. package/resource/set_environment.png +0 -0
  469. package/resource/set_multimodel.png +0 -0
  470. package/skills/a2h-app-migrate/references/specs.example.json +0 -19
  471. package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
  472. package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Exports: MAX_SETUP_STEPS, REPLAY, MAX_REPLAY_STEPS, load, snapshotNames, outputName, extract,
11
11
  * checkSteps, knownTexts, screenTexts, fixtureServerTexts, groundingProblem, stepFailedPhases, stepFailures,
12
- * revisablePhases, validate, apply, main
12
+ * revisablePhases, snapshotLandings, baseProblem, validate, apply, main
13
13
  */
14
14
  import * as fs from 'node:fs';
15
15
  import * as path from 'node:path';
@@ -22,6 +22,8 @@ import { atomicWriteJson } from './utg_explorer/adapters.mjs';
22
22
  import { addItemFilterArgs, nodeFilter, scopeOf, unmappedOnly } from './utg_explorer/coverage.mjs';
23
23
  import { KEYS, MAX_STEPS, STEP_TYPES, overrideFor, selectorProblem, toRunner } from './recover_b.mjs';
24
24
  import { unrunnable } from './close_phases.mjs';
25
+ import { isServed } from './schedule_states.mjs';
26
+ import { loadStates } from './utg_explorer/states.mjs';
25
27
  import { addVariant } from './variant.mjs';
26
28
  import { normalized } from './utg_explorer/strings.mjs';
27
29
 
@@ -52,10 +54,13 @@ const keyOf = (v) => sha256Hex(Buffer.from(jsonDumps(v, { sort_keys: true }), 'u
52
54
 
53
55
  /**
54
56
  * Phases D should build a state for: blocked ones, and pending ones no fixture/probe can enter
55
- * (close_phases only marks those `blocked` at the end of the cycle, after D has run).
57
+ * (close_phases only marks those `blocked` at the end of the cycle, after D has run). A phase a
58
+ * known state already serves (schedule_states.mjs) is not one, and neither is a state phase
59
+ * itself (`st-*`: its origin phase is offered once it no longer counts as served).
56
60
  */
57
61
  export function phasesNeedingState(doc, config) {
58
- return doc.phases.filter((p) => !p.id.startsWith('rec') && (p.status === 'blocked' || unrunnable(p, config)));
62
+ return doc.phases.filter((p) => !p.id.startsWith('rec') && !p.id.startsWith('st-') && !isServed(doc, p)
63
+ && (p.status === 'blocked' || unrunnable(p, config, doc)));
59
64
  }
60
65
 
61
66
  /**
@@ -322,7 +327,7 @@ function recipeFixtures(r, config) {
322
327
  save = { type: 'save_replay', archive, steps: full, from: r.base };
323
328
  } else {
324
329
  restore = [{ type: 'restore_app_data', archive: pJoin(snapDir, r.base),
325
- clear_dirs: ['databases', 'shared_prefs', 'files'] }, launch, { type: 'wait', seconds: 2 }];
330
+ clear_dirs: 'all' }, launch, { type: 'wait', seconds: 2 }];
326
331
  save = { type: 'snapshot_app_data', archive };
327
332
  }
328
333
  const fixtures = [...restore, ...r.steps.map((s) => tagged(s, 'steps')),
@@ -399,7 +404,9 @@ export function extract(doc, root, config, unmapped = false) {
399
404
  'a feed URL that returns an error; never modify existing files. Give positive probes proving ' +
400
405
  'the state on the screen the app shows after relaunch. Choose probe texts that are on that ' +
401
406
  'screen at rest: a section title that only appears while scrolling (sticky header) or inside ' +
402
- "a dialog is not. A `probe-revision` item is a recipe whose steps ran but whose probe did not " +
407
+ "a dialog is not. `snapshot_landings` shows the screen each base lands on after relaunch: a recipe's " +
408
+ 'steps start there (a base landing on an agreement or login screen needs steps through it). ' +
409
+ "A `probe-revision` item is a recipe whose steps ran but whose probe did not " +
403
410
  "match: answer it with verdict 'revise' and new `probes` whose texts are all in its " +
404
411
  "`visible_texts` (open its `screenshot`) and that tell the target state apart from the base " +
405
412
  "one, or verdict 'skipped' when that screen is not the wanted state. Every text or " +
@@ -413,6 +420,9 @@ export function extract(doc, root, config, unmapped = false) {
413
420
  screen_texts: Object.fromEntries([...screenTexts(doc).entries()].sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
414
421
  .map(([sid, list]) => [sid, list.slice(0, SCREEN_TEXTS_PER_PAGE)])),
415
422
  snapshots: snapshotNames(snapDir),
423
+ // what each base holds: the screen a cold launch shows on its data (states.json). A recipe
424
+ // starts from this screen, so its steps must lead from it to the probed one.
425
+ snapshot_landings: snapshotLandings(root, snapshotNames(snapDir)),
416
426
  fixture_server_files: feedDir && pIsDir(feedDir) ? sortedStr(listDirNames(feedDir).map((e) => e.name)) : [],
417
427
  fixture_feed: feedDir && pIsFile(pJoin(feedDir, 'feed.xml')) ? readText(pJoin(feedDir, 'feed.xml'), { encoding: 'utf-8' }) : null };
418
428
  atomicWriteText(pJoin(root, 'recovery_d_worklist.json'), jsonDumps(wl, { ensure_ascii: false, indent: 1 }));
@@ -462,9 +472,57 @@ export function checkRevisedProbes(probes, visible) {
462
472
  }
463
473
  return null;
464
474
  }
475
+ /** The state whose archive file is named `name` (paths in states.json may be Windows or POSIX). */
476
+ const stateOfArchive = (states, name) => states.find((x) => T(x.archive) && pyStr(x.archive).split(/[/\\]/).pop() === name);
477
+
478
+ /** base snapshot name -> its recorded landing (states.json), for the worklist. */
479
+ export function snapshotLandings(root, names) {
480
+ const states = root ? loadStates(root).states : [];
481
+ const out = {};
482
+ for (const n of names) {
483
+ const s = stateOfArchive(states, n);
484
+ const l = get(s ?? {}, 'landing');
485
+ if (l) { out[n] = { state: s.id, activity: l.activity, page: l.static_id, texts: (l.texts || []).slice(0, 15) }; }
486
+ }
487
+ return out;
488
+ }
489
+
490
+ /**
491
+ * baseProblem(r, landing): a recipe with no step that changes the screen (waits only, no
492
+ * probe_steps) whose probe cannot match the screen its base lands on. Such a recipe can only
493
+ * re-read the base: measured (universalapp TV 2026-11-25), six "devices" recipes were [wait] on a
494
+ * first-launch base that lands on the agreement dialog, and each blocked state-probe-failed on
495
+ * the device. Decided from the recorded landing only when a probe names an activity or a text
496
+ * / resource id the landing does not have (content_desc and unknown fields never reject).
497
+ */
498
+ export function baseProblem(r, landing) {
499
+ if (!isDict(landing)) { return null; }
500
+ const steps = [...or_(get(r, 'steps'), []), ...or_(get(r, 'probe_steps'), [])];
501
+ if (steps.some((s) => get(s, 'type') !== 'wait')) { return null; }
502
+ const texts = new Set((landing.texts || []).map((t) => normalized(pyStr(t))));
503
+ const ids = new Set((landing.ids || []).map((x) => pyStr(x)));
504
+ const tails = new Set([...ids].map((x) => x.split('/').pop()));
505
+ const missing = (sel) => {
506
+ if (!isDict(sel)) { return null; }
507
+ if (Object.hasOwn(sel, 'text') && !texts.has(normalized(pyStr(sel.text)))) { return `text ${JSON.stringify(sel.text)}`; }
508
+ if (Object.hasOwn(sel, 'resource_id') && !ids.has(pyStr(sel.resource_id))) { return `resource_id ${pyStr(sel.resource_id)}`; }
509
+ if (Object.hasOwn(sel, 'resource_name') && !tails.has(pyStr(sel.resource_name))) { return `resource_name ${pyStr(sel.resource_name)}`; }
510
+ return null;
511
+ };
512
+ for (const p of or_(get(r, 'probes'), [])) {
513
+ let why = T(get(p, 'activity')) && T(landing.activity) && p.activity !== landing.activity ? `activity ${pyStr(p.activity)}` : null;
514
+ for (const sel of or_(get(p, 'all'), [])) { why = why ?? missing(sel); }
515
+ if (!why && T(get(p, 'any')) && p.any.every((sel) => missing(sel))) { why = 'none of its any-selectors'; }
516
+ if (why) {
517
+ return `steps only wait, but base ${pyStr(r.base)} lands on ${pyStr(landing.static_id || landing.activity)}, which does not show the probe's ${why}: add the steps that lead from that screen to the state`;
518
+ }
519
+ }
520
+ return null;
521
+ }
522
+
465
523
  const FILE_RE = /^[\p{L}\p{N}_.-]{1,40}\.(xml|json|txt|srt|vtt|html)$/u;
466
524
 
467
- export function validate(r, doc, config) {
525
+ export function validate(r, doc, config, root = null) {
468
526
  if (!ID_RE.test(pyStr(get(r, 'id', '')))) { return 'recipe id must be [a-z0-9-]{2,32}'; }
469
527
  const snapDir = pathStr(get(config, 'snapshot_dir', ''));
470
528
  const base = pyStr(get(r, 'base', ''));
@@ -503,7 +561,8 @@ export function validate(r, doc, config) {
503
561
  why = checkSteps(ts[tid], MAX_STEPS);
504
562
  if (why) { return `${tid}: ${why}`; }
505
563
  }
506
- return groundingProblem(r, knownTexts(doc), [], fixtureServerTexts(config));
564
+ const landing = root ? get(stateOfArchive(loadStates(root).states, base) ?? {}, 'landing') : null;
565
+ return baseProblem(r, landing) ?? groundingProblem(r, knownTexts(doc), [], fixtureServerTexts(config));
507
566
  }
508
567
 
509
568
  /**
@@ -583,7 +642,7 @@ export function apply(doc, config, root) {
583
642
  tasks: doc.tasks.filter((t) => t.phase === existing.id).length, archive: pJoin(snapDir, outputName(r.base, r.id)) });
584
643
  continue;
585
644
  }
586
- const why = ids.has(get(r, 'id')) ? 'duplicate recipe id' : validate(r, doc, config);
645
+ const why = ids.has(get(r, 'id')) ? 'duplicate recipe id' : validate(r, doc, config, root);
587
646
  if (why) { report.push({ ...(key !== null ? { key } : {}), id: get(r, 'id'), status: 'rejected', why }); continue; }
588
647
  ids.add(r.id);
589
648
  for (const f of get(r, 'fixture_files', [])) { writeText(pJoin(feedDir, f.name), f.content); }
@@ -196,6 +196,38 @@ function homeWithLists() {
196
196
  return { observation_id: 'home', nodes: n, static_resolution: { status: 'verified', static_id: 'pager:Home' } };
197
197
  }
198
198
 
199
+ // ---- the same label twice on one page (coolmall 2026-11-27: "View all" under "My orders" and "My footprints") ----
200
+ function meTwice() {
201
+ // two sections of different shape (the second has an extra line), so they are not one row template
202
+ const n = [vw(null, [0, 0, 1080, 2400]), vw(0, [0, 560, 1080, 660]), tv('View all', 1, [839, 589, 963, 634]),
203
+ vw(0, [0, 900, 1080, 1000]), tv('View all', 3, [839, 932, 963, 977]), tv('Recently viewed', 3, [40, 932, 400, 977])];
204
+ return { observation_id: 'me', nodes: n, static_resolution: { status: 'verified', static_id: 'pager:Me' } };
205
+ }
206
+
207
+ test('a label on screen twice is probed by landing page when the step names it, never by coordinates alone', () => {
208
+ const r = runner(meTwice());
209
+ const acts = [];
210
+ r.config = { package: 'com.ex' };
211
+ r.at = (id) => get(r.current.static_resolution, 'static_id') === id;
212
+ r.emit = () => {};
213
+ r.atom = (a) => {
214
+ acts.push(a.type + (a.y ? `@${a.y}` : ''));
215
+ if (a.type === 'back') { r.current = meTwice(); }
216
+ else { r.current = { observation_id: 'x', nodes: [], static_resolution: { status: 'verified', static_id: a.y > 800 ? 'r:Footprint' : 'r:OrderList' } }; }
217
+ return {};
218
+ };
219
+ const step = (target_id) => ({ type: 'click_candidates', selectors: [{ text: 'View all' }], ...(target_id ? { target_id } : {}) });
220
+ r.seek(step('r:OrderList'), 't', 'replay');
221
+ assert.deepEqual(acts, ['click_point@611'], 'the first match opens the order list');
222
+ acts.length = 0; r.current = meTwice();
223
+ r.seek(step('r:Footprint'), 't', 'replay');
224
+ assert.deepEqual(acts, ['click_point@611', 'back', 'click_point@954'], 'a wrong landing is backed out of');
225
+ r.current = meTwice();
226
+ assert.throws(() => r.seek(step(null), 't', 'replay'), /ambiguous selector/, 'no target: no guessing');
227
+ r.current = meTwice();
228
+ assert.throws(() => r.seek(step('r:Nowhere'), 't', 'replay'), /ambiguous selector/, 'no match opens the target');
229
+ });
230
+
199
231
  test('several lists: rows are probed, most rows first, until one opens the step target', () => {
200
232
  const r = runner(homeWithLists());
201
233
  const acts = [];
@@ -0,0 +1,40 @@
1
+ // A full-screen DialogFragment renders in window "main" with no framework modal marker
2
+ // (alertTitle / parentPanel). Its own layout ids are then the evidence that it is open.
3
+ // Measured (universalapp TV 2026-11-25): 47 captures of the agreement dialog resolved to the
4
+ // host activity by exact-activity, so the dialog and its three child pages stayed source-only.
5
+ import { test } from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import { resolvePage, dialogShown } from '../utg_explorer/semantics.mjs';
8
+ import { get } from '../utg_explorer/_py.mjs';
9
+
10
+ const P = { app_package: 'x' };
11
+ const page = (kind, ids, component = null) => ({ kind, titles: [], hint_titles: [], row_titles: [], widget_ids: ids, component });
12
+ const AGREE = ['root_layout', 'agreement_summary_tv', 'user_protocol_tv', 'privacy_protocol_tv', 'reject_layout', 'agree_layout'];
13
+
14
+ function catalog() {
15
+ return {
16
+ 'activity:Splash': page('activity', [], 'x.Splash'),
17
+ 'fragment:AgreementDialog': page('dialog', [...AGREE, 'iv_control_back']),
18
+ 'fragment:Other': page('fragment', ['iv_control_back', 'other_list']),
19
+ };
20
+ }
21
+
22
+ test('a dialog whose own layout is on screen resolves without a modal marker', () => {
23
+ const nodes = ['content', ...AGREE, 'iv_control_back'].map((r) => ({ resource_id: `x:id/${r}` }));
24
+ const r = resolvePage({ package: 'x', activity: 'x.Splash', window: 'main', nodes }, catalog(), null, P);
25
+ assert.deepEqual([get(r, 'status'), get(r, 'static_id'), get(r, 'reason')], ['verified', 'fragment:AgreementDialog', 'own-layout-ids']);
26
+ });
27
+
28
+ test('a few of a dialog\'s ids on a plain page do not open it', () => {
29
+ const nodes = ['root_layout', 'agree_layout', 'iv_control_back', 'other_list'].map((r) => ({ resource_id: `x:id/${r}` }));
30
+ const r = resolvePage({ package: 'x', activity: 'x.Splash', window: 'main', nodes }, catalog(), null, P);
31
+ assert.notEqual(get(r, 'static_id'), 'fragment:AgreementDialog');
32
+ });
33
+
34
+ test('dialogShown needs both a minimum count and coverage of the unique ids', () => {
35
+ const counts = new Map([['a', 1], ['b', 1], ['c', 1], ['d', 1], ['e', 1], ['shared', 4]]);
36
+ const ids = ['a', 'b', 'c', 'd', 'e', 'shared'];
37
+ assert.equal(dialogShown(ids, new Set(['a', 'b', 'c', 'd']), counts), true);
38
+ assert.equal(dialogShown(ids, new Set(['a', 'b', 'c', 'shared']), counts), false); // 3/5 < 0.8
39
+ assert.equal(dialogShown(['a', 'b'], new Set(['a', 'b']), counts), false); // below the minimum
40
+ });
@@ -855,6 +855,7 @@ function _resolveBySource(observation, nodes, catalog) {
855
855
  weakBody = candidates[0].weak; candidates = [];
856
856
  }
857
857
  }
858
+ if (candidates.length) { candidates = _surfaceOverHost(candidates, nodes, catalog, observation, tabBar); }
858
859
  if (!candidates.length) {
859
860
  for (const [ident, page] of Object.entries(catalog)) {
860
861
  const hasList = nodes.some((n) => g(n, 'resource_id') === 'android:id/list');
@@ -882,6 +883,43 @@ function _resolveBySource(observation, nodes, catalog) {
882
883
 
883
884
  export const _SCREEN_KINDS = ['fragment', 'activity', 'screen', 'compose-route', 'panel', 'view-page'];
884
885
 
886
+ /**
887
+ * keepTreeUnreliable(observation, prev, next) -> the resolution a re-judge (rejudge / recover) keeps:
888
+ * a capture whose tree the adapter marked `tree_unreliable` stays `tree-unreliable` (with the
889
+ * candidate target the runner gave it, `prev.candidate_for`) unless the new catalog verifies it.
890
+ */
891
+ export function keepTreeUnreliable(observation, prev, next) {
892
+ if (!truthy(g(observation, 'tree_unreliable')) || ['verified', 'foreign-package'].includes(g(next, 'status'))) { return next; }
893
+ const want = g(prev || {}, 'candidate_for');
894
+ return { status: 'tree-unreliable', reason: observation.tree_unreliable, candidates: [], ...(truthy(want) ? { candidate_for: want } : {}) };
895
+ }
896
+
897
+ /** Catalog kinds a host route swaps in by a state flag (a2h-utg-static `in-route-surface`, id `surface:<Composable>`). */
898
+ export const SURFACE_KINDS = ['in-route-surface'];
899
+
900
+ /**
901
+ * _surfaceOverHost(candidates, nodes, catalog, observation, tabBar) -> candidates. An in-route surface
902
+ * renders inside its host's window, under the host's own bar and tabs, so the host's anchors (its
903
+ * toolbar title, its tab, its body texts) stay on screen with it and the tiers above name the host.
904
+ * When a surface of a candidate host (`opened_from` / `host_node`) has its own body anchors on screen
905
+ * (the same test as any page's body text), the surface is what the screen shows, as an overlay
906
+ * is identified over its host by its own texts. No surface anchor on screen: the candidates stand.
907
+ */
908
+ export function _surfaceOverHost(candidates, nodes, catalog, observation, tabBar = null) {
909
+ const hosts = new Set(candidates.map((c) => g(c, 'static_id')).filter((x) => truthy(x)));
910
+ if (!hosts.size) { return candidates; }
911
+ const surfaces = {};
912
+ for (const [ident, page] of Object.entries(catalog)) {
913
+ if (!SURFACE_KINDS.includes(g(page, 'kind'))) { continue; }
914
+ const on = [...(g(page, 'opened_from', []) || []), g(page, 'host_node')].filter((x) => truthy(x));
915
+ if (on.some((h) => hosts.has(h)) || hosts.has(ident)) { dset(surfaces, ident, page); }
916
+ }
917
+ if (!Object.keys(surfaces).length) { return candidates; }
918
+ const own = _bodyTextCandidates(nodes, surfaces, observation, tabBar);
919
+ if (!own.length || own[0].weak) { return candidates; }
920
+ return own.map((c) => ({ ...c, reason: 'in-route-surface-body-text' }));
921
+ }
922
+
885
923
  /** _share_row_container(nodes, texts): >=2 of `texts` are rows of ONE list. */
886
924
  export function _shareRowContainer(nodes, texts) {
887
925
  const rowList = (n) => {
@@ -1208,6 +1246,22 @@ export function _tabTitleCandidates(nodes, catalog, observation) {
1208
1246
 
1209
1247
  const setKey = (xs) => JSON.stringify(sortedStr(new Set(xs)));
1210
1248
 
1249
+ /** Unique own ids a dialog must show, and the share of its unique ids that must be visible. */
1250
+ export const DIALOG_OWN_MIN = 3;
1251
+ export const DIALOG_OWN_COVER = 0.8;
1252
+
1253
+ /**
1254
+ * dialogShown(shown, visible, counts): a dialog/sheet layout is open on screen without any
1255
+ * framework modal marker. At least DIALOG_OWN_MIN of the ids only this layout declares are
1256
+ * visible, and they are at least DIALOG_OWN_COVER of those ids. A few shared or stray ids
1257
+ * (two rows reused inline on a page) never qualify.
1258
+ */
1259
+ export function dialogShown(shown, visible, counts) {
1260
+ const unique = [...new Set(shown)].filter((r) => counts.get(r) === 1);
1261
+ const seen = unique.filter((r) => visible.has(r));
1262
+ return seen.length >= DIALOG_OWN_MIN && seen.length >= DIALOG_OWN_COVER * unique.length;
1263
+ }
1264
+
1211
1265
  /** _own_widget_candidates(nodes, catalog, observation): identify a page by ids only its layout declares. */
1212
1266
  export function _ownWidgetCandidates(nodes, catalog, observation) {
1213
1267
  const overlay = new Set();
@@ -1244,9 +1298,16 @@ export function _ownWidgetCandidates(nodes, catalog, observation) {
1244
1298
  for (const { ids } of groups.values()) { for (const r of ids) { counts.set(r, (counts.get(r) ?? 0) + 1); } }
1245
1299
  const modalOpen = g(observation, 'window') === 'dialog' || nodes.some((n) =>
1246
1300
  ['alertTitle', 'parentPanel', 'design_bottom_sheet'].includes(tail(S(g(n, 'resource_id', '')))));
1301
+ // A dialog/sheet is admitted when the framework marks a modal, or when its own layout is itself
1302
+ // the evidence that it is open (dialogShown). Measured (universalapp TV 2026-11-25): a full-screen
1303
+ // DialogFragment renders in window "main" with no alertTitle; all 9 ids only its layout declares
1304
+ // were on screen, yet the capture fell through to exact-activity on the host.
1305
+ const shownIds = (page) => { const hidden = g(page, 'hidden_ids', []); return g(page, 'widget_ids', []).filter((r) => !hidden.includes(r)); };
1306
+ const admitted = (page) => !['dialog', 'sheet'].includes(g(page, 'kind')) || modalOpen
1307
+ || dialogShown(shownIds(page), visible, counts);
1247
1308
  let scored = [];
1248
1309
  for (const [ident, page] of Object.entries(catalog)) {
1249
- if (['dialog', 'sheet'].includes(g(page, 'kind')) && !modalOpen) { continue; }
1310
+ if (!admitted(page)) { continue; }
1250
1311
  const unique = sortedStr(g(page, 'widget_ids', []).filter((r) => counts.get(r) === 1 && visible.has(r)));
1251
1312
  const hiddenIds = g(page, 'hidden_ids', []);
1252
1313
  const shown = g(page, 'widget_ids', []).filter((r) => !hiddenIds.includes(r));
@@ -1256,7 +1317,7 @@ export function _ownWidgetCandidates(nodes, catalog, observation) {
1256
1317
  if (!scored.length) {
1257
1318
  const own = [];
1258
1319
  for (const [ident, page] of Object.entries(catalog)) {
1259
- if (['dialog', 'sheet'].includes(g(page, 'kind')) && !modalOpen) { continue; }
1320
+ if (!admitted(page)) { continue; }
1260
1321
  if (!_hostCompatible(page, catalog, observation)) { continue; }
1261
1322
  const ids = new Set(g(page, 'widget_ids', []));
1262
1323
  const informative = new Set([...ids].filter((r) => visible.has(r) && (counts.get(r) ?? 0) <= 5));
@@ -42,7 +42,7 @@ import { coverageMode, coveredStaticIds, scopeOf } from './coverage.mjs';
42
42
  import { COLLAPSE_MIN_CASCADE, collapsedPrefixes, collapseNote, emptyStateComponents, emptyStateShown } from './diagnostics.mjs';
43
43
  import { loadStringTables, deviceTextsIn } from './strings.mjs';
44
44
  import { triggerAttests } from './attest.mjs';
45
- import { fallbackScope } from './state_phase.mjs';
45
+ import { orderHosts, isHostFailure, alternativeHost, baseTaskId, HOST_RETRY_TAG } from './hosts.mjs';
46
46
 
47
47
  /** Indirection for functions tests replace (Python patches module globals). */
48
48
  export const deps = { observationMatchesStatic, resolvePage, triggerAttests };
@@ -398,8 +398,18 @@ export function derivedOverflowOpeners(tasks, limit = 4, depth = 1) {
398
398
  return sortedBy([...groups.keys()], (k) => [-count.get(k), k]).slice(0, Math.max(0, limit)).map((k) => groups.get(k));
399
399
  }
400
400
 
401
+ /**
402
+ * The static_resolution of a capture whose tree is unreliable (adapters observe `tree_unreliable`):
403
+ * status `tree-unreliable`, and `candidate_for` the expected target of the task whose action led to
404
+ * it (not confirmed: nothing in the tree proves it). final_utg / promote_dynamic make no page of it.
405
+ */
406
+ export function treeUnreliableResolution(observation, expected = null) {
407
+ return { status: 'tree-unreliable', reason: get(observation, 'tree_unreliable'), candidates: [],
408
+ ...(truthy(expected) ? { candidate_for: expected } : {}) };
409
+ }
410
+
401
411
  /** Static kinds that open over their page (what a container opener is expected to show). */
402
- export const OVERLAY_KINDS = new Set(['menu', 'dialog', 'panel', 'overlay', 'ui-state', 'mode']);
412
+ export const OVERLAY_KINDS = new Set(['menu', 'dialog', 'panel', 'overlay', 'ui-state', 'mode', 'in-route-surface', 'surface']);
403
413
 
404
414
  /**
405
415
  * The click left its page: another activity, or another verified static page that is not an
@@ -555,6 +565,47 @@ export class Runner {
555
565
  return this._scope !== null && !this._scope.has(staticId);
556
566
  }
557
567
 
568
+ /**
569
+ * The host fields of a task_result (hosts.mjs): a task that has alternative hosts, or is a host
570
+ * retry, names its source host and what it retried, so the gap report can list every host tried.
571
+ */
572
+ _hostFields(payload) {
573
+ const q = this._hostQueue;
574
+ const task = q ? q.tasks[q.cursor] : null;
575
+ if (!task || get(payload, 'task_id') !== task.task_id) { return payload; }
576
+ if (!truthy(get(task, 'host_alternatives')) && !truthy(get(task, 'host_retry_of'))) { return payload; }
577
+ return { ...payload, source_static: task.source_static,
578
+ ...(truthy(get(task, 'host_retry_of')) ? { host_retry_of: task.host_retry_of } : {}) };
579
+ }
580
+
581
+ /**
582
+ * After a task_result: when the task failed because of its host (isHostFailure: the source page
583
+ * was not reached, or only attested) and its target is still uncovered, run the same target
584
+ * through the next alternative host right away, as a copy of that host's task in this phase
585
+ * (`<task>@host-retry:<phase>`). Only a host whose task this phase does not run anyway, that has
586
+ * not started yet, and whose requirements this phase holds (alternativeHost). Every host tried
587
+ * is recorded once per target, so the retries end when the alternatives do.
588
+ */
589
+ _hostRetry(payload) {
590
+ const q = this._hostQueue;
591
+ const task = q ? q.tasks[q.cursor] : null;
592
+ if (!task || get(payload, 'task_id') !== task.task_id || get(payload, 'retrying')) { return; }
593
+ const target = task.target_static;
594
+ if (!q.tried.has(target)) { q.tried.set(target, new Set()); }
595
+ q.tried.get(target).add(task.source_static);
596
+ if (!isHostFailure(payload, { hostVerified: this._hostVerified }) || this.covered.has(target)) { return; }
597
+ const base = q.byId.get(baseTaskId(task.task_id)) ?? task;
598
+ const startedAs = (id) => (q.starts.get(id) ?? 0) > 0 || (q.starts.get(id + HOST_RETRY_TAG + this.phase.id) ?? 0) > 0;
599
+ const alt = alternativeHost(base, q.byId, { tried: q.tried.get(target), requires: or(this.phase.requires, []),
600
+ inPhase: q.phaseIds, started: startedAs });
601
+ if (!alt) { return; }
602
+ const retry = { ...JSON.parse(JSON.stringify(alt)), task_id: alt.task_id + HOST_RETRY_TAG + this.phase.id,
603
+ phase: this.phase.id, environment_id: this.env, requires: or(this.phase.requires, []), host_retry_of: task.task_id };
604
+ q.tasks.splice(q.cursor + 1, 0, retry);
605
+ this.emit('host_retry', { task_id: task.task_id, target_static: target, failed_host: task.source_static,
606
+ next_host: alt.source_static, retry_task_id: retry.task_id, reason: or(get(payload, 'reason'), get(payload, 'outcome')) });
607
+ }
608
+
558
609
  save() {
559
610
  atomicWriteJson(pJoin(this.root, 'campaign.json'), this.doc);
560
611
  this._saved_at = monotonic();
@@ -595,9 +646,11 @@ export class Runner {
595
646
  }
596
647
 
597
648
  emit(kind, payload, evidence = []) {
649
+ if (kind === 'task_result') { payload = this._hostFields(payload); }
598
650
  const e = event(kind, this.env, payload, evidence);
599
651
  this.doc.events.push(e);
600
652
  appendText(pJoin(this.root, 'events.jsonl'), jsonDumps(e, { ensure_ascii: false }) + '\n');
653
+ if (kind === 'task_result') { this._hostRetry(payload); }
601
654
  const interval = toFloat(get(this.config, 'save_interval', 15));
602
655
  if (['task_result', 'environment_verified', 'discovery_result', 'environment_restored'].includes(kind)
603
656
  || monotonic() - (this._saved_at ?? 0) >= interval) { this.save(); }
@@ -689,9 +742,15 @@ export class Runner {
689
742
  this.emit('ime_switcher_dismissed', { observation_id: get(observation, 'observation_id'),
690
743
  outcome: observation.ime_switcher_dismissed, action: { type: 'back', automatic: true } });
691
744
  }
692
- const resolution = resolveTwinByOpener(
745
+ let resolution = resolveTwinByOpener(
693
746
  deps.resolvePage(observation, this.catalog, get(observation, 'identity'), { app_package: get(this.config, 'package') }),
694
747
  this.current, this.catalog);
748
+ // The dump showed nothing usable of a screen that is not blank (adapters observe): no page can be
749
+ // read from it. Unless something still identified it, it is `tree-unreliable`, a candidate for the
750
+ // running task's expected target (after that task's action), never `unmapped` (a new dynamic page).
751
+ if (get(observation, 'tree_unreliable') && !['verified', 'foreign-package'].includes(get(resolution, 'status'))) {
752
+ resolution = treeUnreliableResolution(observation, this.stage === 'target' ? this._expectTarget : null);
753
+ }
695
754
  observation.static_resolution = resolution;
696
755
  const states = resolution.status === 'verified' ? uiStatesOf(observation, this.catalog) : [];
697
756
  if (states.length) { resolution.ui_states = states; }
@@ -711,6 +770,10 @@ export class Runner {
711
770
  }
712
771
  this.current = observation;
713
772
  this.emit('observation', observation, Object.values(observation.artifacts));
773
+ if (truthy(get(resolution, 'candidate_for'))) {
774
+ this.emit('candidate_capture', { static_id: resolution.candidate_for, observation_id: observation.observation_id,
775
+ task_id: this._expectTask, basis: 'tree-unreliable', confirmed: false });
776
+ }
714
777
  if (observation.loading && !acceptLoading) { return observation; }
715
778
  this.mapCapture(observation);
716
779
  return observation;
@@ -925,6 +988,50 @@ export class Runner {
925
988
  throw new AdapterError(`list-item: none of ${lists.length} lists opened ${target}`);
926
989
  }
927
990
 
991
+ /**
992
+ * A step names the page it opens (`target_id`) but its label is on screen more than once (coolmall:
993
+ * "View all" under both "My orders" and "My footprints"). Tap each match top-down until one lands on that
994
+ * page, going Back after one that opened another; the landing page is checked by its own identity, so
995
+ * a wrong match is never taken for the right one. Without this a single such step failed every task
996
+ * behind it (a collapsed phase: 28 tasks never ran). Never for a control that writes data.
997
+ */
998
+ probeAmbiguous(action, taskId, purpose) {
999
+ const fail = () => new AdapterError('ambiguous selector; no coordinate guessing');
1000
+ const target = action.target_id;
1001
+ const origin = get(get(this.current, 'static_resolution', {}), 'status') === 'verified' ? this.current.static_resolution.static_id : null;
1002
+ const sels = Object.hasOwn(CANDIDATE_KINDS, get(action, 'type')) ? get(action, 'selectors', []) : [get(action, 'selector', {})];
1003
+ const find = () => {
1004
+ const hidden = occludedIndices(this.current.nodes);
1005
+ for (const s of sels) {
1006
+ const hits = matching(this.current.nodes, s).filter((n, i) => {
1007
+ const b = get(n, 'bounds', []);
1008
+ return b.length === 4 && b[2] > b[0] && b[3] > b[1] && !hidden.has(i);
1009
+ });
1010
+ if (hits.length > 1) { return hits.sort((a, b) => a.bounds[1] - b.bounds[1] || a.bounds[0] - b.bounds[0]); }
1011
+ }
1012
+ return [];
1013
+ };
1014
+ const first = find();
1015
+ const writes = first.some((h) => [get(h, 'text'), get(h, 'content_desc')].some(writesData));
1016
+ if (origin === null || !first.length || (writes && get(this.config, 'allow_data_writes') !== true)) { throw fail(); }
1017
+ for (let k = 0; k < Math.min(first.length, Math.max(2, toInt(get(this.config, 'max_list_probes', 3)))); k++) {
1018
+ if (k > 0) {
1019
+ if (!this.at(origin)) { this.atom({ type: 'back' }, taskId, 'ambiguous-probe-back'); }
1020
+ if (!this.at(origin)) { throw fail(); }
1021
+ }
1022
+ const hit = find()[k];
1023
+ if (!hit) { break; }
1024
+ const b = hit.bounds;
1025
+ const done = this.atom({ type: 'click_point', x: Math.floor((b[0] + b[2]) / 2), y: Math.floor((b[1] + b[3]) / 2),
1026
+ row: { class: get(hit, 'class'), bounds: b } }, taskId, purpose);
1027
+ if (this.at(target)) {
1028
+ if (typeof this.emit === 'function') { this.emit('ambiguous_probe', { task_id: taskId, target, chosen: k, matches: first.length }); }
1029
+ return done;
1030
+ }
1031
+ }
1032
+ throw fail();
1033
+ }
1034
+
928
1035
  /**
929
1036
  * [listIndex, firstActionableRow] of every visible list holding rows, most rows first, then top-down.
930
1037
  * Nested scrollables that offer the same first row are one list (a page container around its grid).
@@ -1632,7 +1739,12 @@ export class Runner {
1632
1739
  return this.atom({ type: 'click_point', x: Math.floor((b[0] + b[2]) / 2), y: Math.floor((b[1] + b[3]) / 2), row: { class: get(n, 'class'), bounds: b } }, taskId, purpose);
1633
1740
  }
1634
1741
  if (!Object.hasOwn(CANDIDATE_KINDS, type)) { return this.atom(action, taskId, purpose); }
1635
- let selected = this.choose(action);
1742
+ let selected;
1743
+ try { selected = this.choose(action); } catch (e) {
1744
+ // the label is on screen twice and the step names its landing page: probe, never guess coordinates
1745
+ if (!(e instanceof AdapterError) || !/^ambiguous selector/.test(errStr(e)) || !truthy(get(action, 'target_id'))) { throw e; }
1746
+ return this.probeAmbiguous(action, taskId, purpose);
1747
+ }
1636
1748
  if (selected) { return this.atom(selected, taskId, purpose); }
1637
1749
  if (this.clearInterruption(taskId)) {
1638
1750
  selected = this.choose(action);
@@ -2240,12 +2352,22 @@ export class Runner {
2240
2352
  * launch, so a setting one task changed does not reshape the next one's start page (measured,
2241
2353
  * Simple Calendar: a task chose the week view, the app stored it, and every later launch opened
2242
2354
  * on a week view with no FAB). `am start -S` only kills the process. Applies only to a phase with
2243
- * no fixtures: a fixture-built state would be wiped with nothing to rebuild it.
2355
+ * no fixtures: a fixture-built state would be wiped with nothing to rebuild it. Off while
2356
+ * config.user_state_protected is set (d_prereqs initial: the handed-over data could not be
2357
+ * archived): the clear would be refused and fail every task; one `reset_skipped` event says so.
2244
2358
  */
2245
2359
  resetsBetweenTasks() {
2246
2360
  const want = get(this.config, 'reset_between_tasks', false);
2247
2361
  const on = Array.isArray(want) ? want.includes(get(this.phase, 'id')) : truthy(want);
2248
- return on && !get(get(this.config, 'fixtures', {}), get(this.phase, 'id'), []).length;
2362
+ if (!on || get(get(this.config, 'fixtures', {}), get(this.phase, 'id'), []).length) { return false; }
2363
+ if (get(this.config, 'user_state_protected') === true) {
2364
+ if (!this._resetSkipNoted) {
2365
+ this._resetSkipNoted = true;
2366
+ this.emit('reset_skipped', { phase: get(this.phase, 'id'), reason: 'user_state_protected: clear_app_data would lose the handed-over data' });
2367
+ }
2368
+ return false;
2369
+ }
2370
+ return true;
2249
2371
  }
2250
2372
 
2251
2373
  /**
@@ -2355,14 +2477,13 @@ export class Runner {
2355
2477
  run() {
2356
2478
  this._launched = false;
2357
2479
  this.awaitContent(this.capture());
2358
- const tasks = get(this.doc, 'tasks', []).filter((t) => t.phase === this.phase.id);
2480
+ // One target opened from several hosts: the cheapest host (verified, fewest data preconditions) first.
2481
+ const tasks = orderHosts(get(this.doc, 'tasks', []).filter((t) => t.phase === this.phase.id), this.covered, { variants: true });
2359
2482
  const probesFor = get(get(this.config, 'phase_probes', {}), this.phase.id);
2483
+ // A state phase never runs on a guess: schedule_states.mjs runs it as a variant in a known
2484
+ // state its requirements hold in (with that state's probe), and D builds the others.
2360
2485
  if (truthy(this.phase.requires) && !truthy(probesFor)) {
2361
- const fallback = fallbackScope(this.config, this.phase, probesFor, this.doc);
2362
- if (fallback === null) {
2363
- return this._block('unresolved prerequisites: ' + this.phase.requires.join(', '));
2364
- }
2365
- this.emit('state_probe_missing', { phase: this.phase.id, requires: this.phase.requires, fallback });
2486
+ return this._block('unresolved prerequisites: ' + this.phase.requires.join(', '));
2366
2487
  }
2367
2488
  // A phase that writes to the backend (a seeding recipe) runs only while the switch is still on:
2368
2489
  // turning `allow_data_writes` off after scheduling stops it on the next run. `writes_data` decides;
@@ -2385,8 +2506,7 @@ export class Runner {
2385
2506
  return this._block('state-probe-failed');
2386
2507
  }
2387
2508
  this.emit('environment_verified', { phase: this.phase.id, observation_id: this.current.observation_id,
2388
- scope: truthy(probes) ? 'configured probes'
2389
- : (truthy(this.phase.requires) ? fallbackScope(this.config, this.phase, probes, this.doc) : 'existing state, no guard assumed') });
2509
+ scope: truthy(probes) ? 'configured probes' : 'existing state, no guard assumed' });
2390
2510
  this.phase.status = 'running'; this.save();
2391
2511
  let routeFailures = 0;
2392
2512
  for (const route of get(get(this.config, 'routes', {}), this.phase.id, [])) {
@@ -2413,8 +2533,14 @@ export class Runner {
2413
2533
  let scheduled = 0;
2414
2534
  const transient = new Map();
2415
2535
  const skipped = new Set();
2536
+ // _hostRetry inserts the next host's task right after the one whose host failed (hosts.mjs).
2537
+ this._hostQueue = { tasks, cursor: -1, starts, tried: new Map(),
2538
+ byId: new Map(get(this.doc, 'tasks', []).map((t) => [t.task_id, t])),
2539
+ phaseIds: new Set(tasks.flatMap((t) => [t.task_id, baseTaskId(t.task_id)])) };
2416
2540
  try {
2417
2541
  for (const task of tasks) {
2542
+ this._hostQueue.cursor += 1;
2543
+ this._hostVerified = null;
2418
2544
  const ident = task.task_id;
2419
2545
  if (done.has(ident) || (starts.get(ident) ?? 0) >= toInt(get(this.config, 'max_task_attempts', 1))) { continue; }
2420
2546
  if (this.coverage === 'nodes' && this.covered.has(get(task, 'target_static'))) {
@@ -2447,6 +2573,7 @@ export class Runner {
2447
2573
  scheduled += 1; starts.set(ident, (starts.get(ident) ?? 0) + 1);
2448
2574
  this.emit('task_started', { task_id: ident, target_static: task.target_static });
2449
2575
  this.keep = [task.source_static, task.target_static, get(task, 'source_context')].filter((x) => truthy(x));
2576
+ this._expectTarget = task.target_static; this._expectTask = ident;
2450
2577
  this._launched = false; // only a launch of this task's own opens the consent window
2451
2578
  this._clearedFor = null; // every attempt of a task starts from cleared data (resetBetweenTasks)
2452
2579
  if (get(task, 'purpose') === 'direct-launch') { this.runDirect(task, done); continue; }
@@ -2587,6 +2714,8 @@ export class Runner {
2587
2714
  _runTask(task, ident, done) {
2588
2715
  this.stage = 'source';
2589
2716
  this.source(task);
2717
+ // An attested-only host (anchorless, not verified): a failure past it is the host's (hosts.mjs).
2718
+ this._hostVerified = this.at(task.source_static);
2590
2719
  if (this.sweep(task.source_static) && (this.dirty ?? false)) { this.source(task); }
2591
2720
  this.stage = 'target';
2592
2721
  let result; let mark;
@@ -87,9 +87,9 @@ unless a qualified static caller proves the owning page.
87
87
  | XML + routes | Manifest activities, Compose route↔screen join | scripts (manifest.mjs, compose_*.mjs) |
88
88
  | Semantics | implicit-intent & string-route resolution | you (the agent) |
89
89
 
90
- **Node** = a page. Fields: `id`, `kind` (activity/fragment/compose-route/dialog/sheet/menu/…), `label`, `declared_at` (file:line), `status`, `provenance`. Dynamic fields stay empty here; `a2h-utg-explorer` writes captures into its own `utg.final.json` (`screenshot`, `component_tree`, `evidence`), never back into this `utg.json`.
90
+ **Node** = a page. Fields: `id`, `kind` (activity/fragment/compose-route/dialog/sheet/menu/in-route-surface/…), `label`, `declared_at` (file:line), `status`, `provenance`. Dynamic fields stay empty here; `a2h-utg-explorer` writes captures into its own `utg.final.json` (`screenshot`, `component_tree`, `evidence`), never back into this `utg.json`.
91
91
 
92
- **Edge** = a navigation. Fields: `source`, `target`, `mechanism` (startActivity-explicit/implicit, fragment-transaction, compose-navigate, voyager-push, open-overlay, …), `trigger` (onClick@file:line — **never** `ref@`, see Rules), `guard` (condition or null), `args`, `provenance`, `confidence`.
92
+ **Edge** = a navigation. Fields: `source`, `target`, `mechanism` (startActivity-explicit/implicit, fragment-transaction, compose-navigate, voyager-push, open-overlay, surface-switch, …), `trigger` (onClick@file:line — **never** `ref@`, see Rules), `guard` (condition or null), `args`, `provenance`, `confidence`.
93
93
 
94
94
  **Status lifecycle**: this stage writes `static-only` (or `unreachable` for proven-dead code). The explorer does not rewrite `status`; its `utg.final.json` records runtime coverage per node as `evidence.coverage` (`static-only` → `observed`), and screens no static node claims as `dynamic-only` nodes.
95
95
 
@@ -244,7 +244,7 @@ node scripts/click_paths.mjs <ws>
244
244
  ```
245
245
  Emits `click_paths.json` = shortest paths from root, with `labels` (on-screen tap text from `args.label`), `steps[].action` (tap/swipe-*/default/double_tap/long_press), `steps[].label_source` (screen-text vs code-name), `steps[].non_gesture` (startDestination/render-branch — not a touch transition).
246
246
 
247
- **Path cost avoids hops the explorer refuses or cannot place.** A hop whose label writes data (`writesData`, the same rule as the explorer: 「领取」「加入购物车」「删除」, a `vm_fn` like `receiveCoupon`) costs +6, a label two controls on the source page share (`label_ambiguous`) +4, and a branch taken only while logged out (`polarity: logged-out`) +4, so a longer path of plain taps wins and a page reachable only through such a hop keeps it. A gesture a login interceptor guards (`redirect_when_unmet`) also gets its **logged-out arm**: the same tap, landing on the redirect page, labelled like the tap (`steps[].redirect_of` names the page it opens when logged in, so it shares that step's nl_hint). An arm costs one more than an ordinary hop (an edge the code shows into the page wins a tie), and three more from a page that is not a tab or the root. Measured (coolmall): Login went 「我的」 → 「点击登录账号」 instead of the home coupon's 「领取」 → 「立即领取」.
247
+ **Path cost avoids hops the explorer refuses or cannot place.** A hop whose label writes data (`writesData`, the same rule as the explorer: 「领取」「加入购物车」「删除」, a `vm_fn` like `receiveCoupon`) costs +6, a label two controls on the source page share (`label_ambiguous`) +4, and a branch taken only while logged out (`polarity: logged-out`) +4, so a longer path of plain taps wins and a page reachable only through such a hop keeps it. A gesture a login interceptor guards (`redirect_when_unmet`) also gets its **logged-out arm**: the same tap, landing on the redirect page, labelled like the tap (`steps[].redirect_of` names the page it opens when logged in, so it shares that step's nl_hint). An arm costs one more than an ordinary hop (an edge the code shows into the page wins a tie), and three more from a page that is not a tab or the root. Measured in practice: the winning route to Login used plain taps — a profile tab, then its login button — instead of a shorter home-page hop that writes data and whose label two controls share.
248
248
 
249
249
  **Order matters**: run `click_paths.mjs` BEFORE `nl_hints.mjs apply`, or hints are discarded (it REGENERATES `click_paths.json` from `utg.json`, which has no record of them).
250
250