@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
@@ -7,7 +7,7 @@
7
7
  // the earlier siblings (FAQ faqs-arkui-549: a frame image over an avatar made the avatar unclickable).
8
8
 
9
9
  import { report } from '../core/findings.ts';
10
- import { attrChainFrom, attrsWithArgs, directUiChildren, exclusiveBranches, fullOnAxis, lineOfIndex, matchBracket, CONTROL_ROOTS } from '../core/parse.ts';
10
+ import { attrChainFrom, attrsWithArgs, definiteOnAxis, directUiChildren, exclusiveBranches, fullOnAxis, hasAttr, lineOfIndex, matchBracket, structBodyAt, structMembers, CONTROL_ROOTS } from '../core/parse.ts';
11
11
  import type { UiAttr, UiChild } from '../core/parse.ts';
12
12
  import { ancestorsOf, builderCallSites, inAttrArgs, maskedOf, structCallSites } from '../core/scan.ts';
13
13
  import type { FileScan } from '../core/scan.ts';
@@ -21,7 +21,7 @@ export const meta: RuleMeta[] = [
21
21
  invariant: "interaction",
22
22
  card: "interaction",
23
23
  needs: [],
24
- summary: "a later, always-shown child of a `Stack`/`RelativeContainer` is `'100%'` in width and height, has no `hitTestBehavior`, takes no input itself or in its subtree, and an earlier sibling has a clickable element (items a `ForEach` / `LazyForEach` / `Repeat` repeats count at its position among the siblings). Any `hitTestBehavior` on the layer (`Block` / `Default` included) counts as the author's explicit choice and is not reported.",
24
+ summary: "a later, always-shown child of a `Stack`/`RelativeContainer` fills its parent (each axis `'100%'`, or the same size expression the parent `Stack` writes on that axis, e.g. both `.height(this.panelHeight)`), has no `hitTestBehavior`, takes no input itself or in its subtree, and an earlier sibling has a clickable element (items a `ForEach` / `LazyForEach` / `Repeat` repeats count at its position among the siblings). Any `hitTestBehavior` on the layer (`Block` / `Default` included) counts as the author's explicit choice and is not reported. Also (single-axis form): a later non-interactive child of a `Stack` that spans the parent on **only one axis** (e.g. a centered title `Text.width('100%')`), with no `hitTestBehavior` / positioning / margin, necessarily intersects an earlier clickable sibling that spans the parent on **the other axis** (e.g. a back-button row with `.height(bar height)`), so it swallows that tap.",
25
25
  fix: "give the layer `.hitTestBehavior(HitTestMode.None)` (`HitTestMode.Transparent` when the layer must still receive events itself). The default `HitTestMode.Default` blocks the touch test of sibling nodes, so a transparent layer with no onClick still swallows every tap below it.",
26
26
  escape: null,
27
27
  cases: [
@@ -34,7 +34,7 @@ export const meta: RuleMeta[] = [
34
34
  invariant: "interaction",
35
35
  card: "interaction",
36
36
  needs: [],
37
- summary: "a node `'100%'` in width and height with no `hitTestBehavior` that the checker cannot prove, from the layer structure, leaves the taps below it alone. Nodes it can prove (taking input itself, a non-layered parent, nothing clickable below, a page root) are no longer listed. Any `hitTestBehavior` (`Block` / `Default` included) counts as the author's explicit choice and is out of scope.",
37
+ summary: "a node `'100%'` in width and height (in a `Stack`/`RelativeContainer`, an axis written with the parent's own size expression counts too) with no `hitTestBehavior` that the checker cannot prove, from the layer structure, leaves the taps below it alone. Nodes it can prove (taking input itself, a non-layered parent, nothing clickable below, a page root) are no longer listed. Any `hitTestBehavior` (`Block` / `Default` included) counts as the author's explicit choice and is out of scope.",
38
38
  fix: "GATE \"conditional overlay\": while shown it covers clickable elements below it. When blocking input is the intent (loading mask, modal layer) write the downgrade marker `// HIT-TEST: blocks-input: <basis>`; otherwise add `.hitTestBehavior(HitTestMode.None)`. GATE \"layer whose children take input\": its own area covers clickable elements below it; size or place it so it does not, or add `.hitTestBehavior(HitTestMode.Transparent)` when a tap on it should reach them too; when covering the lower layer is the intent (a full-screen sheet over its own scrim) write `// HIT-TEST: covers-below: <basis>`. CAND (a component outside the scanned files drawn by it or below it, `zIndex` reordering, no call site found): the checker cannot decide it; check it under \"Interaction Reachability Evidence\".",
39
39
  escape: "// HIT-TEST: <blocks-input|covers-below>:",
40
40
  cases: [
@@ -159,7 +159,10 @@ export function rangeInteractive(scans: FileScan[], s: FileScan, from: number, t
159
159
  const next: Set<string> = new Set([...seen, key]);
160
160
  if (m[1]) {
161
161
  const b: Body | null = builderBody(s, m[2]);
162
- if (b !== null) { parts.push(rangeInteractive(scans, b.scan, b.open, b.close, next)); }
162
+ if (b !== null) { parts.push(rangeInteractive(scans, b.scan, b.open, b.close, next)); continue; }
163
+ // A @BuilderParam draws what the callers pass in.
164
+ const bp: Tri | undefined = builderParamInteractive(scans, s, at, m[2], next);
165
+ if (bp !== undefined) { parts.push(bp); }
163
166
  continue;
164
167
  }
165
168
  if (!/^[A-Z]/.test(m[2])) { continue; }
@@ -170,6 +173,96 @@ export function rangeInteractive(scans: FileScan[], s: FileScan, from: number, t
170
173
  return anyTri(parts);
171
174
  }
172
175
 
176
+ /** `@BuilderParam X` of the struct wrapping pos: the struct, X's default builder (`= this.Y`), whether it is the only one. */
177
+ function builderParamAt(s: FileScan, pos: number, name: string): { struct: string; def: string | null; only: boolean } | null {
178
+ const masked: string = maskedOf(s);
179
+ const [open] = structBodyAt(s.code, masked, pos);
180
+ const head: RegExpMatchArray | null = masked.slice(0, open + 1).match(/\bstruct\s+([A-Za-z_$][\w$]*)[^{]*\{$/);
181
+ if (head === null) { return null; }
182
+ const all: RegExpMatchArray[] = [...structMembers(masked, pos).matchAll(
183
+ /@BuilderParam\s+(?:(?:private|public|protected)\s+)?([A-Za-z_$][\w$]*)[^=;\n]*(?:=\s*this\.([A-Za-z_$][\w$]*))?/g)];
184
+ const own: RegExpMatchArray | undefined = all.find((x) => x[1] === name);
185
+ return own === undefined ? null : { struct: head[1], def: own[2] ?? null, only: all.length === 1 };
186
+ }
187
+
188
+ /** [from, to) of the value of `name:` at the top level of the object literal opening at masked[from], or null. */
189
+ function propValue(masked: string, from: number, to: number, name: string): [number, number] | null {
190
+ const re: RegExp = new RegExp(`[{,]\\s*${name.replace(/\$/g, '\\$')}\\s*:`, 'g');
191
+ re.lastIndex = from;
192
+ for (let m: RegExpExecArray | null = re.exec(masked); m !== null && m.index < to; m = re.exec(masked)) {
193
+ let depth: number = 0;
194
+ for (let k = from; k <= m.index; k++) {
195
+ const c: string = masked[k];
196
+ if (c === '(' || c === '{' || c === '[') { depth++; } else if (c === ')' || c === '}' || c === ']') { depth--; }
197
+ }
198
+ if (depth !== 1) { continue; }
199
+ const v: number = m.index + m[0].length;
200
+ let d: number = 0;
201
+ let k: number = v;
202
+ for (; k < to; k++) {
203
+ const c: string = masked[k];
204
+ if (c === '(' || c === '{' || c === '[') { d++; continue; }
205
+ if (c === ')' || c === '}' || c === ']') { if (d === 0) { break; } d--; continue; }
206
+ if (c === ',' && d === 0) { break; }
207
+ }
208
+ return [v, k];
209
+ }
210
+ return null;
211
+ }
212
+
213
+ /**
214
+ * `this.X()` where X is a @BuilderParam: what the callers pass for X (`X: () => { this.b() }`, `X: this.b`, or the
215
+ * trailing closure when X is the only one), else X's default builder. undefined when X is no @BuilderParam.
216
+ */
217
+ function builderParamInteractive(scans: FileScan[], s: FileScan, pos: number, name: string, seen: Set<string>): Tri | undefined {
218
+ const bp = builderParamAt(s, pos, name);
219
+ if (bp === null) { return undefined; }
220
+ const fallback = (): Tri => {
221
+ const d: Body | null = bp.def === null ? null : builderBody(s, bp.def);
222
+ return d === null ? false : rangeInteractive(scans, d.scan, d.open, d.close, seen);
223
+ };
224
+ const sites = structCallSites(scans, bp.struct);
225
+ if (sites.length === 0) { return fallback(); }
226
+ return anyTri(sites.map((site): Tri => {
227
+ const masked: string = maskedOf(site.scan);
228
+ const close: number = matchBracket(masked, site.paren);
229
+ if (close < 0) { return null; }
230
+ const v: [number, number] | null = propValue(masked, site.paren + 1, close, name);
231
+ if (v !== null) {
232
+ const ref: RegExpMatchArray | null = site.scan.code.slice(v[0], v[1]).match(/^\s*this\.([A-Za-z_$][\w$]*)\s*$/);
233
+ const b: Body | null = ref === null ? null : builderBody(site.scan, ref[1]);
234
+ return b !== null ? rangeInteractive(scans, b.scan, b.open, b.close, seen) : rangeInteractive(scans, site.scan, v[0], v[1], seen);
235
+ }
236
+ if (bp.only) {
237
+ const blk: [number, number] | null = blockAfter(site.scan.code, site.paren);
238
+ if (blk !== null) { return rangeInteractive(scans, site.scan, blk[0], blk[1], seen); }
239
+ }
240
+ return fallback();
241
+ }));
242
+ }
243
+
244
+ /** The axis expression of attrs (`.width(x)` or `.size({ width: x })`), whitespace and `this.` dropped; '' when unset. */
245
+ function axisExpr(attrs: UiAttr[], axis: 'width' | 'height'): string {
246
+ const norm = (x: string): string => x.replace(/\s+/g, '').replace(/\bthis\./g, '');
247
+ const a: UiAttr | undefined = attrs.find((x) => x.name === axis);
248
+ if (a !== undefined) { return norm(a.args); }
249
+ const sz: UiAttr | undefined = attrs.find((x) => x.name === 'size');
250
+ const m: RegExpMatchArray | null = sz === undefined ? null : sz.args.match(new RegExp(`\\b${axis}\\s*:\\s*([^,}]+)`));
251
+ return m === null ? '' : norm(m[1]);
252
+ }
253
+
254
+ /**
255
+ * On axis the layer spans its parent: '100%', or the same size expression the parent writes on that axis.
256
+ * A percentage is relative to the parent, so an equal percentage ('90%' in a '90%' Stack) is a fraction of
257
+ * it, not the whole: only a non-percent expression (a constant, a state field) counts when equal.
258
+ */
259
+ export function spansParent(attrs: UiAttr[], parent: UiAttr[], axis: 'width' | 'height'): boolean {
260
+ if (fullOnAxis(attrs, axis)) { return true; }
261
+ const mine: string = axisExpr(attrs, axis);
262
+ if (mine === '' || /%/.test(mine)) { return false; }
263
+ return mine === axisExpr(parent, axis);
264
+ }
265
+
173
266
  export type VerdictKind = 'safe' | 'swallows' | 'covers' | 'conditional' | 'unknown' | 'zindex' | 'unplaced' | 'unparsed';
174
267
  export type Verdict = { kind: VerdictKind; scan?: FileScan; at?: number; below?: string[] };
175
268
  const RANK: Record<VerdictKind, number> = { safe: 0, unplaced: 1, unknown: 2, zindex: 2, unparsed: 2, conditional: 3, covers: 3, swallows: 4 };
@@ -193,9 +286,12 @@ const layerKids = (code: string, open: number, close: number): UiChild[] =>
193
286
  */
194
287
  export function judgeLayer(scans: FileScan[], L: Layer, self: Self, conditional: boolean, seen: Set<string> = new Set()): Verdict {
195
288
  if (selfInteractive(L.name, L.attrs) || L.attrs.some((a) => a.name === 'hitTestBehavior')) { return { kind: 'safe' }; }
196
- if (sized(L.attrs, 'width') || sized(L.attrs, 'height')) { return { kind: 'safe' }; }
197
- const cond: boolean = conditional || L.attrs.some((a) => a.name === 'visibility');
198
289
  const anc = ancestorsOf(L.s.code, maskedOf(L.s), L.pos)[0];
290
+ // A sized axis keeps the layer off part of its parent, unless it is the parent's own size expression
291
+ // (`.height(this.panelHeight)` inside a Stack of `.height(this.panelHeight)` fills it as '100%' does).
292
+ const parentAttrs: UiAttr[] = anc !== undefined && anc.kind === 'comp' ? anc.attrs as UiAttr[] : [];
293
+ if ((['width', 'height'] as const).some((ax) => sized(L.attrs, ax) && !spansParent(L.attrs, parentAttrs, ax))) { return { kind: 'safe' }; }
294
+ const cond: boolean = conditional || L.attrs.some((a) => a.name === 'visibility');
199
295
  const here = { scan: L.s, at: L.pos };
200
296
  if (anc === undefined || anc.kind === 'stop') { return { kind: 'unplaced', ...here }; }
201
297
  if (anc.kind === 'comp') {
@@ -272,7 +368,7 @@ export function hasBasis(basis: string): boolean {
272
368
  /** `// HIT-TEST: <disposition>: <basis>` on the line or up to 3 lines above it (original text). */
273
369
  const RE_MARK: RegExp = /\/\/\s*HIT-TEST\s*[::]\s*([A-Za-z-]+)\s*[::]?\s*(.*)$/;
274
370
  export function hitTestMark(src: string, line: number): { disp: string; basis: string } | null {
275
- const lines: string[] = src.split('\n');
371
+ const lines: string[] = src.split(/\r?\n/); // CRLF: a trailing \r would defeat the marker's (.*)$
276
372
  for (let i = Math.max(0, line - 4); i <= Math.min(lines.length - 1, line - 1); i++) {
277
373
  const m: RegExpExecArray | null = RE_MARK.exec(lines[i]);
278
374
  if (m !== null) { return { disp: m[1], basis: m[2].trim() }; }
@@ -295,6 +391,15 @@ const REASON: Record<string, string> = {
295
391
  unparsed: 'cannot prove it: its place among the Stack children was not parsed (an unusual statement form)',
296
392
  };
297
393
 
394
+ /** '100%' on both axes, or (in a Stack / RelativeContainer) each axis '100%' or the parent's own size expression. */
395
+ function fillsParent(s: FileScan, pos: number, attrs: UiAttr[]): boolean {
396
+ if (fullOnAxis(attrs, 'width') && fullOnAxis(attrs, 'height')) { return true; }
397
+ const anc = ancestorsOf(s.code, maskedOf(s), pos)[0];
398
+ if (anc === undefined || anc.kind !== 'comp' || !LAYERED.has(anc.name)) { return false; }
399
+ const parent: UiAttr[] = anc.attrs as UiAttr[];
400
+ return spansParent(attrs, parent, 'width') && spansParent(attrs, parent, 'height');
401
+ }
402
+
298
403
  /** GATE stack-swallows-taps + the structural verdict on every other '100%' × '100%' node without hitTestBehavior. */
299
404
  export function checkHitTest(scans: FileScan[]): void {
300
405
  for (const s of scans) {
@@ -305,7 +410,7 @@ export function checkHitTest(scans: FileScan[]): void {
305
410
  if (inAttrArgs(masked, pos)) { continue; }
306
411
  const paren: number = pos + m[0].length - 1;
307
412
  const attrs: UiAttr[] = attrsWithArgs(s.code, paren);
308
- if (!(fullOnAxis(attrs, 'width') && fullOnAxis(attrs, 'height')) || attrs.some((a) => a.name === 'hitTestBehavior')) { continue; }
413
+ if (attrs.some((a) => a.name === 'hitTestBehavior') || !fillsParent(s, pos, attrs)) { continue; }
309
414
  const v: Verdict = judgeLayer(scans, { s, pos, name: m[1], attrs }, { scan: s, from: pos, to: statementEnd(s.code, paren) }, false);
310
415
  if (v.kind === 'safe') { continue; }
311
416
  const line: number = lineOfIndex(s.code, pos);
@@ -337,3 +442,84 @@ export function checkHitTest(scans: FileScan[]): void {
337
442
  }
338
443
  }
339
444
  }
445
+
446
+ /** Displacement attributes that could move a child off the shared alignContent anchor (so overlap is no longer guaranteed). */
447
+ const DISPLACEMENT: Set<string> = new Set(['offset', 'position', 'markAnchor', 'translate', 'margin', 'alignRules']);
448
+
449
+ /**
450
+ * GATE stack-swallows-taps (single-axis form): in a Stack, a later non-interactive child that spans the parent on
451
+ * exactly ONE axis (e.g. a centered title Text.width('100%')) sits on top of every full-width/full-height area at the
452
+ * shared alignContent anchor. When an earlier sibling is interactive AND spans the OTHER (cross) axis of the Stack,
453
+ * the two rectangles necessarily intersect, so the top layer swallows that sibling's taps — the centered-title toolbar
454
+ * over a back button (CoolMall CenterTopAppBar). Conservative: only Stack (alignContent is uniform), only when the
455
+ * layer carries no displacement (offset/position/margin/…) and the interactive sibling provably spans the cross axis.
456
+ */
457
+ export function checkStackSingleAxisSwallow(scans: FileScan[]): void {
458
+ for (const s of scans) {
459
+ const masked: string = maskedOf(s);
460
+ for (const sm of masked.matchAll(/(?<![\w$.])Stack\s*\(/g)) {
461
+ const paren: number = (sm.index ?? 0) + sm[0].length - 1;
462
+ if (inAttrArgs(masked, sm.index ?? 0)) { continue; }
463
+ const pclose: number = matchBracket(s.code, paren);
464
+ if (pclose < 0) { continue; }
465
+ let k: number = pclose + 1;
466
+ while (k < s.code.length && /\s/.test(s.code[k])) { k++; }
467
+ if (s.code[k] !== '{') { continue; }
468
+ const bodyClose: number = matchBracket(s.code, k);
469
+ if (bodyClose < 0) { continue; }
470
+ const stackAttrs: UiAttr[] = attrChainFrom(s.code, bodyClose + 1)[0];
471
+ const kids: UiChild[] = directUiChildren(s.code, k, bodyClose, undefined, { intoBranches: true })
472
+ .filter((c) => c.control !== true);
473
+ for (let i = 0; i < kids.length; i++) {
474
+ const kid: UiChild = kids[i];
475
+ if (kid.isBuilderCall) { continue; }
476
+ if (selfInteractive(kid.name, kid.attrs) || hasAttr(kid.attrs, 'hitTestBehavior')) { continue; }
477
+ // translate alone moves the band by a state value that is often 0 at rest: not provable either way → CAND below.
478
+ const moved: boolean = hasAttr(kid.attrs, 'translate');
479
+ if (kid.attrs.some((a) => DISPLACEMENT.has(a.name) && a.name !== 'translate')) { continue; }
480
+ // Exactly one axis spans the parent.
481
+ const fullW: boolean = spansParent(kid.attrs, stackAttrs, 'width');
482
+ const fullH: boolean = spansParent(kid.attrs, stackAttrs, 'height');
483
+ if (fullW === fullH) { continue; }
484
+ const cross: 'width' | 'height' = fullW ? 'height' : 'width';
485
+ // The layer must be UNSIZED on the cross axis — a thin band (e.g. a centered title: width 100%, no height).
486
+ // A cross axis sized to a fraction (height '100%' + width '90%') is a block, not a band, and is left to the
487
+ // both-axis path; this keeps a partial-width/height overlay from being treated as a full filler.
488
+ // A fixed vp size on the cross axis (`.height(32)`) is still a band: anchored at the same alignContent corner,
489
+ // it intersects any sibling that spans that axis.
490
+ const fixedCross: boolean = kid.attrs.some((a) => a.name === cross && !/%|['"`]/.test(a.args)) &&
491
+ !kid.attrs.some((a) => a.name !== cross && definiteOnAxis([a], cross));
492
+ if ((definiteOnAxis(kid.attrs, cross) && !fixedCross) ||
493
+ kid.attrs.some((a) => a.name === 'constraintSize' && new RegExp(`\\b(?:min|max)${cross === 'width' ? 'Width' : 'Height'}\\b`).test(a.args))) { continue; }
494
+ // An earlier sibling (not in a mutually exclusive branch) that spans the cross axis and takes input.
495
+ const below: UiChild[] = kids.slice(0, i).filter((c) => !exclusiveBranches(c, kid));
496
+ const victim: UiChild | undefined = below.find((c) =>
497
+ (fullOnAxis(c.attrs, cross) || spansParent(c.attrs, stackAttrs, cross)) &&
498
+ (selfInteractive(c.name, c.attrs) || rangeInteractive(scans, s, c.at, c.end) === true));
499
+ if (victim === undefined) { continue; }
500
+ // Same exclusions as judgeLayer on the both-axis path: a zIndex reorders the layers, a conditional layer is not
501
+ // always drawn, and a layer whose subtree takes input "covers" rather than "swallows". Not provable → CAND.
502
+ const line: number = lineOfIndex(s.code, kid.at);
503
+ const victimAt: string = `the earlier ${victim.name} (line ${lineOfIndex(s.code, victim.at)}) that spans the ${cross} and is clickable`;
504
+ const mine: boolean | null = rangeInteractive(scans, s, kid.at, kid.end);
505
+ const doubt: string | null =
506
+ kids.some((c) => hasAttr(c.attrs, 'zIndex')) ? 'a zIndex in this Stack may draw it below' :
507
+ moved ? 'its .translate() may move it off that sibling (often 0 at rest, so it lies on top)' :
508
+ kid.branch === true || hasAttr(kid.attrs, 'visibility') ? 'it is shown only conditionally' :
509
+ mine === true ? 'its own subtree takes input, so it covers rather than swallows' :
510
+ mine === null ? 'its subtree could not be resolved' : null;
511
+ if (doubt !== null) {
512
+ report('CAND', 'fullsize-container', s.rel, line,
513
+ `${kid.name} spans the Stack on ${fullW ? 'width' : 'height'} with no hitTestBehavior and overlaps ${victimAt}; ${doubt} — ` +
514
+ 'check it under 交互可达性证据 (fix: .hitTestBehavior(HitTestMode.None), or .Transparent if it must receive events too)');
515
+ continue;
516
+ }
517
+ report('GATE', 'stack-swallows-taps', s.rel, line,
518
+ `${kid.name} spans the Stack on ${fullW ? 'width' : 'height'} with no hitTestBehavior and takes no input itself, ` +
519
+ `while the earlier ${victim.name} (line ${lineOfIndex(s.code, victim.at)}) spans the ${cross} and is clickable — ` +
520
+ 'two layers sharing the Stack alignContent anchor, one full-width and one full-height, necessarily intersect, so this layer swallows that tap. ' +
521
+ 'Add .hitTestBehavior(HitTestMode.None) to this layer (or .Transparent if it must receive events too)');
522
+ }
523
+ }
524
+ }
525
+ }
@@ -0,0 +1,138 @@
1
+ // static_check/rules/inset_stacked.ts — the same horizontal padding written on a custom component's build() root
2
+ // and again on a container around its call site.
3
+
4
+ import { report } from '../core/findings.ts';
5
+ import { attrsWithArgs, lineOfIndex, markedAbove, splitTopLevel, structBuildRoots } from '../core/parse.ts';
6
+ import type { UiAttr } from '../core/parse.ts';
7
+ import { ancestorsOf, maskedOf, resolveStructFile, structCallSites, SCROLLERS } from '../core/scan.ts';
8
+ import type { FileScan } from '../core/scan.ts';
9
+ import type { RuleMeta } from '../core/meta.ts';
10
+ import * as path from 'path';
11
+
12
+ /** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
13
+ export const meta: RuleMeta[] = [
14
+ {
15
+ id: "inset-double-applied",
16
+ levels: ["GATE", "CAND"],
17
+ invariant: "geometry",
18
+ card: "geometry",
19
+ needs: [],
20
+ summary: "a custom component's build() root sets left/right `.padding()`, and one of its call sites, or a container around the call site up to the nearest scroll container, sets `.padding()` with the same left/right values — one inset is applied twice.",
21
+ fix: "the root padding of an embedded Fragment / include layout belongs to the component alone: keep it on the component's build() root and drop the host-side copy. The host container (e.g. the Column standing for `flTodayWeather`) writes only its own attributes; when the host needs an extra offset (a collapsing-header height, etc.) it writes only that (e.g. `.padding({ top: HEADER_H })`), never the child layout's left/right inset along with it. When both layers really exist (the Android host container has the same padding too), write `// INSET-STACKED: <host XML file:line>` above the host `.padding(` line to downgrade to CAND. When the component root draws a box itself (background, border, radius, shadow: a card), its padding is the card's content inset and the host's is the page gutter, so the finding is only a CAND; confirm it against the Android host layout.",
22
+ escape: "// INSET-STACKED:",
23
+ cases: [
24
+ "WeatherApp 11-22 home page: TodayView root Column `.padding({left:16,right:16,top:16})` mirrors fragment_today_weather.xml:23-25, and the host MainPage Column around it writes `.padding({left:16,right:16,top:HEADER_H_E+16})` again (flTodayWeather has no padding). Card left edge 112px=32vp (Android 42px=16dp), full-width cards 82.5% of screen width (Android 92%), 2-column cards 37% (Android 44%); phase5 and static_check all green, smoke PASS.",
25
+ ],
26
+ },
27
+ ];
28
+
29
+ type Sides = { l: number | null; r: number | null };
30
+
31
+ /** A literal vp value: `16`, `'16vp'`, `LengthMetrics.vp(16)`; null for expressions, %, resources. */
32
+ function vp(v: string | undefined): number | null {
33
+ if (v === undefined) { return 0; }
34
+ const t: string = v.trim();
35
+ const lm: RegExpMatchArray | null = t.match(/^LengthMetrics\.vp\(\s*(\d+(?:\.\d+)?)\s*\)$/);
36
+ if (lm !== null) { return parseFloat(lm[1]); }
37
+ const m: RegExpMatchArray | null = t.match(/^(?:(\d+(?:\.\d+)?)|(['"`])(\d+(?:\.\d+)?)(?:vp)?\2)$/);
38
+ return m === null ? null : parseFloat(m[1] ?? m[3]);
39
+ }
40
+
41
+ /** Left / right padding of `.padding(args)`; a side is null when it is not a literal. */
42
+ export function horizontalSides(args: string): Sides {
43
+ const all: number | null = vp(args);
44
+ if (all !== null) { return { l: all, r: all }; }
45
+ const t: string = args.trim();
46
+ if (!t.startsWith('{') || !t.endsWith('}')) { return { l: null, r: null }; }
47
+ const f: Map<string, string> = new Map();
48
+ for (const part of splitTopLevel(t.slice(1, -1))) {
49
+ const kv: RegExpMatchArray | null = part.match(/^\s*([A-Za-z_$][\w$]*)\s*:\s*([\s\S]+?)\s*$/);
50
+ if (kv !== null) { f.set(kv[1], kv[2]); }
51
+ }
52
+ return { l: vp(f.get('left') ?? f.get('start')), r: vp(f.get('right') ?? f.get('end')) };
53
+ }
54
+
55
+ /** The last `.padding()` of a chain (later writes win). */
56
+ function lastPadding(attrs: UiAttr[]): UiAttr | undefined {
57
+ return [...attrs].reverse().find((a) => a.name === 'padding');
58
+ }
59
+
60
+ /** Attributes that draw a box: padding inside one is the box's content inset, not the page's. */
61
+ const BOX_ATTRS: Set<string> = new Set(['backgroundColor', 'background', 'backgroundImage', 'linearGradient',
62
+ 'border', 'borderWidth', 'borderRadius', 'shadow']);
63
+
64
+ /** Both sides known, at least one non-zero, and equal side by side. */
65
+ function sameInset(a: Sides, b: Sides): boolean {
66
+ if (a.l === null || a.r === null || b.l === null || b.r === null) { return false; }
67
+ if (a.l === 0 && a.r === 0) { return false; }
68
+ return a.l === b.l && a.r === b.r;
69
+ }
70
+
71
+ /**
72
+ * GATE inset-double-applied.
73
+ *
74
+ * An embedded Fragment / `<include>` keeps its root padding in its own layout; the host container that
75
+ * holds it usually has none. Converting the two separately, the agent writes the fragment's padding on the
76
+ * component's build() root (correct) and copies it onto the host wrapper too (while it was deriving an
77
+ * unrelated top offset there). Each file looks right on its own and every per-file check passes; on screen
78
+ * every card is inset twice and visibly narrower than on Android.
79
+ *
80
+ * Only equal left/right values count: different values are usually a real page gutter plus a card gutter.
81
+ * The walk goes from the call site outward to the nearest scroll container or the build() root, and
82
+ * includes the call site's own chain (a `.padding()` there wraps the component in __Common__, same effect).
83
+ * A root that draws a box (background, border, radius, shadow) is a card: its padding insets the card's
84
+ * content and the host's is the page gutter, the Android "16dp page + 16dp CardView" shape. That is a CAND.
85
+ */
86
+ export function checkInsetDoubleApplied(scans: FileScan[]): void {
87
+ const declCount: Map<string, number> = new Map();
88
+ for (const s of scans) {
89
+ for (const n of s.declaredStructs) { declCount.set(n, (declCount.get(n) || 0) + 1); }
90
+ }
91
+ for (const def of scans) {
92
+ for (const root of structBuildRoots(def.code)) {
93
+ const rootAttrs: UiAttr[] = attrsWithArgs(def.code, root.paren);
94
+ const rootPad: UiAttr | undefined = lastPadding(rootAttrs);
95
+ if (rootPad === undefined) { continue; }
96
+ const inner: Sides = horizontalSides(rootPad.args);
97
+ if (inner.l === null || inner.r === null || (inner.l === 0 && inner.r === 0)) { continue; }
98
+ const rootAt: string = `${def.rel}:${lineOfIndex(def.code, rootPad.index ?? root.paren)}`;
99
+ const card: boolean = rootAttrs.some((a) => BOX_ATTRS.has(a.name));
100
+ const ambiguous: boolean = (declCount.get(root.struct) || 0) > 1;
101
+ const defAbs: string = path.resolve(def.abs);
102
+ for (const site of structCallSites(scans, root.struct)) {
103
+ const s: FileScan = site.scan;
104
+ const resolved: string = resolveStructFile(s, root.struct);
105
+ if (resolved !== '' && resolved !== defAbs) { continue; }
106
+ if (resolved === '' && ambiguous) { continue; }
107
+ const layers: { name: string; attrs: UiAttr[] }[] = [
108
+ { name: `${root.struct}(…)`, attrs: attrsWithArgs(s.code, site.paren) },
109
+ ];
110
+ for (const a of ancestorsOf(s.code, maskedOf(s), site.index)) {
111
+ if (a.kind !== 'comp') { break; }
112
+ if (SCROLLERS.has(a.name)) { break; }
113
+ layers.push({ name: a.name, attrs: a.attrs });
114
+ }
115
+ for (const layer of layers) {
116
+ const pad: UiAttr | undefined = lastPadding(layer.attrs);
117
+ if (pad === undefined || !sameInset(horizontalSides(pad.args), inner)) { continue; }
118
+ const line: number = lineOfIndex(s.code, pad.index ?? site.index);
119
+ const marked: boolean = markedAbove(s.src.split(/\r?\n/), line, 'INSET-STACKED');
120
+ if (card) {
121
+ report('CAND', 'inset-double-applied', s.rel, line,
122
+ `${layer.name} around ${root.struct} sets horizontal padding ${inner.l}/${inner.r}, the same as ${root.struct}'s ` +
123
+ `build() root (${rootAt}), which draws a box: usually a page gutter plus the card's content inset. ` +
124
+ 'Confirm against the Android host layout that the host container has this padding');
125
+ break;
126
+ }
127
+ report(marked ? 'CAND' : 'GATE', 'inset-double-applied', s.rel, line,
128
+ `${layer.name} around ${root.struct} sets horizontal padding ${inner.l}/${inner.r}, and ${root.struct}'s build() root ` +
129
+ `already sets the same ${inner.l}/${inner.r} (${rootAt}) — the inset is applied twice, so every child is ` +
130
+ `${inner.l + inner.r}vp narrower than on Android. The embedded layout's root padding belongs to the component: ` +
131
+ 'drop it here and keep only what the host itself needs (e.g. a top offset). ' +
132
+ 'When the Android host container really has the same padding too, write // INSET-STACKED: <host XML file:line> above it');
133
+ break;
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,181 @@
1
+ // static_check/rules/int_division.ts — GATE java-int-division-not-truncated.
2
+ //
3
+ // Java / Kotlin `int / int` truncates; ArkTS `number / number` does not. An expression copied verbatim from the
4
+ // Android source therefore changes value. Measured in a chart component: the Java source
5
+ // `int dayIndex = i / 24 + 1; float x = dayIndex + (i % 24) / 24.0f - 0.5f;` was written as
6
+ // `(i / 24 + 1) + (i % 24) / 24 - 0.5`: the fraction of the day counts twice, x runs 0.5 → 1.0 → 1.5 → 2.0 → 1.5,
7
+ // and the cubic curve folds back on itself at every day.
8
+ //
9
+ // The rule only looks where the .ets says which Android lines it ports (`Foo.java:148-161`, `Foo.kt:30`), so it never
10
+ // guesses which TypeScript division corresponds to which Java one.
11
+
12
+ import * as path from 'path';
13
+ import { report } from '../core/findings.ts';
14
+ import { lineOfIndex, markedAbove } from '../core/parse.ts';
15
+ import { androidFiles } from '../core/android.ts';
16
+ import type { AndroidFile } from '../core/android.ts';
17
+ import type { FileScan } from '../core/scan.ts';
18
+ import type { RuleMeta } from '../core/meta.ts';
19
+
20
+ /** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
21
+ export const meta: RuleMeta[] = [
22
+ {
23
+ id: "java-int-division-not-truncated",
24
+ levels: ["GATE"],
25
+ invariant: "state",
26
+ card: "dynamics",
27
+ needs: ["--android"],
28
+ summary: "A `.ets` comment cites Android source lines (`X.java:148-161` / `X.kt:30`), those lines contain a division whose both operands are integers (`int`/`long`/`Int`/`Long` variables or integer literals, e.g. `i / 24`), and within the 25 `.ets` lines after the citation the same expression is written as plain `i / 24`, not wrapped in `Math.trunc(...)` / `Math.floor(...)`. Java/Kotlin integer division truncates; ArkTS `/` is a floating-point division, so the value changes.",
29
+ fix: "Write the integer division as `Math.trunc(a / b)` (it matches Java for negative operands too; `Math.floor` is fine only when they are never negative). When the Android side is already a floating-point division (one side is `float`/`double` or a literal like `.0f`) nothing is affected; when the variable is really floating-point and only shares the name, write `// INT-DIV-OK: <basis>` above the line.",
30
+ escape: "// INT-DIV-OK:",
31
+ cases: [
32
+ "Measured: in a chart component, the Java `int dayIndex = i / 24 + 1` was written as `(i / 24 + 1) + (i % 24) / 24 - 0.5`; the fraction of the day counted twice, x ran 0.5→1.0→1.5→2.0→1.5, and the curve folded back into a loop at every day.",
33
+ ],
34
+ },
35
+ ];
36
+
37
+ /** `Foo.java:148`, `Foo.kt:30-41`, `Foo.java:148–161` (en dash) as cited in .ets comments. */
38
+ const CITE: RegExp = /\b([A-Z][\w$]*\.(?:java|kt)):(\d+)(?:\s*[-–~]\s*:?(\d+))?/g;
39
+ /** Lines after the citation searched for the ported expression. */
40
+ const WINDOW: number = 25;
41
+ /** Longest cited range read (a citation of a whole file is no pointer to one expression). */
42
+ const MAX_RANGE: number = 60;
43
+
44
+ /** Names whose every declaration in the Android file is an integer type. */
45
+ export function intNames(src: string, kotlin: boolean): Set<string> {
46
+ const ints: Set<string> = new Set();
47
+ const others: Set<string> = new Set();
48
+ if (kotlin) {
49
+ for (const m of src.matchAll(/\b(?:val|var)\s+([a-z_][\w]*)\s*(?::\s*([A-Za-z?]+))?\s*(=\s*([^\n;]+))?/g)) {
50
+ const [, name, type, , init] = m;
51
+ if (type !== undefined) { (/^(Int|Long|Short|Byte)\??$/.test(type) ? ints : others).add(name); continue; }
52
+ // only a bare integer literal: `val alpha = 1 - progress` starts with `1` but is a Float
53
+ if (init !== undefined && /^-?\d+[lL]?$/.test(init.trim())) {
54
+ ints.add(name);
55
+ } else if (init !== undefined && /\.(size|length|count\(\))\s*$/.test(init.trim())) {
56
+ ints.add(name);
57
+ } else { others.add(name); }
58
+ }
59
+ for (const m of src.matchAll(/\bfor\s*\(\s*([a-z_][\w]*)\s+in\s+-?\d+\s*(?:\.\.|until|downTo)/g)) { ints.add(m[1]); }
60
+ // indices of collections
61
+ for (const m of src.matchAll(/\bfor\s*\(\s*([a-z_][\w]*)\s+in\s+[\w.]+\.indices\b/g)) { ints.add(m[1]); }
62
+ } else {
63
+ for (const m of src.matchAll(/\b(int|long|short|byte|float|double|var|Integer|Long|String|boolean|char|[A-Z][\w<>,\s?]*?)\s+([a-z_][\w]*)\s*(?=[=;,:)])/g)) {
64
+ const [, type, name] = m;
65
+ if (/^(if|return|new|else|case)$/.test(type)) { continue; }
66
+ (/^(int|long|short|byte|Integer|Long)$/.test(type) ? ints : others).add(name);
67
+ }
68
+ }
69
+ for (const n of others) { ints.delete(n); }
70
+ return ints;
71
+ }
72
+
73
+ /** An integer operand: a known integer name, or an integer literal without a float suffix or decimal point. */
74
+ const INT_LIT: RegExp = /^\d+[lL]?$/;
75
+
76
+ /**
77
+ * `a / b` divisions in `line` whose both operands are integers (simple names or literals only: a parenthesised or
78
+ * cast operand is left alone). Returns normalised `a / b` texts.
79
+ */
80
+ export function intDivisions(line: string, ints: Set<string>): string[] {
81
+ const out: string[] = [];
82
+ const isInt = (t: string): boolean => INT_LIT.test(t) || ints.has(t);
83
+ for (const m of line.matchAll(/(?<![\w$.)\]])([A-Za-z_$][\w$]*|\d+(?:\.\d*)?[fFdDlL]?)\s*\/(?![/*=])\s*([A-Za-z_$][\w$]*|\d+(?:\.\d*)?[fFdDlL]?)(?![\w$.(\[])/g)) {
84
+ const [, a, b] = m;
85
+ // a cast right before the left operand (`(float) i / 24`) makes it floating
86
+ const before: string = line.slice(0, m.index ?? 0);
87
+ if (/\(\s*(float|double)\s*\)\s*$/.test(before) || /\.to(Float|Double)\(\)\s*$/.test(before)) { continue; }
88
+ // `*` `/` `%` associate left to right: in `1.5f * i / 24` the left operand of `/` is `1.5f * i`, not `i`
89
+ if (/[*/%]\s*$/.test(before)) { continue; }
90
+ if (isInt(a) && isInt(b)) { out.push(`${a.replace(/[lL]$/, '')} / ${b.replace(/[lL]$/, '')}`); }
91
+ }
92
+ return out;
93
+ }
94
+
95
+ /** Whether the division at `idx` in `code` sits inside `Math.trunc(` / `Math.floor(` (any enclosing level). */
96
+ function truncated(code: string, idx: number): boolean {
97
+ let depth: number = 0;
98
+ for (let i = idx - 1; i >= 0 && i > idx - 400; i--) {
99
+ const c: string = code[i];
100
+ if (c === ')') { depth++; } else if (c === '(') {
101
+ if (depth === 0) {
102
+ if (/Math\.(trunc|floor)\s*$/.test(code.slice(Math.max(0, i - 12), i))) { return true; }
103
+ // keep walking out through the next enclosing paren
104
+ } else { depth--; }
105
+ } else if (c === ';' || c === '{' || c === '}') { break; }
106
+ }
107
+ return false;
108
+ }
109
+
110
+ /**
111
+ * GATE java-int-division-not-truncated: an integer division of the Android lines a .ets comment cites is written as a
112
+ * plain `/` in the .ets lines that follow the citation.
113
+ */
114
+ export function checkJavaIntDivision(scans: FileScan[], androidDir: string): void {
115
+ if (androidDir === '') { return; }
116
+ let files: AndroidFile[] | null = null;
117
+ const byName = (n: string): AndroidFile[] => {
118
+ files = files ?? androidFiles(androidDir);
119
+ return files.filter((f) => f.name === n);
120
+ };
121
+ const intCache: Map<string, Set<string>> = new Map();
122
+ for (const s of scans) {
123
+ const rawLines: string[] = s.src.split(/\r?\n/);
124
+ const seen: Set<string> = new Set();
125
+ rawLines.forEach((raw, li) => {
126
+ for (const c of raw.matchAll(CITE)) {
127
+ const [, name, fromS, toS] = c;
128
+ const cands: AndroidFile[] = byName(name);
129
+ if (cands.length !== 1) { continue; } // ambiguous or absent: no guess
130
+ const af: AndroidFile = cands[0];
131
+ const from: number = Number(fromS);
132
+ const to: number = Math.min(toS === undefined ? from : Number(toS), from + MAX_RANGE);
133
+ const asrc: string = af.read();
134
+ if (asrc === '') { continue; }
135
+ let ints: Set<string> | undefined = intCache.get(af.rel);
136
+ if (ints === undefined) { ints = intNames(asrc, path.extname(name) === '.kt'); intCache.set(af.rel, ints); }
137
+ const alines: string[] = asrc.split(/\r?\n/);
138
+ const divs: Set<string> = new Set();
139
+ for (let k = from - 1; k < Math.min(alines.length, to); k++) {
140
+ const code: string = alines[k].replace(/\/\/.*$/, '');
141
+ for (const d of intDivisions(code, ints)) { divs.add(d); }
142
+ }
143
+ if (divs.size === 0) { continue; }
144
+ // The ported expression: same operands, plain `/`, within WINDOW lines from the citation (comments stripped).
145
+ const winStart: number = lineStartIndex(s.code, li + 1);
146
+ const winEnd: number = lineStartIndex(s.code, li + 1 + WINDOW);
147
+ const win: string = s.code.slice(winStart, winEnd);
148
+ for (const d of divs) {
149
+ const [a, b] = d.split(' / ');
150
+ const re: RegExp = new RegExp(`(?<![\\w$.])${esc(a)}\\s*\\/(?![/*=])\\s*${esc(b)}(?![\\w$.(\\[])`, 'g');
151
+ for (const hit of win.matchAll(re)) {
152
+ const at: number = winStart + (hit.index ?? 0);
153
+ if (truncated(s.code, at)) { continue; }
154
+ const line: number = lineOfIndex(s.code, at);
155
+ const key: string = `${line}|${d}`;
156
+ if (seen.has(key) || markedAbove(rawLines, line, 'INT-DIV-OK')) { continue; }
157
+ seen.add(key);
158
+ report('GATE', 'java-int-division-not-truncated', s.rel, line,
159
+ `\`${d}\` is an integer division in ${af.rel}:${from}${to !== from ? `-${to}` : ''} (both operands are ` +
160
+ `integers there, so Java/Kotlin truncate it), but here it is a plain \`/\`, which ArkTS evaluates as a ` +
161
+ `floating-point division — the value changes. Write Math.trunc(${a} / ${b}). If the Android operand is not ` +
162
+ 'really an integer, write // INT-DIV-OK: <basis> above it');
163
+ }
164
+ }
165
+ }
166
+ });
167
+ }
168
+ }
169
+
170
+ const esc = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
171
+
172
+ /** Code index of the start of 1-based line `line` (code.length past the end). */
173
+ function lineStartIndex(code: string, line: number): number {
174
+ let idx: number = 0;
175
+ for (let l = 1; l < line; l++) {
176
+ const nl: number = code.indexOf('\n', idx);
177
+ if (nl < 0) { return code.length; }
178
+ idx = nl + 1;
179
+ }
180
+ return idx;
181
+ }