@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.
- package/README.md +433 -0
- package/agents/build-fixer.md +1 -2
- package/agents/code-reviewer.md +31 -15
- package/agents/model-render-worker.md +9 -5
- package/dist/cli/config-store.js +128 -0
- package/dist/cli/config.js +48 -0
- package/dist/cli/editors.json +114 -0
- package/dist/cli/env-vars.js +127 -0
- package/dist/cli/index.js +73 -0
- package/dist/cli/init.js +2513 -0
- package/dist/cli/uninstall.js +406 -0
- package/dist/platform/compose.js +228 -0
- package/dist/platform/frontmatter.js +151 -0
- package/dist/platform/installer.js +417 -0
- package/dist/platform/registry.js +337 -0
- package/dist/platform/transform.js +363 -0
- package/dist/platform/types.js +9 -0
- package/dist/platform/validate.js +152 -0
- package/dist/utils/regex.js +7 -0
- package/env-requirements.json +511 -0
- package/package.json +169 -11
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
- package/resource/choose_editor.png +0 -0
- package/resource/convert_pipeline_process.svg +114 -0
- package/resource/project_architecture.svg +120 -0
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.png +0 -0
- package/resource/set_sdk.png +0 -0
- package/resource/title_dark.png +0 -0
- package/skills/a2h-app-migrate/SKILL.md +17 -11
- package/skills/a2h-app-migrate/references/stage-map.md +22 -7
- package/skills/a2h-app-migrate/references/workflow.yaml +276 -209
- package/skills/a2h-app-migrate/scripts/android_index.mjs +34 -16
- package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +12 -12
- package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +12 -12
- package/skills/a2h-app-migrate/scripts/check_signing.mjs +16 -16
- package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +17 -16
- package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +141 -62
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +12 -12
- package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +26 -26
- package/skills/a2h-app-migrate/scripts/cli_values.mjs +7 -7
- package/skills/a2h-app-migrate/scripts/ensure_utg_snapshot.mjs +144 -0
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +474 -365
- package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +115 -108
- package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-app-migrate/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +6 -6
- package/skills/a2h-app-migrate/scripts/json_io.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -15
- package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +99 -99
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +25 -25
- package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +9 -9
- package/skills/a2h-app-migrate/scripts/run_dir.mjs +33 -33
- package/skills/a2h-app-migrate/scripts/spec_layout.mjs +13 -11
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +128 -80
- package/skills/a2h-app-migrate/scripts/write_resume_summary.mjs +349 -0
- package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +21 -21
- package/skills/a2h-arch-generate/scripts/create_project.mjs +23 -23
- package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +48 -40
- package/skills/a2h-arch-generate/scripts/generate_state.mjs +7 -7
- package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-arch-generate/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +10 -1
- package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +41 -36
- package/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
- package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1 -1
- package/skills/a2h-arch-generate/scripts/module_create/create.mjs +17 -17
- package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +54 -50
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +2 -2
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +2 -2
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +2 -2
- package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +42 -42
- package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +69 -44
- package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +62 -17
- package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +5 -4
- package/skills/a2h-arkts-logic-coder/SKILL.md +39 -8
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +28 -17
- package/skills/{a2h-spec-design/SKILL.md → a2h-arkts-logic-coder/references/spec-design.md} +45 -78
- package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +1 -1
- package/skills/a2h-arkts-logic-coder/scripts/check_units.ts +448 -0
- package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +5 -0
- package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +54 -0
- package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/inspect_spec_design_inputs.mjs +18 -12
- package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/lib/py_compat.mjs +1 -1
- package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/move_spec_technical_reference.mjs +10 -7
- package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/resolve_module_design.mjs +13 -7
- package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/validate_spec_design_output.mjs +57 -41
- package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +66 -323
- package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +66 -108
- package/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
- package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +5 -18
- package/skills/a2h-batch-ui-align/SKILL.md +39 -39
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +31 -0
- package/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
- package/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
- package/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +80 -0
- package/skills/a2h-batch-ui-align/references/cards/interaction.md +22 -0
- package/skills/a2h-batch-ui-align/references/cards/resources.md +83 -0
- package/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
- package/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +38 -0
- package/skills/a2h-batch-ui-align/references/cards/window.md +29 -0
- package/skills/a2h-batch-ui-align/references/checker-rules.md +642 -0
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +70 -261
- package/skills/a2h-batch-ui-align/references/host-dispatch.md +34 -0
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +16 -4
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +3 -1
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +32 -1
- package/skills/a2h-batch-ui-align/references/source-only-tier.md +7 -1
- 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
- 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
- package/skills/a2h-batch-ui-align/references/step3-capture.md +14 -12
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +14 -9
- package/skills/a2h-batch-ui-align/references/step5-convert.md +21 -18
- package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +44 -44
- package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +237 -236
- package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +42 -3854
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +34 -32
- package/skills/a2h-batch-ui-align/scripts/detach.mjs +1 -1
- package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +196 -52
- package/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
- package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +26 -25
- package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +1 -1
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +162 -15
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +145 -21
- package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +8 -8
- package/skills/a2h-batch-ui-align/scripts/host_env.mjs +1 -1
- package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +228 -0
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +444 -266
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +66 -32
- package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +141 -57
- package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +410 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +80 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/findings.ts +21 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +22 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/meta.ts +34 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +668 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +392 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +167 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/package.json +3 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +101 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +629 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +67 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +71 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +102 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +551 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +310 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +80 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +64 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +97 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +68 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +153 -0
- package/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +65 -65
- package/skills/a2h-coldstart-smoke-gate/SKILL.md +8 -6
- package/skills/a2h-dashboard-render/SKILL.md +15 -7
- package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +5 -35
- package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +4 -4
- package/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
- package/skills/a2h-dashboard-render/scripts/check-registry.mjs +17 -17
- package/skills/a2h-dashboard-render/scripts/dashboard.css +3546 -0
- package/skills/a2h-dashboard-render/scripts/dashboard.mjs +1021 -941
- package/skills/a2h-dashboard-render/scripts/device_capture.mjs +104 -65
- package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-dashboard-render/scripts/page_capture.mjs +8 -8
- package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +67 -37
- package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +4 -4
- package/skills/a2h-fix-build-errors/SKILL.md +1 -2
- package/skills/a2h-resource-convert/SKILL.md +1 -3
- package/skills/a2h-resource-convert/references/step7-report-template.md +2 -2
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +366 -361
- package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +170 -170
- package/skills/a2h-resource-convert/scripts/app_identity.ts +162 -162
- package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +95 -95
- package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +132 -132
- package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +220 -220
- package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-resource-convert/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +74 -74
- package/skills/a2h-spec-design-pipeline/SKILL.md +113 -63
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +226 -56
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +315 -62
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +4 -2
- package/skills/a2h-spec-design-pipeline/references/initialization.md +12 -9
- package/skills/a2h-spec-design-pipeline/references/legacy-cleanup.md +18 -0
- package/skills/a2h-spec-design-pipeline/references/merge-queue.md +109 -8
- package/skills/a2h-spec-design-pipeline/references/scripts.md +29 -16
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +116 -8
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +179 -0
- package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +33 -5
- package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +36 -16
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +93 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +915 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/ledger.mjs +234 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/plan.mjs +33 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +31 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +94 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/state-mirror.mjs +55 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/timeouts.mjs +34 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +92 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/waker.mjs +60 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +89 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +551 -0
- package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +267 -33
- package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +30 -10
- package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +634 -0
- package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/io.mjs +33 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +107 -19
- package/skills/a2h-spec-design-pipeline/scripts/stage_design_inputs.ts +79 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +4 -4
- package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +121 -38
- package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +58 -11
- package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +31 -31
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +564 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +339 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +161 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +1024 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_ledger.mjs +178 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_plan.mjs +60 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +58 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +91 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +60 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_waker.mjs +95 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_worktree.mjs +81 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +183 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +29 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +294 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +70 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +157 -30
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +2 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_stage_design_inputs.ts +72 -0
- package/skills/a2h-spec-generate/SKILL.md +34 -10
- package/skills/a2h-spec-generate/references/batch-mode.md +4 -1
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +90 -21
- package/skills/a2h-spec-generate/references/recall-guide.md +1 -0
- package/skills/a2h-spec-generate/references/requirement-scope.md +1 -1
- package/skills/a2h-spec-generate/references/specs.schema.json +6 -0
- package/skills/a2h-spec-generate/references/worker-rules.md +2 -1
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +305 -116
- package/skills/a2h-spec-generate/scripts/check_spec.ts +136 -114
- package/skills/a2h-spec-generate/scripts/collect-specs.mjs +19 -4
- package/skills/a2h-spec-generate/scripts/ensure-index.mjs +74 -14
- package/skills/a2h-spec-generate/scripts/feature-stem.mjs +4 -2
- package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-spec-generate/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-spec-generate/scripts/parse_requirements.ts +65 -65
- package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +8 -2
- package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +8 -2
- package/skills/a2h-spec-generate/scripts/publish-specs.mjs +80 -5
- package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +670 -0
- package/skills/a2h-spec-generate/scripts/render-tasks.mjs +37 -30
- package/skills/a2h-spec-generate/scripts/report.mjs +7 -3
- package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +26 -26
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +2 -2
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +2 -2
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +4 -4
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +6 -6
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +3 -3
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +23 -23
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +16 -16
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +27 -26
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +7 -4
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +32 -31
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +3 -2
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +26 -20
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +92 -69
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +7 -3
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +545 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +545 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +177 -2
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +424 -29
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +133 -7
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +302 -103
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/zip.ts +99 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +5 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +54 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +8 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +5 -1
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +39 -33
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +4 -3
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +4 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +48 -6
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +366 -5
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +102 -3
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +81 -52
- package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +21 -11
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +2 -1
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +13 -4
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +2 -2
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +2 -2
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +4 -4
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +6 -6
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +3 -3
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +16 -16
- package/skills/a2h-utg-explorer/SKILL.md +1 -1
- package/skills/a2h-utg-explorer/assets/final_viewer.html +21 -21
- package/skills/a2h-utg-explorer/references/architecture.md +9 -4
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +144 -20
- package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +21 -3
- package/skills/a2h-utg-explorer/scripts/device_health.mjs +91 -6
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +20 -2
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +68 -9
- package/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +229 -0
- package/skills/a2h-utg-explorer/scripts/plan.mjs +45 -2
- package/skills/a2h-utg-explorer/scripts/recover.mjs +7 -1
- package/skills/a2h-utg-explorer/scripts/recover_b.mjs +10 -2
- package/skills/a2h-utg-explorer/scripts/report.mjs +38 -18
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +9 -2
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +268 -25
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +194 -8
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +521 -46
- package/skills/a2h-utg-static/SKILL.md +8 -1
- package/skills/a2h-utg-static/references/view-interactions.md +1 -1
- package/skills/a2h-utg-static/scripts/assemble.mjs +35 -5
- package/skills/a2h-utg-static/scripts/click_paths.mjs +42 -26
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +23 -5
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +29 -3
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +10 -1
- package/skills/a2h-utg-static/scripts/fragment_nav.mjs +4 -2
- package/skills/a2h-utg-static/scripts/i18n-term.d.mts +5 -0
- package/skills/a2h-utg-static/scripts/i18n-term.mjs +54 -0
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +51 -2
- package/skills/a2h-utg-static/scripts/manifest.mjs +91 -10
- package/skills/a2h-utg-static/scripts/nl_hints.mjs +68 -3
- package/skills/a2h-utg-static/scripts/presenter_nav.mjs +2 -1
- package/skills/a2h-utg-static/scripts/route_interceptor.mjs +374 -0
- package/skills/a2h-utg-static/scripts/static_prior.mjs +89 -34
- package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +45 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
- package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +17 -0
- package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +155 -0
- package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +328 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +50 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +3 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
- package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +240 -8
- package/skills/a2h-utg-static/scripts/utg_html.mjs +51 -51
- package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +100 -100
- package/devecocli-plugin/common.ts +0 -2203
- package/devecocli-plugin/install.ts +0 -61
- package/devecocli-plugin/uninstall.ts +0 -26
- package/devecocli-plugin/update.ts +0 -66
- package/index.js +0 -1418
- package/plugin.jsonc +0 -12
- package/skills/a2h-app-migrate/test/test_android_index.mjs +0 -80
- package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +0 -63
- package/skills/a2h-app-migrate/test/test_arch_done.mjs +0 -54
- package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +0 -92
- package/skills/a2h-app-migrate/test/test_config_example.mjs +0 -42
- package/skills/a2h-app-migrate/test/test_entry_guards.mjs +0 -93
- package/skills/a2h-app-migrate/test/test_env_requirements.mjs +0 -544
- package/skills/a2h-app-migrate/test/test_finalize.mjs +0 -89
- package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +0 -146
- package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +0 -68
- package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +0 -91
- package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -122
- package/skills/a2h-app-migrate/test/test_json_io.mjs +0 -32
- package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +0 -109
- package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +0 -53
- package/skills/a2h-app-migrate/test/test_parse_args.mjs +0 -69
- package/skills/a2h-app-migrate/test/test_preflight_report.mjs +0 -93
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +0 -144
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +0 -100
- package/skills/a2h-app-migrate/test/test_run_dir.mjs +0 -315
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +0 -133
- package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +0 -133
- package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +0 -158
- package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +0 -181
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +0 -76
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +0 -53
- package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +0 -226
- package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +0 -83
- package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +0 -39
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +0 -168
- package/skills/a2h-app-migrate/test/test_validate_races.mjs +0 -50
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +0 -11
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +0 -12
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +0 -8
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +0 -17
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +0 -3
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +0 -1
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +0 -8
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +0 -14
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +0 -7
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +0 -1
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +0 -3
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +0 -7
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +0 -1
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +0 -3
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +0 -7
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +0 -1
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +0 -3
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +0 -1
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +0 -1
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +0 -7
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +0 -9
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +0 -7
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +0 -10
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +0 -6
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +0 -16
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +0 -5
- package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +0 -548
- package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +0 -1122
- package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +0 -191
- package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +0 -52
- package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +0 -34
- package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +0 -138
- package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +0 -224
- package/skills/a2h-batch-ui-align/flowchart.html +0 -271
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/skills/a2h-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +0 -911
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +0 -217
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +0 -253
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +0 -312
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +0 -241
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +0 -365
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +0 -298
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +0 -365
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +0 -91
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +0 -473
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +0 -356
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +0 -290
- package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +0 -74
- package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +0 -31
- package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +0 -564
- package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +0 -123
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +0 -126
- package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +0 -241
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +0 -1451
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +0 -215
- package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +0 -95
- package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +0 -115
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +0 -170
- package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +0 -102
- package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +0 -244
- package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +0 -166
- package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +0 -49
- package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +0 -219
- package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +0 -83
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +0 -1
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +0 -156
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +0 -1
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +0 -1
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +0 -1
- package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +0 -170
- package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +0 -99
- package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +0 -182
- package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +0 -64
- package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +0 -1172
- package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +0 -251
- package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +0 -81
- package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +0 -115
- package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +0 -303
- package/skills/a2h-dashboard-render/test/test_page_capture.mjs +0 -147
- package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +0 -444
- package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +0 -187
- package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +0 -351
- package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +0 -495
- package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +0 -157
- package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +0 -388
- package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +0 -182
- package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +0 -206
- package/skills/a2h-spec-design/test/golden/inspect_happy.json +0 -20
- package/skills/a2h-spec-design/test/golden/move_design.md +0 -18
- package/skills/a2h-spec-design/test/golden/move_design_crlf.md +0 -18
- package/skills/a2h-spec-design/test/golden/move_spec.md +0 -7
- package/skills/a2h-spec-design/test/golden/resolve_cases.json +0 -36
- package/skills/a2h-spec-design/test/golden/validate_issue_file.md +0 -12
- package/skills/a2h-spec-design/test/golden/validate_issues.json +0 -57
- package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +0 -381
- package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +0 -944
- package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +0 -95
- package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +0 -218
- package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +0 -64
- package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +0 -452
- package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +0 -182
- package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +0 -289
- package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +0 -441
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +0 -50
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +0 -75
- package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +0 -256
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +0 -576
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +0 -290
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +0 -1323
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +0 -574
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +0 -339
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +0 -831
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +0 -548
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +0 -117
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +0 -396
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +0 -175
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +0 -298
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +0 -1061
- package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +0 -286
- package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +0 -25
- package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +0 -159
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +0 -632
- package/skills/a2h-spec-generate/test/check-spec.test.ts +0 -200
- package/skills/a2h-spec-generate/test/collect-specs.test.mjs +0 -538
- package/skills/a2h-spec-generate/test/detect-project.test.mjs +0 -37
- package/skills/a2h-spec-generate/test/ensure-index.test.mjs +0 -45
- package/skills/a2h-spec-generate/test/feature-stem.test.mjs +0 -147
- package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +0 -3
- package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +0 -3
- package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +0 -3
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +0 -9
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +0 -8
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +0 -9
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +0 -1
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +0 -6
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +0 -4
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +0 -1
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +0 -33
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +0 -1
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +0 -23
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +0 -3
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +0 -8
- package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +0 -1
- package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +0 -54
- package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +0 -157
- package/skills/a2h-spec-generate/test/publish-specs.test.mjs +0 -282
- package/skills/a2h-spec-generate/test/render-tasks.test.mjs +0 -593
- package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +0 -66
- package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +0 -45
- package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +0 -243
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +0 -104
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +0 -223
- package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +0 -88
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +0 -187
- package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +0 -130
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +0 -136
- package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +0 -135
- package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +0 -16
- package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +0 -251
- package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +0 -42
- package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +0 -162
- package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +0 -193
- package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +0 -204
- package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +0 -355
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +0 -240
- package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +0 -212
- package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +0 -173
- package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +0 -280
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +0 -213
- package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +0 -345
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +0 -453
- package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +0 -131
- package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +0 -229
- package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +0 -336
- package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +0 -102
- package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +0 -92
- package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +0 -119
- package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +0 -346
- package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +0 -112
- package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +0 -63
- 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
|
|
4
|
-
*
|
|
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
|
-
*
|
|
7
|
-
*
|
|
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
|
-
//
|
|
26
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
357
|
-
*
|
|
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
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* am start
|
|
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
|
-
*
|
|
428
|
+
* Capture device density and resolution -- written into each page's meta.json `device_info` field.
|
|
428
429
|
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* 24dp@3.0
|
|
432
|
-
*
|
|
433
|
-
*
|
|
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
|
-
/**
|
|
437
|
+
/** Effective dpi (override takes precedence). null if unavailable. */
|
|
437
438
|
dpi: number | null;
|
|
438
|
-
/** dpi / 160
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
501
|
+
console.log(` [WARN] adb command timed out: ${args.join(' ')}`);
|
|
501
502
|
return '';
|
|
502
503
|
}
|
|
503
504
|
if (code === 'ENOENT') {
|
|
504
|
-
throw new Error('
|
|
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
|
|
509
|
-
// Permission Denial
|
|
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
|
-
*
|
|
521
|
+
* Ask the system for the target package's actually launchable launcher entry component.
|
|
521
522
|
*
|
|
522
|
-
*
|
|
523
|
-
* `exported="false"`
|
|
524
|
-
* exported
|
|
525
|
-
*
|
|
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
|
|
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
|
-
*
|
|
547
|
-
*
|
|
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`
|
|
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(`
|
|
573
|
-
+ (info.width_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
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
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
|
-
//
|
|
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
|
-
//
|
|
618
|
-
//
|
|
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]
|
|
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('
|
|
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(`
|
|
640
|
-
//
|
|
641
|
-
//
|
|
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}
|
|
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(`
|
|
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]
|
|
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(`
|
|
656
|
+
console.log(` using the given device: ${this.deviceSerial}`);
|
|
656
657
|
}
|
|
657
658
|
return true;
|
|
658
659
|
}
|
|
659
660
|
|
|
660
661
|
/**
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
* `dumpsys activity activities`
|
|
664
|
-
* mCurrentFocus / topResumedActivity
|
|
665
|
-
* launcher
|
|
666
|
-
*
|
|
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
|
-
//
|
|
672
|
-
//
|
|
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
|
-
//
|
|
681
|
-
// `Last ANR continued`
|
|
682
|
-
//
|
|
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
|
-
*
|
|
745
|
-
*
|
|
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
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
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
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
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
|
-
//
|
|
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]
|
|
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
|
-
//
|
|
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]
|
|
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
|
-
//
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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(` 📜
|
|
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(` 📸
|
|
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📄 [
|
|
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
|
|
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(` 📜
|
|
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(` 📜
|
|
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(`
|
|
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]
|
|
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]
|
|
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
|
-
//
|
|
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]
|
|
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
|
|
1134
|
-
console.log(' [INFO]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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⏩
|
|
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(`
|
|
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(`
|
|
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(`
|
|
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(` ✅
|
|
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 =
|
|
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"
|
|
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 : '
|
|
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 ? '
|
|
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">📄
|
|
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
|
|
1421
|
-
<div><b
|
|
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">🗂
|
|
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
|
|
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
|
|
1467
|
+
<h1>📱 Android Page Crawl Report (fast)</h1>
|
|
1467
1468
|
<div class="summary">
|
|
1468
|
-
<b
|
|
1469
|
-
<b
|
|
1469
|
+
<b>Generated:</b> ${genTime} |
|
|
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]
|
|
1487
|
+
console.log(` [WARN] failed to write the report: ${(e as Error).message}`);
|
|
1487
1488
|
}
|
|
1488
1489
|
}
|
|
1489
1490
|
|
|
1490
|
-
/**
|
|
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)
|
|
1507
|
-
// 2)
|
|
1508
|
-
//
|
|
1509
|
-
//
|
|
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(
|
|
1515
|
+
console.log(`not inside the target app (${this.package}), force-stopping and launching...`);
|
|
1515
1516
|
} else {
|
|
1516
1517
|
console.log(
|
|
1517
|
-
|
|
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
|
|
1525
|
-
//
|
|
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]
|
|
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]
|
|
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
|
|
1537
|
-
// pickBestLine()
|
|
1538
|
-
//
|
|
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(
|
|
1546
|
+
console.log(`launch Activity: ${resolved} (from resolve-activity)`);
|
|
1546
1547
|
} else {
|
|
1547
|
-
//
|
|
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(
|
|
1552
|
+
console.log(`launch Activity: ${launchPackage}/${launchActivity} (from the foreground window, fallback)`);
|
|
1552
1553
|
} else {
|
|
1553
1554
|
console.log(
|
|
1554
|
-
`[WARN]
|
|
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
|
-
//
|
|
1560
|
-
//
|
|
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📂
|
|
1565
|
+
console.log(`\n📂 output dir: ${path.resolve(this.outputRoot)}\n`);
|
|
1565
1566
|
console.log('='.repeat(60));
|
|
1566
|
-
console.log('
|
|
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(`⏩
|
|
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(
|
|
1587
|
+
if (rootActivityKeyword) console.log(`root Activity keyword: ${rootActivityKeyword} (from ${p.page_id})`);
|
|
1587
1588
|
break;
|
|
1588
1589
|
}
|
|
1589
1590
|
}
|
|
1590
1591
|
} else {
|
|
1591
|
-
//
|
|
1592
|
-
//
|
|
1593
|
-
//
|
|
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]
|
|
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(
|
|
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🧭
|
|
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]
|
|
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(` 📜
|
|
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]
|
|
1675
|
+
console.log(` [SKIP] element not found: ${JSON.stringify(elemId.slice(0, 3))}`);
|
|
1675
1676
|
continue;
|
|
1676
1677
|
}
|
|
1677
1678
|
|
|
1678
|
-
// input tap/swipe
|
|
1679
|
-
//
|
|
1680
|
-
//
|
|
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]
|
|
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👆
|
|
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(' ⚠️
|
|
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(
|
|
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(`✅
|
|
1761
|
-
console.log(`📂
|
|
1762
|
-
console.log(`📋
|
|
1763
|
-
console.log(`🌐 HTML
|
|
1764
|
-
console.log('\n📊
|
|
1765
|
-
console.log(`
|
|
1766
|
-
console.log(`
|
|
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
|
-
/**
|
|
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]
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
1794
|
-
*
|
|
1795
|
-
* report.html
|
|
1796
|
-
*
|
|
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(`📂
|
|
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📂
|
|
1807
|
-
console.log(`📝
|
|
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✅
|
|
1819
|
-
console.log(`📂
|
|
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(`📂
|
|
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📂
|
|
1831
|
-
console.log(`📝
|
|
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.
|
|
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('📝
|
|
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
|
|
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✅
|
|
1866
|
-
console.log(`📂
|
|
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
|
|
1892
|
-
' --output, -o
|
|
1893
|
-
' --manual
|
|
1894
|
-
' --page "
|
|
1895
|
-
` --device ADB
|
|
1896
|
-
` --adb-path adb
|
|
1897
|
-
` --max-pages
|
|
1898
|
-
` --max-scrolls
|
|
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
|
|
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
|
-
//
|
|
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;
|