@buaa_smat/hometrans 26.0.0-devecocli.4 → 26.0.1

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 (632) hide show
  1. package/README.md +433 -0
  2. package/agents/build-fixer.md +1 -2
  3. package/agents/code-reviewer.md +31 -15
  4. package/agents/model-render-worker.md +9 -5
  5. package/dist/cli/config-store.js +128 -0
  6. package/dist/cli/config.js +48 -0
  7. package/dist/cli/editors.json +114 -0
  8. package/dist/cli/env-vars.js +127 -0
  9. package/dist/cli/index.js +73 -0
  10. package/dist/cli/init.js +2513 -0
  11. package/dist/cli/uninstall.js +406 -0
  12. package/dist/platform/compose.js +228 -0
  13. package/dist/platform/frontmatter.js +151 -0
  14. package/dist/platform/installer.js +417 -0
  15. package/dist/platform/registry.js +337 -0
  16. package/dist/platform/transform.js +363 -0
  17. package/dist/platform/types.js +9 -0
  18. package/dist/platform/validate.js +152 -0
  19. package/dist/utils/regex.js +7 -0
  20. package/env-requirements.json +511 -0
  21. package/package.json +169 -11
  22. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  23. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  24. package/resource/choose_editor.png +0 -0
  25. package/resource/convert_pipeline_process.svg +114 -0
  26. package/resource/project_architecture.svg +120 -0
  27. package/resource/set_environment.png +0 -0
  28. package/resource/set_multimodel.png +0 -0
  29. package/resource/set_sdk.png +0 -0
  30. package/resource/title_dark.png +0 -0
  31. package/skills/a2h-app-migrate/SKILL.md +17 -11
  32. package/skills/a2h-app-migrate/references/stage-map.md +22 -7
  33. package/skills/a2h-app-migrate/references/workflow.yaml +276 -209
  34. package/skills/a2h-app-migrate/scripts/android_index.mjs +34 -16
  35. package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +12 -12
  36. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +12 -12
  37. package/skills/a2h-app-migrate/scripts/check_signing.mjs +16 -16
  38. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +17 -16
  39. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +141 -62
  40. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +12 -12
  41. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +26 -26
  42. package/skills/a2h-app-migrate/scripts/cli_values.mjs +7 -7
  43. package/skills/a2h-app-migrate/scripts/ensure_utg_snapshot.mjs +144 -0
  44. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +474 -365
  45. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +115 -108
  46. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +5 -0
  47. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +54 -0
  48. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +6 -6
  49. package/skills/a2h-app-migrate/scripts/json_io.mjs +1 -1
  50. package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -15
  51. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +99 -99
  52. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +25 -25
  53. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +9 -9
  54. package/skills/a2h-app-migrate/scripts/run_dir.mjs +33 -33
  55. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +13 -11
  56. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +128 -80
  57. package/skills/a2h-app-migrate/scripts/write_resume_summary.mjs +349 -0
  58. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +21 -21
  59. package/skills/a2h-arch-generate/scripts/create_project.mjs +23 -23
  60. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +48 -40
  61. package/skills/a2h-arch-generate/scripts/generate_state.mjs +7 -7
  62. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +5 -0
  63. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +54 -0
  64. package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +10 -1
  65. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +41 -36
  66. package/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  67. package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1 -1
  68. package/skills/a2h-arch-generate/scripts/module_create/create.mjs +17 -17
  69. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +54 -50
  70. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +2 -2
  71. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +2 -2
  72. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +2 -2
  73. package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +42 -42
  74. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +69 -44
  75. package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +62 -17
  76. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +5 -4
  77. package/skills/a2h-arkts-logic-coder/SKILL.md +39 -8
  78. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  79. package/skills/a2h-arkts-logic-coder/references/code-generation.md +28 -17
  80. package/skills/{a2h-spec-design/SKILL.md → a2h-arkts-logic-coder/references/spec-design.md} +45 -78
  81. package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +1 -1
  82. package/skills/a2h-arkts-logic-coder/scripts/check_units.ts +448 -0
  83. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +5 -0
  84. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +54 -0
  85. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/inspect_spec_design_inputs.mjs +18 -12
  86. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/lib/py_compat.mjs +1 -1
  87. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/move_spec_technical_reference.mjs +10 -7
  88. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/resolve_module_design.mjs +13 -7
  89. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/validate_spec_design_output.mjs +57 -41
  90. package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +66 -323
  91. package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +66 -108
  92. package/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  93. package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +5 -18
  94. package/skills/a2h-batch-ui-align/SKILL.md +39 -39
  95. package/skills/a2h-batch-ui-align/references/cards/alignment.md +31 -0
  96. package/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  97. package/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  98. package/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  99. package/skills/a2h-batch-ui-align/references/cards/geometry.md +80 -0
  100. package/skills/a2h-batch-ui-align/references/cards/interaction.md +22 -0
  101. package/skills/a2h-batch-ui-align/references/cards/resources.md +83 -0
  102. package/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  103. package/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  104. package/skills/a2h-batch-ui-align/references/cards/widgets.md +38 -0
  105. package/skills/a2h-batch-ui-align/references/cards/window.md +29 -0
  106. package/skills/a2h-batch-ui-align/references/checker-rules.md +642 -0
  107. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +70 -261
  108. package/skills/a2h-batch-ui-align/references/host-dispatch.md +34 -0
  109. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +16 -4
  110. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +3 -1
  111. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +32 -1
  112. package/skills/a2h-batch-ui-align/references/source-only-tier.md +7 -1
  113. 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 +28 -0
  114. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +220 -0
  115. package/skills/a2h-batch-ui-align/references/step3-capture.md +14 -12
  116. package/skills/a2h-batch-ui-align/references/step4-prepare.md +14 -9
  117. package/skills/a2h-batch-ui-align/references/step5-convert.md +21 -18
  118. package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +44 -44
  119. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +237 -236
  120. package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +42 -3854
  121. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +34 -32
  122. package/skills/a2h-batch-ui-align/scripts/detach.mjs +1 -1
  123. package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  124. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +196 -52
  125. package/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  126. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +26 -25
  127. package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +1 -1
  128. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +162 -15
  129. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +145 -21
  130. package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +8 -8
  131. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +1 -1
  132. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +5 -0
  133. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +54 -0
  134. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +228 -0
  135. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +444 -266
  136. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +66 -32
  137. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +141 -57
  138. package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +410 -0
  139. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +80 -0
  140. package/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  141. package/skills/a2h-batch-ui-align/scripts/static_check/core/findings.ts +21 -0
  142. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +22 -0
  143. package/skills/a2h-batch-ui-align/scripts/static_check/core/meta.ts +34 -0
  144. package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +668 -0
  145. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +392 -0
  146. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +167 -0
  147. package/skills/a2h-batch-ui-align/scripts/static_check/package.json +3 -0
  148. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +101 -0
  149. package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +629 -0
  150. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  151. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +67 -0
  152. package/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  153. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  154. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  155. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +71 -0
  156. package/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  157. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +102 -0
  158. package/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  159. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  160. package/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  161. package/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  162. package/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  163. package/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  164. package/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  165. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  166. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +551 -0
  167. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  168. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +310 -0
  169. package/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  170. package/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  171. package/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  172. package/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  173. package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +80 -0
  174. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +64 -0
  175. package/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  176. package/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  177. package/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  178. package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +97 -0
  179. package/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  180. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -0
  181. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  182. package/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  183. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  184. package/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  185. package/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  186. package/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  187. package/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  188. package/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  189. package/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  190. package/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  191. package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  192. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +68 -0
  193. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +153 -0
  194. package/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +65 -65
  195. package/skills/a2h-coldstart-smoke-gate/SKILL.md +8 -6
  196. package/skills/a2h-dashboard-render/SKILL.md +15 -7
  197. package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +5 -35
  198. package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +4 -4
  199. package/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  200. package/skills/a2h-dashboard-render/scripts/check-registry.mjs +17 -17
  201. package/skills/a2h-dashboard-render/scripts/dashboard.css +3546 -0
  202. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +1021 -941
  203. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +104 -65
  204. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +5 -0
  205. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +54 -0
  206. package/skills/a2h-dashboard-render/scripts/page_capture.mjs +8 -8
  207. package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +67 -37
  208. package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +4 -4
  209. package/skills/a2h-fix-build-errors/SKILL.md +1 -2
  210. package/skills/a2h-resource-convert/SKILL.md +1 -3
  211. package/skills/a2h-resource-convert/references/step7-report-template.md +2 -2
  212. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +366 -361
  213. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +170 -170
  214. package/skills/a2h-resource-convert/scripts/app_identity.ts +162 -162
  215. package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +95 -95
  216. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +132 -132
  217. package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +220 -220
  218. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +5 -0
  219. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +54 -0
  220. package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +74 -74
  221. package/skills/a2h-spec-design-pipeline/SKILL.md +113 -63
  222. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +226 -56
  223. package/skills/a2h-spec-design-pipeline/references/execution-model.md +315 -62
  224. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +4 -2
  225. package/skills/a2h-spec-design-pipeline/references/initialization.md +12 -9
  226. package/skills/a2h-spec-design-pipeline/references/legacy-cleanup.md +18 -0
  227. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +109 -8
  228. package/skills/a2h-spec-design-pipeline/references/scripts.md +29 -16
  229. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +116 -8
  230. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +179 -0
  231. package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +33 -5
  232. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +36 -16
  233. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +93 -0
  234. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +915 -0
  235. package/skills/a2h-spec-design-pipeline/scripts/dispatch/ledger.mjs +234 -0
  236. package/skills/a2h-spec-design-pipeline/scripts/dispatch/plan.mjs +33 -0
  237. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +31 -0
  238. package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +94 -0
  239. package/skills/a2h-spec-design-pipeline/scripts/dispatch/state-mirror.mjs +55 -0
  240. package/skills/a2h-spec-design-pipeline/scripts/dispatch/timeouts.mjs +34 -0
  241. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +92 -0
  242. package/skills/a2h-spec-design-pipeline/scripts/dispatch/waker.mjs +60 -0
  243. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +89 -0
  244. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +551 -0
  245. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +267 -33
  246. package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +30 -10
  247. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +634 -0
  248. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +5 -0
  249. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +54 -0
  250. package/skills/a2h-spec-design-pipeline/scripts/lib/io.mjs +33 -0
  251. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +107 -19
  252. package/skills/a2h-spec-design-pipeline/scripts/stage_design_inputs.ts +79 -0
  253. package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +4 -4
  254. package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +121 -38
  255. package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +58 -11
  256. package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +31 -31
  257. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +564 -0
  258. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +339 -0
  259. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +161 -0
  260. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +1024 -0
  261. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_ledger.mjs +178 -0
  262. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_plan.mjs +60 -0
  263. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +58 -0
  264. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +91 -0
  265. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +60 -0
  266. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_waker.mjs +95 -0
  267. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_worktree.mjs +81 -0
  268. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +183 -2
  269. package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +29 -2
  270. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +294 -0
  271. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +70 -0
  272. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +157 -30
  273. package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +2 -2
  274. package/skills/a2h-spec-design-pipeline/scripts/test_stage_design_inputs.ts +72 -0
  275. package/skills/a2h-spec-generate/SKILL.md +34 -10
  276. package/skills/a2h-spec-generate/references/batch-mode.md +4 -1
  277. package/skills/a2h-spec-generate/references/fusion-task-contract.md +90 -21
  278. package/skills/a2h-spec-generate/references/recall-guide.md +1 -0
  279. package/skills/a2h-spec-generate/references/requirement-scope.md +1 -1
  280. package/skills/a2h-spec-generate/references/specs.schema.json +6 -0
  281. package/skills/a2h-spec-generate/references/worker-rules.md +2 -1
  282. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +305 -116
  283. package/skills/a2h-spec-generate/scripts/check_spec.ts +136 -114
  284. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +19 -4
  285. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +74 -14
  286. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +4 -2
  287. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +5 -0
  288. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +54 -0
  289. package/skills/a2h-spec-generate/scripts/parse_requirements.ts +65 -65
  290. package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +8 -2
  291. package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +8 -2
  292. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +80 -5
  293. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +670 -0
  294. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +37 -30
  295. package/skills/a2h-spec-generate/scripts/report.mjs +7 -3
  296. package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +26 -26
  297. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +2 -2
  298. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +2 -2
  299. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +4 -4
  300. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +6 -6
  301. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +3 -3
  302. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +23 -23
  303. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +16 -16
  304. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +27 -26
  305. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +7 -4
  306. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +32 -31
  307. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +3 -2
  308. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +26 -20
  309. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +92 -69
  310. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +7 -3
  311. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +545 -0
  312. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +545 -0
  313. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +177 -2
  314. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +424 -29
  315. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +133 -7
  316. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +302 -103
  317. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/zip.ts +99 -0
  318. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +5 -0
  319. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +54 -0
  320. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +8 -0
  321. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +5 -1
  322. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +39 -33
  323. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +4 -3
  324. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +4 -0
  325. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +48 -6
  326. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +366 -5
  327. package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +102 -3
  328. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +81 -52
  329. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +21 -11
  330. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +2 -1
  331. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +13 -4
  332. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +2 -2
  333. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +2 -2
  334. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +4 -4
  335. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +6 -6
  336. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +3 -3
  337. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +16 -16
  338. package/skills/a2h-utg-explorer/SKILL.md +1 -1
  339. package/skills/a2h-utg-explorer/assets/final_viewer.html +21 -21
  340. package/skills/a2h-utg-explorer/references/architecture.md +9 -4
  341. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +144 -20
  342. package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +21 -3
  343. package/skills/a2h-utg-explorer/scripts/device_health.mjs +91 -6
  344. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +20 -2
  345. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +68 -9
  346. package/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  347. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +5 -0
  348. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +54 -0
  349. package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +229 -0
  350. package/skills/a2h-utg-explorer/scripts/plan.mjs +45 -2
  351. package/skills/a2h-utg-explorer/scripts/recover.mjs +7 -1
  352. package/skills/a2h-utg-explorer/scripts/recover_b.mjs +10 -2
  353. package/skills/a2h-utg-explorer/scripts/report.mjs +38 -18
  354. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +9 -2
  355. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +268 -25
  356. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +194 -8
  357. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +521 -46
  358. package/skills/a2h-utg-static/SKILL.md +8 -1
  359. package/skills/a2h-utg-static/references/view-interactions.md +1 -1
  360. package/skills/a2h-utg-static/scripts/assemble.mjs +35 -5
  361. package/skills/a2h-utg-static/scripts/click_paths.mjs +42 -26
  362. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +23 -5
  363. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +29 -3
  364. package/skills/a2h-utg-static/scripts/compose_titles.mjs +10 -1
  365. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +4 -2
  366. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +5 -0
  367. package/skills/a2h-utg-static/scripts/i18n-term.mjs +54 -0
  368. package/skills/a2h-utg-static/scripts/label_resolve.mjs +51 -2
  369. package/skills/a2h-utg-static/scripts/manifest.mjs +91 -10
  370. package/skills/a2h-utg-static/scripts/nl_hints.mjs +68 -3
  371. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +2 -1
  372. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +374 -0
  373. package/skills/a2h-utg-static/scripts/static_prior.mjs +89 -34
  374. package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +45 -0
  375. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
  376. package/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  377. package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +17 -0
  378. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +155 -0
  379. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +328 -0
  380. package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +50 -0
  381. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  382. package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +3 -0
  383. package/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  384. package/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  385. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +240 -8
  386. package/skills/a2h-utg-static/scripts/utg_html.mjs +51 -51
  387. package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +100 -100
  388. package/devecocli-plugin/common.ts +0 -2203
  389. package/devecocli-plugin/install.ts +0 -61
  390. package/devecocli-plugin/uninstall.ts +0 -26
  391. package/devecocli-plugin/update.ts +0 -66
  392. package/index.js +0 -1418
  393. package/plugin.jsonc +0 -12
  394. package/skills/a2h-app-migrate/test/test_android_index.mjs +0 -80
  395. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +0 -63
  396. package/skills/a2h-app-migrate/test/test_arch_done.mjs +0 -54
  397. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +0 -92
  398. package/skills/a2h-app-migrate/test/test_config_example.mjs +0 -42
  399. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +0 -93
  400. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +0 -544
  401. package/skills/a2h-app-migrate/test/test_finalize.mjs +0 -89
  402. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +0 -146
  403. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +0 -68
  404. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +0 -91
  405. package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -122
  406. package/skills/a2h-app-migrate/test/test_json_io.mjs +0 -32
  407. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +0 -109
  408. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +0 -53
  409. package/skills/a2h-app-migrate/test/test_parse_args.mjs +0 -69
  410. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +0 -93
  411. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +0 -144
  412. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +0 -100
  413. package/skills/a2h-app-migrate/test/test_run_dir.mjs +0 -315
  414. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +0 -133
  415. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +0 -133
  416. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +0 -158
  417. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +0 -181
  418. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +0 -76
  419. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +0 -53
  420. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +0 -226
  421. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +0 -83
  422. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +0 -39
  423. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +0 -168
  424. package/skills/a2h-app-migrate/test/test_validate_races.mjs +0 -50
  425. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +0 -11
  426. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +0 -12
  427. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +0 -8
  428. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +0 -17
  429. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +0 -3
  430. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +0 -1
  431. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +0 -8
  432. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +0 -14
  433. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +0 -7
  434. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +0 -1
  435. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +0 -3
  436. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +0 -7
  437. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +0 -1
  438. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +0 -3
  439. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +0 -7
  440. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +0 -1
  441. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +0 -3
  442. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +0 -1
  443. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +0 -1
  444. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +0 -7
  445. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +0 -9
  446. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +0 -7
  447. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +0 -10
  448. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +0 -6
  449. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +0 -16
  450. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +0 -5
  451. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +0 -548
  452. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +0 -1122
  453. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +0 -191
  454. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +0 -52
  455. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +0 -34
  456. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +0 -138
  457. package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +0 -224
  458. package/skills/a2h-batch-ui-align/flowchart.html +0 -271
  459. package/skills/a2h-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -648
  460. package/skills/a2h-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +0 -2089
  461. package/skills/a2h-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +0 -1033
  462. package/skills/a2h-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -1183
  463. package/skills/a2h-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +0 -576
  464. package/skills/a2h-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +0 -297
  465. package/skills/a2h-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +0 -395
  466. package/skills/a2h-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -903
  467. package/skills/a2h-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +0 -106
  468. package/skills/a2h-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -1178
  469. package/skills/a2h-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +0 -911
  470. package/skills/a2h-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -355
  471. package/skills/a2h-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +0 -11
  472. package/skills/a2h-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +0 -206
  473. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +0 -373
  474. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +0 -158
  475. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +0 -750
  476. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +0 -1704
  477. package/skills/a2h-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +0 -1012
  478. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +0 -164
  479. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +0 -840
  480. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -856
  481. package/skills/a2h-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +0 -83
  482. package/skills/a2h-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -294
  483. package/skills/a2h-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +0 -1407
  484. package/skills/a2h-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -1220
  485. package/skills/a2h-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +0 -47
  486. package/skills/a2h-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +0 -133
  487. package/skills/a2h-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +0 -840
  488. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +0 -217
  489. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +0 -253
  490. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +0 -312
  491. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +0 -241
  492. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +0 -365
  493. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +0 -298
  494. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +0 -365
  495. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +0 -91
  496. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +0 -473
  497. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +0 -356
  498. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +0 -290
  499. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +0 -74
  500. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +0 -31
  501. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +0 -564
  502. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +0 -123
  503. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +0 -126
  504. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +0 -241
  505. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +0 -1451
  506. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +0 -215
  507. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +0 -95
  508. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +0 -115
  509. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +0 -170
  510. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +0 -102
  511. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +0 -244
  512. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +0 -166
  513. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +0 -49
  514. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +0 -219
  515. package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +0 -83
  516. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +0 -1
  517. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +0 -156
  518. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +0 -1
  519. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +0 -1
  520. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +0 -1
  521. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +0 -170
  522. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +0 -99
  523. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +0 -182
  524. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +0 -64
  525. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +0 -1172
  526. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +0 -251
  527. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +0 -81
  528. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +0 -115
  529. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +0 -303
  530. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +0 -147
  531. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +0 -444
  532. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +0 -187
  533. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +0 -351
  534. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +0 -495
  535. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +0 -157
  536. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +0 -388
  537. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +0 -182
  538. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +0 -206
  539. package/skills/a2h-spec-design/test/golden/inspect_happy.json +0 -20
  540. package/skills/a2h-spec-design/test/golden/move_design.md +0 -18
  541. package/skills/a2h-spec-design/test/golden/move_design_crlf.md +0 -18
  542. package/skills/a2h-spec-design/test/golden/move_spec.md +0 -7
  543. package/skills/a2h-spec-design/test/golden/resolve_cases.json +0 -36
  544. package/skills/a2h-spec-design/test/golden/validate_issue_file.md +0 -12
  545. package/skills/a2h-spec-design/test/golden/validate_issues.json +0 -57
  546. package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +0 -381
  547. package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +0 -944
  548. package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +0 -95
  549. package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +0 -218
  550. package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +0 -64
  551. package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +0 -452
  552. package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +0 -182
  553. package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +0 -289
  554. package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +0 -441
  555. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +0 -50
  556. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +0 -75
  557. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +0 -256
  558. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +0 -576
  559. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +0 -290
  560. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +0 -1323
  561. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +0 -574
  562. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +0 -339
  563. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +0 -831
  564. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +0 -548
  565. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +0 -117
  566. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +0 -396
  567. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +0 -175
  568. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +0 -298
  569. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +0 -1061
  570. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +0 -286
  571. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +0 -25
  572. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +0 -159
  573. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +0 -632
  574. package/skills/a2h-spec-generate/test/check-spec.test.ts +0 -200
  575. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +0 -538
  576. package/skills/a2h-spec-generate/test/detect-project.test.mjs +0 -37
  577. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +0 -45
  578. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +0 -147
  579. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +0 -3
  580. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +0 -3
  581. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +0 -3
  582. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +0 -9
  583. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +0 -8
  584. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +0 -9
  585. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +0 -1
  586. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +0 -6
  587. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +0 -4
  588. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +0 -1
  589. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +0 -33
  590. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +0 -1
  591. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +0 -23
  592. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +0 -3
  593. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +0 -8
  594. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +0 -1
  595. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +0 -54
  596. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +0 -157
  597. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +0 -282
  598. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +0 -593
  599. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +0 -66
  600. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +0 -45
  601. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +0 -243
  602. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +0 -104
  603. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +0 -223
  604. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +0 -88
  605. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +0 -187
  606. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +0 -130
  607. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +0 -136
  608. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +0 -135
  609. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +0 -16
  610. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +0 -251
  611. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +0 -42
  612. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +0 -162
  613. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +0 -193
  614. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +0 -204
  615. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +0 -355
  616. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +0 -240
  617. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +0 -212
  618. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +0 -173
  619. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +0 -280
  620. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +0 -213
  621. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +0 -345
  622. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +0 -453
  623. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +0 -131
  624. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +0 -229
  625. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +0 -336
  626. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +0 -102
  627. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +0 -92
  628. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +0 -119
  629. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +0 -346
  630. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +0 -112
  631. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +0 -63
  632. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +0 -24
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Android 模拟器页面遍历工具(加速版, TypeScript 版)
4
- * 功能:BFS 遍历每个页面,保存截图、View XML、Activity/Window 信息,生成 index.json + report.html。
3
+ * Android emulator page traversal tool (fast version, TypeScript edition)
4
+ * Features: BFS-traverses every page, saves screenshot, View XML, Activity/Window info, and generates index.json + report.html.
5
5
  *
6
- * 零第三方依赖,仅使用 Node 内置模块,可独立分发。
7
- * 等价于原 android_parse_fast.py(functional equivalence)。
6
+ * Zero third-party dependencies, only Node built-in modules; can be distributed standalone.
7
+ * Equivalent to the original android_parse_fast.py (functional equivalence).
8
8
  *
9
- * 用法:
9
+ * Usage:
10
10
  * node android_parse_fast.ts --package <pkg> --output <dir> [--device serial] [--adb-path adb]
11
- * [--max-pages 500] [--max-scrolls 10] [--manual] [--page "<描述>"]
11
+ * [--max-pages 500] [--max-scrolls 10] [--manual] [--page "<description>"]
12
12
  */
13
13
 
14
14
  import { spawnSync, type SpawnSyncReturns } from 'node:child_process';
@@ -17,13 +17,14 @@ import * as path from 'node:path';
17
17
  import * as readline from 'node:readline';
18
18
  import { createHash } from 'node:crypto';
19
19
  import { pathToFileURL } from 'node:url';
20
+ import { term } from './i18n-term.mjs';
20
21
 
21
22
  // ─────────────────────────────────────────────
22
- // 默认配置值
23
+ // Default configuration values
23
24
  // ─────────────────────────────────────────────
24
25
  const ADB_PATH_DEFAULT = process.env.ADB_PATH || 'adb';
25
- // 不指定 = 不加 -s:adb 自己按 ANDROID_SERIAL / 唯一在线设备选择。写死 emulator-5554 会让真机或
26
- // 其他端口的模拟器全部抓取失败(首屏就拿不到,整轮 0 页)。
26
+ // Unset = no -s: adb picks by ANDROID_SERIAL / the only online device. Hard-coding emulator-5554 makes capture fail on real devices or
27
+ // emulators on other ports (the first screen cannot be fetched; the whole run yields 0 pages).
27
28
  const DEVICE_SERIAL_DEFAULT = '';
28
29
  const IDLE_POLL_INTERVAL_DEFAULT = 0.2;
29
30
  const IDLE_TIMEOUT_DEFAULT = 5;
@@ -46,7 +47,7 @@ function sleep(seconds: number): void {
46
47
  }
47
48
 
48
49
  // ─────────────────────────────────────────────
49
- // 最小 XML 解析器(等价 xml.etree 的 root.iter("node") + get 属性)
50
+ // Minimal XML parser (equivalent to xml.etree root.iter("node") + get attribute)
50
51
  // ─────────────────────────────────────────────
51
52
  interface XmlNode {
52
53
  tag: string;
@@ -152,7 +153,7 @@ function extractInts(s: string): number[] {
152
153
  }
153
154
 
154
155
  // ─────────────────────────────────────────────
155
- // 元素/签名 纯函数(等价 PageCrawler 的 @staticmethod)
156
+ // Element/signature pure functions (equivalent to PageCrawler @staticmethod)
156
157
  // ─────────────────────────────────────────────
157
158
  interface ClickableElement {
158
159
  class: string;
@@ -187,7 +188,7 @@ function getClickableElements(xmlContent: string): ClickableElement[] {
187
188
  try {
188
189
  root = parseXml(xmlContent);
189
190
  } catch (e) {
190
- console.log(` [WARN] XML 解析失败: ${(e as Error).message}`);
191
+ console.log(` [WARN] XML parse failed: ${(e as Error).message}`);
191
192
  return elements;
192
193
  }
193
194
 
@@ -345,16 +346,16 @@ function isSameRootPage(rootInfo: RootIdentity, currentInfo: RootIdentity, thres
345
346
  return union > 0 && inter / union >= threshold;
346
347
  }
347
348
 
348
- /** current_focus 是否含 `package/activity` 分量(弹窗/overlay 焦点没有)。 */
349
+ /** Whether current_focus contains a `package/activity` component (dialog/overlay focus does not). */
349
350
  function focusHasActivityComponent(activityInfo: Record<string, string>): boolean {
350
351
  return /[\w.]+\/[\w.]+/.test(activityInfo['current_focus'] ?? '');
351
352
  }
352
353
 
353
354
  /**
354
- * 从已采集的首屏 activity_info 里取"根页面 Activity"的短名,用于 restartToRoot 判定是否已回到根页。
355
+ * Take the short name of the "root page Activity" from the already-captured first-screen activity_info; restartToRoot uses it to decide whether it is back on the root page.
355
356
  *
356
- * 必须用**实际落地的首屏**,而不是启动组件:入口可能是 trampoline
357
- * (com.ichi2.anki/.IntentHandler),落地页却是 DeckPicker,用入口短名做关键字会永远判不到根页。
357
+ * Must use the **actually landed first screen**, not the launch component: the entry may be a trampoline
358
+ * (com.ichi2.anki/.IntentHandler) while the landing page is DeckPicker; using the entry short name as the keyword would never match the root page.
358
359
  */
359
360
  function rootKeywordFromActivityInfo(activityInfo: Record<string, string> | undefined): string | null {
360
361
  for (const key of ['resumed_activity', 'current_focus', 'focused_app']) {
@@ -371,9 +372,9 @@ function rootKeywordFromActivityInfo(activityInfo: Record<string, string> | unde
371
372
  }
372
373
 
373
374
  /**
374
- * 从 activity 信息提取启动组件 [package, activity]。
375
- * 优先 current_focus(通常是全限定 Activity),回退 resumed_activity(可能是相对名 `.ui.Main`,
376
- * am start 同样接受)。都取不到返回 null。
375
+ * Extract the launch component [package, activity] from activity info.
376
+ * Prefer current_focus (usually a fully qualified Activity), fall back to resumed_activity (may be a relative name `.ui.Main`,
377
+ * which am start also accepts). Returns null if neither is available.
377
378
  */
378
379
  function extractLaunchComponent(activityInfo: Record<string, string>): [string, string] | null {
379
380
  for (const key of ['current_focus', 'resumed_activity']) {
@@ -421,32 +422,32 @@ function findElementOnScreen(xmlContent: string, elemId: ElemId | [string, strin
421
422
  }
422
423
 
423
424
  // ─────────────────────────────────────────────
424
- // 设备常量:密度与物理分辨率
425
+ // Device constants: density and physical resolution
425
426
  // ─────────────────────────────────────────────
426
427
  /**
427
- * 采集设备的密度与分辨率 —— 每页写进 meta.json 的 `device_info` 字段。
428
+ * Capture device density and resolution -- written into each page's meta.json `device_info` field.
428
429
  *
429
- * 为什么必须在采集期记:密度是「同一台设备上每页同值」的常量,而下游 measure_pack
430
- * 只能拿 view tree 里正方形节点的边长去**反解**它。反解在数学上不唯一 —— 72px 既能解释成
431
- * 24dp@3.0,也能解释成 36dp@2.0 / 48dp@1.5,整个谐波族全部自洽;工具栏图标尺寸单一的页面
432
- * 更是必然平局。一旦解错,该页所有 vp 数值整体差 2~3 倍,而编译、引用检查、跨页一致性
433
- * 全都照样通过(因为每页错得一样)。`wm density` 一行就能拿到真值,采集期不记 = 主动丢弃它。
430
+ * Why it must be recorded at capture time: density is a constant "identical on every page of the same device", while downstream measure_pack
431
+ * can only **back-solve** it from the side length of square nodes in the view tree. Back-solving is mathematically non-unique -- 72px can be
432
+ * 24dp@3.0, or 36dp@2.0 / 48dp@1.5; the whole harmonic family is self-consistent; pages with a single toolbar icon size
433
+ * are guaranteed ties. Once solved wrong, all vp values on that page are off by 2-3x, yet compilation, reference checks and cross-page consistency
434
+ * all still pass (since every page is wrong the same way). `wm density` gives the true value in one line; not recording it at capture time = discarding it.
434
435
  */
435
436
  interface DeviceInfo {
436
- /** 生效 dpi(覆盖优先)。取不到为 null。 */
437
+ /** Effective dpi (override takes precedence). null if unavailable. */
437
438
  dpi: number | null;
438
- /** dpi / 160,即 ArkUI 侧 px→vp 的换算系数。取不到为 null。 */
439
+ /** dpi / 160, i.e. the px->vp conversion factor on the ArkUI side. null if unavailable. */
439
440
  density: number | null;
440
- /** 密度取自哪条来源,便于复核。 */
441
+ /** Which source the density came from, for review. */
441
442
  density_source: 'wm density (override)' | 'wm density (physical)' | 'unavailable';
442
443
  width_px: number | null;
443
444
  height_px: number | null;
444
- /** 原始输出,供人工核对(`wm density` 改过的设备两行值不同)。 */
445
+ /** Raw output for manual checking (the two lines differ on devices changed via `wm density`). */
445
446
  raw: { wm_density: string; wm_size: string };
446
447
  }
447
448
 
448
449
  // ─────────────────────────────────────────────
449
- // ADBHelper:封装所有 ADB 设备通信与交互操作
450
+ // ADBHelper: wraps all ADB device communication and interaction
450
451
  // ─────────────────────────────────────────────
451
452
  class ADBHelper {
452
453
  adbPath: string;
@@ -454,11 +455,11 @@ class ADBHelper {
454
455
  idlePollInterval: number;
455
456
  idleTimeout: number;
456
457
  scrollDurationMs: number;
457
- /** 目标 App 包名;多屏设备(车机等)上用于从多条 focus/resumed 行中挑出正确的那条。 */
458
+ /** Target app package name; on multi-display devices (car head units etc.) used to pick the right line among multiple focus/resumed lines. */
458
459
  targetPackage: string | null;
459
- /** screencap -d 用的物理 display id 缓存;undefined=未解析,null=解析失败(退回无 -d)。 */
460
+ /** Cached physical display id for screencap -d; undefined = not resolved, null = resolution failed (fall back to no -d). */
460
461
  private cachedPhysicalDisplayId: string | null | undefined = undefined;
461
- /** 设备密度/分辨率缓存;整轮遍历只查一次(密度不会中途变)。 */
462
+ /** Device density/resolution cache; queried only once per traversal (density does not change mid-run). */
462
463
  private cachedDeviceInfo: DeviceInfo | undefined = undefined;
463
464
 
464
465
  constructor(opts: {
@@ -497,17 +498,17 @@ class ADBHelper {
497
498
  if (res.error) {
498
499
  const code = (res.error as NodeJS.ErrnoException).code;
499
500
  if (code === 'ETIMEDOUT') {
500
- console.log(` [WARN] adb 命令超时: ${args.join(' ')}`);
501
+ console.log(` [WARN] adb command timed out: ${args.join(' ')}`);
501
502
  return '';
502
503
  }
503
504
  if (code === 'ENOENT') {
504
- throw new Error('找不到 adb,请确认已安装并配置 PATH,或修改 ADB_PATH');
505
+ throw new Error('adb not found; make sure it is installed and on PATH, or set ADB_PATH');
505
506
  }
506
507
  }
507
508
  const out = res.stdout ?? Buffer.alloc(0);
508
- // adb 的 `am start` 等子命令失败时把原因写到 stderr(如 SecurityException:
509
- // Permission Denial —— 目标 Activity 未 exported)。只读 stdout 会把整条原因丢掉,
510
- // 上层只能看到"没到达目标页面"这种误导性结论。
509
+ // When adb subcommands like `am start` fail, the reason goes to stderr (e.g. SecurityException:
510
+ // Permission Denial -- target Activity not exported). Reading only stdout drops the whole reason,
511
+ // and the upper layer only sees a misleading "did not reach target page" conclusion.
511
512
  const err = (res.stderr ?? Buffer.alloc(0)).toString('utf-8').trim();
512
513
  if (err && res.status !== 0) {
513
514
  console.log(` [ADB-ERR] ${args.join(' ')}`);
@@ -517,14 +518,14 @@ class ADBHelper {
517
518
  }
518
519
 
519
520
  /**
520
- * 问系统要目标包真正可启动的 launcher 入口组件。
521
+ * Ask the system for the target package's actually launchable launcher entry component.
521
522
  *
522
- * 不能用"当前前台窗口的 Activity"代替:很多 App 的首屏 Activity 是
523
- * `exported="false"` 的(AnkiDroid 的 DeckPicker 就是),真正的入口是一个
524
- * exported 的 trampoline(IntentHandler)。拿首屏 Activity 去 `am start -n`
525
- * 会被系统以 SecurityException 拒绝,App 根本起不来。
523
+ * Cannot substitute "the Activity of the current foreground window": in many apps the first-screen Activity is
524
+ * `exported="false"` (AnkiDroid's DeckPicker is one); the real entry is an
525
+ * exported trampoline (IntentHandler). Running `am start -n` with the first-screen Activity
526
+ * is rejected by the system with SecurityException, and the app never starts.
526
527
  *
527
- * @returns 形如 "com.ichi2.anki/.IntentHandler",解析失败返回 null
528
+ * @returns e.g. "com.ichi2.anki/.IntentHandler"; null if parsing fails
528
529
  */
529
530
  resolveLauncherActivity(pkg: string): string | null {
530
531
  const out = this.shell(['cmd', 'package', 'resolve-activity', '--brief', pkg], 20);
@@ -541,10 +542,10 @@ class ADBHelper {
541
542
  }
542
543
 
543
544
  /**
544
- * 读取设备密度与物理分辨率(整轮只查一次,结果缓存)。
545
+ * Read device density and physical resolution (queried once per run, result cached).
545
546
  *
546
- * 覆盖密度(`wm density N` 改过的设备)**优先于**物理密度 —— UI 实际按覆盖值布局,
547
- * 拿物理值去换算会得到一套系统性偏移的 vp。
547
+ * Override density (devices changed via `wm density N`) **takes precedence over** physical density -- the UI is laid out by the override,
548
+ * and converting with the physical value yields systematically offset vp.
548
549
  */
549
550
  deviceInfo(): DeviceInfo {
550
551
  if (this.cachedDeviceInfo !== undefined) return this.cachedDeviceInfo;
@@ -567,21 +568,21 @@ class ADBHelper {
567
568
  raw: { wm_density: densRaw, wm_size: sizeRaw },
568
569
  };
569
570
  if (info.density === null) {
570
- console.log(' [WARN] `wm density` 未返回可解析的密度,下游 measure_pack 只能反解(结果可能不唯一)');
571
+ console.log(' [WARN] `wm density` returned no parsable density; downstream measure_pack can only infer it (the result may be ambiguous)');
571
572
  } else {
572
- console.log(` 设备密度: ${info.density} (${info.dpi}dpi, ${info.density_source})`
573
- + (info.width_px ? ` 分辨率 ${info.width_px}x${info.height_px}` : ''));
573
+ console.log(` device density: ${info.density} (${info.dpi}dpi, ${info.density_source})`
574
+ + (info.width_px ? ` resolution ${info.width_px}x${info.height_px}` : ''));
574
575
  }
575
576
  this.cachedDeviceInfo = info;
576
577
  return info;
577
578
  }
578
579
 
579
580
  /**
580
- * 等目标包在**当前焦点窗口**里稳定下来,返回是否等到。
581
+ * Wait until the target package settles in the **current focused window**; returns whether it did.
581
582
  *
582
- * 与 waitForIdle() 的区别:这里要求焦点窗口非 null 且属于目标包。
583
- * 透明 trampoline(如 AnkiDroid 的 IntentHandler)过场时 mCurrentFocus=null,
584
- * 对 waitForIdle() 来说"稳定",但对 uiautomator 来说不可 dump。
583
+ * Difference from waitForIdle(): here the focused window must be non-null and belong to the target package.
584
+ * During a transparent trampoline transition (e.g. AnkiDroid's IntentHandler) mCurrentFocus=null,
585
+ * which is "stable" for waitForIdle() but not dumpable for uiautomator.
585
586
  */
586
587
  waitForPackageForeground(pkg: string, timeoutSec = 12): boolean {
587
588
  const deadline = Date.now() + timeoutSec * 1000;
@@ -590,7 +591,7 @@ class ADBHelper {
590
591
  while (Date.now() < deadline) {
591
592
  const info = this.getCurrentActivity();
592
593
  const focus = info['current_focus'] ?? '';
593
- // 必须是"有焦点窗口 + 焦点属于目标包",null 焦点不算落地。
594
+ // Must be "has a focused window + focus belongs to target package"; null focus does not count as landed.
594
595
  const ok = !/=null\b/.test(focus) && focus.includes(pkg) && /[\w.]+\/[\w.$]+/.test(focus);
595
596
  if (ok && focus === prev) {
596
597
  stableCount += 1;
@@ -614,8 +615,8 @@ class ADBHelper {
614
615
  const transitionOut = this.shell(['dumpsys', 'window', 'animator']);
615
616
  if (transitionOut.includes('Transition ready') || transitionOut.includes('Running animations')) continue;
616
617
  const focusOut = this.shell(['dumpsys', 'window']);
617
- // 多屏设备上每个 display 各有一条 mCurrentFocus,全部拼起来做稳定性比较,
618
- // 避免只看副屏那条(常为 null,永远"稳定")而误判 UI 已空闲。
618
+ // On multi-display devices each display has its own mCurrentFocus line; concatenate all for the stability comparison,
619
+ // to avoid looking only at the secondary display line (often null, always "stable") and misjudging the UI as idle.
619
620
  const currentFocus = focusOut
620
621
  .split(/\r?\n/)
621
622
  .filter((line) => line.includes('mCurrentFocus'))
@@ -624,7 +625,7 @@ class ADBHelper {
624
625
  if (currentFocus && currentFocus === prevFocus) return;
625
626
  prevFocus = currentFocus;
626
627
  }
627
- console.log(` [WARN] 等待 UI 空闲超时 (${this.idleTimeout}s),继续执行`);
628
+ console.log(` [WARN] timed out waiting for the UI to go idle (${this.idleTimeout}s), continuing`);
628
629
  }
629
630
 
630
631
  checkDevice(): boolean {
@@ -632,44 +633,44 @@ class ADBHelper {
632
633
  const lines = out.split(/\r?\n/).filter((l) => l.trim() && !l.includes('List of devices'));
633
634
  const online = lines.filter((l) => l.includes('device') && !l.includes('offline'));
634
635
  if (online.length === 0) {
635
- console.log(' 未检测到在线设备,请先启动模拟器并确认 adb devices 有输出');
636
+ console.log(' no online device detected; start the emulator first and check that adb devices lists it');
636
637
  return false;
637
638
  }
638
639
  const onlineDevices = online.map((line) => line.split(/\s+/)[0]);
639
- console.log(` 在线设备: [${onlineDevices.map((d) => `'${d}'`).join(', ')}]`);
640
- // 未指定时与 adb 自身规则一致:ANDROID_SERIAL,否则唯一在线设备;多台在线不替用户挑。
641
- // 指定的设备不在线 → 失败,绝不悄悄换到另一台上抓(抓到的是另一个 App 状态 / 另一块屏幕)。
640
+ console.log(` online devices: [${onlineDevices.map((d) => `'${d}'`).join(', ')}]`);
641
+ // When unspecified, follow adb's own rule: ANDROID_SERIAL, else the only online device; with several online, do not pick for the user.
642
+ // Specified device not online -> fail; never silently switch to another device (it would capture another app state / another screen).
642
643
  const envSerial = (process.env.ANDROID_SERIAL || '').trim();
643
644
  if (!this.deviceSerial && envSerial) this.deviceSerial = envSerial;
644
645
  if (!this.deviceSerial) {
645
646
  if (onlineDevices.length > 1) {
646
- console.log(` [ERR] ${onlineDevices.length} 台在线设备,请用 --device <serial> 或 ANDROID_SERIAL 指定抓取用哪台`);
647
+ console.log(` [ERR] ${onlineDevices.length} online devices; pick the one to capture with --device <serial> or ANDROID_SERIAL`);
647
648
  return false;
648
649
  }
649
650
  this.deviceSerial = onlineDevices[0];
650
- console.log(` 未指定设备,使用唯一在线设备: ${this.deviceSerial}`);
651
+ console.log(` no device given, using the only online device: ${this.deviceSerial}`);
651
652
  } else if (!onlineDevices.includes(this.deviceSerial)) {
652
- console.log(` [ERR] 指定的设备 ${this.deviceSerial} 不在线(在线: ${onlineDevices.join(', ')})`);
653
+ console.log(` [ERR] the given device ${this.deviceSerial} is not online (online: ${onlineDevices.join(', ')})`);
653
654
  return false;
654
655
  } else {
655
- console.log(` 使用指定的设备: ${this.deviceSerial}`);
656
+ console.log(` using the given device: ${this.deviceSerial}`);
656
657
  }
657
658
  return true;
658
659
  }
659
660
 
660
661
  /**
661
- * 从多条候选行中挑一条最可信的。
662
- * 多屏设备(车机 / 折叠屏 / cluster+主屏)上,`dumpsys window` 与
663
- * `dumpsys activity activities` 会为**每个 display 各输出一条**
664
- * mCurrentFocus / topResumedActivity,其中副屏那条常常是 `null` 或系统
665
- * launcher。因此不能取第一条就 break:优先取包含目标包名的那条,
666
- * 其次取任意带 `pkg/activity` 组件名的非 null 行,最后兜底第一条。
662
+ * Pick the most trustworthy line among multiple candidates.
663
+ * On multi-display devices (car units / foldables / cluster+main screen), `dumpsys window` and
664
+ * `dumpsys activity activities` output **one line per display** for
665
+ * mCurrentFocus / topResumedActivity, where the secondary display line is often `null` or the system
666
+ * launcher. So we cannot just take the first and break: prefer the line containing the target package,
667
+ * then any non-null line with a `pkg/activity` component name, and finally fall back to the first line.
667
668
  */
668
669
  private pickBestLine(lines: string[]): string | undefined {
669
670
  if (lines.length === 0) return undefined;
670
- // 不要"优先挑含目标包的行":目标包不在前台时,那样会翻出一条陈旧或次要的
671
- // 含包名行,伪造出"目标 App 在前台"的假象,使 isInTargetApp() 误判为真,
672
- // 于是把别的 App 的界面当目标页面采下来。前台判定必须忠实反映当前状态。
671
+ // Do not "prefer lines containing the target package": when the target package is not in foreground, that would dig up a stale or secondary
672
+ // line containing the package name, faking "target app in foreground", making isInTargetApp() wrongly true,
673
+ // and another app's screen gets captured as the target page. The foreground check must faithfully reflect the current state.
673
674
  const withComponent = lines.find((l) => !/=null\b/.test(l) && /[\w.]+\/[\w.]+/.test(l));
674
675
  return withComponent ?? lines[0];
675
676
  }
@@ -677,9 +678,9 @@ class ADBHelper {
677
678
  getCurrentActivity(): Record<string, string> {
678
679
  const info: Record<string, string> = {};
679
680
  const actOut = this.shell(['dumpsys', 'activity', 'activities']);
680
- // 必须用 `window displays` 而不是 `window`:后者的输出里可能夹着
681
- // `Last ANR continued` 段落中的历史 DISPLAY CONTENTS 快照,pickBestLine()
682
- // 会取到那份陈旧的 mCurrentFocus(实测为一个无关 App)。
681
+ // Must use `window displays` rather than `window`: the latter's output may include
682
+ // historical DISPLAY CONTENTS snapshots inside the `Last ANR continued` section; pickBestLine()
683
+ // would pick that stale mCurrentFocus (observed to be an unrelated app).
683
684
  const winOut = this.shell(['dumpsys', 'window', 'displays']);
684
685
 
685
686
  const resumedLines: string[] = [];
@@ -741,16 +742,16 @@ class ADBHelper {
741
742
  }
742
743
 
743
744
  /**
744
- * 解析目标 App 所在屏幕的 SurfaceFlinger **物理** display id(screencap -d 只认物理 id,
745
- * 逻辑 id 如 0/2/3 会直接 "Failed to take screenshot. Status: -2")。
745
+ * Resolve the SurfaceFlinger **physical** display id of the screen hosting the target app (screencap -d only accepts physical ids;
746
+ * logical ids like 0/2/3 fail directly with "Failed to take screenshot. Status: -2").
746
747
  *
747
- * 多屏设备(车机 cluster + 主屏、折叠屏等)上不传 -d 时,screencap 会先往 stdout
748
- * 打一段 "[Warning] Multiple displays were found..." 文本,把 PNG 二进制整体前移
749
- * 导致图片打不开;且它"默认取第一个 display",不保证就是 App 所在那块屏。
748
+ * On multi-display devices (car cluster + main screen, foldables etc.) without -d, screencap first writes to stdout
749
+ * a "[Warning] Multiple displays were found..." text, shifting the whole PNG binary forward
750
+ * so the image cannot be opened; and it "defaults to the first display", not necessarily the one hosting the app.
750
751
  *
751
- * 流程:dumpsys activity activities 找到目标包所在的 `Display #N`
752
- * → dumpsys display 里用 `displayId N,` 所在行的 uniqueId "local:<physId>" 取物理 id。
753
- * 单屏设备解析失败时返回 null,退回不带 -d 的老行为(此时也不会有警告)。
752
+ * Flow: dumpsys activity activities finds the `Display #N` hosting the target package
753
+ * -> in dumpsys display, take the physical id from uniqueId "local:<physId>" on the line with `displayId N,`.
754
+ * On single-display devices resolution fails and returns null, falling back to the old no -d behavior (no warning then either).
754
755
  */
755
756
  private resolveTargetPhysicalDisplayId(): string | null {
756
757
  if (this.cachedPhysicalDisplayId !== undefined) return this.cachedPhysicalDisplayId;
@@ -770,7 +771,7 @@ class ADBHelper {
770
771
  }
771
772
  if (logicalId !== null) {
772
773
  const dispOut = this.shell(['dumpsys', 'display']);
773
- // 逐行扫描:DisplayInfo 是单行长串,`displayId <N>,` 与 uniqueId 同行。
774
+ // Line-by-line scan: DisplayInfo is one long line; `displayId <N>,` and uniqueId are on the same line.
774
775
  for (const line of dispOut.split(/\r?\n/)) {
775
776
  if (!line.includes(`displayId ${logicalId},`)) continue;
776
777
  const m = line.match(/uniqueId "local:(\d+)"/);
@@ -784,7 +785,7 @@ class ADBHelper {
784
785
  } catch {
785
786
  result = null;
786
787
  }
787
- if (result) console.log(` [INFO] 截图目标 display 物理 id: ${result}`);
788
+ if (result) console.log(` [INFO] screenshot target display physical id: ${result}`);
788
789
  this.cachedPhysicalDisplayId = result;
789
790
  return result;
790
791
  }
@@ -800,16 +801,16 @@ class ADBHelper {
800
801
  windowsHide: true,
801
802
  }) as SpawnSyncReturns<Buffer>;
802
803
  if (res.error && (res.error as NodeJS.ErrnoException).code === 'ETIMEDOUT') {
803
- console.log(' [WARN] 截图超时');
804
+ console.log(' [WARN] screenshot timed out');
804
805
  return null;
805
806
  }
806
807
  const out = res.stdout ?? Buffer.alloc(0);
807
808
  if (out.length === 0) return null;
808
- // 兜底:无论如何都从 PNG magic 处截断,剥掉 screencap 可能前置到 stdout 的警告文本。
809
+ // Fallback: always truncate at the PNG magic, stripping any warning text screencap may prepend to stdout.
809
810
  const magic = Buffer.from([0x89, 0x50, 0x4e, 0x47]);
810
811
  const at = out.indexOf(magic);
811
812
  if (at < 0) {
812
- console.log(` [WARN] 截图输出不含 PNG 数据: ${out.subarray(0, 120).toString('utf-8').trim()}`);
813
+ console.log(` [WARN] screenshot output contains no PNG data: ${out.subarray(0, 120).toString('utf-8').trim()}`);
813
814
  return null;
814
815
  }
815
816
  return at === 0 ? out : out.subarray(at);
@@ -823,7 +824,7 @@ class ADBHelper {
823
824
  } else {
824
825
  const remotePath = '/sdcard/screenshot.png';
825
826
  const physId = this.resolveTargetPhysicalDisplayId();
826
- // 落盘到设备再 pull 时同样要指定 display,否则多屏下可能抓到副屏。
827
+ // When saving to device then pulling, the display must also be specified, or a secondary display may be captured on multi-display devices.
827
828
  if (physId) this.shell(['screencap', '-d', physId, '-p', remotePath]);
828
829
  else this.shell(['screencap', '-p', remotePath]);
829
830
  sleep(0.3);
@@ -846,12 +847,12 @@ class ADBHelper {
846
847
  }
847
848
 
848
849
  flushPendingPulls(): void {
849
- // TS 版截图为同步写入,无异步 pull 队列,保留空实现以对齐调用点。
850
+ // The TS version writes screenshots synchronously with no async pull queue; keep an empty implementation to match call sites.
850
851
  }
851
852
  }
852
853
 
853
854
  // ─────────────────────────────────────────────
854
- // 队列项 / 记录类型
855
+ // Queue item / record types
855
856
  // ─────────────────────────────────────────────
856
857
  interface ScrollInfo {
857
858
  scroll_index: number;
@@ -874,7 +875,7 @@ interface PageRecord {
874
875
  label: string;
875
876
  timestamp: string;
876
877
  activity_info: Record<string, string>;
877
- /** 采集设备的密度/分辨率真值;measure_pack 优先采用,避免反解歧义。 */
878
+ /** Captured true device density/resolution; measure_pack prefers it to avoid back-solving ambiguity. */
878
879
  device_info?: DeviceInfo;
879
880
  clickable_count: number;
880
881
  clickable_elements: ClickableElement[];
@@ -902,7 +903,7 @@ function escapeHtml(s: string): string {
902
903
  }
903
904
 
904
905
  // ─────────────────────────────────────────────
905
- // PageCrawler:UI 遍历逻辑、页面采集、断点续跑、报告生成
906
+ // PageCrawler: UI traversal logic, page capture, checkpoint resume, report generation
906
907
  // ─────────────────────────────────────────────
907
908
  class PageCrawler {
908
909
  adb: ADBHelper;
@@ -912,7 +913,7 @@ class PageCrawler {
912
913
  maxScrolls: number;
913
914
  skipPatterns: string[];
914
915
 
915
- // 运行时状态
916
+ // Runtime state
916
917
  pagesIndex: PageRecord[] = [];
917
918
  visitedSignatures = new Set<string>();
918
919
  pathSignatures: Record<string, string> = {};
@@ -988,7 +989,7 @@ class PageCrawler {
988
989
  const newXml = this.adb.dumpXmlQuick();
989
990
  const newKeys = extractNodeKeys(newXml);
990
991
  if (prevKeys !== null && setsEqual(newKeys, prevKeys)) {
991
- console.log(` 📜 滚动 ${i + 1} 次后到达底部,跳过截图`);
992
+ console.log(` 📜 reached the bottom after ${i + 1} scroll(s), skipping the screenshot`);
992
993
  break;
993
994
  }
994
995
  prevKeys = newKeys;
@@ -1001,7 +1002,7 @@ class PageCrawler {
1001
1002
  if (data) {
1002
1003
  fs.writeFileSync(ssPath, data);
1003
1004
  screenshotPaths.push(ssPath);
1004
- console.log(` 📸 滚动 ${i + 1}: XML + 截图已保存`);
1005
+ console.log(` 📸 scroll ${i + 1}: XML + screenshot saved`);
1005
1006
  }
1006
1007
  }
1007
1008
  return { xmlList, xmlPaths, screenshotPaths };
@@ -1017,15 +1018,15 @@ class PageCrawler {
1017
1018
  if (fs.existsSync(tmpDir)) fs.rmSync(tmpDir, { recursive: true, force: true });
1018
1019
  fs.mkdirSync(tmpDir, { recursive: true });
1019
1020
 
1020
- console.log(`\n📄 [采集中] ${label}`);
1021
+ console.log(`\n📄 [capturing] ${label}`);
1021
1022
  const actInfo = this.adb.getCurrentActivity();
1022
1023
  console.log(` Focus : ${actInfo['current_focus'] ?? 'N/A'}`);
1023
1024
  console.log(` Activity: ${actInfo['resumed_activity'] ?? 'N/A'}`);
1024
1025
 
1025
1026
  const xmlContent = this.adb.getViewXmlFast(tmpDir);
1026
- console.log(` View XML 已保存 (${Buffer.byteLength(xmlContent, 'utf-8')} bytes)`);
1027
+ console.log(` View XML saved (${Buffer.byteLength(xmlContent, 'utf-8')} bytes)`);
1027
1028
  this.adb.takeScreenshot(tmpDir);
1028
- console.log(' 截图已保存');
1029
+ console.log(' screenshot saved');
1029
1030
 
1030
1031
  const allScreenshots = [path.join(tmpDir, 'screenshot.png')];
1031
1032
  const allViewXmls = [path.join(tmpDir, 'view.xml')];
@@ -1033,13 +1034,13 @@ class PageCrawler {
1033
1034
  const scrollContainers = findScrollableContainers(xmlContent);
1034
1035
  if (scrollContainers.length > 0) {
1035
1036
  const container = scrollContainers[0];
1036
- console.log(` 📜 检测到可滚动容器: ${container.class} ${container['resource-id']}`);
1037
+ console.log(` 📜 scrollable container detected: ${container.class} ${container['resource-id']}`);
1037
1038
  const { xmlList, xmlPaths, screenshotPaths } = this.scrollAndDump(tmpDir, container.bounds, xmlContent);
1038
1039
  if (xmlList.length > 0) {
1039
1040
  allXmlContents.push(...xmlList);
1040
1041
  allViewXmls.push(...xmlPaths);
1041
1042
  allScreenshots.push(...screenshotPaths);
1042
- console.log(` 📜 滚动采集完成:${xmlList.length} 次滚动,共 ${allScreenshots.length} 张截图`);
1043
+ console.log(` 📜 scroll capture done: ${xmlList.length} scroll(s), ${allScreenshots.length} screenshot(s) in total`);
1043
1044
  }
1044
1045
  }
1045
1046
 
@@ -1062,7 +1063,7 @@ class PageCrawler {
1062
1063
  }
1063
1064
  }
1064
1065
  });
1065
- console.log(` 可点击元素: ${clickable.length} 个`);
1066
+ console.log(` clickable elements: ${clickable.length}`);
1066
1067
 
1067
1068
  const scrollContainerBounds = scrollContainers.length > 0 ? scrollContainers[0].bounds : null;
1068
1069
  const record: PageRecord = {
@@ -1088,7 +1089,7 @@ class PageCrawler {
1088
1089
  rootIdentity: RootIdentity | null = null,
1089
1090
  ): boolean {
1090
1091
  if (!launchPackage || !launchActivity) {
1091
- console.log(' [WARN] 包名或 Activity 名为空,无法重启');
1092
+ console.log(' [WARN] package or Activity name is empty, cannot restart');
1092
1093
  return false;
1093
1094
  }
1094
1095
  const component = `${launchPackage}/${launchActivity}`;
@@ -1110,7 +1111,7 @@ class PageCrawler {
1110
1111
  for (const v of rootElems) if (curElems.has(v)) inter++;
1111
1112
  const union = rootElems.size + curElems.size - inter;
1112
1113
  const sim = union ? inter / union : 0;
1113
- console.log(` [DEBUG] 根页面相似度: ${sim.toFixed(2)} (交集${inter}/并集${union})`);
1114
+ console.log(` [DEBUG] root page similarity: ${sim.toFixed(2)} (intersection ${inter}/union ${union})`);
1114
1115
  return false;
1115
1116
  }
1116
1117
  }
@@ -1121,21 +1122,21 @@ class PageCrawler {
1121
1122
  sleep(1.0);
1122
1123
  this.adb.shell(['am', 'start', '-n', component, '--activity-clear-task', '--activity-clear-top']);
1123
1124
  this.adb.waitForIdle();
1124
- // 入口是 trampoline 时,落地页要再等一拍才可 dump(同 crawl() 里的首次启动)。
1125
+ // When the entry is a trampoline, the landing page needs one more beat before it is dumpable (same as the first launch in crawl()).
1125
1126
  this.adb.waitForPackageForeground(launchPackage);
1126
1127
 
1127
1128
  for (let retry = 0; retry < 4; retry++) {
1128
1129
  if (isAtRoot()) return true;
1129
- console.log(` [INFO] 等待页面加载完成... (重试 ${retry + 1}/4)`);
1130
+ console.log(` [INFO] waiting for the page to finish loading... (retry ${retry + 1}/4)`);
1130
1131
  sleep(2);
1131
1132
  }
1132
1133
 
1133
- console.log(' [WARN] force-stop 后未到达根页面(App 未起来 / 停在非根页面,见上方 [ADB-ERR])');
1134
- console.log(' [INFO] 尝试 back + 点击路径恢复...');
1134
+ console.log(' [WARN] root page not reached after force-stop (the app did not start / stopped on a non-root page, see [ADB-ERR] above)');
1135
+ console.log(' [INFO] trying to recover with back + the click path...');
1135
1136
  this.adb.pressBack();
1136
1137
  if (isAtRoot()) return true;
1137
1138
 
1138
- console.log(' [WARN] 所有恢复方式均失败,跳过此次导航');
1139
+ console.log(' [WARN] every recovery method failed, skipping this navigation');
1139
1140
  return false;
1140
1141
  }
1141
1142
 
@@ -1148,12 +1149,12 @@ class PageCrawler {
1148
1149
  rootIdentity: RootIdentity | null = null,
1149
1150
  ): boolean {
1150
1151
  if (!launchPackage || !launchActivity) {
1151
- console.log(' [WARN] 包名或 Activity 名为空,无法导航');
1152
+ console.log(' [WARN] package or Activity name is empty, cannot navigate');
1152
1153
  return false;
1153
1154
  }
1154
1155
  if (clickPath.length === 0) return true;
1155
1156
  if (!this.restartToRoot(launchPackage, launchActivity, rootActivityKeyword, rootIdentity)) {
1156
- console.log(' [ERR] 无法回到根页面,导航失败');
1157
+ console.log(' [ERR] cannot get back to the root page, navigation failed');
1157
1158
  return false;
1158
1159
  }
1159
1160
 
@@ -1171,10 +1172,10 @@ class PageCrawler {
1171
1172
  if (found && found.center) {
1172
1173
  this.adb.tapOrLongPress(found.center[0], found.center[1], isLong);
1173
1174
  } else if (step.center) {
1174
- console.log(` [WARN] 未找到元素 ${step.element ?? '?'},使用记录坐标`);
1175
+ console.log(` [WARN] element ${step.element ?? '?'} not found, using the recorded coordinates`);
1175
1176
  this.adb.tapOrLongPress(step.center[0], step.center[1], isLong);
1176
1177
  } else {
1177
- console.log(` [ERR] 无法导航到步骤: ${step.element ?? '?'}`);
1178
+ console.log(` [ERR] cannot navigate to step: ${step.element ?? '?'}`);
1178
1179
  return false;
1179
1180
  }
1180
1181
 
@@ -1186,7 +1187,7 @@ class PageCrawler {
1186
1187
  const expectedAct = stepSignatures[i].split('|')[0];
1187
1188
  const actualAct = actualSig.split('|')[0];
1188
1189
  if (expectedAct !== actualAct) {
1189
- console.log(` [WARN] 导航步骤 ${i + 1} 后 Activity 不匹配 (期望=${expectedAct}, 实际=${actualAct})`);
1190
+ console.log(` [WARN] Activity mismatch after navigation step ${i + 1} (expected=${expectedAct}, actual=${actualAct})`);
1190
1191
  return false;
1191
1192
  }
1192
1193
  }
@@ -1195,13 +1196,13 @@ class PageCrawler {
1195
1196
  return true;
1196
1197
  }
1197
1198
 
1198
- // ── 断点续跑 ──
1199
+ // ── Checkpoint resume ──
1199
1200
  private saveQueue(): void {
1200
1201
  const items = this.queue.map(([clickPath, elemId, stepSigs, scrollInfo]) => [clickPath, [...elemId], stepSigs, scrollInfo]);
1201
1202
  try {
1202
1203
  fs.writeFileSync(path.join(this.outputRoot, 'queue_checkpoint.json'), JSON.stringify(items), 'utf-8');
1203
1204
  } catch (e) {
1204
- console.log(` [WARN] 保存队列检查点失败: ${(e as Error).message}`);
1205
+ console.log(` [WARN] failed to save the queue checkpoint: ${(e as Error).message}`);
1205
1206
  }
1206
1207
  }
1207
1208
 
@@ -1217,7 +1218,7 @@ class PageCrawler {
1217
1218
  scrollInfo,
1218
1219
  ]);
1219
1220
  } catch (e) {
1220
- console.log(` [WARN] 加载队列检查点失败: ${(e as Error).message},将重建队列`);
1221
+ console.log(` [WARN] failed to load the queue checkpoint: ${(e as Error).message}, rebuilding the queue`);
1221
1222
  return null;
1222
1223
  }
1223
1224
  }
@@ -1254,12 +1255,12 @@ class PageCrawler {
1254
1255
  try {
1255
1256
  pagesIndex = JSON.parse(fs.readFileSync(indexFile, 'utf-8')) as PageRecord[];
1256
1257
  } catch (e) {
1257
- console.log(` [WARN] 读取 index.json 失败: ${(e as Error).message},重新开始`);
1258
+ console.log(` [WARN] failed to read index.json: ${(e as Error).message}, starting over`);
1258
1259
  return null;
1259
1260
  }
1260
1261
  if (!pagesIndex || pagesIndex.length === 0) return null;
1261
1262
 
1262
- console.log(`\n⏩ 发现已有检查点:${pagesIndex.length} 个页面,尝试断点续跑...`);
1263
+ console.log(`\n⏩ found an existing checkpoint: ${pagesIndex.length} page(s), trying to resume...`);
1263
1264
  const visited = new Set<string>();
1264
1265
  let pageCounter = 0;
1265
1266
  for (const page of pagesIndex) {
@@ -1278,17 +1279,17 @@ class PageCrawler {
1278
1279
  let queue: QueueItem[];
1279
1280
  if (savedQueue !== null) {
1280
1281
  queue = savedQueue;
1281
- console.log(` 队列已从检查点恢复:${queue.length} 个待处理元素(精确续跑)`);
1282
+ console.log(` queue restored from the checkpoint: ${queue.length} pending element(s) (exact resume)`);
1282
1283
  } else {
1283
1284
  queue = this.rebuildQueueFromPages(pagesIndex);
1284
- console.log(` 队列已重建(fallback):${queue.length} 个元素(含已探索项,BFS 会自动跳过)`);
1285
+ console.log(` queue rebuilt (fallback): ${queue.length} element(s) (explored ones included, BFS skips them)`);
1285
1286
  }
1286
1287
  const blocked = new Set<string>();
1287
- console.log(` 已恢复 ${visited.size} 个已访问签名,队列 ${queue.length} 个待处理元素`);
1288
+ console.log(` restored ${visited.size} visited signature(s), ${queue.length} pending element(s) in the queue`);
1288
1289
  return { pagesIndex, visited, pageCounter, queue, blocked };
1289
1290
  }
1290
1291
 
1291
- // ── 页面提交 ──
1292
+ // ── Page commit ──
1292
1293
  private finalizePage(record: PageRecord, pageId: string): void {
1293
1294
  const pageDir = path.join(this.outputRoot, pageId);
1294
1295
  const tmpDir = record._tmp_dir!;
@@ -1318,7 +1319,7 @@ class PageCrawler {
1318
1319
  delete record._view_xmls;
1319
1320
 
1320
1321
  fs.writeFileSync(path.join(pageDir, 'meta.json'), JSON.stringify(record, null, 2), 'utf-8');
1321
- console.log(` ✅ 已保存为 [${pageId}]`);
1322
+ console.log(` ✅ saved as [${pageId}]`);
1322
1323
  }
1323
1324
 
1324
1325
  private activityNameSuffix(record: PageRecord): string {
@@ -1351,7 +1352,7 @@ class PageCrawler {
1351
1352
  return pageId;
1352
1353
  }
1353
1354
 
1354
- // ── HTML 报告生成 ──
1355
+ // ── HTML report generation ──
1355
1356
  generateHtmlReport(pages: PageRecord[]): void {
1356
1357
  let cards = '';
1357
1358
  for (const p of pages) {
@@ -1360,17 +1361,17 @@ class PageCrawler {
1360
1361
  const clickPath = p.click_path ?? [];
1361
1362
  let pathDisplay: string;
1362
1363
  if (clickPath === 'manual') {
1363
- pathDisplay = `(手动采集:${escapeHtml(p.description ?? '手动采集')})`;
1364
+ pathDisplay = term('(手动采集:{desc})', { desc: escapeHtml(p.description ?? term('手动采集')) });
1364
1365
  } else if (Array.isArray(clickPath) && clickPath.length > 0) {
1365
- const longClickTag = '<b class="long-click">长按</b>';
1366
+ const longClickTag = '<b class="long-click">long-press</b>';
1366
1367
  pathDisplay = clickPath
1367
1368
  .map(
1368
1369
  (s) =>
1369
- `<code>${escapeHtml(s.from)}</code> ${s['long-clickable'] ? longClickTag : '点击'} <b>${escapeHtml(s.element)}</b>`,
1370
+ `<code>${escapeHtml(s.from)}</code> ${s['long-clickable'] ? longClickTag : 'tap'} <b>${escapeHtml(s.element)}</b>`,
1370
1371
  )
1371
1372
  .join(' → ');
1372
1373
  } else {
1373
- pathDisplay = '(初始页)';
1374
+ pathDisplay = '(initial page)';
1374
1375
  }
1375
1376
 
1376
1377
  const screenshotPath = escapeHtml(p.screenshot ?? '');
@@ -1381,7 +1382,7 @@ class PageCrawler {
1381
1382
  let pairsHtml = '';
1382
1383
  screenshots.forEach((ss, idx) => {
1383
1384
  const xmlLink = idx < viewXmls.length ? viewXmls[idx] : viewXmls[viewXmls.length - 1];
1384
- const labelTag = idx === 0 ? '初始' : `滚动${idx}`;
1385
+ const labelTag = idx === 0 ? 'initial' : `scroll ${idx}`;
1385
1386
  pairsHtml +=
1386
1387
  `<div class="scroll-pair">` +
1387
1388
  `<img src="${escapeHtml(ss)}" alt="screenshot" onerror="this.style.display='none'"/>` +
@@ -1402,7 +1403,7 @@ class PageCrawler {
1402
1403
  .map((vx, i) => `<a href="${escapeHtml(vx)}" target="_blank">📄 XML${i === 0 ? '' : `_${i}`}</a>`)
1403
1404
  .join(' ');
1404
1405
  } else {
1405
- xmlLinksHtml = `<a href="${viewXmlEscaped}" target="_blank">📄 查看 View XML</a>`;
1406
+ xmlLinksHtml = `<a href="${viewXmlEscaped}" target="_blank">📄 View XML</a>`;
1406
1407
  }
1407
1408
 
1408
1409
  cards += `
@@ -1417,11 +1418,11 @@ class PageCrawler {
1417
1418
  <div class="meta">
1418
1419
  <div><b>Focus:</b> <code>${activity}</code></div>
1419
1420
  <div><b>Activity:</b> <code>${resumed}</code></div>
1420
- <div><b>点击路径:</b> ${pathDisplay}</div>
1421
- <div><b>可点击元素:</b> ${p.clickable_count} 个</div>
1421
+ <div><b>Click path:</b> ${pathDisplay}</div>
1422
+ <div><b>Clickable elements:</b> ${p.clickable_count}</div>
1422
1423
  <div class="links">
1423
1424
  ${xmlLinksHtml}
1424
- <a href="${pageIdEscaped}/meta.json" target="_blank">🗂 元数据 JSON</a>
1425
+ <a href="${pageIdEscaped}/meta.json" target="_blank">🗂 Metadata JSON</a>
1425
1426
  </div>
1426
1427
  </div>
1427
1428
  </div>
@@ -1436,7 +1437,7 @@ class PageCrawler {
1436
1437
  <html lang="zh">
1437
1438
  <head>
1438
1439
  <meta charset="UTF-8">
1439
- <title>Android 页面遍历报告(加速版)</title>
1440
+ <title>Android Page Crawl Report (fast)</title>
1440
1441
  <style>
1441
1442
  body { font-family: -apple-system, sans-serif; background: #f5f5f5; margin: 0; padding: 20px; }
1442
1443
  h1 { color: #333; }
@@ -1463,10 +1464,10 @@ class PageCrawler {
1463
1464
  </style>
1464
1465
  </head>
1465
1466
  <body>
1466
- <h1>📱 Android 页面遍历报告(加速版)</h1>
1467
+ <h1>📱 Android Page Crawl Report (fast)</h1>
1467
1468
  <div class="summary">
1468
- <b>生成时间:</b>${genTime} &nbsp;|&nbsp;
1469
- <b>共采集页面:</b>${pages.length} 个
1469
+ <b>Generated:</b> ${genTime} &nbsp;|&nbsp;
1470
+ <b>Pages captured:</b> ${pages.length}
1470
1471
  </div>
1471
1472
  <div class="grid">
1472
1473
  ${cards}
@@ -1483,16 +1484,16 @@ ${cards}
1483
1484
  this.generateHtmlReport(this.pagesIndex);
1484
1485
  this.saveQueue();
1485
1486
  } catch (e) {
1486
- console.log(` [WARN] 写入报告失败: ${(e as Error).message}`);
1487
+ console.log(` [WARN] failed to write the report: ${(e as Error).message}`);
1487
1488
  }
1488
1489
  }
1489
1490
 
1490
- /** 成功 = 至少采到一页。失败(无设备 / 进不了 App / 首屏失败 / 0 页)返回 false → 进程 exit 1。 */
1491
+ /** Success = at least one page captured. Failure (no device / cannot enter app / first screen failed / 0 pages) returns false -> process exit 1. */
1491
1492
  crawl(): boolean {
1492
1493
  const ok = this.crawlInner();
1493
1494
  if (ok === false) return false;
1494
1495
  if (this.pagesIndex.length === 0) {
1495
- console.log('[ERR] 一页都没有采到');
1496
+ console.log('[ERR] no page was captured');
1496
1497
  return false;
1497
1498
  }
1498
1499
  return true;
@@ -1502,68 +1503,68 @@ ${cards}
1502
1503
  if (!this.adb.checkDevice()) return false;
1503
1504
 
1504
1505
  let activityInfo = this.adb.getCurrentActivity();
1505
- // 需要干净重启的两种情况:
1506
- // 1) 不在目标 App 内(原逻辑)。
1507
- // 2) 在目标 App 内,但前台是弹窗/overlay —— current_focus 无 activity 分量,提取不到启动组件。
1508
- // 常见于上一轮遍历/续跑结束时停在弹窗上(resumed_activity 仍含包名,会被判定"在 App 内")。
1509
- // 此时若不重启,后续所有 force-stop 导航都会因缺少启动信息而中止。
1506
+ // Two cases needing a clean restart:
1507
+ // 1) Not inside the target app (original logic).
1508
+ // 2) Inside the target app, but the foreground is a dialog/overlay -- current_focus has no activity component, so no launch component can be extracted.
1509
+ // Common when the previous traversal/resume ended on a dialog (resumed_activity still contains the package, so it is judged "in app").
1510
+ // Without a restart, all later force-stop navigations would abort for lack of launch info.
1510
1511
  const focusHasComponent = focusHasActivityComponent(activityInfo);
1511
1512
  const notInApp = !this.isInTargetApp(activityInfo);
1512
1513
  if (notInApp || !focusHasComponent) {
1513
1514
  if (notInApp) {
1514
- console.log(`当前不在目标 App (${this.package}) 内,force-stop 后启动...`);
1515
+ console.log(`not inside the target app (${this.package}), force-stopping and launching...`);
1515
1516
  } else {
1516
1517
  console.log(
1517
- `当前前台为弹窗/overlay(${activityInfo['current_focus'] ?? 'N/A'}),force-stop 后重新启动以回到干净根页面...`,
1518
+ `the foreground is a dialog/overlay (${activityInfo['current_focus'] ?? 'N/A'}), force-stopping and relaunching to get back to a clean root page...`,
1518
1519
  );
1519
1520
  }
1520
1521
  this.adb.shell(['am', 'force-stop', this.package]);
1521
1522
  sleep(0.5);
1522
1523
  this.adb.shell(['monkey', '-p', this.package, '-c', 'android.intent.category.LAUNCHER', '1']);
1523
1524
  this.adb.waitForIdle();
1524
- // trampoline 过场期间 mCurrentFocus=null,waitForIdle() 会误判为已空闲;
1525
- // 必须再等到目标包真正持有焦点窗口,否则采到的是不可 dump 的中间态。
1525
+ // During the trampoline transition mCurrentFocus=null, and waitForIdle() wrongly judges it idle;
1526
+ // must also wait until the target package truly holds the focused window, otherwise a non-dumpable intermediate state is captured.
1526
1527
  if (!this.adb.waitForPackageForeground(this.package)) {
1527
- console.log(` [WARN] 等待 ${this.package} 取得焦点窗口超时,继续尝试`);
1528
+ console.log(` [WARN] timed out waiting for ${this.package} to get the focused window, still trying`);
1528
1529
  }
1529
1530
  activityInfo = this.adb.getCurrentActivity();
1530
1531
  if (!this.isInTargetApp(activityInfo)) {
1531
- console.log(`[ERR] 启动后仍未进入目标 App (${this.package}),请检查包名是否正确`);
1532
+ console.log(`[ERR] still not inside the target app (${this.package}) after launch; check the package name`);
1532
1533
  return false;
1533
1534
  }
1534
1535
  }
1535
1536
 
1536
- // launchPackage 只认 --package 传入值。绝不从前台窗口反推:
1537
- // pickBestLine() 在目标包不在前台时会退回"任何带 包名/Activity 的行",
1538
- // 于是 launchPackage 可能变成一个无关 App —— 而它会被 `am force-stop` 强杀。
1537
+ // launchPackage only accepts the --package value. Never infer it from the foreground window:
1538
+ // when the target package is not in foreground, pickBestLine() falls back to "any line with package/Activity",
1539
+ // so launchPackage could become an unrelated app -- which would then be killed by `am force-stop`.
1539
1540
  const launchPackage: string = this.package;
1540
1541
  let launchActivity: string | null = null;
1541
1542
 
1542
1543
  const resolved = this.adb.resolveLauncherActivity(launchPackage);
1543
1544
  if (resolved) {
1544
1545
  launchActivity = resolved.split('/')[1];
1545
- console.log(`启动 Activity: ${resolved} (来自 resolve-activity)`);
1546
+ console.log(`launch Activity: ${resolved} (from resolve-activity)`);
1546
1547
  } else {
1547
- // 兜底:resolve-activity 没给出结果时才退回前台窗口,且必须同包。
1548
+ // Fallback: only when resolve-activity gives no result, fall back to the foreground window, and it must be the same package.
1548
1549
  const comp = extractLaunchComponent(activityInfo);
1549
1550
  if (comp && comp[0] === launchPackage) {
1550
1551
  launchActivity = comp[1];
1551
- console.log(`启动 Activity: ${launchPackage}/${launchActivity} (来自前台窗口,兜底)`);
1552
+ console.log(`launch Activity: ${launchPackage}/${launchActivity} (from the foreground window, fallback)`);
1552
1553
  } else {
1553
1554
  console.log(
1554
- `[WARN] 无法确定 ${launchPackage} 的启动 Activity: focus=${activityInfo['current_focus'] ?? ''} resumed=${activityInfo['resumed_activity'] ?? ''}`,
1555
+ `[WARN] cannot determine the launch Activity of ${launchPackage}: focus=${activityInfo['current_focus'] ?? ''} resumed=${activityInfo['resumed_activity'] ?? ''}`,
1555
1556
  );
1556
1557
  }
1557
1558
  }
1558
1559
 
1559
- // 根页面关键字在首屏采集之后才能确定(入口可能是 trampoline,落地页另有其名),
1560
- // 这里先声明,赋值见下方 checkpoint / 首屏采集两个分支。
1560
+ // The root page keyword can only be determined after first-screen capture (the entry may be a trampoline with a differently named landing page);
1561
+ // declared here first; assigned in the checkpoint / first-screen capture branches below.
1561
1562
  let rootActivityKeyword: string | null = null;
1562
1563
 
1563
1564
  fs.mkdirSync(this.outputRoot, { recursive: true });
1564
- console.log(`\n📂 输出目录: ${path.resolve(this.outputRoot)}\n`);
1565
+ console.log(`\n📂 output dir: ${path.resolve(this.outputRoot)}\n`);
1565
1566
  console.log('='.repeat(60));
1566
- console.log('开始遍历(加速版:BFS + 轻量探测)...');
1567
+ console.log('starting the crawl (fast: BFS + lightweight probing)...');
1567
1568
  console.log('='.repeat(60));
1568
1569
 
1569
1570
  let rootIdentity: RootIdentity | null = null;
@@ -1574,7 +1575,7 @@ ${cards}
1574
1575
  this.pageCounter = checkpoint.pageCounter;
1575
1576
  this.queue = checkpoint.queue;
1576
1577
  this.blockedElements = checkpoint.blocked;
1577
- console.log(`⏩ 断点续跑:从第 ${this.pageCounter + 1} 个页面继续\n`);
1578
+ console.log(`⏩ resuming from page ${this.pageCounter + 1}\n`);
1578
1579
  for (const p of this.pagesIndex) {
1579
1580
  if (!p.click_path || (Array.isArray(p.click_path) && p.click_path.length === 0)) {
1580
1581
  const rootXmlPath = path.join(this.outputRoot, p.page_id!, 'view.xml');
@@ -1583,30 +1584,30 @@ ${cards}
1583
1584
  rootIdentity = rootIdentifiedSet(p.activity_info ?? {}, rootXml);
1584
1585
  }
1585
1586
  rootActivityKeyword = rootKeywordFromActivityInfo(p.activity_info ?? {});
1586
- if (rootActivityKeyword) console.log(`根 Activity 关键字: ${rootActivityKeyword} (来自 ${p.page_id})`);
1587
+ if (rootActivityKeyword) console.log(`root Activity keyword: ${rootActivityKeyword} (from ${p.page_id})`);
1587
1588
  break;
1588
1589
  }
1589
1590
  }
1590
1591
  } else {
1591
- // 首屏必须在"目标包持有焦点窗口"时采。只用 isInTargetApp() 不够:
1592
- // 它对 focus=null + resumed=<trampoline> 也返回 true,而那一刻 uiautomator
1593
- // dump 不出任何东西(view.xml 0 字节、0 个可点击元素)。
1592
+ // The first screen must be captured while "the target package holds the focused window". isInTargetApp() alone is not enough:
1593
+ // it also returns true for focus=null + resumed=<trampoline>, and at that moment uiautomator
1594
+ // dumps nothing (view.xml 0 bytes, 0 clickable elements).
1594
1595
  if (!this.adb.waitForPackageForeground(this.package)) {
1595
1596
  const preInfo = this.adb.getCurrentActivity();
1596
1597
  console.log(
1597
- `[ERR] 采集首屏前目标 App (${this.package}) 未取得焦点窗口:focus=${preInfo['current_focus'] ?? 'N/A'} resumed=${preInfo['resumed_activity'] ?? 'N/A'}`,
1598
+ `[ERR] the target app (${this.package}) does not hold the focused window before the first screen is captured: focus=${preInfo['current_focus'] ?? 'N/A'} resumed=${preInfo['resumed_activity'] ?? 'N/A'}`,
1598
1599
  );
1599
- console.log(' 首屏是后续所有页面的基准,采错会污染整轮结果,已中止。');
1600
+ console.log(' the first screen is the baseline for every later page; a wrong capture would pollute the whole run, aborted.');
1600
1601
  return false;
1601
1602
  }
1602
- const { record, xmlContent, clickable, scrollContainerBounds } = this.capturePage('初始页面');
1603
+ const { record, xmlContent, clickable, scrollContainerBounds } = this.capturePage(term('初始页面'));
1603
1604
  const pageId = this.commitPage(record);
1604
1605
  record.click_path = [];
1605
1606
  fs.writeFileSync(path.join(this.outputRoot, pageId, 'meta.json'), JSON.stringify(record, null, 2), 'utf-8');
1606
1607
  const sig = pageSignature(record.activity_info, xmlContent);
1607
1608
  rootIdentity = rootIdentifiedSet(record.activity_info, xmlContent);
1608
1609
  rootActivityKeyword = rootKeywordFromActivityInfo(record.activity_info);
1609
- if (rootActivityKeyword) console.log(`根 Activity 关键字: ${rootActivityKeyword} (来自首屏)`);
1610
+ if (rootActivityKeyword) console.log(`root Activity keyword: ${rootActivityKeyword} (from the first screen)`);
1610
1611
  this.visitedSignatures.add(sig);
1611
1612
  this.pathSignatures[JSON.stringify([])] = sig;
1612
1613
  this.pagesIndex.push(record);
@@ -1641,54 +1642,54 @@ ${cards}
1641
1642
  }
1642
1643
  if (skip) continue;
1643
1644
 
1644
- const pathDesc = clickPath.length > 0 ? clickPath.map((s) => s.element ?? '?').join(' → ') : '根页面';
1645
- console.log(`\n🧭 导航到: ${pathDesc}`);
1645
+ const pathDesc = clickPath.length > 0 ? clickPath.map((s) => s.element ?? '?').join(' → ') : term('根页面');
1646
+ console.log(`\n🧭 navigating to: ${pathDesc}`);
1646
1647
 
1647
1648
  if (!launchPackage || !launchActivity) {
1648
- console.log(' [ERR] 无法重启 App,缺少启动信息');
1649
+ console.log(' [ERR] cannot restart the app, launch info missing');
1649
1650
  continue;
1650
1651
  }
1651
1652
 
1652
1653
  if (clickPath.length > 0) {
1653
1654
  if (!this.navigateViaRestart(clickPath, launchPackage, launchActivity, rootActivityKeyword, stepSignatures, rootIdentity)) {
1654
- console.log(' [ERR] 导航失败,跳过');
1655
+ console.log(' [ERR] navigation failed, skipping');
1655
1656
  failedPaths.add(pathKey);
1656
1657
  continue;
1657
1658
  }
1658
1659
  } else {
1659
1660
  if (!this.restartToRoot(launchPackage, launchActivity, rootActivityKeyword, rootIdentity)) {
1660
- console.log(' [ERR] 无法回到根页面,跳过');
1661
+ console.log(' [ERR] cannot get back to the root page, skipping');
1661
1662
  continue;
1662
1663
  }
1663
1664
  }
1664
1665
 
1665
1666
  let freshXml = this.adb.dumpXmlQuick();
1666
1667
  if (scrollInfo && scrollInfo.scroll_index > 0) {
1667
- console.log(` 📜 滚动 ${scrollInfo.scroll_index} 次到达元素位置`);
1668
+ console.log(` 📜 scrolled ${scrollInfo.scroll_index} time(s) to reach the element`);
1668
1669
  this.adb.scrollToPosition(scrollInfo.container_bounds as [number, number, number, number], scrollInfo.scroll_index);
1669
1670
  freshXml = this.adb.dumpXmlQuick();
1670
1671
  }
1671
1672
 
1672
1673
  const foundElem = findElementOnScreen(freshXml, elemId);
1673
1674
  if (!foundElem || !foundElem.center) {
1674
- console.log(` [SKIP] 无法找到元素: ${JSON.stringify(elemId.slice(0, 3))}`);
1675
+ console.log(` [SKIP] element not found: ${JSON.stringify(elemId.slice(0, 3))}`);
1675
1676
  continue;
1676
1677
  }
1677
1678
 
1678
- // input tap/swipe 是全局事件,打到的是**当时的前台窗口**,不绑定 App。
1679
- // 若此刻前台已不是目标 App(导航半路跳走、弹窗被系统抢焦点等),
1680
- // 点下去就是点在别人家界面上,且随后的 dump/截图也会把它录进 ui_info。
1679
+ // input tap/swipe are global events hitting **whatever window is foreground at that time**, not bound to an app.
1680
+ // If the foreground is no longer the target app (navigation jumped away midway, system stole focus for a dialog, etc.),
1681
+ // the tap lands on someone else's screen, and the following dump/screenshot also records it into ui_info.
1681
1682
  const preTapInfo = this.adb.getCurrentActivity();
1682
1683
  if (!this.isInTargetApp(preTapInfo)) {
1683
- console.log(` [SKIP] 点击前前台已不是目标 App(${preTapInfo['current_focus'] ?? 'N/A'}),跳过`);
1684
+ console.log(` [SKIP] the foreground is no longer the target app before the tap (${preTapInfo['current_focus'] ?? 'N/A'}), skipping`);
1684
1685
  continue;
1685
1686
  }
1686
1687
 
1687
1688
  const center = foundElem.center;
1688
1689
  const labelText = foundElem.text || foundElem['content-desc'] || foundElem['resource-id'] || 'unknown';
1689
- console.log(`\n👆 点击: [${labelText}] @ ${JSON.stringify(center)}`);
1690
+ console.log(`\n👆 tap: [${labelText}] @ ${JSON.stringify(center)}`);
1690
1691
  const isLong = foundElem['long-clickable'] ?? false;
1691
- if (isLong) console.log(' 🔁 使用长按触发');
1692
+ if (isLong) console.log(' 🔁 triggering with a long press');
1692
1693
  this.adb.tapOrLongPress(center[0], center[1], isLong);
1693
1694
 
1694
1695
  const probeXml = this.adb.dumpXmlQuick();
@@ -1696,18 +1697,18 @@ ${cards}
1696
1697
  let newSig = pageSignature(probeInfo, probeXml);
1697
1698
 
1698
1699
  if (!this.isInTargetApp(probeInfo)) {
1699
- console.log(' ⚠️ 跳转到其他 App,标记并跳过');
1700
+ console.log(' ⚠️ jumped to another app, marking and skipping');
1700
1701
  this.blockedElements.add(elemKey);
1701
1702
  continue;
1702
1703
  }
1703
1704
  if (this.visitedSignatures.has(newSig)) {
1704
- console.log(' ♻️ 页面已访问过,跳过(省截图)');
1705
+ console.log(' ♻️ page already visited, skipping (screenshot saved)');
1705
1706
  this.stats.probe_skipped += 1;
1706
1707
  continue;
1707
1708
  }
1708
1709
 
1709
1710
  const { record: newRecord, xmlContent: newXml, clickable: newClickable, scrollContainerBounds: newScrollBounds } =
1710
- this.capturePage(`点击'${labelText}'后`);
1711
+ this.capturePage(term("点击'{label}'后", { label: labelText }));
1711
1712
  newSig = pageSignature(newRecord.activity_info, newXml);
1712
1713
  this.visitedSignatures.add(newSig);
1713
1714
  const pageId = this.commitPage(newRecord);
@@ -1757,29 +1758,29 @@ ${cards}
1757
1758
  }
1758
1759
 
1759
1760
  console.log('\n' + '='.repeat(60));
1760
- console.log(`✅ 遍历完成!共采集 ${this.pagesIndex.length} 个页面`);
1761
- console.log(`📂 输出目录: ${path.resolve(this.outputRoot)}`);
1762
- console.log(`📋 索引文件: ${path.join(this.outputRoot, 'index.json')}`);
1763
- console.log(`🌐 HTML报告: ${path.join(this.outputRoot, 'report.html')}`);
1764
- console.log('\n📊 加速统计:');
1765
- console.log(` 过滤低价值元素: ${this.stats.skipped_elements} 个`);
1766
- console.log(` 轻量探测跳过(省截图): ${this.stats.probe_skipped} 次`);
1761
+ console.log(`✅ crawl finished! ${this.pagesIndex.length} page(s) captured`);
1762
+ console.log(`📂 output dir: ${path.resolve(this.outputRoot)}`);
1763
+ console.log(`📋 index file: ${path.join(this.outputRoot, 'index.json')}`);
1764
+ console.log(`🌐 HTML report: ${path.join(this.outputRoot, 'report.html')}`);
1765
+ console.log('\n📊 speed-up stats:');
1766
+ console.log(` low-value elements filtered: ${this.stats.skipped_elements}`);
1767
+ console.log(` skipped by lightweight probing (screenshots saved): ${this.stats.probe_skipped}`);
1767
1768
  console.log('='.repeat(60));
1768
1769
  }
1769
1770
 
1770
- /** 读取已有 index.json(不存在或损坏时返回空数组)。手动/单页采集共用。 */
1771
+ /** Read existing index.json (empty array if missing or corrupt). Shared by manual/single-page capture. */
1771
1772
  private loadExistingIndex(): PageRecord[] {
1772
1773
  const indexFile = path.join(this.outputRoot, 'index.json');
1773
1774
  if (!fs.existsSync(indexFile)) return [];
1774
1775
  try {
1775
1776
  return JSON.parse(fs.readFileSync(indexFile, 'utf-8')) as PageRecord[];
1776
1777
  } catch (e) {
1777
- console.log(`[WARN] 读取 index.json 失败: ${(e as Error).message},将创建新索引`);
1778
+ console.log(`[WARN] failed to read index.json: ${(e as Error).message}, creating a new index`);
1778
1779
  return [];
1779
1780
  }
1780
1781
  }
1781
1782
 
1782
- /** 已有页面里最大的 manual_NNNN 编号,用于续编号。 */
1783
+ /** Largest manual_NNNN number among existing pages, used to continue numbering. */
1783
1784
  static lastManualCounter(pagesIndex: PageRecord[]): number {
1784
1785
  let counter = 0;
1785
1786
  for (const p of pagesIndex) {
@@ -1790,21 +1791,21 @@ ${cards}
1790
1791
  }
1791
1792
 
1792
1793
  /**
1793
- * 单页采集模式(--page "<描述>"):不做任何导航,直接把设备**当前**页面
1794
- * 当作待采集页抓一次(截图 + view.xml + 可滚动容器滚动采集),写入 index.json /
1795
- * report.html 后退出。等价于 manualCrawl 里输入一次描述、再输入 q,但无需交互,
1796
- * 便于外部脚本按自己的 UI 序列逐页调用。
1794
+ * Single-page capture mode (--page "<description>"): no navigation; directly takes the device's **current** page
1795
+ * as the page to capture once (screenshot + view.xml + scrolling capture of scrollable containers), writes index.json /
1796
+ * report.html then exits. Equivalent to entering one description then q in manualCrawl, but non-interactive,
1797
+ * so external scripts can call it page by page following their own UI sequence.
1797
1798
  */
1798
1799
  capturePageOnce(description: string): boolean | void {
1799
1800
  if (!this.adb.checkDevice()) return false;
1800
1801
  fs.mkdirSync(this.outputRoot, { recursive: true });
1801
1802
 
1802
1803
  const pagesIndex = this.loadExistingIndex();
1803
- if (pagesIndex.length > 0) console.log(`📂 已加载 ${pagesIndex.length} 个已有页面`);
1804
+ if (pagesIndex.length > 0) console.log(`📂 loaded ${pagesIndex.length} existing page(s)`);
1804
1805
  const manualCounter = PageCrawler.lastManualCounter(pagesIndex) + 1;
1805
1806
 
1806
- console.log(`\n📂 输出目录: ${path.resolve(this.outputRoot)}`);
1807
- console.log(`📝 单页采集模式:${description}`);
1807
+ console.log(`\n📂 output dir: ${path.resolve(this.outputRoot)}`);
1808
+ console.log(`📝 single-page capture mode: ${description}`);
1808
1809
 
1809
1810
  const { record } = this.capturePage(description);
1810
1811
  record.click_path = 'manual';
@@ -1815,8 +1816,8 @@ ${cards}
1815
1816
  this.pagesIndex = pagesIndex;
1816
1817
  this.generateHtmlReport(pagesIndex);
1817
1818
 
1818
- console.log(`\n✅ 单页采集完成:[${pageId}](index.json 共 ${pagesIndex.length} 个页面)`);
1819
- console.log(`📂 输出目录: ${path.resolve(this.outputRoot)}`);
1819
+ console.log(`\n✅ single-page capture done: [${pageId}] (index.json has ${pagesIndex.length} page(s))`);
1820
+ console.log(`📂 output dir: ${path.resolve(this.outputRoot)}`);
1820
1821
  }
1821
1822
 
1822
1823
  async manualCrawl(): Promise<boolean | void> {
@@ -1824,16 +1825,16 @@ ${cards}
1824
1825
  fs.mkdirSync(this.outputRoot, { recursive: true });
1825
1826
 
1826
1827
  const pagesIndex = this.loadExistingIndex();
1827
- if (pagesIndex.length > 0) console.log(`📂 已加载 ${pagesIndex.length} 个已有页面`);
1828
+ if (pagesIndex.length > 0) console.log(`📂 loaded ${pagesIndex.length} existing page(s)`);
1828
1829
  let manualCounter = PageCrawler.lastManualCounter(pagesIndex);
1829
1830
 
1830
- console.log(`\n📂 输出目录: ${path.resolve(this.outputRoot)}`);
1831
- console.log(`📝 手动采集模式已启动(manual 编号从 ${manualCounter + 1} 开始)`);
1831
+ console.log(`\n📂 output dir: ${path.resolve(this.outputRoot)}`);
1832
+ console.log(`📝 manual capture mode started (manual numbering starts at ${manualCounter + 1})`);
1832
1833
  console.log('='.repeat(60));
1833
- console.log('操作说明:');
1834
- console.log(' 1. 在设备上手动导航到目标页面');
1835
- console.log(' 2. 输入页面描述(如"设置页 > 关于"),然后按回车开始采集');
1836
- console.log(' 3. 输入 q 退出');
1834
+ console.log('How to use:');
1835
+ console.log(' 1. navigate to the target page on the device by hand');
1836
+ console.log(' 2. type a page description (e.g. "Settings > About"), then press Enter to capture');
1837
+ console.log(' 3. type q to quit');
1837
1838
  console.log('='.repeat(60));
1838
1839
 
1839
1840
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
@@ -1842,12 +1843,12 @@ ${cards}
1842
1843
  try {
1843
1844
  for (;;) {
1844
1845
  console.log();
1845
- let desc = (await question('📝 输入页面描述(q 退出): ')).trim();
1846
+ let desc = (await question('📝 page description (q to quit): ')).trim();
1846
1847
  if (desc.toLowerCase() === 'q') {
1847
- console.log('👋 退出手动采集模式');
1848
+ console.log('👋 leaving manual capture mode');
1848
1849
  break;
1849
1850
  }
1850
- if (!desc) desc = '手动采集';
1851
+ if (!desc) desc = term('手动采集');
1851
1852
  manualCounter += 1;
1852
1853
  const { record } = this.capturePage(desc);
1853
1854
  record.click_path = 'manual';
@@ -1857,13 +1858,13 @@ ${cards}
1857
1858
  fs.writeFileSync(path.join(this.outputRoot, 'index.json'), JSON.stringify(pagesIndex, null, 2), 'utf-8');
1858
1859
  this.pagesIndex = pagesIndex;
1859
1860
  this.generateHtmlReport(pagesIndex);
1860
- console.log(` 📋 index.json 和 report.html 已更新(共 ${pagesIndex.length} 个页面)`);
1861
+ console.log(` 📋 index.json and report.html updated (${pagesIndex.length} page(s) in total)`);
1861
1862
  }
1862
1863
  } finally {
1863
1864
  rl.close();
1864
1865
  }
1865
- console.log(`\n✅ 手动采集完成!共 ${pagesIndex.length} 个页面(含自动遍历)`);
1866
- console.log(`📂 输出目录: ${path.resolve(this.outputRoot)}`);
1866
+ console.log(`\n✅ manual capture done! ${pagesIndex.length} page(s) in total (crawled ones included)`);
1867
+ console.log(`📂 output dir: ${path.resolve(this.outputRoot)}`);
1867
1868
  }
1868
1869
  }
1869
1870
 
@@ -1884,18 +1885,18 @@ interface CliArgs {
1884
1885
  function printHelp(): void {
1885
1886
  console.log(
1886
1887
  [
1887
- 'Android 模拟器页面遍历工具(加速版)',
1888
+ 'Android emulator page crawler (fast)',
1888
1889
  '',
1889
1890
  'Usage: node android_parse_fast.ts --package <pkg> --output <dir> [options]',
1890
1891
  '',
1891
- ' --package, -p 目标 App 包名(必选)',
1892
- ' --output, -o 输出目录(必选)',
1893
- ' --manual 手动采集模式:手动导航到页面后按回车触发采集',
1894
- ' --page "<描述>" 单页采集模式:直接用该描述采集设备当前页面,抓完一页即退出(不遍历)',
1895
- ` --device ADB 设备 serial(默认: 不指定,adb 按 ANDROID_SERIAL / 唯一在线设备选择)`,
1896
- ` --adb-path adb 可执行文件路径(默认: env ADB_PATH,否则 PATH 上的 adb)`,
1897
- ` --max-pages 最多遍历页面数(默认: ${MAX_PAGES_DEFAULT})`,
1898
- ` --max-scrolls 每个可滚动容器最多滚动次数(默认: ${MAX_SCROLLS_DEFAULT})`,
1892
+ ' --package, -p target app package name (required)',
1893
+ ' --output, -o output directory (required)',
1894
+ ' --manual manual capture mode: navigate to a page by hand, then press Enter to capture',
1895
+ ' --page "<desc>" single-page capture mode: capture the device\'s current page under this description and exit (no crawl)',
1896
+ ` --device ADB device serial (default: none, adb picks by ANDROID_SERIAL / the only online device)`,
1897
+ ` --adb-path path to the adb executable (default: env ADB_PATH, else adb on PATH)`,
1898
+ ` --max-pages maximum pages to crawl (default: ${MAX_PAGES_DEFAULT})`,
1899
+ ` --max-scrolls maximum scrolls per scrollable container (default: ${MAX_SCROLLS_DEFAULT})`,
1899
1900
  ].join('\n'),
1900
1901
  );
1901
1902
  }
@@ -1945,7 +1946,7 @@ function parseArgs(argv: string[]): CliArgs {
1945
1946
  process.exit(2);
1946
1947
  }
1947
1948
  if (args.page !== null && args.manual) {
1948
- console.error('error: --page 与 --manual 互斥');
1949
+ console.error('error: --page and --manual are mutually exclusive');
1949
1950
  process.exit(2);
1950
1951
  }
1951
1952
  return args;
@@ -1961,9 +1962,9 @@ async function main(): Promise<number> {
1961
1962
  maxPages: args.maxPages,
1962
1963
  maxScrolls: args.maxScrolls,
1963
1964
  });
1964
- // 以前一律 return 0:没设备 / 首屏失败 / 0 页也 exit 0,调用方(ui-align Step 3.2)把空目录当成功。
1965
+ // Previously always returned 0: no device / first screen failed / 0 pages also exit 0, and the caller (ui-align Step 3.2) treated an empty dir as success.
1965
1966
  let ok: boolean | void;
1966
- if (args.page !== null) ok = crawler.capturePageOnce(args.page.trim() || '单页采集');
1967
+ if (args.page !== null) ok = crawler.capturePageOnce(args.page.trim() || term('单页采集'));
1967
1968
  else if (args.manual) ok = await crawler.manualCrawl();
1968
1969
  else ok = crawler.crawl();
1969
1970
  return ok === false ? 1 : 0;