@buaa_smat/hometrans 0.1.20 → 26.0.0-devecocli.2
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/agents/build-fixer.md +406 -0
- package/agents/code-reviewer.md +461 -496
- package/agents/model-render-worker.md +34 -0
- package/agents/model-worker.md +23 -0
- package/agents/specgen-worker.md +18 -0
- package/commands/hometrans.md +17 -0
- package/devecocli-plugin/common.ts +2203 -0
- package/devecocli-plugin/install.ts +61 -0
- package/devecocli-plugin/uninstall.ts +26 -0
- package/devecocli-plugin/update.ts +66 -0
- package/index.js +1418 -0
- package/package.json +81 -64
- package/platforms/atomcode/agents/build-fixer.frontmatter.md +6 -0
- package/platforms/atomcode/agents/code-reviewer.frontmatter.md +6 -0
- package/platforms/atomcode/agents/model-render-worker.frontmatter.md +6 -0
- package/platforms/atomcode/agents/model-worker.frontmatter.md +6 -0
- package/platforms/atomcode/agents/specgen-worker.frontmatter.md +6 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/deveco/agents/model-worker.frontmatter.md +5 -0
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +5 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/opencode/agents/model-worker.frontmatter.md +5 -0
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +5 -0
- package/plugin.jsonc +12 -0
- package/skills/a2h-app-migrate/SKILL.md +181 -0
- package/skills/a2h-app-migrate/references/config.example.json +27 -0
- package/skills/a2h-app-migrate/references/specs.example.json +19 -0
- package/skills/a2h-app-migrate/references/stage-map.md +33 -0
- package/skills/a2h-app-migrate/references/workflow.yaml +1600 -0
- package/skills/a2h-app-migrate/scripts/android_index.mjs +109 -0
- package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +80 -0
- package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +95 -0
- package/skills/a2h-app-migrate/scripts/check_signing.mjs +152 -0
- package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
- package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +277 -0
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +77 -0
- package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +147 -0
- package/skills/a2h-app-migrate/scripts/cli_values.mjs +32 -0
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1388 -0
- package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +651 -0
- package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +53 -0
- package/skills/a2h-app-migrate/scripts/json_io.mjs +35 -0
- package/skills/a2h-app-migrate/scripts/ledger.mjs +104 -0
- package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +288 -0
- package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +713 -0
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +205 -0
- package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +121 -0
- package/skills/a2h-app-migrate/scripts/run_dir.mjs +212 -0
- package/skills/a2h-app-migrate/scripts/spec_layout.mjs +30 -0
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +455 -0
- package/skills/a2h-app-migrate/test/test_android_index.mjs +80 -0
- package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
- package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
- package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +92 -0
- package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
- package/skills/a2h-app-migrate/test/test_entry_guards.mjs +93 -0
- package/skills/a2h-app-migrate/test/test_env_requirements.mjs +505 -0
- package/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
- package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
- package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
- package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +91 -0
- package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
- package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
- package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +109 -0
- package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +53 -0
- package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
- package/skills/a2h-app-migrate/test/test_preflight_report.mjs +83 -0
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +144 -0
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
- package/skills/a2h-app-migrate/test/test_run_dir.mjs +315 -0
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +133 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +133 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +158 -0
- package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +181 -0
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +53 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
- package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +39 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +168 -0
- package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
- package/skills/a2h-arch-generate/SKILL.md +375 -0
- package/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
- package/skills/a2h-arch-generate/examples/simple-conversion-android.md +103 -0
- package/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
- package/skills/a2h-arch-generate/examples/simple-conversion-uniapp.md +106 -0
- package/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
- package/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
- package/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
- package/skills/a2h-arch-generate/references/clustering-guidance.md +33 -0
- package/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
- package/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
- package/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
- package/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
- package/skills/a2h-arch-generate/references/homegraph-workflow.md +120 -0
- package/skills/a2h-arch-generate/references/module-evidence-subagent.md +45 -0
- package/skills/a2h-arch-generate/references/reconciliation-model.md +204 -0
- package/skills/a2h-arch-generate/references/scope-policy.md +28 -0
- package/skills/a2h-arch-generate/references/semantic-review.md +65 -0
- package/skills/a2h-arch-generate/references/source-baseline.md +93 -0
- package/skills/a2h-arch-generate/references/source-ecosystems.md +54 -0
- package/skills/a2h-arch-generate/references/transformation-model.md +78 -0
- package/skills/a2h-arch-generate/scripts/check_module_staleness.mjs +284 -0
- package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +260 -0
- package/skills/a2h-arch-generate/scripts/compute_processing_order.mjs +325 -0
- package/skills/a2h-arch-generate/scripts/create_project.mjs +149 -0
- package/skills/a2h-arch-generate/scripts/dump_core_facts.mjs +151 -0
- package/skills/a2h-arch-generate/scripts/extract_core_components.mjs +167 -0
- package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +363 -0
- package/skills/a2h-arch-generate/scripts/generate_state.mjs +60 -0
- package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +326 -0
- package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +3739 -0
- package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +800 -0
- package/skills/a2h-arch-generate/scripts/inspect_project.mjs +251 -0
- package/skills/a2h-arch-generate/scripts/inspect_uniapp_project.mjs +809 -0
- package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1454 -0
- package/skills/a2h-arch-generate/scripts/module_create/create.mjs +136 -0
- package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +636 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/build-profile.json5 +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/hvigorfile.ts +6 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/obfuscation-rules.txt +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/oh-package.json5 +10 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/applicationability/ApplicationAbility.ets +43 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/module.json5 +26 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/color.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/float.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/string.json +16 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/background.png +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/foreground.png +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/layered_image.json +7 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/mock/mock-config.json5 +2 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/module.json5 +11 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/LocalUnit.test.ets +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/Index.ets +1 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/build-profile.json5 +36 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/hvigorfile.ts +6 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/obfuscation-rules.txt +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/oh-package.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +19 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/module.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/float.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/string.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/module.json5 +11 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/test/LocalUnit.test.ets +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/Index.ets +1 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/build-profile.json5 +36 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/consumer-rules.txt +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/hvigorfile.ts +6 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/obfuscation-rules.txt +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/oh-package.json5 +10 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +20 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/utils/Calc.ets +3 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/module.json5 +12 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/float.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/string.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/module.json5 +11 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/LocalUnit.test.ets +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
- package/skills/a2h-arch-generate/scripts/resolve_android_stores.mjs +529 -0
- package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +230 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
- package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1122 -0
- package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +191 -0
- package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
- package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
- package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
- package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +829 -0
- package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +937 -0
- package/skills/a2h-arch-generate/scripts/validate_homegraph_artifacts.mjs +542 -0
- package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +415 -0
- package/skills/a2h-arkts-logic-coder/SKILL.md +125 -0
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +6 -0
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +124 -0
- package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +224 -0
- package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +377 -0
- package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +443 -0
- package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +211 -0
- package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +81 -0
- package/skills/a2h-batch-ui-align/SKILL.md +309 -0
- package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +81 -0
- package/skills/a2h-batch-ui-align/flowchart.html +271 -0
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/conversion-procedure.md +523 -661
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
- package/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +8 -8
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +3 -0
- package/skills/a2h-batch-ui-align/references/source-only-tier.md +32 -0
- package/skills/a2h-batch-ui-align/references/step3-capture.md +211 -0
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +192 -0
- package/skills/a2h-batch-ui-align/references/step5-convert.md +202 -0
- package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +572 -0
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/scripts/android_parse_fast.ts +246 -39
- package/skills/a2h-batch-ui-align/scripts/answers_check.mjs +86 -0
- package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +2689 -0
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1656 -0
- package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
- package/skills/a2h-batch-ui-align/scripts/detach.mjs +258 -0
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1524 -0
- package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
- package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +166 -0
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1437 -0
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1869 -0
- package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +696 -0
- package/skills/a2h-batch-ui-align/scripts/harmony_index.mjs +218 -0
- package/skills/a2h-batch-ui-align/scripts/host_env.mjs +208 -0
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1229 -0
- package/skills/a2h-batch-ui-align/scripts/occlusion.mjs +141 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1124 -0
- package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +996 -0
- package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +217 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +253 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +72 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +353 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +345 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +290 -0
- package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +74 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +507 -0
- package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +189 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1451 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
- package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +170 -0
- package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
- package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +244 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +130 -0
- package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
- package/skills/a2h-coldstart-smoke-gate/SKILL.md +57 -0
- package/skills/a2h-dashboard-render/SKILL.md +65 -0
- package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +147 -0
- package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
- package/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
- package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +83 -0
- package/skills/a2h-dashboard-render/scripts/artifact_contract.mjs +138 -0
- package/skills/a2h-dashboard-render/scripts/check-registry.mjs +87 -0
- package/skills/a2h-dashboard-render/scripts/dashboard.mjs +3215 -0
- package/skills/a2h-dashboard-render/scripts/device_capture.mjs +2010 -0
- package/skills/a2h-dashboard-render/scripts/page_capture.mjs +828 -0
- package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +459 -0
- package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +13 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
- package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +170 -0
- package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +182 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +64 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1172 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +251 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
- package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
- package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +303 -0
- package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
- package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +444 -0
- package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/SKILL.md +305 -293
- package/skills/a2h-module-semantic-docs/SKILL.md +227 -0
- package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +168 -0
- package/skills/a2h-module-semantic-docs/scripts/lib/py_compat.mjs +688 -0
- package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +1021 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
- package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
- package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
- package/skills/a2h-resource-convert/SKILL.md +369 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/code-vector-icon-rules.md +4 -4
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/conversion-rules.md +16 -5
- package/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/lottie-conversion-rules.md +17 -17
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/resource-mapping-rules.md +15 -4
- package/skills/a2h-resource-convert/references/step3_5-dependency-filter.md +54 -0
- package/skills/a2h-resource-convert/references/step4-qualifiers-and-values.md +142 -0
- package/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
- package/skills/a2h-resource-convert/references/step5-reference-resolution.md +154 -0
- package/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/xml-drawable-to-svg-rules.md +38 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/a2h_resource_convert.ts +456 -90
- package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +1072 -0
- package/skills/a2h-resource-convert/scripts/app_identity.ts +947 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/code_vector_icons.ts +19 -3
- package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +989 -0
- package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +1464 -0
- package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
- package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
- package/skills/a2h-spec-design/SKILL.md +336 -0
- package/skills/a2h-spec-design/scripts/inspect_spec_design_inputs.mjs +146 -0
- package/skills/a2h-spec-design/scripts/lib/py_compat.mjs +481 -0
- package/skills/a2h-spec-design/scripts/move_spec_technical_reference.mjs +159 -0
- package/skills/a2h-spec-design/scripts/resolve_module_design.mjs +102 -0
- package/skills/a2h-spec-design/scripts/validate_spec_design_output.mjs +285 -0
- package/skills/a2h-spec-design/test/golden/inspect_happy.json +20 -0
- package/skills/a2h-spec-design/test/golden/move_design.md +18 -0
- package/skills/a2h-spec-design/test/golden/move_design_crlf.md +18 -0
- package/skills/a2h-spec-design/test/golden/move_spec.md +7 -0
- package/skills/a2h-spec-design/test/golden/resolve_cases.json +36 -0
- package/skills/a2h-spec-design/test/golden/validate_issue_file.md +12 -0
- package/skills/a2h-spec-design/test/golden/validate_issues.json +57 -0
- package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +381 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +228 -0
- package/skills/a2h-spec-design-pipeline/package.json +4 -0
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +63 -0
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +69 -0
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +24 -0
- package/skills/a2h-spec-design-pipeline/references/initialization.md +57 -0
- package/skills/a2h-spec-design-pipeline/references/merge-queue.md +21 -0
- package/skills/a2h-spec-design-pipeline/references/scripts.md +27 -0
- package/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +21 -0
- package/skills/a2h-spec-design-pipeline/scripts/atomic_write.ts +42 -0
- package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +252 -0
- package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +77 -0
- package/skills/a2h-spec-design-pipeline/scripts/deps_ready.ts +195 -0
- package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +651 -0
- package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +124 -0
- package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +944 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +95 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +502 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_waves.ts +475 -0
- package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +218 -0
- package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +164 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +44 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +301 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +64 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +87 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +265 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +675 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +105 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +452 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +375 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +561 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +182 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +138 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +289 -0
- package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +441 -0
- package/skills/a2h-spec-generate/SKILL.md +285 -0
- package/skills/a2h-spec-generate/package.json +9 -0
- package/skills/a2h-spec-generate/references/batch-mode.md +151 -0
- package/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +114 -0
- package/skills/a2h-spec-generate/references/input-formats.md +27 -0
- package/skills/a2h-spec-generate/references/library-evidence.md +3 -0
- package/skills/a2h-spec-generate/references/method-discipline.md +64 -0
- package/skills/a2h-spec-generate/references/optional-gates.json +45 -0
- package/skills/a2h-spec-generate/references/recall-guide.md +83 -0
- package/skills/a2h-spec-generate/references/recall-terse.md +3 -0
- package/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
- package/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
- package/skills/a2h-spec-generate/references/review-checklist.md +21 -0
- package/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
- package/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
- package/skills/a2h-spec-generate/references/spec-samples.md +65 -0
- package/skills/a2h-spec-generate/references/specs.schema.json +79 -0
- package/skills/a2h-spec-generate/references/synthesis-rules.md +143 -0
- package/skills/a2h-spec-generate/references/transfer-file.md +5 -0
- package/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
- package/skills/a2h-spec-generate/references/worker-rules.md +126 -0
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +514 -0
- package/skills/a2h-spec-generate/scripts/check_spec.ts +361 -0
- package/skills/a2h-spec-generate/scripts/collect-specs.mjs +470 -0
- package/skills/a2h-spec-generate/scripts/detect-project.mjs +271 -0
- package/skills/a2h-spec-generate/scripts/ensure-index.mjs +188 -0
- package/skills/a2h-spec-generate/scripts/feature-stem.mjs +150 -0
- package/skills/a2h-spec-generate/scripts/inspect-uniapp.mjs +733 -0
- package/skills/{hmos-spec-generate → a2h-spec-generate}/scripts/parse_requirements.ts +1 -1
- package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +307 -0
- package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +171 -0
- package/skills/a2h-spec-generate/scripts/publish-specs.mjs +280 -0
- package/skills/a2h-spec-generate/scripts/render-tasks.mjs +399 -0
- package/skills/a2h-spec-generate/scripts/report.mjs +132 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +149 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +49 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +140 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +16 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +42 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-splitters.js +78 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-state.js +47 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +194 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-virtual-list.js +118 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.css +245 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +99 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +220 -0
- package/skills/a2h-spec-generate/scripts/reqgen/package-lock.json +47 -0
- package/skills/a2h-spec-generate/scripts/reqgen/package.json +23 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/agent-render/serve.ts +95 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/callback-call-sites.ts +82 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/area-ownership.ts +496 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/callback-flow.ts +386 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/index.ts +24 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/index.ts +22 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1270 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/index.ts +10 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/projection.ts +804 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/render-projection.ts +51 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/android-interaction-registry.ts +286 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/builder.ts +453 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/compose-api-registry.ts +526 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/index.ts +15 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/connector/index.ts +1 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/connector/utg-inbound.ts +763 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/area-graph.ts +383 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/artifact.ts +68 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/common.ts +88 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/diagnostic.ts +64 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/gap-audit.ts +113 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/index.ts +12 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/name-traceability.ts +108 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/raw-fact.ts +377 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/req-model.ts +238 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/run.ts +134 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/semantic-completeness.ts +35 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/source-facts.ts +48 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/utg.ts +133 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/core/output-guard.ts +42 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/core/stable-id.ts +118 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/cross-area-tally-cli.ts +179 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dashboard-cli.ts +188 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dump/dump.ts +1184 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dump/index.ts +1 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dump-cli.ts +373 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1014 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +32 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +142 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +312 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +310 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +685 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/graph/paths.ts +575 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/homegraph-cli.ts +50 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/android-resource-resolver.ts +391 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/androidx-preference-contracts.ts +44 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +640 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/cross-area.ts +207 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/finalizer.ts +1297 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/identity.ts +186 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/index.ts +16 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/planner.ts +312 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/preference-enrichment.ts +793 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/raw-facts.ts +355 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/rules.ts +271 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/scanner.ts +666 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +365 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/stable-key.ts +144 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +301 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/uniapp-utg-adapter.ts +543 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/xml-adapter.ts +262 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/assemble.ts +2079 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +157 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +809 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/index.ts +17 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/io.ts +165 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +806 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +360 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/seeds.ts +218 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/spec-bindings-sidecar.ts +240 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +359 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model-cli.ts +500 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/index.ts +7 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/output.ts +307 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +172 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/index.ts +1 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/source-cov.ts +176 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/area-graph.ts +490 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/index.ts +23 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-model.ts +957 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +248 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/semantic-area-graph.ts +1600 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/types.ts +10 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/artifact-data.ts +201 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +74 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +180 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +18 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +55 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-splitters.ts +78 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-state.ts +66 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +232 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-virtual-list.ts +179 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +240 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/contracts.d.ts +86 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/index.ts +3 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/server.ts +239 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/source-project.ts +316 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz-cli.ts +200 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +290 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1323 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +574 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +831 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +548 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +396 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +298 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
- package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.json +16 -0
- package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.viz-client.json +12 -0
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +632 -0
- package/skills/a2h-spec-generate/test/check-spec.test.ts +200 -0
- package/skills/a2h-spec-generate/test/collect-specs.test.mjs +538 -0
- package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
- package/skills/a2h-spec-generate/test/ensure-index.test.mjs +45 -0
- package/skills/a2h-spec-generate/test/feature-stem.test.mjs +147 -0
- package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
- package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
- package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
- package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
- package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
- package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +157 -0
- package/skills/a2h-spec-generate/test/publish-specs.test.mjs +282 -0
- package/skills/a2h-spec-generate/test/render-tasks.test.mjs +593 -0
- package/skills/a2h-utg-explorer/SKILL.md +120 -0
- package/skills/a2h-utg-explorer/assets/final_viewer.html +64 -0
- package/skills/a2h-utg-explorer/assets/u2.LICENSE +21 -0
- package/skills/a2h-utg-explorer/assets/u2.NOTICE +25 -0
- package/skills/a2h-utg-explorer/assets/u2.jar +0 -0
- package/skills/a2h-utg-explorer/references/architecture.md +270 -0
- package/skills/a2h-utg-explorer/references/protocol.md +9 -0
- package/skills/a2h-utg-explorer/scripts/app_settings.mjs +143 -0
- package/skills/a2h-utg-explorer/scripts/audit.mjs +167 -0
- package/skills/a2h-utg-explorer/scripts/close_phases.mjs +66 -0
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +749 -0
- package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +597 -0
- package/skills/a2h-utg-explorer/scripts/device_health.mjs +227 -0
- package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +276 -0
- package/skills/a2h-utg-explorer/scripts/evidence.mjs +108 -0
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +376 -0
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +89 -0
- package/skills/a2h-utg-explorer/scripts/plan.mjs +258 -0
- package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +170 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +467 -0
- package/skills/a2h-utg-explorer/scripts/recover_b.mjs +542 -0
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +302 -0
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +203 -0
- package/skills/a2h-utg-explorer/scripts/report.mjs +143 -0
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +831 -0
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +137 -0
- package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
- package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
- package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +207 -0
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +223 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +88 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
- package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +136 -0
- package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
- package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
- package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +251 -0
- package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +42 -0
- package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +162 -0
- package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
- package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +204 -0
- package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +355 -0
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +207 -0
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
- package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +453 -0
- package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +131 -0
- package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
- package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +321 -0
- package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
- package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
- package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
- package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/_device_io.mjs +244 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/_py.mjs +2097 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +1213 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/attest.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/chain.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/coverage.mjs +89 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/device_lock.mjs +46 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1136 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +1513 -0
- package/skills/a2h-utg-explorer/scripts/variant.mjs +75 -0
- package/skills/a2h-utg-explorer/scripts/worklist_parts.mjs +122 -0
- package/skills/a2h-utg-static/SKILL.md +361 -0
- package/skills/a2h-utg-static/config.json +19 -0
- package/skills/a2h-utg-static/references/extractors.md +217 -0
- package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
- package/skills/a2h-utg-static/references/view-interactions.md +215 -0
- package/skills/a2h-utg-static/scripts/_graph.mjs +361 -0
- package/skills/a2h-utg-static/scripts/_py.mjs +2177 -0
- package/skills/a2h-utg-static/scripts/_spawn.mjs +45 -0
- package/skills/a2h-utg-static/scripts/activity_nav.mjs +738 -0
- package/skills/a2h-utg-static/scripts/activity_widgets.mjs +254 -0
- package/skills/a2h-utg-static/scripts/adapter_nav.mjs +229 -0
- package/skills/a2h-utg-static/scripts/androidfragment_nav.mjs +208 -0
- package/skills/a2h-utg-static/scripts/assemble.mjs +2065 -0
- package/skills/a2h-utg-static/scripts/audit.mjs +268 -0
- package/skills/a2h-utg-static/scripts/carry_answers.mjs +201 -0
- package/skills/a2h-utg-static/scripts/click_paths.mjs +594 -0
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +172 -0
- package/skills/a2h-utg-static/scripts/compose_merge.mjs +263 -0
- package/skills/a2h-utg-static/scripts/compose_nav.mjs +1216 -0
- package/skills/a2h-utg-static/scripts/compose_navbar_nav.mjs +238 -0
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +2760 -0
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +365 -0
- package/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
- package/skills/a2h-utg-static/scripts/dialog_listener_nav.mjs +237 -0
- package/skills/a2h-utg-static/scripts/dialogshow_nav.mjs +308 -0
- package/skills/a2h-utg-static/scripts/fragfactory_nav.mjs +170 -0
- package/skills/a2h-utg-static/scripts/fragment_nav.mjs +1136 -0
- package/skills/a2h-utg-static/scripts/guard_subjects.mjs +162 -0
- package/skills/a2h-utg-static/scripts/hg_query.mjs +137 -0
- package/skills/a2h-utg-static/scripts/host_resolve.mjs +393 -0
- package/skills/a2h-utg-static/scripts/hybrid_bundle.mjs +165 -0
- package/skills/a2h-utg-static/scripts/hybrid_pages.mjs +713 -0
- package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
- package/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
- package/skills/a2h-utg-static/scripts/io_utils.mjs +59 -0
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +864 -0
- package/skills/a2h-utg-static/scripts/launch_extras.mjs +91 -0
- package/skills/a2h-utg-static/scripts/layout_resolve.mjs +148 -0
- package/skills/a2h-utg-static/scripts/manifest.mjs +483 -0
- package/skills/a2h-utg-static/scripts/measure/measure_corpus.mjs +297 -0
- package/skills/a2h-utg-static/scripts/measure/measure_guards.mjs +98 -0
- package/skills/a2h-utg-static/scripts/media_browse_nav.mjs +356 -0
- package/skills/a2h-utg-static/scripts/menu_nav.mjs +603 -0
- package/skills/a2h-utg-static/scripts/navactions_nav.mjs +255 -0
- package/skills/a2h-utg-static/scripts/nl_hints.mjs +453 -0
- package/skills/a2h-utg-static/scripts/orphan_overlay_nav.mjs +89 -0
- package/skills/a2h-utg-static/scripts/phase_plan.mjs +108 -0
- package/skills/a2h-utg-static/scripts/phase_planner.mjs +119 -0
- package/skills/a2h-utg-static/scripts/plaindialog_nav.mjs +411 -0
- package/skills/a2h-utg-static/scripts/preference_nav.mjs +761 -0
- package/skills/a2h-utg-static/scripts/preference_widgets.mjs +142 -0
- package/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
- package/skills/a2h-utg-static/scripts/registry_nav.mjs +288 -0
- package/skills/a2h-utg-static/scripts/run_pipeline.mjs +870 -0
- package/skills/a2h-utg-static/scripts/scope_utils.mjs +430 -0
- package/skills/a2h-utg-static/scripts/screen_merge.mjs +287 -0
- package/skills/a2h-utg-static/scripts/screen_nav.mjs +279 -0
- package/skills/a2h-utg-static/scripts/single_host_nav.mjs +291 -0
- package/skills/a2h-utg-static/scripts/starter_nav.mjs +198 -0
- package/skills/a2h-utg-static/scripts/state_guard.mjs +579 -0
- package/skills/a2h-utg-static/scripts/static_prior.mjs +904 -0
- package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
- package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
- package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
- package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +90 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
- package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
- package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
- package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
- package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +267 -0
- package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
- package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
- package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
- package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
- package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +119 -0
- package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
- package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
- package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +33 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
- package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
- package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
- package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
- package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
- package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
- package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
- package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
- package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
- package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
- package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
- package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
- package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
- package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
- package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
- package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
- package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
- package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +273 -0
- package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
- package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
- package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1119 -0
- package/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
- package/skills/a2h-utg-static/scripts/utg_html.mjs +721 -0
- package/skills/a2h-utg-static/scripts/view_interactions.mjs +799 -0
- package/skills/a2h-utg-static/scripts/view_widgets.mjs +512 -0
- package/skills/a2h-utg-static/scripts/viewpage_nav.mjs +485 -0
- package/skills/a2h-utg-static/scripts/vm_nav.mjs +422 -0
- package/skills/a2h-utg-static/scripts/window_nav.mjs +240 -0
- package/skills/a2h-utg-static/scripts/worklist_parts.mjs +154 -0
- package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
- package/skills/a2h-utg-static/tools/package.json +3 -0
- package/README.md +0 -445
- package/agents/logic-coder.md +0 -224
- package/agents/logic-context-builder.md +0 -212
- package/agents/scripts/hmos-precheck/backends/arkts.mjs +0 -567
- package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +0 -159
- package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +0 -398
- package/agents/scripts/hmos-precheck/backends/codelinter.mjs +0 -250
- package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +0 -321
- package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +0 -247
- package/agents/scripts/hmos-precheck/core/config.mjs +0 -184
- package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +0 -20
- package/agents/scripts/hmos-precheck/core/process_adapter.mjs +0 -47
- package/agents/scripts/hmos-precheck/core/project_catalog.mjs +0 -50
- package/agents/scripts/hmos-precheck/core/result_projection.mjs +0 -147
- package/agents/scripts/hmos-precheck/core/scope_plan.mjs +0 -131
- package/agents/scripts/hmos-precheck/core/sdk_context.mjs +0 -67
- package/agents/scripts/hmos-precheck/docs/architecture.md +0 -37
- package/agents/scripts/hmos-precheck/docs/performance-optimization.md +0 -28
- package/agents/scripts/hmos-precheck/docs/upstream-reference.json +0 -19
- package/agents/scripts/hmos-precheck/docs/validation.md +0 -50
- package/agents/scripts/hmos-precheck/index.mjs +0 -17
- package/agents/scripts/hmos-precheck/invocation.mjs +0 -231
- package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +0 -32
- package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +0 -64
- package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +0 -59
- package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +0 -54
- package/agents/scripts/platform_query.mjs +0 -626
- package/agents/scripts/platform_query.test.mjs +0 -422
- package/agents/self-test-fixer.md +0 -298
- package/agents/self-tester.md +0 -55
- package/agents/test-case-generation-generator.md +0 -317
- package/agents/test-case-generation-validator.md +0 -231
- package/dist/cli/config-store.js +0 -310
- package/dist/cli/config.js +0 -44
- package/dist/cli/env-vars.js +0 -127
- package/dist/cli/index.js +0 -56
- package/dist/cli/init.js +0 -1187
- package/dist/cli/uninstall.js +0 -427
- package/dist/utils/regex.js +0 -8
- package/env-requirements.json +0 -179
- package/resource/choose_editor.png +0 -0
- package/resource/convert_pipeline_process.svg +0 -103
- package/resource/project_architecture.svg +0 -122
- 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/hmos-batch-ui-align/SKILL.md +0 -413
- package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +0 -1592
- package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +0 -752
- package/skills/hmos-convert-pipeline/SKILL.md +0 -486
- package/skills/hmos-incremental-ui-align/README.md +0 -251
- package/skills/hmos-incremental-ui-align/SKILL.md +0 -375
- package/skills/hmos-incremental-ui-align/diff_analysis.md +0 -53
- package/skills/hmos-incremental-ui-align/page_align.md +0 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +0 -38
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +0 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/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/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +0 -47
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//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/hmos-incremental-ui-align/references/State_Model_Template.md +0 -74
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +0 -34
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +0 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +0 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -117
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +0 -937
- package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +0 -343
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +0 -76
- package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +0 -977
- package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +0 -188
- package/skills/hmos-integration-test/README.md +0 -341
- package/skills/hmos-integration-test/SKILL.md +0 -464
- package/skills/hmos-integration-test/scripts/report-tool.ts +0 -791
- package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +0 -125
- package/skills/hmos-integration-test/scripts/self-test-runner.ts +0 -756
- package/skills/hmos-integration-test/scripts/testcases-tool.ts +0 -239
- package/skills/hmos-resources-convert/SKILL.md +0 -891
- package/skills/hmos-spec-generate/SKILL.md +0 -404
- package/skills/hmos-test-case-generation/README.md +0 -241
- package/skills/hmos-test-case-generation/SKILL.md +0 -324
- package/skills/hmos-test-case-generation/references/contract.md +0 -315
- package/skills/hmos-test-case-generation/references/review-notes-template.md +0 -84
- package/skills/hmos-test-case-generation/references/ui-elements-schema.md +0 -142
- package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +0 -550
- package/skills/hmos-test-case-generation/tools/validate.ts +0 -1312
- package/tools/bfs-crawl/README.md +0 -73
- package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +0 -1662
- /package/skills/{hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md" → a2h-arch-generate/references/arkts-mvvm-v2.md} +0 -0
- /package/{README.en.md → skills/a2h-arch-generate/scripts/module_create/har/consumer-rules.txt} +0 -0
- /package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md" +0 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md" +0 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md" +0 -0
- /package/skills/{hmos-batch-ui-align → 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 -0
- /package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/arkts-strict-patterns.md +0 -0
- /package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/known-patterns.md +0 -0
- /package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/rdb-entity-pattern.md +0 -0
- /package/skills/{hmos-resources-convert → a2h-resource-convert}/references/dependency-analysis-rules.md +0 -0
- /package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/svg_fidelity_check.ts +0 -0
- /package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.txt +0 -0
- /package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.xlsx +0 -0
|
@@ -0,0 +1,1213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters.mjs — port of adapters.py. Device and external-tool boundaries; no application-
|
|
3
|
+
* specific navigation knowledge. ADB owns atomic input; layouts come from the resident
|
|
4
|
+
* uiautomator2 server (layout_backend "u2", default), `uiautomator dump`, or the Android CLI.
|
|
5
|
+
*
|
|
6
|
+
* Exports: AdapterError, readJson, writeJson, atomicWriteJson, event, normalizeNodes,
|
|
7
|
+
* _descendsFrom, matching, ruleMatches, rowState, resolveIdentity, observationKey,
|
|
8
|
+
* DeviceAdapter, CommandAdapter, importDroidbot,
|
|
9
|
+
* U2Server (native replacement of the uiautomator2 package's server client),
|
|
10
|
+
* U2_JAR, U2_REMOTE_JAR, U2_DEFAULT_PORT, U2_DUMP_TIMEOUT, time (sleep/monotonic hooks, patchable in tests)
|
|
11
|
+
*
|
|
12
|
+
* Everything is synchronous (spawnSync for adb one-shots; the persistent shell, the u2 server
|
|
13
|
+
* child and its HTTP calls go through the blocking worker bridge in _device_io.mjs).
|
|
14
|
+
*
|
|
15
|
+
* Deliberate differences from adapters.py (decided for the port):
|
|
16
|
+
* - screenshots are always `adb exec-out screencap -p` (the u2 JPEG/Pillow path is gone);
|
|
17
|
+
* - the u2 server ships with the skill (assets/u2.jar = uiautomator2 3.7.0's u2.jar 0.4.0),
|
|
18
|
+
* so the "uiautomator2 not installed -> uiautomator" default fallback no longer exists;
|
|
19
|
+
* - the HTTP transport is `adb forward tcp:<free> tcp:9008` (u2 used an adb socket directly);
|
|
20
|
+
* close() kills the server process and removes that forward;
|
|
21
|
+
* - DeviceAdapter's u2 dump times out after config.u2_http_timeout (U2_DUMP_TIMEOUT s, not u2's
|
|
22
|
+
* 300 s), and a timeout is a `device-timeout` (device recovery), not a parse failure.
|
|
23
|
+
*/
|
|
24
|
+
import * as fs from 'node:fs';
|
|
25
|
+
import { fileURLToPath } from 'node:url';
|
|
26
|
+
import { spawnSync } from 'node:child_process';
|
|
27
|
+
import {
|
|
28
|
+
get, mget, truthy, or, pyStr, pyIn, pyEq, pyRepr, pyRe, reFindall, reFullmatch, pyInt, toInt, toFloat, fmtFixed,
|
|
29
|
+
pyRound, asFloat, jsonLoads, jsonDumps, keysOf, dset, sortedBy, sortedStr, pOrder, readText, writeText, readBytes,
|
|
30
|
+
atomicWriteText, pathStr, pJoin, pResolve, pMkdir, pIsFile, pName, pStem, pSuffix, pParent, pParents, pEq,
|
|
31
|
+
pGlob, pathStr as P, decodeReplace, strTail, cpSlice, shlexQuote, sha256Hex, md5File, uuid4, uuid4Hex, subprocessRun,
|
|
32
|
+
TimeoutExpired, time as epoch, reprTuple, sleep, monotonic, XmlParseError, etParse, etFromString, pyStrip, isFloat,
|
|
33
|
+
} from './_py.mjs';
|
|
34
|
+
import { treePackage, occludedIndices } from './semantics.mjs';
|
|
35
|
+
import { bridge, killPidsSync } from './_device_io.mjs';
|
|
36
|
+
|
|
37
|
+
/** adapters.time: the sleep/monotonic the adapter uses (tests replace members like patch()). */
|
|
38
|
+
export const time = { sleep, monotonic };
|
|
39
|
+
|
|
40
|
+
/** AdapterError (RuntimeError subclass in Python): str(exc) is the message. */
|
|
41
|
+
export class AdapterError extends Error {
|
|
42
|
+
constructor(message = '') { super(String(message)); this.name = 'AdapterError'; }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** read_json(path): utf-8-sig text -> jsonLoads. */
|
|
46
|
+
export function readJson(p) { return jsonLoads(readText(p, { encoding: 'utf-8-sig' })); }
|
|
47
|
+
|
|
48
|
+
/** write_json(path, value): mkdir parents, json.dumps(ensure_ascii=False, indent=2), text mode. */
|
|
49
|
+
export function writeJson(p, value) {
|
|
50
|
+
pMkdir(pParent(p), { parents: true, exist_ok: true });
|
|
51
|
+
writeText(p, jsonDumps(value, { ensure_ascii: false, indent: 2 }));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** atomic_write_json(path, value, retries=6). */
|
|
55
|
+
export function atomicWriteJson(p, value, retries = 6) {
|
|
56
|
+
if (retries && typeof retries === 'object') { retries = retries.retries ?? 6; }
|
|
57
|
+
atomicWriteText(p, jsonDumps(value, { ensure_ascii: false, indent: 2 }), retries);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** event(kind, environment_id, payload, evidence=(), event_id=None) -> utg-event/1 dict. */
|
|
61
|
+
export function event(kind, environmentId, payload, evidence = [], eventId = null) {
|
|
62
|
+
if (eventId && typeof eventId === 'object') { eventId = eventId.event_id ?? null; }
|
|
63
|
+
return { schema: 'utg-event/1', id: truthy(eventId) ? eventId : uuid4(), kind, environment_id: environmentId,
|
|
64
|
+
ts: asFloat(pyRound(epoch(), 3)), payload, evidence: [...evidence].map((p) => pResolve(pyStr(p))) };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const FLAGS = ['clickable', 'scrollable', 'long-clickable', 'enabled', 'focused', 'checked', 'selected', 'password'];
|
|
68
|
+
const ALIASES = [['resource-id', 'resource_id'], ['resourceId', 'resource_id'], ['content-desc', 'content_desc'],
|
|
69
|
+
['contentDesc', 'content_desc'], ['content_description', 'content_desc'], ['className', 'class']];
|
|
70
|
+
const isDict = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) && !(v instanceof Map);
|
|
71
|
+
const INT_RE = pyRe('-?\\d+');
|
|
72
|
+
|
|
73
|
+
/** normalize_nodes(raw): flatten XML attributes, Android CLI trees or DroidBot views. */
|
|
74
|
+
export function normalizeNodes(raw) {
|
|
75
|
+
const result = [];
|
|
76
|
+
if (isDict(raw)) {
|
|
77
|
+
const w = ['nodes', 'views', 'elements', 'roots', 'windows'].find((k) => Object.hasOwn(raw, k));
|
|
78
|
+
raw = w !== undefined ? raw[w] : [raw];
|
|
79
|
+
}
|
|
80
|
+
if (!Array.isArray(raw)) { throw new AdapterError('Layout must contain a list or tree of UI elements'); }
|
|
81
|
+
const visit = (item, parent = null) => {
|
|
82
|
+
if (!isDict(item)) { return; }
|
|
83
|
+
const n = {};
|
|
84
|
+
for (const k of keysOf(item)) { if (k !== 'children') { dset(n, k, item[k]); } }
|
|
85
|
+
const children = Object.hasOwn(item, 'children') ? item.children : [];
|
|
86
|
+
for (const [src, dst] of ALIASES) { if (Object.hasOwn(n, src)) { dset(n, dst, n[src]); } }
|
|
87
|
+
dset(n, 'parent_index', parent);
|
|
88
|
+
const interactions = or(get(n, 'interactions'), []);
|
|
89
|
+
for (const flag of FLAGS) {
|
|
90
|
+
const val = Object.hasOwn(n, flag) ? n[flag] : (flag !== 'enabled' ? pyIn(flag, interactions) : true);
|
|
91
|
+
dset(n, flag, typeof val === 'boolean' ? val : pyStr(val).toLowerCase() === 'true');
|
|
92
|
+
}
|
|
93
|
+
n.focused = n.focused || pyIn('focused', or(get(n, 'state'), []));
|
|
94
|
+
dset(n, 'visible', !truthy(get(n, 'off-screen', false)) && pyStr(get(n, 'visible-to-user', 'true')).toLowerCase() !== 'false');
|
|
95
|
+
let bounds = get(n, 'bounds', []);
|
|
96
|
+
if (typeof bounds === 'string') { bounds = reFindall(INT_RE, bounds).map(pyInt); }
|
|
97
|
+
if (Array.isArray(bounds) && bounds.length === 2 && Array.isArray(bounds[0])) { bounds = [...bounds[0], ...bounds[1]]; }
|
|
98
|
+
dset(n, 'bounds', bounds);
|
|
99
|
+
const idx = result.length;
|
|
100
|
+
result.push(n);
|
|
101
|
+
for (const child of Array.isArray(children) ? children : []) { visit(child, idx); }
|
|
102
|
+
};
|
|
103
|
+
for (const item of raw) { visit(item); }
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** _descends_from(nodes, i, ancestors): walk parent_index links (ancestors: Set of indices). */
|
|
108
|
+
export function _descendsFrom(nodes, i, ancestors) {
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
while (i !== null && i !== undefined && i >= 0 && i < nodes.length && !seen.has(i)) {
|
|
111
|
+
if (ancestors.has(i)) { return true; }
|
|
112
|
+
seen.add(i);
|
|
113
|
+
i = get(nodes[i], 'parent_index');
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const ALLOWED = new Set(['resource_id', 'resource_name', 'text', 'content_desc', 'class', 'package', 'checked', 'selected',
|
|
119
|
+
'focused', 'actionable', 'within', 'index']);
|
|
120
|
+
const bkey = (n) => { const b = or(get(n, 'bounds'), [0, 0]); return b.length >= 2 ? [b[1], b[0]] : b.slice(0, 2).reverse(); };
|
|
121
|
+
|
|
122
|
+
/** matching(nodes, selector): visible, enabled nodes matching every field (within/index scopes). */
|
|
123
|
+
export function matching(nodes, selector) {
|
|
124
|
+
if (!truthy(selector) || !isDict(selector)) { throw new AdapterError('A nonempty exact selector is required'); }
|
|
125
|
+
const extra = new Set(Object.keys(selector).filter((k) => !ALLOWED.has(k)));
|
|
126
|
+
if (extra.size) { throw new AdapterError('Unsupported selector fields: ' + pyRepr(extra)); }
|
|
127
|
+
if (Object.hasOwn(selector, 'within') || Object.hasOwn(selector, 'index')) {
|
|
128
|
+
const base = {};
|
|
129
|
+
for (const k of Object.keys(selector)) { if (k !== 'within' && k !== 'index') { base[k] = selector[k]; } }
|
|
130
|
+
if (!Object.keys(base).length) { throw new AdapterError('A scoped selector needs at least one own field'); }
|
|
131
|
+
let hits = matching(nodes, base);
|
|
132
|
+
if (Object.hasOwn(selector, 'within')) {
|
|
133
|
+
const scope = matching(nodes, selector.within);
|
|
134
|
+
if (scope.length !== 1) { return []; }
|
|
135
|
+
const anchor = nodes.indexOf(scope[0]);
|
|
136
|
+
hits = hits.filter((h) => _descendsFrom(nodes, nodes.indexOf(h), new Set([anchor])) && h !== scope[0]);
|
|
137
|
+
}
|
|
138
|
+
if (Object.hasOwn(selector, 'index')) {
|
|
139
|
+
let idx = selector.index;
|
|
140
|
+
if (typeof idx === 'boolean') { idx = idx ? 1 : 0; }
|
|
141
|
+
if (!(typeof idx === 'number' && Number.isInteger(idx)) || idx < 0) { throw new AdapterError('index must be a non-negative integer'); }
|
|
142
|
+
const ordered = sortedBy(hits, bkey);
|
|
143
|
+
return idx < ordered.length ? [ordered[idx]] : [];
|
|
144
|
+
}
|
|
145
|
+
return hits;
|
|
146
|
+
}
|
|
147
|
+
const actionable = (n) => {
|
|
148
|
+
const visited = new Set(); const original = n;
|
|
149
|
+
for (let depth = 0; depth < 5; depth++) {
|
|
150
|
+
if (truthy(get(n, 'clickable'))) { return true; }
|
|
151
|
+
if (['android.widget.ListView', 'android.widget.GridView'].includes(get(n, 'class'))) {
|
|
152
|
+
return depth > 1 || pyIn(get(original, 'checkable'), [true, 'true']);
|
|
153
|
+
}
|
|
154
|
+
const idx = get(n, 'parent_index');
|
|
155
|
+
if (idx === null || visited.has(idx) || !(idx >= 0 && idx < nodes.length)) { return false; }
|
|
156
|
+
visited.add(idx); n = nodes[idx];
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
};
|
|
160
|
+
const fieldMatches = (n, key, value) => {
|
|
161
|
+
if (key === 'actionable') { return pyEq(actionable(n), value); }
|
|
162
|
+
if (key === 'resource_name') { return pyStr(or(get(n, 'resource_id'), '')).split('/').pop() === value; }
|
|
163
|
+
return pyEq(get(n, key), value);
|
|
164
|
+
};
|
|
165
|
+
return nodes.filter((n) => truthy(get(n, 'visible', true)) && truthy(get(n, 'enabled', true))
|
|
166
|
+
&& Object.entries(selector).every(([k, v]) => fieldMatches(n, k, v)));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** rule_matches(observation, rule): positive evidence required; absence alone proves nothing. */
|
|
170
|
+
export function ruleMatches(observation, rule) {
|
|
171
|
+
if (!(truthy(get(rule, 'activity')) || truthy(get(rule, 'all')) || truthy(get(rule, 'any')))) { return false; }
|
|
172
|
+
if (truthy(get(rule, 'activity')) && get(observation, 'activity') !== rule.activity) { return false; }
|
|
173
|
+
if (truthy(get(rule, 'package')) && get(observation, 'package') !== rule.package) { return false; }
|
|
174
|
+
const nodes = get(observation, 'nodes', []);
|
|
175
|
+
if (!get(rule, 'all', []).every((s) => matching(nodes, s).length > 0)) { return false; }
|
|
176
|
+
if (truthy(get(rule, 'any')) && !rule.any.some((s) => matching(nodes, s).length > 0)) { return false; }
|
|
177
|
+
for (const row of get(rule, 'rows', [])) {
|
|
178
|
+
if (!pyEq(rowState(nodes, get(row, 'title')), get(row, 'checked'))) { return false; }
|
|
179
|
+
}
|
|
180
|
+
return !get(rule, 'none', []).some((s) => matching(nodes, s).length > 0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const CHECK_CLS = ['Switch', 'SwitchCompat', 'SwitchMaterial', 'CheckBox'];
|
|
184
|
+
|
|
185
|
+
/** row_state(nodes, title): checked state of the two-state control in the row titled `title`, or null. */
|
|
186
|
+
export function rowState(nodes, title) {
|
|
187
|
+
const hits = [];
|
|
188
|
+
nodes.forEach((n, i) => { if (truthy(get(n, 'visible', true)) && pyEq(get(n, 'text'), title)) { hits.push(i); } });
|
|
189
|
+
if (hits.length !== 1) { return null; }
|
|
190
|
+
const kids = new Map();
|
|
191
|
+
nodes.forEach((n, i) => { const p = get(n, 'parent_index'); if (!kids.has(p)) { kids.set(p, []); } kids.get(p).push(i); });
|
|
192
|
+
const checkables = (root) => {
|
|
193
|
+
const out = []; const stack = [root];
|
|
194
|
+
while (stack.length) {
|
|
195
|
+
const j = stack.pop(); const n = nodes[j];
|
|
196
|
+
if (pyIn(get(n, 'checkable'), [true, 'true']) || CHECK_CLS.some((c) => pyStr(get(n, 'class', '')).endsWith(c))) { out.push(j); }
|
|
197
|
+
stack.push(...(kids.get(j) ?? []));
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
};
|
|
201
|
+
let idx = get(nodes[hits[0]], 'parent_index');
|
|
202
|
+
for (let k = 0; k < 3; k++) {
|
|
203
|
+
if (idx === null || !(idx >= 0 && idx < nodes.length)) { return null; }
|
|
204
|
+
const found = checkables(idx);
|
|
205
|
+
if (found.length === 1) { return truthy(get(nodes[found[0]], 'checked')); }
|
|
206
|
+
if (found.length > 1) { return null; }
|
|
207
|
+
idx = get(nodes[idx], 'parent_index');
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** resolve_identity(observation, config). */
|
|
213
|
+
export function resolveIdentity(observation, config) {
|
|
214
|
+
const pageMatches = get(config, 'page_rules', []).filter((r) => ruleMatches(observation, r));
|
|
215
|
+
const state = {}; const conflicts = new Set(); const proofs = [];
|
|
216
|
+
for (const rule of get(config, 'state_rules', [])) {
|
|
217
|
+
if (ruleMatches(observation, rule)) {
|
|
218
|
+
const values = get(rule, 'values', {});
|
|
219
|
+
for (const key of keysOf(values)) {
|
|
220
|
+
if (Object.hasOwn(state, key) && !pyEq(state[key], values[key])) { conflicts.add(key); }
|
|
221
|
+
dset(state, key, values[key]);
|
|
222
|
+
}
|
|
223
|
+
proofs.push(get(rule, 'id', 'state-rule'));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const key of conflicts) { delete state[key]; }
|
|
227
|
+
const families = new Set(pageMatches.map((r) => mget(r, 'family')));
|
|
228
|
+
const verified = families.size === 1;
|
|
229
|
+
return { family: verified ? [...families][0] : get(observation, 'activity', 'unknown'), state,
|
|
230
|
+
status: verified ? 'verified' : 'unmapped',
|
|
231
|
+
basis: [...pageMatches.map((r) => 'anchors:' + (Object.hasOwn(r, 'id') ? r.id : r.family)), ...proofs],
|
|
232
|
+
reason: verified ? 'unique configured anchor rule' : 'missing or ambiguous page rules',
|
|
233
|
+
conflicts: sortedStr(conflicts) };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const KEY_FIELDS = ['resource_id', 'class', 'text', 'content_desc', 'checked', 'selected', 'enabled'];
|
|
237
|
+
|
|
238
|
+
/** observation_key(observation): sha256 of activity, window and per-node text fields (bounds excluded). */
|
|
239
|
+
export function observationKey(observation) {
|
|
240
|
+
const value = [get(observation, 'activity'), get(observation, 'window'),
|
|
241
|
+
get(observation, 'nodes', []).map((n) => KEY_FIELDS.map((k) => get(n, k)))];
|
|
242
|
+
return sha256Hex(jsonDumps(value, { sort_keys: true, ensure_ascii: false }));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ------------------------------------------------------------------ native uiautomator2 server client
|
|
246
|
+
// Reproduces what the explorer used from the uiautomator2 3.7.0 package (core.py
|
|
247
|
+
// BasicUiautomatorServer + __init__.py dump_hierarchy): push assets/u2.jar (u2.jar 0.4.0)
|
|
248
|
+
// when the remote md5 differs, launch `app_process` as a long-lived `adb shell` child, wait
|
|
249
|
+
// for /ping, call `dumpWindowHierarchy` over JSON-RPC, restart once on HTTP/UiAutomation errors.
|
|
250
|
+
|
|
251
|
+
/** Bundled server jar (copied from uiautomator2 3.7.0 assets; assets/version.json: "u2.jar": "0.4.0"). */
|
|
252
|
+
export const U2_JAR = pathStr(fileURLToPath(new URL('../../assets/u2.jar', import.meta.url)));
|
|
253
|
+
/** Device path the jar is pushed to (same as uiautomator2). */
|
|
254
|
+
export const U2_REMOTE_JAR = '/data/local/tmp/u2.jar';
|
|
255
|
+
/** Device port of the server (uiautomator2 DEFAULT_SERVER_PORT). */
|
|
256
|
+
export const U2_DEFAULT_PORT = 9008;
|
|
257
|
+
const U2_HTTP_TIMEOUT = 300; // uiautomator2._proto.HTTP_TIMEOUT, used by jsonrpc calls without http_timeout
|
|
258
|
+
/** DeviceAdapter's dump timeout (s), config.u2_http_timeout: a hung server fails in 1 min, not 5. */
|
|
259
|
+
export const U2_DUMP_TIMEOUT = 60;
|
|
260
|
+
const U2_EMPTY_XML = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\r\n<hierarchy rotation=\"0\" />";
|
|
261
|
+
|
|
262
|
+
/** uiautomator2 exception look-alikes: str(exc) = message, or repr of the args tuple when several. */
|
|
263
|
+
class U2Error extends Error {
|
|
264
|
+
constructor(kind, ...args) {
|
|
265
|
+
// a JS array argument stands for the Python params tuple
|
|
266
|
+
const r = (a) => (Array.isArray(a) ? reprTuple(a) : pyRepr(a));
|
|
267
|
+
super(args.length === 1 ? pyStr(args[0]) : '(' + args.map(r).join(', ') + ')');
|
|
268
|
+
this.name = kind;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const HTTP_ERRORS = new Set(['HTTPError', 'HTTPTimeoutError']);
|
|
272
|
+
|
|
273
|
+
/** U2Server(adb_argv, {device_server_port, jar}): the BasicUiautomatorServer of uiautomator2, native. */
|
|
274
|
+
export class U2Server {
|
|
275
|
+
constructor(adbArgv, opts = {}) {
|
|
276
|
+
this.adb = [...adbArgv];
|
|
277
|
+
this.serial = adbArgv[adbArgv.indexOf('-s') + 1];
|
|
278
|
+
this.adbBase = adbArgv.slice(0, adbArgv.indexOf('-s')); // adb program argv without `-s <serial>`
|
|
279
|
+
this.devicePort = opts.device_server_port ?? U2_DEFAULT_PORT;
|
|
280
|
+
this.jar = opts.jar ?? U2_JAR;
|
|
281
|
+
this.timeout = opts.timeout ?? 60;
|
|
282
|
+
this.httpTimeout = opts.http_timeout ?? U2_HTTP_TIMEOUT; // dumpWindowHierarchy request timeout (s)
|
|
283
|
+
this._process = null; // {handle, pid}
|
|
284
|
+
this.localPort = null;
|
|
285
|
+
this.settings = { max_depth: 50 };
|
|
286
|
+
this._waitForDevice();
|
|
287
|
+
this._forward();
|
|
288
|
+
LIVE_SERVERS.add(this);
|
|
289
|
+
try { this.startUiautomator(); } catch (e) { this.close(); throw e; }
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
_adb(args, timeout = this.timeout) {
|
|
293
|
+
const r = subprocessRun([...this.adb, ...args], { timeout });
|
|
294
|
+
return { code: r.returncode, out: decodeReplace(r.stdout), err: decodeReplace(r.stderr) };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
_waitForDevice(timeout = 10) {
|
|
298
|
+
const listed = () => {
|
|
299
|
+
const r = subprocessRun([...this.adbBase, 'devices'], { timeout: 10 });
|
|
300
|
+
return decodeReplace(r.stdout).split('\n').some((l) => { const f = pyStrip(l).split(/\s+/); return f[0] === this.serial && f[1] === 'device'; });
|
|
301
|
+
};
|
|
302
|
+
if (listed()) { return; }
|
|
303
|
+
const deadline = epoch() + timeout;
|
|
304
|
+
while (epoch() < deadline) {
|
|
305
|
+
try { this._adb(['wait-for-device'], 1); } catch { /* adb timeout */ }
|
|
306
|
+
if (listed()) { return; }
|
|
307
|
+
}
|
|
308
|
+
throw new U2Error('ConnectError', `device ${this.serial} not online`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_forward() {
|
|
312
|
+
const r = this._adb(['forward', 'tcp:0', `tcp:${this.devicePort}`]);
|
|
313
|
+
const port = Number.parseInt(r.out.trim(), 10);
|
|
314
|
+
if (r.code || !(port > 0)) { throw new U2Error('ConnectError', `adb forward failed: ${(r.err || r.out).trim()}`); }
|
|
315
|
+
this.localPort = port;
|
|
316
|
+
recordForwards(this);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
_removeForward() {
|
|
320
|
+
if (this.localPort === null) { return; }
|
|
321
|
+
try { this._adb(['forward', '--remove', `tcp:${this.localPort}`], 10); } catch { /* best effort */ }
|
|
322
|
+
this.localPort = null;
|
|
323
|
+
recordForwards(null, this);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** _http_request(method, path, data=None, timeout=10.0) -> Buffer body. */
|
|
327
|
+
_httpRequest(method, urlPath, data = null, timeout = 10.0) {
|
|
328
|
+
const headers = { 'User-Agent': 'uiautomator2', 'Accept-Encoding': '', 'Content-Type': 'application/json' };
|
|
329
|
+
const body = truthy(data) ? Buffer.from(jsonDumps(data)) : null;
|
|
330
|
+
if (body) { headers['Content-Length'] = String(body.length); }
|
|
331
|
+
const r = bridge().call('http', { port: this.localPort, method, path: urlPath, headers,
|
|
332
|
+
body: body ? body.toString('base64') : null, timeoutMs: Math.round(timeout * 1000) }, timeout * 1000 + 10000);
|
|
333
|
+
if (r.error !== undefined) {
|
|
334
|
+
// http.client raises socket TimeoutError (an OSError) here, which uiautomator2 does not wrap
|
|
335
|
+
if (r.kind === 'timeout' || r.kind === 'bridge-timeout') { const e = new Error('timed out'); e.name = 'TimeoutError'; e.code = 'ETIMEDOUT'; e.syscall = 'recv'; throw e; }
|
|
336
|
+
throw new U2Error('HTTPError', `Unable to connect to uiautomator2 server: ${r.error}`);
|
|
337
|
+
}
|
|
338
|
+
if (r.status !== 200) { throw new U2Error('HTTPError', `HTTP request failed: ${r.status} ${r.reason}`); }
|
|
339
|
+
return Buffer.from(r.body, 'base64');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
_jsonrpcCallOnce(method, params, timeout) {
|
|
343
|
+
const content = this._httpRequest('POST', '/jsonrpc/0', { jsonrpc: '2.0', id: 1, method, params }, timeout);
|
|
344
|
+
const text = decodeReplace(content);
|
|
345
|
+
const data = jsonLoads(content.toString('utf8'));
|
|
346
|
+
if (!isDict(data)) { throw new U2Error('RPCInvalidError', 'Unknown RPC error: not a dict'); }
|
|
347
|
+
if (Object.hasOwn(data, 'error')) {
|
|
348
|
+
const code = get(data.error, 'code'); const message = get(data.error, 'message', ''); const stack = get(data.error, 'data');
|
|
349
|
+
if (text.includes('UiAutomation not connected')) { throw new U2Error('UiAutomationNotConnectedError', 'UiAutomation not connected'); }
|
|
350
|
+
if (message.includes('android.os.DeadObjectException')) { throw new U2Error('UiAutomationNotConnectedError', 'android.os.DeadObjectException'); }
|
|
351
|
+
if (message.includes('android.os.DeadSystemRuntimeException')) { throw new U2Error('UiAutomationNotConnectedError', 'android.os.DeadSystemRuntimeException'); }
|
|
352
|
+
const p = params;
|
|
353
|
+
if (message.includes('uiautomator.UiObjectNotFoundException')) { throw new U2Error('UiObjectNotFoundError', code, message, p); }
|
|
354
|
+
if (message.includes('java.lang.StackOverflowError')) {
|
|
355
|
+
throw new U2Error('RPCStackOverflowError', `StackOverflowError: ${message}`, p, cpSlice(stack, 0, 1000) + '...' + cpSlice(stack, -1000));
|
|
356
|
+
}
|
|
357
|
+
throw new U2Error('RPCUnknownError', `Unknown RPC error: ${pyStr(code)} ${message}`, p, stack);
|
|
358
|
+
}
|
|
359
|
+
if (!Object.hasOwn(data, 'result')) { throw new U2Error('RPCInvalidError', 'Unknown RPC error: no result field'); }
|
|
360
|
+
return data.result;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** jsonrpc_call(method, params=None, timeout=10): on HTTPError/UiAutomationNotConnected restart once. */
|
|
364
|
+
jsonrpcCall(method, params = null, timeout = 10) {
|
|
365
|
+
try { return this._jsonrpcCallOnce(method, params, timeout); } catch (e) {
|
|
366
|
+
if (!(HTTP_ERRORS.has(e.name) || e.name === 'UiAutomationNotConnectedError')) { throw e; }
|
|
367
|
+
this.stopUiautomator();
|
|
368
|
+
this.startUiautomator();
|
|
369
|
+
return this._jsonrpcCallOnce(method, params, timeout);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
_checkAlive() {
|
|
374
|
+
try { return this._httpRequest('GET', '/ping').toString('latin1') === 'pong'; } catch (e) {
|
|
375
|
+
if (HTTP_ERRORS.has(e.name)) { return false; }
|
|
376
|
+
throw e;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
_checkDeviceFileHash(local, remote) {
|
|
381
|
+
const md5 = md5File(local);
|
|
382
|
+
let output = this._adb(['shell', 'toybox md5sum ' + remote]).out;
|
|
383
|
+
if (output.includes('toybox') && output.includes('not found')) { output = this._adb(['shell', 'md5 ' + remote]).out; }
|
|
384
|
+
return output.includes(md5);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
_setupJar() {
|
|
388
|
+
if (!pIsFile(this.jar)) { throw new AdapterError('layout_backend=u2 requires the bundled server jar: ' + this.jar); }
|
|
389
|
+
if (this._checkDeviceFileHash(this.jar, U2_REMOTE_JAR)) { return; }
|
|
390
|
+
const r = this._adb(['push', this.jar, U2_REMOTE_JAR], 120);
|
|
391
|
+
if (r.code) { throw new U2Error('AdbError', strTail((r.err || r.out).trim(), 1200)); }
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** start_uiautomator(): push jar, reuse a live server, else launch and wait (30 s). */
|
|
395
|
+
startUiautomator() {
|
|
396
|
+
this._setupJar();
|
|
397
|
+
if (this._process && bridge().call('poll', { handle: this._process.handle }).exited) { this._process = null; }
|
|
398
|
+
if (!this._checkAlive()) {
|
|
399
|
+
const command = `CLASSPATH=${U2_REMOTE_JAR} app_process / com.wetest.uia2.Main -p ${this.devicePort}`;
|
|
400
|
+
const r = bridge().call('spawn', { argv: [...this.adb, 'shell', command] });
|
|
401
|
+
if (r.error !== undefined) { throw new U2Error('LaunchUiAutomationError', r.error); }
|
|
402
|
+
this._process = { handle: r.handle, pid: r.pid };
|
|
403
|
+
LIVE_PIDS.add(r.pid);
|
|
404
|
+
this._waitAppProcessReady(30);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
_waitAppProcessReady(timeout) {
|
|
409
|
+
const deadline = epoch() + timeout;
|
|
410
|
+
let buffer = '';
|
|
411
|
+
while (epoch() < deadline) {
|
|
412
|
+
const st = bridge().call('output', { handle: this._process.handle });
|
|
413
|
+
const output = decodeReplace(Buffer.from(st.output, 'base64'));
|
|
414
|
+
buffer += output;
|
|
415
|
+
if (output.includes('already registered')) { throw new U2Error('AccessibilityServiceAlreadyRegisteredError', output); }
|
|
416
|
+
if (st.exited) { throw new U2Error('LaunchUiAutomationError', 'server quit unexpectly', buffer); }
|
|
417
|
+
if (this._checkAlive()) { return; }
|
|
418
|
+
time.sleep(0.5);
|
|
419
|
+
}
|
|
420
|
+
throw new U2Error('LaunchUiAutomationError', 'server not ready', buffer);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** stop_uiautomator(wait=True): kill the server child, then wait (10 s) until /ping fails. */
|
|
424
|
+
stopUiautomator(opts = {}) {
|
|
425
|
+
const wait = opts.wait ?? true;
|
|
426
|
+
if (this._process) {
|
|
427
|
+
bridge().call('kill', { handle: this._process.handle }, 10000);
|
|
428
|
+
LIVE_PIDS.delete(this._process.pid);
|
|
429
|
+
this._process = null;
|
|
430
|
+
}
|
|
431
|
+
if (wait) {
|
|
432
|
+
const deadline = epoch() + 10;
|
|
433
|
+
while (epoch() < deadline) {
|
|
434
|
+
if (!this._checkAlive()) { return; }
|
|
435
|
+
time.sleep(0.5);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** close(): stop the server and remove this client's adb forward. */
|
|
441
|
+
close() {
|
|
442
|
+
try { this.stopUiautomator(); } finally { this._removeForward(); LIVE_SERVERS.delete(this); }
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** dump_hierarchy(compressed=False, pretty=False, max_depth=None, root_in_active=None) -> xml str. */
|
|
446
|
+
dumpHierarchy(opts = {}) {
|
|
447
|
+
const compressed = opts.compressed ?? false;
|
|
448
|
+
const maxDepth = opts.max_depth ?? this.settings.max_depth;
|
|
449
|
+
const rootInActive = opts.root_in_active ?? null;
|
|
450
|
+
const params = rootInActive === null ? [compressed, maxDepth] : [compressed, maxDepth, rootInActive];
|
|
451
|
+
for (let attempt = 0; attempt < 3; attempt++) { // @retry(HierarchyEmptyError, tries=3, delay=1)
|
|
452
|
+
const content = this.jsonrpcCall('dumpWindowHierarchy', params, this.httpTimeout);
|
|
453
|
+
if (content !== '' && !pyStr(content).includes('<hierarchy rotation="0" />')) { return content; }
|
|
454
|
+
if (attempt < 2) { time.sleep(1); }
|
|
455
|
+
}
|
|
456
|
+
return U2_EMPTY_XML;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* True when `dumpsys window` shows a visible, non-focusable panel window owned by `pkg` (a
|
|
462
|
+
* Compose `Popup` / PopupWindow): it draws above the activity but is never the active window.
|
|
463
|
+
*/
|
|
464
|
+
export function appPopupWindow(dump, pkg) {
|
|
465
|
+
if (!truthy(pkg)) { return false; }
|
|
466
|
+
for (const block of pyStr(dump).split(/\n(?=\s*Window #\d+ )/)) {
|
|
467
|
+
if (!block.includes('package=' + pkg + ' ')) { continue; }
|
|
468
|
+
if (!/\bty=APPLICATION_(?:SUB_)?PANEL\b/.test(block) || !/\bfl=[^\n]*\bNOT_FOCUSABLE\b/.test(block)) { continue; }
|
|
469
|
+
if (/\bisVisible=true\b/.test(block) || /\bisOnScreen=true\b/.test(block)) { return true; }
|
|
470
|
+
}
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* The all-windows hierarchy `xml` cut to its first (topmost) window root owned by `pkg`, or null.
|
|
476
|
+
* Root order is the server's window order, topmost first.
|
|
477
|
+
*/
|
|
478
|
+
export function topWindowOf(xml, pkg) {
|
|
479
|
+
const text = pyStr(xml);
|
|
480
|
+
const open = text.indexOf('<hierarchy');
|
|
481
|
+
if (open < 0) { return null; }
|
|
482
|
+
const headEnd = text.indexOf('>', open) + 1;
|
|
483
|
+
const re = /<(\/?)node\b([^>]*?)(\/?)>/g;
|
|
484
|
+
re.lastIndex = headEnd;
|
|
485
|
+
let depth = 0; let start = -1; let m;
|
|
486
|
+
while ((m = re.exec(text)) !== null) {
|
|
487
|
+
if (m[1]) {
|
|
488
|
+
depth--;
|
|
489
|
+
if (depth === 0 && start >= 0) { return text.slice(0, headEnd) + text.slice(start, re.lastIndex) + '</hierarchy>'; }
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
if (depth === 0 && start < 0 && m[2].includes(`package="${pkg}"`)) { start = m.index; if (m[3]) { return text.slice(0, headEnd) + m[0] + '</hierarchy>'; } }
|
|
493
|
+
if (!m[3]) { depth++; }
|
|
494
|
+
}
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* `uiautomator dump --windows` output (`<window>` → `<hierarchy>` → root `<node>`, windows in
|
|
500
|
+
* z-order, topmost first, child windows nested in their parent) cut to the first window root
|
|
501
|
+
* owned by `pkg`, as a plain one-window hierarchy; null when no window root is the app's.
|
|
502
|
+
*/
|
|
503
|
+
export function topWindowOfWindows(xml, pkg) {
|
|
504
|
+
const text = pyStr(xml);
|
|
505
|
+
const re = /<(\/?)(window|hierarchy|node)\b([^>]*?)(\/?)>/g;
|
|
506
|
+
const stack = []; let start = -1; let rootDepth = -1; let m;
|
|
507
|
+
while ((m = re.exec(text)) !== null) {
|
|
508
|
+
const [, closing, tag, attrs, selfClosing] = m;
|
|
509
|
+
if (closing) {
|
|
510
|
+
stack.pop();
|
|
511
|
+
if (start >= 0 && tag === 'node' && stack.length === rootDepth) {
|
|
512
|
+
return '<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\' ?><hierarchy rotation="0">'
|
|
513
|
+
+ text.slice(start, re.lastIndex) + '</hierarchy>';
|
|
514
|
+
}
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
const isRoot = tag === 'node' && stack.length >= 2 && stack[stack.length - 1] === 'hierarchy'
|
|
518
|
+
&& stack[stack.length - 2] === 'window';
|
|
519
|
+
if (start < 0 && isRoot && attrs.includes(`package="${pkg}"`)) {
|
|
520
|
+
if (selfClosing) {
|
|
521
|
+
return '<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\' ?><hierarchy rotation="0">' + m[0] + '</hierarchy>';
|
|
522
|
+
}
|
|
523
|
+
start = m.index; rootDepth = stack.length;
|
|
524
|
+
}
|
|
525
|
+
if (!selfClosing) { stack.push(tag); }
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const LIVE_PIDS = new Set();
|
|
531
|
+
const LIVE_SERVERS = new Set();
|
|
532
|
+
/**
|
|
533
|
+
* $UTG_FORWARDS_FILE (set by run_cycle.mjs sh for each stage): the adb forwards this process holds,
|
|
534
|
+
* rewritten on every change as [{adb, port}]. A stage killed on timeout runs no 'exit' handler,
|
|
535
|
+
* so the parent removes the forwards listed there (run_cycle.mjs reapStage).
|
|
536
|
+
*/
|
|
537
|
+
const FORWARDS = new Map();
|
|
538
|
+
function recordForwards(add = null, drop = null) {
|
|
539
|
+
if (add) { FORWARDS.set(add, { adb: add.adb, port: add.localPort }); }
|
|
540
|
+
if (drop) { FORWARDS.delete(drop); }
|
|
541
|
+
const f = process.env.UTG_FORWARDS_FILE;
|
|
542
|
+
if (!f) { return; }
|
|
543
|
+
try { atomicWriteText(f, jsonDumps([...FORWARDS.values()])); } catch { /* advisory */ }
|
|
544
|
+
}
|
|
545
|
+
// atexit equivalent (uiautomator2 registers stop_uiautomator(wait=False)): kill the server
|
|
546
|
+
// child and drop this process's adb forwards, synchronously.
|
|
547
|
+
process.on('exit', () => {
|
|
548
|
+
killPidsSync([...LIVE_PIDS]);
|
|
549
|
+
for (const s of LIVE_SERVERS) {
|
|
550
|
+
if (s.localPort !== null) { try { spawnSync(s.adb[0], [...s.adb.slice(1), 'forward', '--remove', `tcp:${s.localPort}`], { timeout: 5000, windowsHide: true }); } catch { /* exiting */ } }
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
// ------------------------------------------------------------------ DeviceAdapter
|
|
555
|
+
|
|
556
|
+
const RE = {
|
|
557
|
+
ovD: pyRe('Override density:\\s*(\\d+)'), phD: pyRe('Physical density:\\s*(\\d+)'),
|
|
558
|
+
ovS: pyRe('Override size:\\s*(\\d+)x(\\d+)'), phS: pyRe('Physical size:\\s*(\\d+)x(\\d+)'),
|
|
559
|
+
focus: pyRe('mCurrentFocus=.*?\\s([\\w.]+/[\\w.$]+)'),
|
|
560
|
+
resumed: pyRe('(?:mResumedActivity|topResumedActivity|ResumedActivity):.*?\\s([\\w.]+/[\\w.$]+)'),
|
|
561
|
+
};
|
|
562
|
+
const f0 = (x) => fmtFixed(x, 0);
|
|
563
|
+
const floorDiv = (a, b) => Math.floor(a / b);
|
|
564
|
+
const PNG_MAGIC = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
565
|
+
const LIVE_SHELLS = new Set();
|
|
566
|
+
process.on('exit', () => killPidsSync([...LIVE_SHELLS]));
|
|
567
|
+
// Ctrl+C / kill: exit through process.exit so the 'exit' handlers above (shells, u2 server,
|
|
568
|
+
// forwards) run; the default signal action skips them. TerminateProcess (Windows kill) runs
|
|
569
|
+
// nothing, which is why run_cycle.mjs reapStage cleans up after a timed-out stage.
|
|
570
|
+
for (const [sig, code] of [['SIGINT', 130], ['SIGTERM', 143]]) {
|
|
571
|
+
process.once(sig, () => process.exit(code));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
export class DeviceAdapter {
|
|
575
|
+
// Fast defaults; a campaign config overrides any of them. Opt out with
|
|
576
|
+
// "layout_backend": "uiautomator", "adb_persistent_shell": false, "settle_mode": "fixed".
|
|
577
|
+
static DEFAULTS = { layout_backend: 'u2', adb_persistent_shell: true, settle_mode: 'stable' };
|
|
578
|
+
|
|
579
|
+
constructor(config, artifactDir) {
|
|
580
|
+
this.config = { ...DeviceAdapter.DEFAULTS };
|
|
581
|
+
for (const k of keysOf(config)) { dset(this.config, k, config[k]); }
|
|
582
|
+
// The bundled u2.jar replaces the uiautomator2 package, so there is no "not installed" fallback.
|
|
583
|
+
this.artifact_dir = pResolve(artifactDir);
|
|
584
|
+
pMkdir(this.artifact_dir, { parents: true, exist_ok: true });
|
|
585
|
+
this.serial = get(config, 'serial');
|
|
586
|
+
if (!truthy(this.serial)) { throw new AdapterError('Explicit serial required to avoid controlling the wrong device'); }
|
|
587
|
+
this.adb = [get(config, 'adb', 'adb'), '-s', this.serial];
|
|
588
|
+
this.timeout = toFloat(get(config, 'command_timeout', 30));
|
|
589
|
+
this._ps = null; this._u2 = null; this._device_info = null;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/** True when `run-as <package> id` works (a debuggable build). */
|
|
593
|
+
runAsAvailable() {
|
|
594
|
+
const pkg = get(this.config, 'package');
|
|
595
|
+
if (!truthy(pkg)) { return false; }
|
|
596
|
+
let proc;
|
|
597
|
+
try { proc = subprocessRun([...this.adb, 'shell', 'run-as', pkg, 'id'], { timeout: this.timeout }); } catch (e) {
|
|
598
|
+
if (e instanceof TimeoutExpired) { return false; }
|
|
599
|
+
throw e;
|
|
600
|
+
}
|
|
601
|
+
return proc.returncode === 0 && proc.stdout.includes('uid=');
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** _run(args, binary=False): one-shot command; device-timeout / stderr tail as AdapterError. */
|
|
605
|
+
_run(args, binary = false) {
|
|
606
|
+
if (binary && typeof binary === 'object') { binary = !!binary.binary; }
|
|
607
|
+
let proc;
|
|
608
|
+
try { proc = subprocessRun(args, { timeout: this.timeout }); } catch (e) {
|
|
609
|
+
if (e instanceof TimeoutExpired) {
|
|
610
|
+
throw new AdapterError(`device-timeout: ${args.slice(3, 6).map(pyStr).join(' ')} after ${f0(this.timeout)}s`);
|
|
611
|
+
}
|
|
612
|
+
throw e;
|
|
613
|
+
}
|
|
614
|
+
if (proc.returncode) { throw new AdapterError(strTail(decodeReplace(proc.stderr), 1200)); }
|
|
615
|
+
return binary ? proc.stdout : decodeReplace(proc.stdout);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** _shell(*args): POSIX-quoted remote command, persistent shell when configured. */
|
|
619
|
+
_shell(...args) {
|
|
620
|
+
const command = args.map((a) => shlexQuote(pyStr(a))).join(' ');
|
|
621
|
+
if (truthy(get(this.config, 'adb_persistent_shell'))) { return this._persistentShell(command); }
|
|
622
|
+
return this._run([...this.adb, 'shell', command]);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** _persistent_shell(command): one command in a long-lived `adb shell`, end-marker protocol. */
|
|
626
|
+
_persistentShell(command) {
|
|
627
|
+
const io = bridge();
|
|
628
|
+
let shell = this._ps;
|
|
629
|
+
if (shell === null || shell === undefined || io.call('poll', { handle: shell.handle }).exited) {
|
|
630
|
+
if (shell) { this._closeShell(); }
|
|
631
|
+
const r = io.call('spawn', { argv: [...this.adb, 'shell'] });
|
|
632
|
+
if (r.error !== undefined) {
|
|
633
|
+
const e = new Error(r.code === 'ENOENT' ? '[WinError 2] The system cannot find the file specified' : r.error);
|
|
634
|
+
e.code = r.code; throw e;
|
|
635
|
+
}
|
|
636
|
+
shell = { handle: r.handle, pid: r.pid };
|
|
637
|
+
this._ps = shell;
|
|
638
|
+
LIVE_SHELLS.add(r.pid);
|
|
639
|
+
}
|
|
640
|
+
const tag = '__utg_end_' + uuid4Hex() + '_';
|
|
641
|
+
const script = `(${command}) </dev/null; s=$?; printf '\\n${tag}%d\\n' "$s"; printf '\\n${tag}\\n' >&2\n`;
|
|
642
|
+
const w = io.call('write', { handle: shell.handle, data: script });
|
|
643
|
+
if (w.error !== undefined) {
|
|
644
|
+
this._closeShell();
|
|
645
|
+
throw new AdapterError('error: closed: persistent adb shell: ' + w.error);
|
|
646
|
+
}
|
|
647
|
+
const timeoutMs = Math.max(0, this.timeout * 1000);
|
|
648
|
+
const r = io.call('collect', { handle: shell.handle, tag, timeoutMs }, timeoutMs + 15000);
|
|
649
|
+
if (r.timeout || r.kind === 'bridge-timeout') {
|
|
650
|
+
this._closeShell();
|
|
651
|
+
throw new AdapterError(`device-timeout: ${cpSlice(command, 0, 60)} after ${f0(this.timeout)}s`);
|
|
652
|
+
}
|
|
653
|
+
if (r.closed) {
|
|
654
|
+
this._closeShell();
|
|
655
|
+
throw new AdapterError('error: closed: persistent adb shell exited');
|
|
656
|
+
}
|
|
657
|
+
const join = (lines) => { const o = lines.map((b) => decodeReplace(Buffer.from(b, 'base64'))).join(''); return o.endsWith('\n') ? o.slice(0, -1) : o; };
|
|
658
|
+
const out = join(r.out); const err = join(r.err);
|
|
659
|
+
const status = pyStrip(decodeReplace(Buffer.from(r.status, 'base64')));
|
|
660
|
+
if (status !== '0') { throw new AdapterError(strTail(err, 1200)); }
|
|
661
|
+
return out;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
_closeShell() {
|
|
665
|
+
const shell = this._ps;
|
|
666
|
+
this._ps = null;
|
|
667
|
+
if (shell) {
|
|
668
|
+
bridge().call('close', { handle: shell.handle, waitMs: 3000 }, 15000);
|
|
669
|
+
LIVE_SHELLS.delete(shell.pid);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** _wrapped_in_swiperefresh(nodes, node): a SwipeRefreshLayout ancestor exists. */
|
|
674
|
+
static _wrappedInSwiperefresh(nodes, node) {
|
|
675
|
+
let idx = nodes.indexOf(node);
|
|
676
|
+
if (idx < 0) { idx = null; }
|
|
677
|
+
const seen = new Set();
|
|
678
|
+
while (idx !== null && idx !== undefined && !seen.has(idx) && idx >= 0 && idx < nodes.length) {
|
|
679
|
+
seen.add(idx);
|
|
680
|
+
if (pyStr(or(get(nodes[idx], 'class'), '')).endsWith('SwipeRefreshLayout')) { return true; }
|
|
681
|
+
idx = get(nodes[idx], 'parent_index');
|
|
682
|
+
}
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/** device_info(): wm density / wm size, read once per session. */
|
|
687
|
+
deviceInfo() {
|
|
688
|
+
if (this._device_info !== null && this._device_info !== undefined) { return this._device_info; }
|
|
689
|
+
let densRaw; let sizeRaw;
|
|
690
|
+
try { densRaw = this._shell('wm', 'density'); sizeRaw = this._shell('wm', 'size'); } catch { densRaw = sizeRaw = ''; }
|
|
691
|
+
const ovD = RE.ovD.exec(densRaw); const phD = RE.phD.exec(densRaw);
|
|
692
|
+
const dpi = ovD || phD ? pyInt((ovD || phD)[1]) : null;
|
|
693
|
+
const size = RE.ovS.exec(sizeRaw) || RE.phS.exec(sizeRaw);
|
|
694
|
+
this._device_info = {
|
|
695
|
+
dpi, density: truthy(dpi) ? asFloat(pyRound(dpi / 160, 3)) : null,
|
|
696
|
+
density_source: dpi === null ? 'unavailable' : (ovD ? 'wm density (override)' : 'wm density (physical)'),
|
|
697
|
+
width_px: size ? pyInt(size[1]) : null, height_px: size ? pyInt(size[2]) : null,
|
|
698
|
+
raw: { wm_density: densRaw, wm_size: sizeRaw },
|
|
699
|
+
};
|
|
700
|
+
return this._device_info;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/** _foreground() -> [component, focus text]. */
|
|
704
|
+
_foreground() {
|
|
705
|
+
const focus = this._shell('dumpsys', 'window');
|
|
706
|
+
let match = RE.focus.exec(focus);
|
|
707
|
+
if (match) { return [match[1], focus]; }
|
|
708
|
+
const activities = this._shell('dumpsys', 'activity', 'activities');
|
|
709
|
+
match = RE.resumed.exec(activities);
|
|
710
|
+
if (!match) { throw new AdapterError('Cannot identify foreground window or resumed activity'); }
|
|
711
|
+
return [match[1], focus + '\n' + activities];
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
_retryBackoff(attempt, attempts, settle, expected) {
|
|
715
|
+
let last = null;
|
|
716
|
+
if (attempt + 1 < attempts) {
|
|
717
|
+
if (settle) { time.sleep(Math.min(settle * (2 ** attempt), 8.0)); }
|
|
718
|
+
try {
|
|
719
|
+
const [current] = this._foreground();
|
|
720
|
+
if (current !== expected) { last = new AdapterError('ui-dump-foreground-transition: ' + current); }
|
|
721
|
+
} catch (e) {
|
|
722
|
+
if (!(e instanceof AdapterError)) { throw e; }
|
|
723
|
+
last = new AdapterError('ui-dump-foreground-unavailable: ' + e.message);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return last;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** _dump_uiautomator(tree, expected_component, popup_pkg=null) -> root Element (bounded retry). */
|
|
730
|
+
_dumpUiautomator(tree, expectedComponent, popupPkg = null) {
|
|
731
|
+
const attempts = Math.max(1, toInt(get(this.config, 'ui_dump_retries', get(this.config, 'uiautomator_dump_retries', 3))));
|
|
732
|
+
const settle = Math.max(0.0, toFloat(get(this.config, 'ui_dump_retry_settle_seconds', get(this.config, 'settle_seconds', 0.3))));
|
|
733
|
+
let last = null;
|
|
734
|
+
if (get(this.config, 'layout_backend') === 'u2') { return this._dumpU2(tree, expectedComponent, attempts, settle, popupPkg); }
|
|
735
|
+
if (truthy(get(this.config, 'ui_dump_stream', false))) {
|
|
736
|
+
try {
|
|
737
|
+
const raw = this._run([...this.adb, 'exec-out', 'uiautomator', 'dump', '/dev/tty'], true);
|
|
738
|
+
const end = raw.lastIndexOf('</hierarchy>');
|
|
739
|
+
const start = raw.indexOf('<?xml');
|
|
740
|
+
if (start >= 0 && end > start) {
|
|
741
|
+
fs.writeFileSync(tree, raw.subarray(start, end + '</hierarchy>'.length));
|
|
742
|
+
return etParse(tree);
|
|
743
|
+
}
|
|
744
|
+
last = new AdapterError('ui-dump-stream-empty');
|
|
745
|
+
} catch (e) {
|
|
746
|
+
if (!(e instanceof AdapterError || e instanceof XmlParseError || (e && e.code))) { throw e; }
|
|
747
|
+
last = new AdapterError('ui-dump-stream-failed: ' + e.message);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
751
|
+
const remote = '/data/local/tmp/utg-' + uuid4Hex() + '.xml';
|
|
752
|
+
let root = null;
|
|
753
|
+
try {
|
|
754
|
+
// A non-focusable app popup is never the active window: dump every window (Android 11+
|
|
755
|
+
// `--windows`) and keep the app's topmost one; an older platform falls back to the plain dump.
|
|
756
|
+
let allWindows = popupPkg !== null;
|
|
757
|
+
try {
|
|
758
|
+
if (allWindows) {
|
|
759
|
+
try { this._shell('uiautomator', 'dump', '--windows', remote); } catch (e) {
|
|
760
|
+
if (!(e instanceof AdapterError)) { throw e; }
|
|
761
|
+
allWindows = false;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (!allWindows) { this._shell('uiautomator', 'dump', remote); }
|
|
765
|
+
} catch (e) {
|
|
766
|
+
if (!(e instanceof AdapterError)) { throw e; }
|
|
767
|
+
last = new AdapterError('ui-dump-failed: ' + e.message);
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
try { this._shell('test', '-s', remote); } catch (e) {
|
|
771
|
+
if (!(e instanceof AdapterError)) { throw e; }
|
|
772
|
+
last = new AdapterError('ui-dump-remote-missing: ' + e.message);
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
try { this._run([...this.adb, 'pull', remote, pyStr(tree)]); } catch (e) {
|
|
776
|
+
if (!(e instanceof AdapterError)) { throw e; }
|
|
777
|
+
last = new AdapterError('ui-dump-pull-failed: ' + e.message);
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
if (allWindows) {
|
|
781
|
+
const cut = topWindowOfWindows(readText(tree, { encoding: 'utf-8', errors: 'replace' }), popupPkg);
|
|
782
|
+
if (cut !== null) { writeText(tree, cut); }
|
|
783
|
+
}
|
|
784
|
+
try { root = etParse(tree); } catch (e) {
|
|
785
|
+
if (!(e instanceof XmlParseError || (e && e.code))) { throw e; }
|
|
786
|
+
last = new AdapterError('ui-dump-parse-failed: ' + e.message);
|
|
787
|
+
}
|
|
788
|
+
} finally {
|
|
789
|
+
try { this._shell('rm', '-f', remote); } catch (e) { if (!(e instanceof AdapterError)) { throw e; } } // eslint-disable-line no-unsafe-finally
|
|
790
|
+
if (root === null) { last = this._retryBackoff(attempt, attempts, settle, expectedComponent) ?? last; }
|
|
791
|
+
}
|
|
792
|
+
if (root !== null) { return root; }
|
|
793
|
+
}
|
|
794
|
+
throw last ?? new AdapterError('ui-dump-failed: no attempts made');
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** _u2_device(): the resident server client, started once per adapter. */
|
|
798
|
+
_u2Device() {
|
|
799
|
+
if (this._u2 === null || this._u2 === undefined) {
|
|
800
|
+
try { this._u2 = new U2Server(this.adb, { http_timeout: toFloat(get(this.config, 'u2_http_timeout', U2_DUMP_TIMEOUT)) }); } catch (e) {
|
|
801
|
+
if (e instanceof AdapterError) { throw e; }
|
|
802
|
+
throw new AdapterError('ui-dump-failed: u2 connect: ' + (e && e.message));
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return this._u2;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/** close(): persistent shell, then the u2 server (process killed, adb forward removed). */
|
|
809
|
+
close() {
|
|
810
|
+
this._closeShell();
|
|
811
|
+
const device = this._u2;
|
|
812
|
+
this._u2 = null;
|
|
813
|
+
if (device !== null && device !== undefined) {
|
|
814
|
+
try { device.close(); } catch { /* as Python: ignore */ }
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* _dump_u2(tree, expected_component, attempts, settle, popup_pkg): active-window, uncompressed
|
|
820
|
+
* dump. With `popup_pkg` (the app shows a non-focusable popup window above its activity, which
|
|
821
|
+
* the active-window dump never contains) all windows are dumped and the app's topmost window
|
|
822
|
+
* kept: the server lists windows top-first.
|
|
823
|
+
*/
|
|
824
|
+
_dumpU2(tree, expectedComponent, attempts, settle, popupPkg = null) {
|
|
825
|
+
let last = null;
|
|
826
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
827
|
+
try {
|
|
828
|
+
let xml = this._u2Device().dumpHierarchy({ compressed: false, root_in_active: popupPkg === null });
|
|
829
|
+
if (popupPkg !== null) { xml = topWindowOf(xml, popupPkg) ?? this._u2Device().dumpHierarchy({ compressed: false, root_in_active: true }); }
|
|
830
|
+
writeText(tree, xml);
|
|
831
|
+
return etParse(tree);
|
|
832
|
+
} catch (e) {
|
|
833
|
+
if (e && e.name === 'TimeoutError') {
|
|
834
|
+
// The server stopped answering: a device/transport failure, not a parse failure. Drop the
|
|
835
|
+
// hung server (the next dump starts a fresh one) and fail at once with a device-timeout,
|
|
836
|
+
// which task_runner TRANSIENT_DEVICE_RE recovers (waitDevice) instead of retrying here.
|
|
837
|
+
const hung = this._u2; this._u2 = null;
|
|
838
|
+
try { hung?.close(); } catch { /* as close() */ }
|
|
839
|
+
throw new AdapterError(`device-timeout: u2 dumpWindowHierarchy after ${f0(hung?.httpTimeout ?? 0)}s`);
|
|
840
|
+
}
|
|
841
|
+
if (e instanceof AdapterError) { last = e; }
|
|
842
|
+
else if (e instanceof XmlParseError || (e && e.code && e.syscall)) { last = new AdapterError('ui-dump-parse-failed: ' + e.message); }
|
|
843
|
+
else { last = new AdapterError('ui-dump-failed: u2: ' + (e && e.message)); }
|
|
844
|
+
}
|
|
845
|
+
last = this._retryBackoff(attempt, attempts, settle, expectedComponent) ?? last;
|
|
846
|
+
}
|
|
847
|
+
throw last ?? new AdapterError('ui-dump-failed: no attempts made');
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/** _screenshot(): `adb exec-out screencap -p` raw PNG bytes (every backend). */
|
|
851
|
+
_screenshot() { return this._run([...this.adb, 'exec-out', 'screencap', '-p'], true); }
|
|
852
|
+
|
|
853
|
+
/** observe(environment_id): capture dir with layout, screen.png, window.txt, observation.json. */
|
|
854
|
+
observe(environmentId) {
|
|
855
|
+
const capture = pJoin(this.artifact_dir, uuid4Hex());
|
|
856
|
+
pMkdir(capture);
|
|
857
|
+
const [component, focus] = this._foreground();
|
|
858
|
+
const slash = component.indexOf('/');
|
|
859
|
+
const pkg = component.slice(0, slash);
|
|
860
|
+
let activity = component.slice(slash + 1);
|
|
861
|
+
if (activity.startsWith('.')) { activity = pkg + activity; }
|
|
862
|
+
let tree; let nodes;
|
|
863
|
+
if (get(this.config, 'layout_backend') === 'android') {
|
|
864
|
+
tree = pJoin(capture, 'layout.json');
|
|
865
|
+
this._run([get(this.config, 'android', 'android'), 'layout', '--device=' + this.serial, '--full', '--output=' + tree]);
|
|
866
|
+
nodes = normalizeNodes(readJson(tree));
|
|
867
|
+
} else {
|
|
868
|
+
tree = pJoin(capture, 'layout.xml');
|
|
869
|
+
const root = this._dumpUiautomator(tree, component, appPopupWindow(focus, pkg) ? pkg : null);
|
|
870
|
+
const convert = (el) => { const d = {}; for (const k of keysOf(el.attrib)) { dset(d, k, el.attrib[k]); } d.children = el.children.map(convert); return d; };
|
|
871
|
+
nodes = normalizeNodes(root.children.map(convert));
|
|
872
|
+
}
|
|
873
|
+
const screenshot = pJoin(capture, 'screen.png');
|
|
874
|
+
const png = this._screenshot();
|
|
875
|
+
if (!(png.length >= 8 && png.subarray(0, 8).equals(PNG_MAGIC))) { throw new AdapterError('Device returned an invalid PNG'); }
|
|
876
|
+
fs.writeFileSync(screenshot, png);
|
|
877
|
+
const [finalComponent] = this._foreground();
|
|
878
|
+
if (component !== finalComponent) { throw new AdapterError('Foreground changed during capture; retry observation'); }
|
|
879
|
+
writeText(pJoin(capture, 'window.txt'), focus);
|
|
880
|
+
const shown = or(treePackage(nodes), pkg);
|
|
881
|
+
const result = { observation_id: pName(capture), package: shown, activity,
|
|
882
|
+
window: nodes.some((n) => pyStr(get(n, 'class', '')).includes('Dialog')) ? 'dialog' : 'main',
|
|
883
|
+
nodes, environment_id: environmentId, artifacts: { screenshot, tree }, device_info: this.deviceInfo() };
|
|
884
|
+
if (shown !== pkg) { result.component_package = pkg; }
|
|
885
|
+
result.identity = resolveIdentity(result, this.config);
|
|
886
|
+
writeJson(pJoin(capture, 'observation.json'), result);
|
|
887
|
+
return result;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
_center(b) { return [floorDiv(b[0] + b[2], 2), floorDiv(b[1] + b[3], 2)]; }
|
|
891
|
+
|
|
892
|
+
_snapDir() { return truthy(get(this.config, 'snapshot_dir')) ? pResolve(get(this.config, 'snapshot_dir', '')) : null; }
|
|
893
|
+
|
|
894
|
+
/** act(action, before=None): one atomic device action. */
|
|
895
|
+
act(action, before = null) {
|
|
896
|
+
const kind = get(action, 'type');
|
|
897
|
+
const candidateKinds = { click_candidates: 'click', long_click_candidates: 'long_click', double_tap_candidates: 'double_tap' };
|
|
898
|
+
if (Object.hasOwn(candidateKinds, kind)) {
|
|
899
|
+
const errors = [];
|
|
900
|
+
for (const selector of get(action, 'selectors', [])) {
|
|
901
|
+
try {
|
|
902
|
+
const concrete = { type: candidateKinds[kind], selector };
|
|
903
|
+
if (Object.hasOwn(action, 'duration_ms')) { concrete.duration_ms = action.duration_ms; }
|
|
904
|
+
return this.act(concrete, before);
|
|
905
|
+
} catch (e) { if (!(e instanceof AdapterError)) { throw e; } errors.push(e.message); }
|
|
906
|
+
}
|
|
907
|
+
throw new AdapterError('No selector candidate matched: ' + errors.slice(-3).join(' | '));
|
|
908
|
+
}
|
|
909
|
+
if (['click', 'long_click', 'double_tap', 'input'].includes(kind)) {
|
|
910
|
+
if (before === null || before === undefined) { throw new AdapterError('An immediate observation is required for selector input'); }
|
|
911
|
+
const hidden = occludedIndices(before.nodes);
|
|
912
|
+
const live = before.nodes.map((n, i) => (!hidden.has(i) ? n : { visible: false }));
|
|
913
|
+
const hits = matching(live, get(action, 'selector'));
|
|
914
|
+
if (hits.length !== 1) { throw new AdapterError(`Selector must resolve uniquely; matched ${hits.length} elements`); }
|
|
915
|
+
const node = hits[0];
|
|
916
|
+
const b = get(node, 'bounds', []);
|
|
917
|
+
if (b.length !== 4 || b[2] <= b[0] || b[3] <= b[1]) { throw new AdapterError('Selector has invalid or invisible bounds'); }
|
|
918
|
+
const [x, y] = this._center(b);
|
|
919
|
+
if (kind === 'input') {
|
|
920
|
+
if (!truthy(get(node, 'focused'))) { throw new AdapterError('Focus input explicitly and re-observe before typing'); }
|
|
921
|
+
const text = Object.hasOwn(action, 'value_env') ? (process.env[action.value_env] ?? null) : get(action, 'value');
|
|
922
|
+
if (text === null || text === undefined || !reFullmatch(pyRe('[\\x20-\\x7e]*'), pyStr(text))) {
|
|
923
|
+
throw new AdapterError('ADB text input supports ASCII here; use an IME adapter for other text');
|
|
924
|
+
}
|
|
925
|
+
this._shell('input', 'text', pyStr(text).replaceAll(' ', '%s'));
|
|
926
|
+
} else if (kind === 'long_click') {
|
|
927
|
+
this._shell('input', 'swipe', x, y, x, y, toInt(get(action, 'duration_ms', 700)));
|
|
928
|
+
} else if (kind === 'double_tap') {
|
|
929
|
+
this._shell('input', 'tap', x, y);
|
|
930
|
+
time.sleep(Math.min(Math.max(toFloat(get(action, 'interval_seconds', 0.08)), 0.03), 0.3));
|
|
931
|
+
this._shell('input', 'tap', x, y);
|
|
932
|
+
} else {
|
|
933
|
+
this._shell('input', 'tap', x, y);
|
|
934
|
+
}
|
|
935
|
+
} else if (kind === 'click_point' || kind === 'long_click_point') {
|
|
936
|
+
const x = toInt(mget(action, 'x')); const y = toInt(mget(action, 'y'));
|
|
937
|
+
if (kind === 'long_click_point') { this._shell('input', 'swipe', x, y, x, y, toInt(get(action, 'duration_ms', 700))); }
|
|
938
|
+
else { this._shell('input', 'tap', x, y); }
|
|
939
|
+
} else if (kind === 'snapshot_app_data') {
|
|
940
|
+
const pkg = get(this.config, 'package');
|
|
941
|
+
const snapDir = this._snapDir();
|
|
942
|
+
const archive = pResolve(get(action, 'archive', ''));
|
|
943
|
+
if (!truthy(pkg) || !snapDir || !pParents(archive).some((p) => pEq(p, snapDir)) || pSuffix(archive) !== '.tar') {
|
|
944
|
+
throw new AdapterError('snapshot_app_data needs config.package, config.snapshot_dir and a .tar inside it');
|
|
945
|
+
}
|
|
946
|
+
if (fs.existsSync(archive)) { throw new AdapterError('snapshot archive already exists; never overwrite a fixture: ' + archive); }
|
|
947
|
+
const dirs = get(action, 'dirs', ['databases', 'shared_prefs', 'files']).filter((d) => reFullmatch(pyRe('[\\w.-]+'), pyStr(d)));
|
|
948
|
+
this._shell('am', 'force-stop', pkg);
|
|
949
|
+
const proc = subprocessRun([...this.adb, 'exec-out', 'run-as', pkg, 'tar', '-cf', '-', ...dirs], { timeout: this.timeout });
|
|
950
|
+
if (proc.returncode || proc.stdout.length < 1024) {
|
|
951
|
+
throw new AdapterError('snapshot_app_data failed: ' + strTail(decodeReplace(proc.stderr), 300));
|
|
952
|
+
}
|
|
953
|
+
pMkdir(pParent(archive), { parents: true, exist_ok: true });
|
|
954
|
+
fs.writeFileSync(archive, proc.stdout);
|
|
955
|
+
} else if (kind === 'clear_app_data') {
|
|
956
|
+
const pkg = get(this.config, 'package');
|
|
957
|
+
if (!truthy(pkg)) { throw new AdapterError('clear_app_data requires config.package'); }
|
|
958
|
+
const out = this._shell('pm', 'clear', pkg);
|
|
959
|
+
if (!out.includes('Success')) { throw new AdapterError('clear_app_data failed: ' + strTail(out, 300)); }
|
|
960
|
+
} else if (kind === 'save_replay') {
|
|
961
|
+
const snapDir = this._snapDir();
|
|
962
|
+
const archive = pResolve(get(action, 'archive', ''));
|
|
963
|
+
if (!snapDir || !pParents(archive).some((p) => pEq(p, snapDir)) || !pName(archive).endsWith('.replay.json')) {
|
|
964
|
+
throw new AdapterError('save_replay needs config.snapshot_dir and a .replay.json inside it');
|
|
965
|
+
}
|
|
966
|
+
if (fs.existsSync(archive)) { throw new AdapterError('replay snapshot already exists; never overwrite a fixture: ' + archive); }
|
|
967
|
+
writeText(archive, jsonDumps({ schema: 'utg-replay/1', package: get(this.config, 'package'),
|
|
968
|
+
steps: get(action, 'steps', []), from: get(action, 'from') }, { ensure_ascii: false, indent: 1 }));
|
|
969
|
+
} else if (kind === 'restore_app_data') {
|
|
970
|
+
const pkg = get(this.config, 'package');
|
|
971
|
+
const archive = pathStr(get(action, 'archive', ''));
|
|
972
|
+
if (!truthy(pkg) || !pIsFile(archive)) { throw new AdapterError('restore_app_data requires config.package and an existing archive'); }
|
|
973
|
+
this._shell('am', 'force-stop', pkg);
|
|
974
|
+
const dirs = get(action, 'clear_dirs', []).filter((d) => reFullmatch(pyRe('[\\w.-]+'), pyStr(d)));
|
|
975
|
+
if (dirs.length) {
|
|
976
|
+
this._run([...this.adb, 'shell', 'run-as ' + shlexQuote(pkg) + ' rm -rf ' + dirs.map((d) => shlexQuote(d)).join(' ')]);
|
|
977
|
+
}
|
|
978
|
+
const proc = subprocessRun([...this.adb, 'exec-in', 'run-as', pkg, 'tar', '-xf', '-'], { input: readBytes(archive), timeout: this.timeout });
|
|
979
|
+
if (proc.returncode) { throw new AdapterError('restore_app_data failed: ' + strTail(decodeReplace(proc.stderr), 600)); }
|
|
980
|
+
} else if (kind === 'back') {
|
|
981
|
+
this._shell('input', 'keyevent', 'KEYCODE_BACK');
|
|
982
|
+
} else if (kind === 'key') {
|
|
983
|
+
const key = pyStr(get(action, 'key', '')).toUpperCase();
|
|
984
|
+
if (!['ENTER', 'SEARCH', 'TAB', 'DEL'].includes(key)) { throw new AdapterError('Key not allowed: ' + key); }
|
|
985
|
+
this._shell('input', 'keyevent', 'KEYCODE_' + key);
|
|
986
|
+
} else if (kind === 'scroll') {
|
|
987
|
+
const hits = truthy(before) ? matching(before.nodes, get(action, 'selector')) : [];
|
|
988
|
+
if (hits.length !== 1 || !truthy(get(hits[0], 'scrollable'))) { throw new AdapterError('Scroll requires one visible scrollable container'); }
|
|
989
|
+
const [l, t, r, b] = hits[0].bounds;
|
|
990
|
+
const x = floorDiv(l + r, 2); const high = t + floorDiv(b - t, 4); let low = b - floorDiv(b - t, 4);
|
|
991
|
+
const direction = get(action, 'direction', 'down');
|
|
992
|
+
if (direction === 'up' && truthy(before) && DeviceAdapter._wrappedInSwiperefresh(before.nodes, hits[0])) {
|
|
993
|
+
const dpi = or(get(this.deviceInfo(), 'dpi'), 160);
|
|
994
|
+
const cap = Math.max(40, Math.trunc(0.7 * 64 * dpi / 160));
|
|
995
|
+
low = Math.min(low, high + cap);
|
|
996
|
+
}
|
|
997
|
+
if (direction === 'left' || direction === 'right') {
|
|
998
|
+
const y = floorDiv(t + b, 2); const near = l + floorDiv(r - l, 4); const far = r - floorDiv(r - l, 4);
|
|
999
|
+
const [start, end] = direction === 'right' ? [far, near] : [near, far];
|
|
1000
|
+
this._shell('input', 'swipe', start, y, end, y, toInt(get(action, 'duration_ms', 500)));
|
|
1001
|
+
} else {
|
|
1002
|
+
const [start, end] = direction === 'down' ? [low, high] : [high, low];
|
|
1003
|
+
this._shell('input', 'swipe', x, start, x, end, toInt(get(action, 'duration_ms', 500)));
|
|
1004
|
+
}
|
|
1005
|
+
} else if (kind === 'drag') {
|
|
1006
|
+
if (before === null || before === undefined) { throw new AdapterError('Drag requires an immediate observation'); }
|
|
1007
|
+
const ends = [];
|
|
1008
|
+
for (const key of ['selector', 'to']) {
|
|
1009
|
+
const hits = matching(before.nodes, get(action, key));
|
|
1010
|
+
if (hits.length !== 1) { throw new AdapterError(`Drag ${key} must resolve uniquely; matched ${hits.length} elements`); }
|
|
1011
|
+
const b = get(hits[0], 'bounds', []);
|
|
1012
|
+
if (b.length !== 4 || b[2] <= b[0] || b[3] <= b[1]) { throw new AdapterError('Drag end has invalid bounds'); }
|
|
1013
|
+
ends.push(this._center(b));
|
|
1014
|
+
}
|
|
1015
|
+
const [[x1, y1], [x2, y2]] = ends;
|
|
1016
|
+
const hold = toInt(get(action, 'hold_ms', 800)); const move = toInt(get(action, 'duration_ms', 1200));
|
|
1017
|
+
const out = this._shell('input', 'draganddrop', x1, y1, x2, y2, hold + move);
|
|
1018
|
+
if (out.includes('Error') || out.includes('Unknown')) {
|
|
1019
|
+
this._shell('input', 'swipe', x1, y1, x1, y1, hold);
|
|
1020
|
+
this._shell('input', 'swipe', x1, y1, x2, y2, move);
|
|
1021
|
+
}
|
|
1022
|
+
} else if (kind === 'screen_swipe') {
|
|
1023
|
+
this._screenSwipe(action, before);
|
|
1024
|
+
} else if (kind === 'launch') {
|
|
1025
|
+
this._launch(action);
|
|
1026
|
+
} else if (kind === 'wait') {
|
|
1027
|
+
time.sleep(Math.min(Math.max(toFloat(get(action, 'seconds', 0.5)), 0), 5));
|
|
1028
|
+
} else {
|
|
1029
|
+
throw new AdapterError('Unsupported atomic action: ' + pyStr(kind));
|
|
1030
|
+
}
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
_screenSwipe(action, before) {
|
|
1035
|
+
if (before === null || before === undefined) { throw new AdapterError('Screen swipe requires an immediate observation'); }
|
|
1036
|
+
const bounds = get(before, 'nodes', []).filter((n) => truthy(get(n, 'visible', true))).map((n) => get(n, 'bounds', []))
|
|
1037
|
+
.filter((b) => b.length === 4 && b[2] > b[0] && b[3] > b[1]);
|
|
1038
|
+
if (!bounds.length) { throw new AdapterError('Cannot infer screen bounds for swipe'); }
|
|
1039
|
+
const left = Math.min(...bounds.map((b) => b[0])); const top = Math.min(...bounds.map((b) => b[1]));
|
|
1040
|
+
const right = Math.max(...bounds.map((b) => b[2])); const bottom = Math.max(...bounds.map((b) => b[3]));
|
|
1041
|
+
const width = Math.max(1, right - left); const height = Math.max(1, bottom - top);
|
|
1042
|
+
let direction = get(action, 'direction');
|
|
1043
|
+
if (direction === 'start' || direction === 'end') {
|
|
1044
|
+
const rtl = pyStr(get(this.config, 'layout_direction', 'ltr')).toLowerCase() === 'rtl';
|
|
1045
|
+
direction = direction === 'start' ? (rtl ? 'left' : 'right') : (rtl ? 'right' : 'left');
|
|
1046
|
+
}
|
|
1047
|
+
const midY = floorDiv(top + bottom, 2); const midX = floorDiv(left + right, 2);
|
|
1048
|
+
let start; let end;
|
|
1049
|
+
if (direction === 'right') { start = [left + Math.max(2, floorDiv(width, 50)), midY]; end = [left + floorDiv(4 * width, 5), midY]; }
|
|
1050
|
+
else if (direction === 'left') { start = [right - Math.max(2, floorDiv(width, 50)), midY]; end = [left + floorDiv(width, 5), midY]; }
|
|
1051
|
+
else if (direction === 'down') { start = [midX, top + Math.max(2, floorDiv(height, 50))]; end = [midX, top + floorDiv(4 * height, 5)]; }
|
|
1052
|
+
else if (direction === 'up') { start = [midX, bottom - Math.max(2, floorDiv(height, 50))]; end = [midX, top + floorDiv(height, 5)]; }
|
|
1053
|
+
else { throw new AdapterError('Unsupported screen swipe direction: ' + pyStr(direction)); }
|
|
1054
|
+
this._shell('input', 'swipe', start[0], start[1], end[0], end[1], toInt(get(action, 'duration_ms', 500)));
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
_launch(action) {
|
|
1058
|
+
const args = ['am', 'start', '-W'];
|
|
1059
|
+
if (truthy(get(action, 'restart'))) { args.push('-S', '-f', '0x10008000'); }
|
|
1060
|
+
let pin = [];
|
|
1061
|
+
const fqn = get(action, 'component_fqn');
|
|
1062
|
+
if (truthy(fqn) && truthy(get(this.config, 'package')) && reFullmatch(pyRe('[\\w.$]+'), fqn)) {
|
|
1063
|
+
pin = ['-n', this.config.package + '/' + fqn];
|
|
1064
|
+
}
|
|
1065
|
+
const flag = { boolean: '--ez', long: '--el', int: '--ei', float: '--ef', string: '--es', double: '--ed' };
|
|
1066
|
+
const extraFlags = [];
|
|
1067
|
+
for (const extra of or(get(action, 'extras'), [])) {
|
|
1068
|
+
const f = get(flag, or(get(extra, 'type'), 'string'), '--es');
|
|
1069
|
+
let v = get(extra, 'value');
|
|
1070
|
+
v = v === true ? 'true' : v === false ? 'false' : pyStr(v);
|
|
1071
|
+
if (!reFullmatch(pyRe('[\\w.:/-]+'), pyStr(get(extra, 'key', ''))) || !reFullmatch(pyRe('[\\w.:/@ -]*'), v)) {
|
|
1072
|
+
throw new AdapterError('Unsafe launch extra: ' + pyStr(extra));
|
|
1073
|
+
}
|
|
1074
|
+
extraFlags.push(f, mget(extra, 'key'), v);
|
|
1075
|
+
}
|
|
1076
|
+
const target = [...pin, ...extraFlags];
|
|
1077
|
+
let result;
|
|
1078
|
+
if (truthy(get(action, 'uri'))) {
|
|
1079
|
+
result = this._shell(...args, '-a', 'android.intent.action.VIEW', '-d', action.uri, ...target);
|
|
1080
|
+
} else if (truthy(get(action, 'action'))) {
|
|
1081
|
+
result = this._shell(...args, '-a', action.action, ...target);
|
|
1082
|
+
} else {
|
|
1083
|
+
let component = get(action, 'component', get(this.config, 'launch_component', ''));
|
|
1084
|
+
if (truthy(fqn) && truthy(get(this.config, 'package'))) { component = this.config.package + '/' + fqn; }
|
|
1085
|
+
if (typeof component !== 'string' || !reFullmatch(pyRe('[\\w.]+/[\\w.$]+'), component)) {
|
|
1086
|
+
throw new AdapterError('launch requires a component, action, or uri');
|
|
1087
|
+
}
|
|
1088
|
+
result = this._shell(...args, '-n', component, ...extraFlags);
|
|
1089
|
+
}
|
|
1090
|
+
if (result.includes('Error:') || result.includes('Exception')) { throw new AdapterError(strTail(result, 1000)); }
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** settle(): fixed sleep, or (stable + u2) poll until two consecutive dumps are identical. */
|
|
1094
|
+
settle() {
|
|
1095
|
+
const limit = Math.min(Math.max(toFloat(get(this.config, 'settle_seconds', 0.3)), 0), 5);
|
|
1096
|
+
if (get(this.config, 'settle_mode') !== 'stable' || get(this.config, 'layout_backend') !== 'u2') {
|
|
1097
|
+
time.sleep(limit);
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
const deadline = time.monotonic() + limit;
|
|
1101
|
+
time.sleep(Math.min(Math.max(toFloat(get(this.config, 'settle_min_seconds', 0.1)), 0), limit));
|
|
1102
|
+
let previous = null;
|
|
1103
|
+
while (time.monotonic() < deadline) {
|
|
1104
|
+
let current;
|
|
1105
|
+
try { current = this._u2Device().dumpHierarchy({ compressed: false, root_in_active: true }); } catch { break; }
|
|
1106
|
+
if (current === previous) { return; }
|
|
1107
|
+
previous = current;
|
|
1108
|
+
time.sleep(Math.min(toFloat(get(this.config, 'settle_poll_seconds', 0.05)), Math.max(0.0, deadline - time.monotonic())));
|
|
1109
|
+
}
|
|
1110
|
+
time.sleep(Math.max(0.0, deadline - time.monotonic()));
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/** execute(task, environment_id) -> [before, after, outcome]. */
|
|
1114
|
+
execute(task, environmentId) {
|
|
1115
|
+
const before = this.observe(environmentId);
|
|
1116
|
+
this.act(task.action, before);
|
|
1117
|
+
this.settle();
|
|
1118
|
+
const after = this.observe(environmentId);
|
|
1119
|
+
return [before, after, observationKey(before) === observationKey(after) ? 'no_effect' : 'succeeded'];
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/** actions(observation): bounded candidate actions (unique selector; click/scroll). */
|
|
1123
|
+
actions(observation) {
|
|
1124
|
+
const out = []; const seen = new Set();
|
|
1125
|
+
for (const node of get(observation, 'nodes', [])) {
|
|
1126
|
+
if (!truthy(get(node, 'visible', true)) || !truthy(get(node, 'enabled', true))) { continue; }
|
|
1127
|
+
let selector = null;
|
|
1128
|
+
for (const field of ['resource_id', 'content_desc', 'text']) {
|
|
1129
|
+
if (truthy(get(node, field)) && matching(observation.nodes, { [field]: node[field] }).length === 1) {
|
|
1130
|
+
selector = { [field]: node[field] };
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
if (!selector) { continue; }
|
|
1135
|
+
const kinds = [...(truthy(get(node, 'clickable')) ? ['click'] : []), ...(truthy(get(node, 'scrollable')) ? ['scroll'] : [])];
|
|
1136
|
+
for (const kind of kinds) {
|
|
1137
|
+
const action = { type: kind, selector };
|
|
1138
|
+
if (get(this.config, 'exclude_actions', []).some((r) => ruleMatches({ ...observation, nodes: [node] }, r))) { continue; }
|
|
1139
|
+
const key = jsonDumps(action, { sort_keys: true });
|
|
1140
|
+
if (!seen.has(key)) { seen.add(key); out.push(action); }
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return out.slice(0, toInt(get(this.config, 'max_actions_per_view', 30)));
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* CommandAdapter(argv, timeout=120): run a bounded tool wrapper; argv holds {request}/{response}
|
|
1149
|
+
* tokens. No shell interpolation, implicit installs, guessed flags, or API keys.
|
|
1150
|
+
*/
|
|
1151
|
+
export class CommandAdapter {
|
|
1152
|
+
constructor(argv, timeout = 120) {
|
|
1153
|
+
if (timeout && typeof timeout === 'object') { timeout = timeout.timeout ?? 120; }
|
|
1154
|
+
if (!Array.isArray(argv) || !argv.length || !argv.every((a) => typeof a === 'string')) {
|
|
1155
|
+
throw new AdapterError('External command must be a nonempty argv array');
|
|
1156
|
+
}
|
|
1157
|
+
if (!argv.includes('{request}') || !argv.includes('{response}')) {
|
|
1158
|
+
throw new AdapterError('Command requires separate {request} and {response} arguments');
|
|
1159
|
+
}
|
|
1160
|
+
this.argv = argv; this.timeout = toFloat(timeout);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
/** run(request, directory) -> events[] from the wrapper's response.json. */
|
|
1164
|
+
run(request, directory) {
|
|
1165
|
+
const dir = pJoin(pResolve(directory), uuid4Hex());
|
|
1166
|
+
pMkdir(dir, { parents: true });
|
|
1167
|
+
const req = pJoin(dir, 'request.json'); const resp = pJoin(dir, 'response.json');
|
|
1168
|
+
writeJson(req, request);
|
|
1169
|
+
const argv = this.argv.map((s) => (s === '{request}' ? req : s === '{response}' ? resp : s));
|
|
1170
|
+
const proc = subprocessRun(argv, { timeout: this.timeout });
|
|
1171
|
+
fs.writeFileSync(pJoin(dir, 'stdout.log'), proc.stdout);
|
|
1172
|
+
fs.writeFileSync(pJoin(dir, 'stderr.log'), proc.stderr);
|
|
1173
|
+
if (proc.returncode) { throw new AdapterError(`External adapter failed (${proc.returncode}); see ${dir}`); }
|
|
1174
|
+
if (!pIsFile(resp) || fs.statSync(resp).size > 32 * 1024 * 1024) { throw new AdapterError('External response missing or exceeds 32 MiB'); }
|
|
1175
|
+
const data = readJson(resp);
|
|
1176
|
+
if (!isDict(data) || !Array.isArray(get(data, 'events'))) { throw new AdapterError('External response must contain events[]'); }
|
|
1177
|
+
for (const item of data.events) {
|
|
1178
|
+
if (get(item, 'schema') !== 'utg-event/1' || !truthy(get(item, 'kind')) || !isDict(get(item, 'payload'))) {
|
|
1179
|
+
throw new AdapterError('External response contains malformed events');
|
|
1180
|
+
}
|
|
1181
|
+
if (!pyEq(get(item, 'environment_id'), get(request, 'environment_id'))) { throw new AdapterError('External event belongs to another environment'); }
|
|
1182
|
+
}
|
|
1183
|
+
return data.events;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
const isAbsolute = (p) => /^(?:[A-Za-z]:[\\/]|\\\\|\/\/)/.test(p) || (process.platform !== 'win32' && p.startsWith('/'));
|
|
1188
|
+
|
|
1189
|
+
/** import_droidbot(directory, environment_id): raw DroidBot states as observation events. */
|
|
1190
|
+
export function importDroidbot(directory, environmentId) {
|
|
1191
|
+
directory = pResolve(directory);
|
|
1192
|
+
const events = [];
|
|
1193
|
+
for (const source of sortedBy(pGlob(pJoin(directory, 'states'), '*.json'), pOrder)) {
|
|
1194
|
+
const data = readJson(source);
|
|
1195
|
+
if (!truthy(get(data, 'views'))) { continue; }
|
|
1196
|
+
const shot = get(data, 'screenshot_path');
|
|
1197
|
+
const candidates = truthy(shot) && isAbsolute(shot) ? [pathStr(shot)] : [];
|
|
1198
|
+
if (truthy(shot)) { candidates.push(pJoin(directory, shot), pJoin(pParent(source), pName(shot))); }
|
|
1199
|
+
const stem = pStem(source).replaceAll('state_', 'screen_');
|
|
1200
|
+
const sfx = pSuffix(stem); const base = sfx ? stem.slice(0, -sfx.length) : stem; // .with_suffix() semantics
|
|
1201
|
+
for (const ext of ['.png', '.jpg']) { candidates.push(pJoin(pParent(source), base + ext)); }
|
|
1202
|
+
const found = candidates.find((p) => pIsFile(p));
|
|
1203
|
+
const screenshot = found === undefined ? null : pResolve(found);
|
|
1204
|
+
if (screenshot === null) { throw new AdapterError(`DroidBot state has no matching screenshot: ${source}`); }
|
|
1205
|
+
const oid = sha256Hex(readBytes(source));
|
|
1206
|
+
const fg = get(data, 'foreground_activity', 'unknown');
|
|
1207
|
+
const payload = { observation_id: 'droidbot-' + oid, activity: fg, window: 'unknown', nodes: normalizeNodes(data.views),
|
|
1208
|
+
identity: { family: fg, state: {}, status: 'unmapped', basis: [], reason: 'external discovery, replay required' },
|
|
1209
|
+
artifacts: { tree: source, screenshot }, provenance: { tool: 'droidbot', state_str: get(data, 'state_str') } };
|
|
1210
|
+
events.push(event('observation', environmentId, payload, [source, screenshot], 'droidbot-' + environmentId + '-' + oid));
|
|
1211
|
+
}
|
|
1212
|
+
return events;
|
|
1213
|
+
}
|