@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
@@ -0,0 +1,286 @@
1
+ /**
2
+ * states.mjs — the campaign's inventory of device data states, and the evaluation of phase
3
+ * requirements against it.
4
+ *
5
+ * A phase's `requires` is a static claim ("needs login", "needs a non-empty device list"). Whether
6
+ * the device is in such a state is decided here from evidence, never from whether a fixture was
7
+ * configured:
8
+ *
9
+ * - `states.json` (campaign root) lists every known data state: how to enter it (an app-data
10
+ * archive, or only the live device), whether it can be restored, and its landing observation
11
+ * (the screen a cold launch shows on that data). d_prereqs.mjs records `initial` (the data the
12
+ * device was handed over with, taken before any campaign action) and `fresh` (first-launch
13
+ * data); a recipe's own snapshot is derived from its events.
14
+ * - deriveStates() walks events.jsonl and attributes every verified page capture to the data
15
+ * state the device held at that moment (a clear / restore / snapshot action or an out-of-runner
16
+ * change recorded in `timeline` moves it).
17
+ * - A requirement holds in a state when (a) a page whose phase requires it was verified there
18
+ * (guarded-page evidence: the static plan says the page needs it, and the page rendered), or
19
+ * (b) a compiled predicate (`predicates.json`, predicates.mjs) matches one of its captures.
20
+ *
21
+ * Invariant: user data is never destroyed unrecoverably. When `initial` could not be archived
22
+ * (no run-as), d_prereqs sets `config.user_state_protected`, and DeviceAdapter refuses every
23
+ * `clear_app_data` / `restore_app_data` (adapters.mjs assertDataChangeAllowed).
24
+ *
25
+ * Exports: STATES_FILE, PREDICATES_FILE, loadStates, saveStates, recordState, noteLive,
26
+ * landingSummary, landingRule, deriveStates, guardedPages, requirementHolds,
27
+ * satisfyingStates, enterFixtures
28
+ */
29
+ import { get, jsonLoads, pJoin, pathStr, pIsFile, readText, truthy, pyStr } from './_py.mjs';
30
+ import { atomicWriteJson, ruleMatches } from './adapters.mjs';
31
+ import { guards } from '../plan.mjs';
32
+ import { resolvePage } from './semantics.mjs';
33
+
34
+ export const STATES_FILE = 'states.json';
35
+ export const PREDICATES_FILE = 'predicates.json';
36
+ const SCHEMA = 'utg-states/1';
37
+ /** Texts a landing keeps (recover_d checks a recipe's probe against them; its worklist shows fewer). */
38
+ const LANDING_TEXTS = 200;
39
+ /** Landing ids kept as the state probe: few enough to survive data changes, enough to be unique. */
40
+ const PROBE_IDS = 3;
41
+
42
+ const isDict = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
43
+ const tailId = (r) => pyStr(r).split('/').pop();
44
+
45
+ export function loadStates(root) {
46
+ const p = pJoin(root, STATES_FILE);
47
+ if (!pIsFile(p)) { return { schema: SCHEMA, states: [], timeline: [] }; }
48
+ const d = jsonLoads(readText(p, { encoding: 'utf-8' }));
49
+ return { schema: SCHEMA, states: Array.isArray(get(d, 'states')) ? d.states : [], timeline: Array.isArray(get(d, 'timeline')) ? d.timeline : [] };
50
+ }
51
+
52
+ export function saveStates(root, doc) { atomicWriteJson(pJoin(root, STATES_FILE), doc); }
53
+
54
+ /** Upsert a state by id (a later record of the same id replaces its fields, keeps the rest). */
55
+ export function recordState(root, entry, ts = Date.now() / 1000) {
56
+ const doc = loadStates(root);
57
+ const i = doc.states.findIndex((s) => s.id === entry.id);
58
+ const merged = { ...(i >= 0 ? doc.states[i] : {}), ...entry, recorded_at: ts };
59
+ if (i >= 0) { doc.states[i] = merged; } else { doc.states.push(merged); }
60
+ saveStates(root, doc);
61
+ return merged;
62
+ }
63
+
64
+ /** An out-of-runner change of the device's app data (d_prereqs): `live` is the state now held, or null. */
65
+ export function noteLive(root, live, why, ts = Date.now() / 1000) {
66
+ const doc = loadStates(root);
67
+ doc.timeline.push({ ts, live, why });
68
+ saveStates(root, doc);
69
+ }
70
+
71
+ /** What a state's landing showed: enough for a reviewer and for a probe check, small enough to list. */
72
+ export function landingSummary(obs) {
73
+ if (!isDict(obs)) { return null; }
74
+ const nodes = Array.isArray(obs.nodes) ? obs.nodes : [];
75
+ const texts = [...new Set(nodes.map((n) => pyStr(get(n, 'text', '') ?? '').trim()).filter(Boolean))].slice(0, LANDING_TEXTS);
76
+ const ids = [...new Set(nodes.map((n) => get(n, 'resource_id') || get(n, 'resource-id')).filter(Boolean).map(pyStr))];
77
+ const res = get(obs, 'static_resolution') || {};
78
+ return { observation_id: get(obs, 'observation_id'), package: get(obs, 'package'), activity: get(obs, 'activity'),
79
+ static_id: get(res, 'status') === 'verified' ? get(res, 'static_id') : null, texts, ids };
80
+ }
81
+
82
+ /**
83
+ * The probe that a cold launch reached this state's landing again: same package and activity,
84
+ * plus up to PROBE_IDS ids of the landing page's own layout (catalog widget_ids), so a different
85
+ * screen of the same activity (an agreement dialog over the home page) does not pass.
86
+ */
87
+ export function landingRule(landing, catalog = {}) {
88
+ if (!isDict(landing) || !truthy(landing.activity)) { return null; }
89
+ const own = new Set(get(get(catalog, landing.static_id, {}), 'widget_ids', []) || []);
90
+ const ids = (landing.ids || []).filter((r) => own.has(tailId(r))).slice(0, PROBE_IDS);
91
+ const rule = { package: landing.package, activity: landing.activity };
92
+ if (ids.length) { rule.all = ids.map((r) => ({ resource_id: r })); }
93
+ return rule;
94
+ }
95
+
96
+ function readEvents(root) {
97
+ const p = pJoin(root, 'events.jsonl');
98
+ if (!pIsFile(p)) { return []; }
99
+ const out = [];
100
+ for (const line of readText(p, { encoding: 'utf-8' }).split(/\r?\n/)) {
101
+ if (!line.trim()) { continue; }
102
+ try { out.push(JSON.parse(line)); } catch { /* a torn last line */ }
103
+ }
104
+ return out;
105
+ }
106
+
107
+ /** Actions that change the app data (no_effect still counts: the screen need not move). */
108
+ const DATA_ACTIONS = new Set(['clear_app_data', 'restore_app_data', 'snapshot_app_data']);
109
+ /** The ones that delete data first: half done, they leave neither the old state nor the new. */
110
+ const WIPES = new Set(['clear_app_data', 'restore_app_data']);
111
+
112
+ /** Last component of a Windows or POSIX path (archives recorded on one host are read on another). */
113
+ const fileName = (p) => pyStr(p).split(/[/\\]/).pop();
114
+
115
+ /** The state whose archive is `archive` (by file name). */
116
+ const byArchive = (states, archive) => states.find((s) => truthy(s.archive) && fileName(s.archive) === fileName(archive));
117
+
118
+ /**
119
+ * deriveStates(root, appPackage, catalog): the inventory with `pages` (static id -> observation ids) and
120
+ * `live` (the state the device holds now, null when unknown) filled in from the event log.
121
+ * A recipe snapshot seen in the log becomes a state of its own; its landing is the first capture
122
+ * after the relaunch that follows it, resolved against `catalog`.
123
+ */
124
+ export function deriveStates(root, appPackage = null, catalog = null) {
125
+ const doc = loadStates(root);
126
+ const states = doc.states.map((s) => ({ ...s, pages: {} }));
127
+ const initial = states.find((s) => s.id === 'initial');
128
+ const marks = [...doc.timeline].sort((a, b) => a.ts - b.ts);
129
+ const events = readEvents(root);
130
+ // Before the first recorded change the device holds what it was handed over with; a campaign
131
+ // resumed from before the initial stage (origin "resumed") changed it already, so nothing is.
132
+ let live = initial && initial.origin !== 'resumed' ? 'initial' : null;
133
+ let mi = 0;
134
+ let awaitingLanding = null;
135
+ const obsPkg = new Map();
136
+ // A clear / restore that started and never reported (act() threw: adb dropped, tar failed) may have
137
+ // wiped the data already: what the device holds is unknown until the next data change.
138
+ let pendingWipe = null;
139
+ /** The device now holds the data of the snapshot `archive` (a recipe snapshot becomes a state of its own). */
140
+ const enterSnapshot = (archive) => {
141
+ let s = byArchive(states, archive);
142
+ if (!s) {
143
+ s = { id: fileName(archive).replace(/\.tar$/, ''), origin: 'recipe', archive: pathStr(archive), restorable: true, landing: null, pages: {} };
144
+ states.push(s);
145
+ }
146
+ live = s.id;
147
+ if (!s.landing) { awaitingLanding = s; }
148
+ };
149
+ for (const e of events) {
150
+ const ts = Number(get(e, 'ts', 0));
151
+ // an out-of-runner data change (d_prereqs) says what the device holds, a pending wipe included
152
+ while (mi < marks.length && marks[mi].ts <= ts) { live = marks[mi].live; mi += 1; pendingWipe = null; }
153
+ const p = get(e, 'payload', {}) || {};
154
+ if (pendingWipe && (e.kind === 'attempt_started' || e.kind === 'task_result'
155
+ || (e.kind === 'action_result' && get(p, 'attempt_id') !== pendingWipe))) {
156
+ live = null; awaitingLanding = null; pendingWipe = null;
157
+ }
158
+ if (e.kind === 'attempt_started' && WIPES.has(get(get(p, 'action', {}) || {}, 'type'))) { pendingWipe = e.id; }
159
+ if (e.kind === 'observation') { obsPkg.set(p.observation_id, p.package); }
160
+ // a fixture snapshot already on disk is not taken again (task_runner: fixture_snapshot_kept), but the
161
+ // device holds that state's data from here on, as when it was written
162
+ if (e.kind === 'fixture_snapshot_kept' && get(p, 'type') === 'snapshot_app_data' && truthy(p.archive)) { enterSnapshot(p.archive); }
163
+ if (e.kind === 'action_result') {
164
+ if (get(p, 'attempt_id') === pendingWipe) { pendingWipe = null; }
165
+ const oc = get(p, 'outcome');
166
+ const a = get(p, 'action', {}) || {};
167
+ // Data actions (clear/restore/snapshot) change app state even when the screen does not move,
168
+ // so treat both 'succeeded' and 'no_effect' as a completed action for state tracking.
169
+ const done = oc === 'succeeded' || (oc === 'no_effect' && DATA_ACTIONS.has(a.type));
170
+ if (done && a.type === 'clear_app_data') { live = null; awaitingLanding = null; }
171
+ if (done && a.type === 'restore_app_data') { live = byArchive(states, a.archive)?.id ?? null; awaitingLanding = null; }
172
+ if (done && a.type === 'snapshot_app_data' && truthy(a.archive)) { enterSnapshot(a.archive); }
173
+ if (done && a.type === 'launch' && awaitingLanding && truthy(p.after)) {
174
+ const o = readObservation(root, p.after);
175
+ if (o && (!appPackage || o.package === appPackage)) { awaitingLanding.landing = landingSummary(resolved(o, catalog, appPackage)); }
176
+ awaitingLanding = null;
177
+ }
178
+ }
179
+ // a capture while a wipe has not reported belongs to no state yet
180
+ if (e.kind === 'mapping' && live && !pendingWipe && truthy(p.static_id) && truthy(p.observation_id)) {
181
+ if (appPackage && obsPkg.has(p.observation_id) && obsPkg.get(p.observation_id) !== appPackage) { continue; }
182
+ const s = states.find((x) => x.id === live);
183
+ if (s) { (s.pages[p.static_id] ??= []).push(p.observation_id); }
184
+ }
185
+ }
186
+ while (mi < marks.length) { live = marks[mi].live; mi += 1; }
187
+ if (pendingWipe) { live = null; }
188
+ // a state's own landing page counts as verified in it
189
+ for (const s of states) {
190
+ const l = s.landing;
191
+ if (l && truthy(l.static_id) && truthy(l.observation_id)) { (s.pages[l.static_id] ??= []).push(l.observation_id); }
192
+ }
193
+ return { states, live };
194
+ }
195
+
196
+ /** `o` with a static_resolution (observation.json files written before mapping carry none). */
197
+ function resolved(o, catalog, appPackage) {
198
+ if (get(o, 'static_resolution') || !catalog) { return o; }
199
+ try { return { ...o, static_resolution: resolvePage(o, catalog, get(o, 'identity'), { app_package: appPackage }) }; } catch { return o; }
200
+ }
201
+
202
+ const obsCache = new Map();
203
+ function readObservation(root, oid) {
204
+ const key = `${root}|${oid}`;
205
+ if (obsCache.has(key)) { return obsCache.get(key); }
206
+ let o = null;
207
+ const p = pJoin(root, 'artifacts', pyStr(oid), 'observation.json');
208
+ try { if (pIsFile(p)) { o = jsonLoads(readText(p, { encoding: 'utf-8' })); } } catch { o = null; }
209
+ obsCache.set(key, o);
210
+ return o;
211
+ }
212
+
213
+ /**
214
+ * requirement -> pages whose rendering proves it: node obligations of phases requiring it, except
215
+ * pages that carry it as their OWN guard. A requirement on the route to a page is proved by
216
+ * reaching the page (a device page opens only from a device card, so the list was not empty). A
217
+ * page's own guard is not: the device list page renders with an empty list too, and the login
218
+ * page renders exactly when the user is NOT logged in. Those need a compiled predicate.
219
+ */
220
+ export function guardedPages(doc) {
221
+ const own = new Map();
222
+ for (const n of get(doc, 'nodes', []) || []) { own.set(n.id, new Set(guards(n, { include_task_level: true }))); }
223
+ const out = new Map();
224
+ for (const ph of get(doc, 'phases', []) || []) {
225
+ if (pyStr(ph.id).startsWith('rec') || pyStr(ph.id).startsWith('st-')) { continue; }
226
+ for (const r of ph.requires || []) {
227
+ if (!out.has(r)) { out.set(r, new Set()); }
228
+ for (const o of ph.obligations || []) {
229
+ if (o.type === 'node' && !(own.get(o.id)?.has(r))) { out.get(r).add(o.id); }
230
+ }
231
+ }
232
+ }
233
+ return out;
234
+ }
235
+
236
+ /**
237
+ * requirementHolds(r, state, ctx): evidence that requirement `r` holds in `state`, or null.
238
+ * ctx: { guarded: guardedPages(doc), predicates: predicates.json `items`, root }.
239
+ */
240
+ export function requirementHolds(r, state, ctx) {
241
+ const pages = state.pages || {};
242
+ // No screen shows it (a code branch), so no state can prove or disprove it, and no recipe could
243
+ // build it verifiably either: it is assumed, and the task's own target capture is the check.
244
+ if (get(get(ctx.predicates || {}, r), 'status') === 'unevaluable') { return { kind: 'assumed', page: null, observation_id: null }; }
245
+ for (const page of ctx.guarded.get(r) ?? []) {
246
+ if (truthy(pages[page])) { return { kind: 'guarded-page', page, observation_id: pages[page][0] }; }
247
+ }
248
+ const pred = get(ctx.predicates || {}, r);
249
+ if (get(pred, 'status') !== 'compiled') { return null; }
250
+ for (const c of get(pred, 'clauses', []) || []) {
251
+ for (const oid of pages[c.page] ?? []) {
252
+ const o = truthy(c.rule) ? readObservation(ctx.root, oid) : null;
253
+ if (!truthy(c.rule) || (o && ruleMatches(o, c.rule))) { return { kind: 'predicate', page: c.page, observation_id: oid }; }
254
+ }
255
+ }
256
+ return null;
257
+ }
258
+
259
+ /**
260
+ * States in which every requirement of `phase` holds and that the device can enter: restorable,
261
+ * or the live state (entered by a plain launch). Live first: it needs no data change.
262
+ */
263
+ export function satisfyingStates(phase, derived, ctx) {
264
+ const out = [];
265
+ for (const s of derived.states) {
266
+ if (!(s.restorable || s.id === derived.live)) { continue; }
267
+ const evidence = {};
268
+ let ok = true;
269
+ for (const r of phase.requires || []) {
270
+ const ev = requirementHolds(r, s, ctx);
271
+ if (!ev) { ok = false; break; }
272
+ evidence[r] = ev;
273
+ }
274
+ if (ok) { out.push({ state: s, evidence }); }
275
+ }
276
+ return out.sort((a, b) => Number(b.state.id === derived.live) - Number(a.state.id === derived.live));
277
+ }
278
+
279
+ /** Fixtures that put the device into `state`: a launch on live data, else restore + launch. */
280
+ export function enterFixtures(state, derived, config) {
281
+ const launch = { type: 'launch', component: get(config, 'launch_component'), restart: true };
282
+ if (state.id === derived.live && !state.restorable) { return [launch, { type: 'wait', seconds: 2 }]; }
283
+ return [{ type: 'restore_app_data', archive: state.archive, clear_dirs: 'all' },
284
+ launch, { type: 'wait', seconds: 2 }];
285
+ }
286
+
@@ -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 };
@@ -395,8 +395,18 @@ export function derivedOverflowOpeners(tasks, limit = 4, depth = 1) {
395
395
  return sortedBy([...groups.keys()], (k) => [-count.get(k), k]).slice(0, Math.max(0, limit)).map((k) => groups.get(k));
396
396
  }
397
397
 
398
+ /**
399
+ * The static_resolution of a capture whose tree is unreliable (adapters observe `tree_unreliable`):
400
+ * status `tree-unreliable`, and `candidate_for` the expected target of the task whose action led to
401
+ * it (not confirmed: nothing in the tree proves it). final_utg / promote_dynamic make no page of it.
402
+ */
403
+ export function treeUnreliableResolution(observation, expected = null) {
404
+ return { status: 'tree-unreliable', reason: get(observation, 'tree_unreliable'), candidates: [],
405
+ ...(truthy(expected) ? { candidate_for: expected } : {}) };
406
+ }
407
+
398
408
  /** Static kinds that open over their page (what a container opener is expected to show). */
399
- export const OVERLAY_KINDS = new Set(['menu', 'dialog', 'panel', 'overlay', 'ui-state', 'mode']);
409
+ export const OVERLAY_KINDS = new Set(['menu', 'dialog', 'panel', 'overlay', 'ui-state', 'mode', 'in-route-surface', 'surface']);
400
410
 
401
411
  /**
402
412
  * The click left its page: another activity, or another verified static page that is not an
@@ -411,6 +421,26 @@ export function navigatedAway(before, after, catalog = {}) {
411
421
  return !OVERLAY_KINDS.has(kind);
412
422
  }
413
423
 
424
+ /**
425
+ * The innermost of every pair of nested candidate containers: a page or sheet container that wraps
426
+ * the real list is not a second list. Its own children include the list, so a dump can report it as
427
+ * a row group too (the sheet's Close button, a first row, the bottom buttons), and a
428
+ * `click_list_item` step then failed with 「expected one list, found 2」 although the page shows one
429
+ * list (measured coolmall 2026-11-28: the spec sheet's grid inside its sheet container).
430
+ */
431
+ export function pruneNestedLists(nodes, lists) {
432
+ if (lists.length < 2) { return lists; }
433
+ const ancestors = (i) => {
434
+ const out = new Set(); let p = get(nodes[i], 'parent_index');
435
+ for (let d = 0; d < 64 && p !== null && p !== undefined && p >= 0 && p < nodes.length; d++) {
436
+ out.add(p); p = get(nodes[p], 'parent_index');
437
+ }
438
+ return out;
439
+ };
440
+ const anc = new Map(lists.map((i) => [i, ancestors(i)]));
441
+ return lists.filter((i) => !lists.some((j) => j !== i && anc.get(j).has(i)));
442
+ }
443
+
414
444
  /**
415
445
  * rowGroups(nodes): containers whose children include at least 3 visible clickable rows of one class
416
446
  * and similar height (within 25%), stacked vertically: a list the dump does not flag scrollable.
@@ -552,6 +582,47 @@ export class Runner {
552
582
  return this._scope !== null && !this._scope.has(staticId);
553
583
  }
554
584
 
585
+ /**
586
+ * The host fields of a task_result (hosts.mjs): a task that has alternative hosts, or is a host
587
+ * retry, names its source host and what it retried, so the gap report can list every host tried.
588
+ */
589
+ _hostFields(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) { return payload; }
593
+ if (!truthy(get(task, 'host_alternatives')) && !truthy(get(task, 'host_retry_of'))) { return payload; }
594
+ return { ...payload, source_static: task.source_static,
595
+ ...(truthy(get(task, 'host_retry_of')) ? { host_retry_of: task.host_retry_of } : {}) };
596
+ }
597
+
598
+ /**
599
+ * After a task_result: when the task failed because of its host (isHostFailure: the source page
600
+ * was not reached, or only attested) and its target is still uncovered, run the same target
601
+ * through the next alternative host right away, as a copy of that host's task in this phase
602
+ * (`<task>@host-retry:<phase>`). Only a host whose task this phase does not run anyway, that has
603
+ * not started yet, and whose requirements this phase holds (alternativeHost). Every host tried
604
+ * is recorded once per target, so the retries end when the alternatives do.
605
+ */
606
+ _hostRetry(payload) {
607
+ const q = this._hostQueue;
608
+ const task = q ? q.tasks[q.cursor] : null;
609
+ if (!task || get(payload, 'task_id') !== task.task_id || get(payload, 'retrying')) { return; }
610
+ const target = task.target_static;
611
+ if (!q.tried.has(target)) { q.tried.set(target, new Set()); }
612
+ q.tried.get(target).add(task.source_static);
613
+ if (!isHostFailure(payload, { hostVerified: this._hostVerified }) || this.covered.has(target)) { return; }
614
+ const base = q.byId.get(baseTaskId(task.task_id)) ?? task;
615
+ const startedAs = (id) => (q.starts.get(id) ?? 0) > 0 || (q.starts.get(id + HOST_RETRY_TAG + this.phase.id) ?? 0) > 0;
616
+ const alt = alternativeHost(base, q.byId, { tried: q.tried.get(target), requires: or(this.phase.requires, []),
617
+ inPhase: q.phaseIds, started: startedAs });
618
+ if (!alt) { return; }
619
+ const retry = { ...JSON.parse(JSON.stringify(alt)), task_id: alt.task_id + HOST_RETRY_TAG + this.phase.id,
620
+ phase: this.phase.id, environment_id: this.env, requires: or(this.phase.requires, []), host_retry_of: task.task_id };
621
+ q.tasks.splice(q.cursor + 1, 0, retry);
622
+ this.emit('host_retry', { task_id: task.task_id, target_static: target, failed_host: task.source_static,
623
+ next_host: alt.source_static, retry_task_id: retry.task_id, reason: or(get(payload, 'reason'), get(payload, 'outcome')) });
624
+ }
625
+
555
626
  save() {
556
627
  atomicWriteJson(pJoin(this.root, 'campaign.json'), this.doc);
557
628
  this._saved_at = monotonic();
@@ -592,9 +663,11 @@ export class Runner {
592
663
  }
593
664
 
594
665
  emit(kind, payload, evidence = []) {
666
+ if (kind === 'task_result') { payload = this._hostFields(payload); }
595
667
  const e = event(kind, this.env, payload, evidence);
596
668
  this.doc.events.push(e);
597
669
  appendText(pJoin(this.root, 'events.jsonl'), jsonDumps(e, { ensure_ascii: false }) + '\n');
670
+ if (kind === 'task_result') { this._hostRetry(payload); }
598
671
  const interval = toFloat(get(this.config, 'save_interval', 15));
599
672
  if (['task_result', 'environment_verified', 'discovery_result', 'environment_restored'].includes(kind)
600
673
  || monotonic() - (this._saved_at ?? 0) >= interval) { this.save(); }
@@ -686,9 +759,15 @@ export class Runner {
686
759
  this.emit('ime_switcher_dismissed', { observation_id: get(observation, 'observation_id'),
687
760
  outcome: observation.ime_switcher_dismissed, action: { type: 'back', automatic: true } });
688
761
  }
689
- const resolution = resolveTwinByOpener(
762
+ let resolution = resolveTwinByOpener(
690
763
  deps.resolvePage(observation, this.catalog, get(observation, 'identity'), { app_package: get(this.config, 'package') }),
691
764
  this.current, this.catalog);
765
+ // The dump showed nothing usable of a screen that is not blank (adapters observe): no page can be
766
+ // read from it. Unless something still identified it, it is `tree-unreliable`, a candidate for the
767
+ // running task's expected target (after that task's action), never `unmapped` (a new dynamic page).
768
+ if (get(observation, 'tree_unreliable') && !['verified', 'foreign-package'].includes(get(resolution, 'status'))) {
769
+ resolution = treeUnreliableResolution(observation, this.stage === 'target' ? this._expectTarget : null);
770
+ }
692
771
  observation.static_resolution = resolution;
693
772
  const states = resolution.status === 'verified' ? uiStatesOf(observation, this.catalog) : [];
694
773
  if (states.length) { resolution.ui_states = states; }
@@ -708,6 +787,10 @@ export class Runner {
708
787
  }
709
788
  this.current = observation;
710
789
  this.emit('observation', observation, Object.values(observation.artifacts));
790
+ if (truthy(get(resolution, 'candidate_for'))) {
791
+ this.emit('candidate_capture', { static_id: resolution.candidate_for, observation_id: observation.observation_id,
792
+ task_id: this._expectTask, basis: 'tree-unreliable', confirmed: false });
793
+ }
711
794
  if (observation.loading && !acceptLoading) { return observation; }
712
795
  this.mapCapture(observation);
713
796
  return observation;
@@ -892,6 +975,27 @@ export class Runner {
892
975
  return permissionGrant(live, candidates, kindOf());
893
976
  }
894
977
 
978
+ /**
979
+ * waitForTarget(target, taskId): a tap that opens a data-backed page lands on a sparse frame
980
+ * first (measured coolmall 2026-11-28: the order detail showed only its status bar's buttons
981
+ * while the order was fetched, so a row probe judged it a wrong page and gave up). Wait, bounded
982
+ * (`target_wait_seconds`, default 6), until the page verifies as `target`. A capture already
983
+ * verified as another page ends the wait at once; an unverified frame keeps waiting because its
984
+ * identity may still arrive. Captures only, no action is spent.
985
+ */
986
+ waitForTarget(target, taskId) {
987
+ if (this.at(target)) { return true; }
988
+ const until = monotonic() + Math.max(0, toFloat(get(this.config, 'target_wait_seconds', 6)));
989
+ while (monotonic() < until) {
990
+ const res = get(this.current, 'static_resolution', {});
991
+ if (get(res, 'status') === 'verified' && get(res, 'static_id') !== target) { return false; }
992
+ sleep(0.5);
993
+ this.capture({ acceptLoading: true });
994
+ if (this.at(target)) { return true; }
995
+ }
996
+ return this.at(target);
997
+ }
998
+
895
999
  /**
896
1000
  * Several lists hold rows and the step names the page a row opens (`target_id`): tap the first row
897
1001
  * of each, most rows first, until one lands on that page; Back after a row that opened another.
@@ -914,7 +1018,7 @@ export class Runner {
914
1018
  row = this.listCandidates()[k]?.[1] ?? row;
915
1019
  }
916
1020
  last = tapRow(row);
917
- if (this.at(target)) {
1021
+ if (this.waitForTarget(target, taskId)) {
918
1022
  if (typeof this.emit === 'function') { this.emit('list_probe', { task_id: taskId, target, chosen: k, lists: lists.length }); }
919
1023
  return last;
920
1024
  }
@@ -923,17 +1027,67 @@ export class Runner {
923
1027
  }
924
1028
 
925
1029
  /**
926
- * [listIndex, firstActionableRow] of every visible list holding rows, most rows first, then top-down.
927
- * Nested scrollables that offer the same first row are one list (a page container around its grid).
1030
+ * A step names the page it opens (`target_id`) but its label is on screen more than once (coolmall:
1031
+ * 「查看全部」 under both 「我的订单」 and 「我的足迹」). Tap each match top-down until one lands on that
1032
+ * page, going Back after one that opened another; the landing page is checked by its own identity, so
1033
+ * a wrong match is never taken for the right one. Without this a single such step failed every task
1034
+ * behind it (a collapsed phase: 28 tasks never ran). Never for a control that writes data.
1035
+ */
1036
+ probeAmbiguous(action, taskId, purpose) {
1037
+ const fail = () => new AdapterError('ambiguous selector; no coordinate guessing');
1038
+ const target = action.target_id;
1039
+ const origin = get(get(this.current, 'static_resolution', {}), 'status') === 'verified' ? this.current.static_resolution.static_id : null;
1040
+ const sels = Object.hasOwn(CANDIDATE_KINDS, get(action, 'type')) ? get(action, 'selectors', []) : [get(action, 'selector', {})];
1041
+ const find = () => {
1042
+ const hidden = occludedIndices(this.current.nodes);
1043
+ for (const s of sels) {
1044
+ const hits = matching(this.current.nodes, s).filter((n, i) => {
1045
+ const b = get(n, 'bounds', []);
1046
+ return b.length === 4 && b[2] > b[0] && b[3] > b[1] && !hidden.has(i);
1047
+ });
1048
+ if (hits.length > 1) { return hits.sort((a, b) => a.bounds[1] - b.bounds[1] || a.bounds[0] - b.bounds[0]); }
1049
+ }
1050
+ return [];
1051
+ };
1052
+ const first = find();
1053
+ const writes = first.some((h) => [get(h, 'text'), get(h, 'content_desc')].some(writesData));
1054
+ if (origin === null || !first.length || (writes && get(this.config, 'allow_data_writes') !== true)) { throw fail(); }
1055
+ for (let k = 0; k < Math.min(first.length, Math.max(2, toInt(get(this.config, 'max_list_probes', 3)))); k++) {
1056
+ if (k > 0) {
1057
+ if (!this.at(origin)) { this.atom({ type: 'back' }, taskId, 'ambiguous-probe-back'); }
1058
+ if (!this.at(origin)) { throw fail(); }
1059
+ }
1060
+ const hit = find()[k];
1061
+ if (!hit) { break; }
1062
+ const b = hit.bounds;
1063
+ const done = this.atom({ type: 'click_point', x: Math.floor((b[0] + b[2]) / 2), y: Math.floor((b[1] + b[3]) / 2),
1064
+ row: { class: get(hit, 'class'), bounds: b } }, taskId, purpose);
1065
+ if (this.waitForTarget(target, taskId)) {
1066
+ if (typeof this.emit === 'function') { this.emit('ambiguous_probe', { task_id: taskId, target, chosen: k, matches: first.length }); }
1067
+ return done;
1068
+ }
1069
+ }
1070
+ throw fail();
1071
+ }
1072
+
1073
+ /**
1074
+ * [listIndex, firstActionableRow] of every visible list holding rows: vertical lists first, then
1075
+ * most rows, then top-down. Nested scrollables that offer the same first row are one list (a page
1076
+ * container around its grid).
928
1077
  */
929
1078
  listCandidates() {
930
1079
  const out = [];
931
- for (const li of this._listContainers()) {
1080
+ for (const li of pruneNestedLists(this.current.nodes, this._listContainers())) {
932
1081
  const rows = this._rowsOf(li);
933
1082
  if (rows.length) { out.push([li, sortedBy(rows, (n) => [n.bounds[1], n.bounds[0]])[0], rows.length]); }
934
1083
  }
1084
+ // Vertical lists first: a status tab strip or chip bar (horizontal) beside the data list is
1085
+ // usually a filter control, and probing it first changes the very filter the recorded path
1086
+ // chose (measured coolmall 2026-11-28: the order list's status tab row was tapped as a "row",
1087
+ // so the probe opened a 已退款 order, not the 待付款 one). It stays a candidate: a target only
1088
+ // a horizontal strip opens is still probed.
935
1089
  const seen = new Set();
936
- return sortedBy(out, (x) => [-x[2], x[1].bounds[1], x[1].bounds[0]])
1090
+ return sortedBy(out, (x) => [_isHorizontal(this.current.nodes[x[0]]) ? 1 : 0, -x[2], x[1].bounds[1], x[1].bounds[0]])
937
1091
  .filter(([, r]) => { const k = JSON.stringify(r.bounds); if (seen.has(k)) { return false; } seen.add(k); return true; })
938
1092
  .map(([li, r]) => [li, r]);
939
1093
  }
@@ -1023,6 +1177,8 @@ export class Runner {
1023
1177
  const withRows = lists.filter((li) => rowsOf(li).length > 0);
1024
1178
  if (withRows.length === 1) { lists = withRows; }
1025
1179
  }
1180
+ // A container around the list is not a second list: keep the innermost candidates.
1181
+ lists = pruneNestedLists(nodes, lists);
1026
1182
  if (lists.length !== 1) { throw new AdapterError(`list-item: expected one list, found ${lists.length}`); }
1027
1183
  const rows = rowsOf(lists[0]);
1028
1184
  if (!rows.length) { throw new AdapterError('list-item: list has no actionable rows'); }
@@ -1631,7 +1787,12 @@ export class Runner {
1631
1787
  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);
1632
1788
  }
1633
1789
  if (!Object.hasOwn(CANDIDATE_KINDS, type)) { return this.atom(action, taskId, purpose); }
1634
- let selected = this.choose(action);
1790
+ let selected;
1791
+ try { selected = this.choose(action); } catch (e) {
1792
+ // the label is on screen twice and the step names its landing page: probe, never guess coordinates
1793
+ if (!(e instanceof AdapterError) || !/^ambiguous selector/.test(errStr(e)) || !truthy(get(action, 'target_id'))) { throw e; }
1794
+ return this.probeAmbiguous(action, taskId, purpose);
1795
+ }
1635
1796
  if (selected) { return this.atom(selected, taskId, purpose); }
1636
1797
  if (this.clearInterruption(taskId)) {
1637
1798
  selected = this.choose(action);
@@ -2239,12 +2400,22 @@ export class Runner {
2239
2400
  * launch, so a setting one task changed does not reshape the next one's start page (measured,
2240
2401
  * Simple Calendar: a task chose the week view, the app stored it, and every later launch opened
2241
2402
  * on a week view with no FAB). `am start -S` only kills the process. Applies only to a phase with
2242
- * no fixtures: a fixture-built state would be wiped with nothing to rebuild it.
2403
+ * no fixtures: a fixture-built state would be wiped with nothing to rebuild it. Off while
2404
+ * config.user_state_protected is set (d_prereqs initial: the handed-over data could not be
2405
+ * archived): the clear would be refused and fail every task; one `reset_skipped` event says so.
2243
2406
  */
2244
2407
  resetsBetweenTasks() {
2245
2408
  const want = get(this.config, 'reset_between_tasks', false);
2246
2409
  const on = Array.isArray(want) ? want.includes(get(this.phase, 'id')) : truthy(want);
2247
- return on && !get(get(this.config, 'fixtures', {}), get(this.phase, 'id'), []).length;
2410
+ if (!on || get(get(this.config, 'fixtures', {}), get(this.phase, 'id'), []).length) { return false; }
2411
+ if (get(this.config, 'user_state_protected') === true) {
2412
+ if (!this._resetSkipNoted) {
2413
+ this._resetSkipNoted = true;
2414
+ this.emit('reset_skipped', { phase: get(this.phase, 'id'), reason: 'user_state_protected: clear_app_data would lose the handed-over data' });
2415
+ }
2416
+ return false;
2417
+ }
2418
+ return true;
2248
2419
  }
2249
2420
 
2250
2421
  /**
@@ -2354,14 +2525,13 @@ export class Runner {
2354
2525
  run() {
2355
2526
  this._launched = false;
2356
2527
  this.awaitContent(this.capture());
2357
- const tasks = get(this.doc, 'tasks', []).filter((t) => t.phase === this.phase.id);
2528
+ // One target opened from several hosts: the cheapest host (verified, fewest data preconditions) first.
2529
+ const tasks = orderHosts(get(this.doc, 'tasks', []).filter((t) => t.phase === this.phase.id), this.covered, { variants: true });
2358
2530
  const probesFor = get(get(this.config, 'phase_probes', {}), this.phase.id);
2531
+ // A state phase never runs on a guess: schedule_states.mjs runs it as a variant in a known
2532
+ // state its requirements hold in (with that state's probe), and D builds the others.
2359
2533
  if (truthy(this.phase.requires) && !truthy(probesFor)) {
2360
- const fallback = fallbackScope(this.config, this.phase, probesFor, this.doc);
2361
- if (fallback === null) {
2362
- return this._block('unresolved prerequisites: ' + this.phase.requires.join(', '));
2363
- }
2364
- this.emit('state_probe_missing', { phase: this.phase.id, requires: this.phase.requires, fallback });
2534
+ return this._block('unresolved prerequisites: ' + this.phase.requires.join(', '));
2365
2535
  }
2366
2536
  // A phase that writes to the backend (a seeding recipe) runs only while the switch is still on:
2367
2537
  // turning `allow_data_writes` off after scheduling stops it on the next run. `writes_data` decides;
@@ -2384,8 +2554,7 @@ export class Runner {
2384
2554
  return this._block('state-probe-failed');
2385
2555
  }
2386
2556
  this.emit('environment_verified', { phase: this.phase.id, observation_id: this.current.observation_id,
2387
- scope: truthy(probes) ? 'configured probes'
2388
- : (truthy(this.phase.requires) ? fallbackScope(this.config, this.phase, probes, this.doc) : 'existing state, no guard assumed') });
2557
+ scope: truthy(probes) ? 'configured probes' : 'existing state, no guard assumed' });
2389
2558
  this.phase.status = 'running'; this.save();
2390
2559
  let routeFailures = 0;
2391
2560
  for (const route of get(get(this.config, 'routes', {}), this.phase.id, [])) {
@@ -2412,8 +2581,14 @@ export class Runner {
2412
2581
  let scheduled = 0;
2413
2582
  const transient = new Map();
2414
2583
  const skipped = new Set();
2584
+ // _hostRetry inserts the next host's task right after the one whose host failed (hosts.mjs).
2585
+ this._hostQueue = { tasks, cursor: -1, starts, tried: new Map(),
2586
+ byId: new Map(get(this.doc, 'tasks', []).map((t) => [t.task_id, t])),
2587
+ phaseIds: new Set(tasks.flatMap((t) => [t.task_id, baseTaskId(t.task_id)])) };
2415
2588
  try {
2416
2589
  for (const task of tasks) {
2590
+ this._hostQueue.cursor += 1;
2591
+ this._hostVerified = null;
2417
2592
  const ident = task.task_id;
2418
2593
  if (done.has(ident) || (starts.get(ident) ?? 0) >= toInt(get(this.config, 'max_task_attempts', 1))) { continue; }
2419
2594
  if (this.coverage === 'nodes' && this.covered.has(get(task, 'target_static'))) {
@@ -2446,6 +2621,7 @@ export class Runner {
2446
2621
  scheduled += 1; starts.set(ident, (starts.get(ident) ?? 0) + 1);
2447
2622
  this.emit('task_started', { task_id: ident, target_static: task.target_static });
2448
2623
  this.keep = [task.source_static, task.target_static, get(task, 'source_context')].filter((x) => truthy(x));
2624
+ this._expectTarget = task.target_static; this._expectTask = ident;
2449
2625
  this._launched = false; // only a launch of this task's own opens the consent window
2450
2626
  this._clearedFor = null; // every attempt of a task starts from cleared data (resetBetweenTasks)
2451
2627
  if (get(task, 'purpose') === 'direct-launch') { this.runDirect(task, done); continue; }
@@ -2586,6 +2762,8 @@ export class Runner {
2586
2762
  _runTask(task, ident, done) {
2587
2763
  this.stage = 'source';
2588
2764
  this.source(task);
2765
+ // An attested-only host (anchorless, not verified): a failure past it is the host's (hosts.mjs).
2766
+ this._hostVerified = this.at(task.source_static);
2589
2767
  if (this.sweep(task.source_static) && (this.dirty ?? false)) { this.source(task); }
2590
2768
  this.stage = 'target';
2591
2769
  let result; let mark;