@buaa_smat/hometrans 26.0.5 → 26.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -279
- package/agents/code-reviewer.md +1 -1
- package/dist/cli/editors.json +20 -0
- package/dist/platform/registry.js +1 -0
- package/dist/platform/validate.js +2 -1
- package/i18n/agents/code-reviewer.md +1 -1
- package/i18n/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/i18n/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
- package/i18n/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/i18n/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/skills/a2h-app-migrate/SKILL.md +32 -15
- package/i18n/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +148 -89
- package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
- package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +9 -3
- package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +14 -12
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
- package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
- package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
- package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
- package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
- package/i18n/skills/a2h-module-semantic-docs/SKILL.md +3 -2
- package/i18n/skills/a2h-page-specgen/SKILL.md +36 -5
- package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +89 -21
- package/i18n/skills/a2h-page-specgen/references/gates.md +33 -7
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +166 -32
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +8 -5
- package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +37 -1
- package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
- package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
- package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
- package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +19 -10
- package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +62 -3
- package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +116 -6
- package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
- package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +26 -14
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +216 -216
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +100 -15
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +155 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +75 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +124 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +106 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +12 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +11 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
- package/i18n/skills/a2h-resource-convert/SKILL.md +1 -1
- package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
- package/i18n/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +15 -12
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
- package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +5 -3
- package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
- package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
- package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
- package/i18n/skills/a2h-spec-generate/references/input-formats.md +1 -1
- package/i18n/skills/a2h-utg-explorer/SKILL.md +11 -5
- package/i18n/skills/a2h-utg-explorer/references/architecture.md +37 -19
- package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +48 -3
- package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
- package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +143 -14
- package/i18n/skills/a2h-utg-static/SKILL.md +3 -3
- package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
- package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
- package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
- package/package.json +2 -1
- package/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/codebuddy/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/model-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +2 -0
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +2 -0
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +2 -0
- package/platforms/deveco/agents/model-worker.frontmatter.md +2 -0
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +2 -0
- package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +2 -0
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +2 -0
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +2 -0
- package/platforms/opencode/agents/model-worker.frontmatter.md +2 -0
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +2 -0
- package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
- package/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/skills/a2h-app-migrate/SKILL.md +31 -14
- package/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/skills/a2h-app-migrate/references/workflow.yaml +152 -89
- package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +28 -11
- package/skills/a2h-app-migrate/scripts/dag_action_catalog.mjs +76 -0
- package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +60 -5
- package/skills/a2h-app-migrate/scripts/dag_runner.mjs +184 -4
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/ledger.mjs +2 -2
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -3
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
- package/skills/a2h-app-migrate/test/test_dag_blocked_guard.mjs +291 -0
- package/skills/a2h-app-migrate/test/test_dag_production.mjs +40 -0
- package/skills/a2h-app-migrate/test/test_dag_runner.mjs +4 -3
- package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +36 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +19 -6
- package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
- package/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
- package/skills/a2h-batch-ui-align/SKILL.md +14 -12
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
- package/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
- package/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
- package/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
- package/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
- package/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
- package/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
- package/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
- package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
- package/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
- package/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
- package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +6 -1
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
- package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +270 -0
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +134 -16
- package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +39 -8
- package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
- package/skills/a2h-batch-ui-align/scripts/module_placement.mjs +189 -0
- package/skills/a2h-batch-ui-align/scripts/overlay_effects.mjs +205 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +28 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +28 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_chrome_defaults.test.mjs +328 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_click_handler.test.mjs +127 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_compose_semantics.test.mjs +150 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +117 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +413 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +159 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_sheet_builder.test.mjs +192 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +4 -2
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_compose.test.mjs +106 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +15 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pass.test.mjs +150 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +125 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +56 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack_icon_leaf.test.mjs +143 -0
- package/skills/a2h-batch-ui-align/scripts/tests/module_placement.test.mjs +248 -0
- package/skills/a2h-batch-ui-align/scripts/tests/overlay_effects.test.mjs +214 -0
- package/skills/a2h-fix-build-errors/references/known-patterns.md +5 -5
- package/skills/a2h-module-semantic-docs/SKILL.md +3 -2
- package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +10 -0
- package/skills/a2h-module-semantic-docs/scripts/design_baseline.mjs +158 -0
- package/skills/a2h-module-semantic-docs/test/test_design_baseline.mjs +128 -0
- package/skills/a2h-page-specgen/SKILL.md +36 -5
- package/skills/a2h-page-specgen/references/behavior-ledger.md +88 -21
- package/skills/a2h-page-specgen/references/evidence.md +2 -1
- package/skills/a2h-page-specgen/references/execution-model.md +13 -5
- package/skills/a2h-page-specgen/references/gates.md +33 -7
- package/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
- package/skills/a2h-page-specgen/references/spec-example.md +166 -32
- package/skills/a2h-page-specgen/references/spec-template.md +8 -5
- package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +40 -2
- package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
- package/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
- package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +35 -2
- package/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
- package/skills/a2h-page-specgen/scripts/finalize.mjs +55 -2
- package/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
- package/skills/a2h-page-specgen/scripts/gate.mjs +20 -11
- package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +56 -3
- package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
- package/skills/a2h-page-specgen/scripts/lib/hg.mjs +114 -5
- package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +20 -3
- package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
- package/skills/a2h-page-specgen/scripts/prepare.mjs +25 -14
- package/skills/a2h-page-specgen/scripts/report.mjs +26 -5
- package/skills/a2h-page-specgen/scripts/submission.mjs +69 -2
- package/skills/a2h-page-specgen/scripts/submit.mjs +105 -4
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +224 -224
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +153 -3
- package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
- package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
- package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
- package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +82 -3
- package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +11 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +94 -1
- package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
- package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +14 -0
- package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +49 -1
- package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
- package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +12 -4
- package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
- package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
- package/skills/a2h-page-specgen/scripts/test/report.test.mjs +80 -1
- package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
- package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +23 -0
- package/skills/a2h-page-specgen/scripts/waker.mjs +8 -1
- package/skills/a2h-resource-convert/SKILL.md +1 -1
- package/skills/a2h-resource-convert/data/framework-strings/NOTICE +10 -0
- package/skills/a2h-resource-convert/data/framework-strings/manifest.json +90 -0
- package/skills/a2h-resource-convert/data/framework-strings/strings.json +382 -0
- package/skills/a2h-resource-convert/references/conversion-rules.md +7 -1
- package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
- package/skills/a2h-resource-convert/references/step5-reference-resolution.md +16 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
- package/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
- package/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +14 -11
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +3 -0
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -3
- package/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
- package/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/scripts.md +4 -3
- package/skills/a2h-spec-design-pipeline/references/shared-layer.md +24 -19
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +12 -5
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +27 -3
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +46 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +2511 -295
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +27 -72
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +39 -83
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +132 -101
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +158 -115
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +60 -93
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +73 -100
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-cn.md +52 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-en.md +59 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +57 -8
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +475 -18
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +472 -4
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/RoutePageSideEffectImportCheck.js +570 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/arkui/RouteParamCarrierSubCheck.js +1053 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/sql/SqlIdentifierAnalysis.js +427 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +7 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/settle.ts +785 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +286 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +166 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_docs_refresh_contract.ts +40 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +350 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_route_page_side_effect_import.ts +185 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_route_param_carrier.ts +341 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_settle.ts +593 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +92 -1
- package/skills/a2h-spec-design-pipeline/scripts/test_sql_identifier_analysis.ts +137 -0
- package/skills/a2h-spec-generate/references/input-formats.md +1 -1
- package/skills/a2h-utg-explorer/SKILL.md +11 -5
- package/skills/a2h-utg-explorer/references/architecture.md +37 -19
- package/skills/a2h-utg-explorer/scripts/audit.mjs +6 -2
- package/skills/a2h-utg-explorer/scripts/close_phases.mjs +8 -5
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +95 -19
- package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +192 -4
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
- package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/plan.mjs +16 -1
- package/skills/a2h-utg-explorer/scripts/predicates.mjs +270 -0
- package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +2 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +4 -3
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +4 -3
- package/skills/a2h-utg-explorer/scripts/report.mjs +32 -2
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +103 -36
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +3 -8
- package/skills/a2h-utg-explorer/scripts/schedule_states.mjs +189 -0
- package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +9 -0
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +11 -0
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +31 -2
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
- package/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +4 -1
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +6 -28
- package/skills/a2h-utg-explorer/scripts/tests/in_route_surface.test.mjs +125 -0
- package/skills/a2h-utg-explorer/scripts/tests/list_probe_target_wait.test.mjs +86 -0
- package/skills/a2h-utg-explorer/scripts/tests/multi_host.test.mjs +167 -0
- package/skills/a2h-utg-explorer/scripts/tests/nested_list.test.mjs +58 -0
- package/skills/a2h-utg-explorer/scripts/tests/overlay_opener.test.mjs +100 -0
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +8 -1
- package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +1 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +2 -31
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +56 -7
- package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +117 -6
- package/skills/a2h-utg-explorer/scripts/tests/state_inventory.test.mjs +414 -0
- package/skills/a2h-utg-explorer/scripts/tests/tree_unreliable.test.mjs +197 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +196 -30
- package/skills/a2h-utg-explorer/scripts/utg_explorer/hosts.mjs +146 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
- package/skills/a2h-utg-explorer/scripts/utg_explorer/states.mjs +286 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +197 -19
- package/skills/a2h-utg-static/SKILL.md +3 -3
- package/skills/a2h-utg-static/references/extractors.md +7 -0
- package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
- package/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +642 -22
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
- package/skills/a2h-utg-static/scripts/tests/test_in_route_surface.mjs +123 -0
- package/skills/a2h-utg-static/scripts/tests/test_overlay_host_effects.mjs +239 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_host_depths.mjs +48 -0
- package/skills/a2h-utg-static/scripts/utg_html.mjs +2 -0
- package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
- package/i18n/skills/a2h-app-migrate/references/specs.example.json +0 -19
- package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
- package/resource/convert_pipeline_process.svg +0 -114
- package/resource/project_architecture.svg +0 -120
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.png +0 -0
- package/skills/a2h-app-migrate/references/specs.example.json +0 -19
- package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
- package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// A click path that could not attribute an overlay's trigger (`label_ambiguous`) records a label
|
|
2
|
+
// that may be a sibling control's or the overlay's own title (measured coolmall 2026-11-28: every
|
|
3
|
+
// order overlay failed with selector-not-found-after-bounded-scroll). The path's nl_hint names the
|
|
4
|
+
// gesture; compile it to the opener it quotes instead of the untrustworthy label.
|
|
5
|
+
import { test, describe } from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import * as fs from 'node:fs';
|
|
8
|
+
import * as os from 'node:os';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
import { spawnSync } from 'node:child_process';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { ambiguousHintLabels } from '../compile_tasks.mjs';
|
|
13
|
+
|
|
14
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const run = (script, ...args) => spawnSync(process.execPath, [path.join(HERE, '..', script), ...args], { encoding: 'utf8' });
|
|
16
|
+
|
|
17
|
+
const MAIN = 'compose-route:T.Main';
|
|
18
|
+
const ORDERS = 'compose-route:T.Orders';
|
|
19
|
+
const SHEET = 'overlay:T.Sheet';
|
|
20
|
+
const launch = { action: 'launch', label: null, target_id: MAIN, launch: { type: 'component', component_fqn: 'com.ex.MainActivity' } };
|
|
21
|
+
const toOrders = { action: 'tap', label: '我的订单', target_id: ORDERS };
|
|
22
|
+
|
|
23
|
+
/** plan.mjs + compile_tasks.mjs over a graph and paths in a temp dir -> campaign tasks. */
|
|
24
|
+
function compile(paths, sheetNode = {}) {
|
|
25
|
+
const graph = {
|
|
26
|
+
nodes: [
|
|
27
|
+
{ id: MAIN, kind: 'compose-route', label: 'MainRoute', entry: true, body_text: [{ text: '主页面' }] },
|
|
28
|
+
{ id: ORDERS, kind: 'compose-route', label: 'OrdersRoute', body_text: [{ text: '订单列表' }] },
|
|
29
|
+
{ id: SHEET, kind: 'sheet', label: '选择取消原因', expected: { title_any: ['选择取消原因'] }, ...sheetNode },
|
|
30
|
+
],
|
|
31
|
+
links: [
|
|
32
|
+
{ source: MAIN, target: ORDERS, mechanism: 'compose-navigate', trigger: 'onClick@app/Main.kt:10', args: { label: '我的订单' } },
|
|
33
|
+
{ source: ORDERS, target: SHEET, mechanism: 'open-overlay', trigger: 'onClick@app/Orders.kt:20', args: { label: '确认收货' } },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'opener-'));
|
|
37
|
+
fs.writeFileSync(path.join(d, 'utg.json'), JSON.stringify(graph));
|
|
38
|
+
fs.writeFileSync(path.join(d, 'click_paths.json'), JSON.stringify({ root: MAIN, paths }));
|
|
39
|
+
const camp = path.join(d, 'campaign');
|
|
40
|
+
let r = run('plan.mjs', path.join(d, 'utg.json'), camp);
|
|
41
|
+
assert.equal(r.status, 0, r.stderr);
|
|
42
|
+
r = run('compile_tasks.mjs', path.join(d, 'utg.json'), camp);
|
|
43
|
+
assert.equal(r.status, 0, r.stderr);
|
|
44
|
+
const tasks = JSON.parse(fs.readFileSync(path.join(camp, 'campaign.json'), 'utf8')).tasks;
|
|
45
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
46
|
+
return tasks.find((t) => t.source_static === ORDERS && t.target_static === SHEET);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const pathsWith = (step) => ({ [MAIN]: { steps: [launch] }, [ORDERS]: { steps: [launch, toOrders] },
|
|
50
|
+
[SHEET]: { steps: [launch, toOrders, step] } });
|
|
51
|
+
|
|
52
|
+
const textOf = (sel) => sel.text ?? sel.content_desc;
|
|
53
|
+
|
|
54
|
+
describe('ambiguous overlay opener', () => {
|
|
55
|
+
test('the hint\'s quoted opener replaces the untrustworthy label', () => {
|
|
56
|
+
const task = compile(pathsWith({ action: 'tap', label: '确认收货', target_id: SHEET, label_ambiguous: true,
|
|
57
|
+
nl_hint: '点击「取消订单」(待付款订单卡片上的按钮,会弹出选择取消原因的弹窗)' }));
|
|
58
|
+
assert.equal(task.status, 'compiled', JSON.stringify(task.compile_issues));
|
|
59
|
+
assert.equal(task.action.type, 'click_candidates');
|
|
60
|
+
assert.equal(task.action.static_label, '取消订单');
|
|
61
|
+
assert.equal(textOf(task.action.selectors[0]), '取消订单');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('a parenthetical 「即「X」」 names the real button, the generic first quote is the fallback', () => {
|
|
65
|
+
const task = compile(pathsWith({ action: 'tap', label: '选择要评价的商品', target_id: SHEET, label_ambiguous: true,
|
|
66
|
+
nl_hint: '点击「购买」(订单卡片右侧文字为「再次购买」的按钮,会弹出选择要购买的商品弹窗)' }),
|
|
67
|
+
{ label: '选择要购买的商品', expected: { title_any: ['选择要购买的商品'] } });
|
|
68
|
+
assert.equal(task.action.static_label, '再次购买');
|
|
69
|
+
assert.equal(textOf(task.action.selectors[0]), '再次购买');
|
|
70
|
+
assert.ok(task.action.selectors.some((s) => textOf(s) === '购买'), 'the generic quote stays a fallback');
|
|
71
|
+
assert.ok(!task.action.selectors.some((s) => textOf(s) === '选择要购买的商品'), 'the overlay title is not an opener');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('an id hint becomes the first selector, with the quoted label as its fallback', () => {
|
|
75
|
+
const task = compile(pathsWith({ action: 'tap', label: '选择要评价的商品', target_id: SHEET, label_ambiguous: true,
|
|
76
|
+
nl_hint: '点击订单详情页底部的〔id:rebuy_now〕按钮(即「再次购买」,订单含多件商品时弹出「选择要购买的商品」弹层)' }),
|
|
77
|
+
{ label: '选择要购买的商品', expected: { title_any: ['选择要购买的商品'] } });
|
|
78
|
+
assert.deepEqual(task.action.selectors[0], { resource_name: 'rebuy_now' });
|
|
79
|
+
assert.ok(task.action.selectors.some((s) => textOf(s) === '再次购买'));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('a hint that names only the overlay title leaves the recorded opener alone', () => {
|
|
83
|
+
const task = compile(pathsWith({ action: 'tap', label: '确认收货', target_id: SHEET, label_ambiguous: true,
|
|
84
|
+
nl_hint: '在订单详情页底部点击「确认收货」,弹出确认对话框' }));
|
|
85
|
+
assert.equal(task.action.static_label, '确认收货');
|
|
86
|
+
assert.ok(task.action.selectors.some((s) => textOf(s) === '确认收货'));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('a non-ambiguous step keeps its static label', () => {
|
|
90
|
+
const task = compile(pathsWith({ action: 'tap', label: '确认收货', target_id: SHEET, nl_hint: '点击「取消订单」' }));
|
|
91
|
+
assert.equal(task.action.static_label, '确认收货');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('ambiguousHintLabels drops the overlay\'s own title and keeps its ids and quoted openers', () => {
|
|
96
|
+
const node = { label: '选择要购买的商品', expected: { title_any: ['选择要购买的商品'] } };
|
|
97
|
+
assert.deepEqual(ambiguousHintLabels({ nl_hint: '点击订单详情页底部的〔id:rebuy_now〕按钮(即「再次购买」,弹出「选择要购买的商品」弹层)' }, node),
|
|
98
|
+
{ ids: ['rebuy_now'], words: ['再次购买'] });
|
|
99
|
+
assert.deepEqual(ambiguousHintLabels({ nl_hint: '点击「确认收货」' }, { label: '确认收货' }), { ids: [], words: [] });
|
|
100
|
+
});
|
|
@@ -6,7 +6,7 @@ import fsDefault from 'node:fs';
|
|
|
6
6
|
import * as os from 'node:os';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import { syncBuiltinESMExports } from 'node:module';
|
|
9
|
-
import { compilePlan } from '../plan.mjs';
|
|
9
|
+
import { compilePlan, bypassNodeIds } from '../plan.mjs';
|
|
10
10
|
import { merge } from '../evidence.mjs';
|
|
11
11
|
import {
|
|
12
12
|
normalizeNodes, matching, resolveIdentity, ruleMatches, CommandAdapter, AdapterError, atomicWriteJson, DeviceAdapter,
|
|
@@ -168,6 +168,13 @@ describe('PipelineTests', () => {
|
|
|
168
168
|
assert.deepEqual(obligations.map((o) => o.id), ['root']);
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
+
test('the campaign carries the pages the legacy plan bypassed, for the audit denominator', () => {
|
|
172
|
+
const legacy = { nodes: [{ id: 'root', phase: 'P0_fresh', level: 'AUTO' },
|
|
173
|
+
{ id: 'compose-route:Pay', phase: 'BYPASS_paywall', level: 'BYPASS' }] };
|
|
174
|
+
assert.deepEqual(bypassNodeIds(legacy), ['compose-route:Pay']);
|
|
175
|
+
assert.deepEqual(bypassNodeIds(null), []);
|
|
176
|
+
});
|
|
177
|
+
|
|
171
178
|
test('empty guard is not evidence', () => {
|
|
172
179
|
assert.equal(ruleMatches({ nodes: [] }, { none: [{ text: 'Login' }] }), false);
|
|
173
180
|
});
|
|
@@ -76,6 +76,7 @@ test('the list probe presses Back only after a row that left the page', () => {
|
|
|
76
76
|
current: { static_resolution: { status: 'verified', static_id: 'r:Home' } },
|
|
77
77
|
listCandidates: () => [[0, 'chip'], [1, 'goods']],
|
|
78
78
|
at: (id) => page === id,
|
|
79
|
+
waitForTarget: (id) => page === id,
|
|
79
80
|
atom: (a) => { backs.push(a.type); page = 'r:Home'; },
|
|
80
81
|
};
|
|
81
82
|
// the first row (a category chip) only switches a tab; the second opens the target
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// Review fixes for !191 (uni-app / hybrid route jump):
|
|
2
|
-
// - state_phase_fallback defaults on only for a uni-app / hybrid app
|
|
3
2
|
// - plan and audit agree on which edges leave the denominator (native denominator:false nodes keep theirs)
|
|
4
3
|
// - hybrid_route_cdp.mjs: pending sends fail on close/error, every send/fetch is bounded,
|
|
5
4
|
// a closed connection during reLaunch counts as dispatched, adb errors are reported as such
|
|
@@ -14,7 +13,6 @@ import { spawnSync } from 'node:child_process';
|
|
|
14
13
|
import { fileURLToPath } from 'node:url';
|
|
15
14
|
import { compilePlan } from '../plan.mjs';
|
|
16
15
|
import { audit } from '../audit.mjs';
|
|
17
|
-
import { isHybridApp, statePhaseFallbackEnabled, fallbackScope } from '../utg_explorer/state_phase.mjs';
|
|
18
16
|
import { isNonNavigable } from '../utg_explorer/hybrid_route.mjs';
|
|
19
17
|
import { firstRoundPhases } from '../run_cycle.mjs';
|
|
20
18
|
import { Runner, routeErrorCode } from '../utg_explorer/task_runner.mjs';
|
|
@@ -25,33 +23,6 @@ const HELPER = path.join(path.dirname(path.dirname(fileURLToPath(import.meta.url
|
|
|
25
23
|
const APP = '__UNI__T';
|
|
26
24
|
const page = (route, extra = {}) => ({ id: `hybrid-page:${APP}/${route}`, kind: 'hybrid-page', route, appid: APP, ...extra });
|
|
27
25
|
|
|
28
|
-
// ------------------------------------------------------------------ #1 state phase fallback
|
|
29
|
-
|
|
30
|
-
describe('state_phase_fallback default', () => {
|
|
31
|
-
const uni = { nodes: [page('pages/index/index', { entry: true, is_launcher: true }), page('pages/mine/mine')] };
|
|
32
|
-
const bundled = { nodes: [{ id: 'activity:Host', kind: 'host-activity', denominator: false }, page('pages/a/a')] };
|
|
33
|
-
const native = { nodes: [{ id: 'activity:Main', kind: 'activity', is_launcher: true }, { id: 'activity:Detail', kind: 'activity' }] };
|
|
34
|
-
const mixed = { nodes: [{ id: 'activity:Main', kind: 'activity', is_launcher: true }, page('pages/a/a')] };
|
|
35
|
-
const phase = { id: 'state-login', requires: ['login'] };
|
|
36
|
-
|
|
37
|
-
test('on for a uni-app / pre-bundled hybrid app, off for native and native+embedded hybrid', () => {
|
|
38
|
-
assert.equal(isHybridApp(uni), true);
|
|
39
|
-
assert.equal(isHybridApp(bundled), true);
|
|
40
|
-
assert.equal(isHybridApp(native), false);
|
|
41
|
-
assert.equal(isHybridApp(mixed), false);
|
|
42
|
-
assert.equal(statePhaseFallbackEnabled({}, uni), true);
|
|
43
|
-
assert.equal(statePhaseFallbackEnabled({}, native), false);
|
|
44
|
-
assert.equal(statePhaseFallbackEnabled({}), false);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('an explicit flag overrides the default both ways', () => {
|
|
48
|
-
assert.equal(statePhaseFallbackEnabled({ state_phase_fallback: true }, native), true);
|
|
49
|
-
assert.equal(statePhaseFallbackEnabled({ state_phase_fallback: false }, uni), false);
|
|
50
|
-
assert.match(fallbackScope({ state_phase_fallback: true }, phase, undefined, native), /best-effort/);
|
|
51
|
-
assert.equal(fallbackScope({}, phase, undefined, native), null);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
26
|
// ------------------------------------------------------------------ #2 plan / audit agreement
|
|
56
27
|
|
|
57
28
|
describe('plan and audit agree on edge obligations', () => {
|
|
@@ -281,12 +252,12 @@ describe('runRoute failure classes', () => {
|
|
|
281
252
|
assert.equal(kinds(r, 'task_result', 'a')[0].payload.outcome, 'unsupported');
|
|
282
253
|
});
|
|
283
254
|
|
|
284
|
-
test('first round:
|
|
255
|
+
test('first round: a probe-less state phase waits for stage S for every app type', () => {
|
|
285
256
|
const phases = [{ id: 'p0-fresh', requires: [] }, { id: 'state-login', requires: ['login'] }];
|
|
286
257
|
const tasks = [{ phase: 'state-login', status: 'compiled' }];
|
|
287
258
|
const uni = { phases, tasks, nodes: [page('pages/index/index', { entry: true })] };
|
|
288
259
|
const native = { phases, tasks, nodes: [{ id: 'activity:Main', kind: 'activity', is_launcher: true }] };
|
|
289
|
-
assert.deepEqual(firstRoundPhases({ fixtures: { 'p0-fresh': [] } }, uni), ['p0-fresh'
|
|
260
|
+
assert.deepEqual(firstRoundPhases({ fixtures: { 'p0-fresh': [] } }, uni), ['p0-fresh']);
|
|
290
261
|
assert.deepEqual(firstRoundPhases({ fixtures: { 'p0-fresh': [] } }, native), ['p0-fresh']);
|
|
291
262
|
});
|
|
292
263
|
});
|
|
@@ -86,7 +86,7 @@ describe('run_cycle device loss', () => {
|
|
|
86
86
|
fs.writeFileSync(path.join(root, 'direct_launch_worklist.json'), JSON.stringify({ items: [], auto_skipped: true }));
|
|
87
87
|
fs.writeFileSync(path.join(root, 'direct_launch_answers.json'), '[]');
|
|
88
88
|
let cov = 0; const saves = [];
|
|
89
|
-
const state = { done: ['first', 'r1:A-extract', 'r1:A', 'r1:BC-extract', 'r1:BC', 'r1:direct-extract'], round: 1, round_start_covered: 0, waiting: [], blocked_on: [] };
|
|
89
|
+
const state = { done: ['initial', 'first', 'fresh', 'r1:S-extract', 'r1:S', 'r1:A-extract', 'r1:A', 'r1:BC-extract', 'r1:BC', 'r1:direct-extract'], round: 1, round_start_covered: 0, waiting: [], blocked_on: [] };
|
|
90
90
|
const sh = (args) => { if (args[0] === 'report.mjs') { fs.writeFileSync(path.join(root, 'audit.json'), JSON.stringify({ mapped_static_nodes: ++cov })); } return {}; };
|
|
91
91
|
withSh(sh, () => {
|
|
92
92
|
rc.deps.save = () => saves.push({ round: state.round, bak: fs.existsSync(path.join(root, 'direct_launch_answers.json.r1.bak')) });
|
|
@@ -105,7 +105,8 @@ describe('Cycle', () => {
|
|
|
105
105
|
assert.ok(calls.includes('worklist_parts.mjs:merge'));
|
|
106
106
|
assert.ok(calls.includes('recover.mjs:apply'));
|
|
107
107
|
assert.ok(!calls.includes('run_device.mjs:' + root + 'x'));
|
|
108
|
-
|
|
108
|
+
// extracted while stage S was still open: re-extracted once after S (its phases may map pages)
|
|
109
|
+
assert.equal(calls.filter((c) => c === 'recover.mjs:extract').length, 1);
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
test('D runs by default and makes base snapshot', () => {
|
|
@@ -123,6 +124,48 @@ describe('Cycle', () => {
|
|
|
123
124
|
assert.ok(!calls.includes('d_prereqs.mjs:snapshot'));
|
|
124
125
|
});
|
|
125
126
|
|
|
127
|
+
test('the handed-over data is archived first, restored last; a resumed campaign never archives changed data', () => {
|
|
128
|
+
const [done, , calls] = drive({});
|
|
129
|
+
assert.equal(done, true);
|
|
130
|
+
assert.equal(calls[0], 'd_prereqs.mjs:initial');
|
|
131
|
+
assert.equal(calls.at(-1), 'd_prereqs.mjs:restore-initial');
|
|
132
|
+
const resumed = { done: ['first'], round_start_covered: 0 };
|
|
133
|
+
const seen = [];
|
|
134
|
+
withSh(fakeShFactory(root, seen, {}), () => { for (;;) { resumed.waiting = []; if (rc.step(root, a, resumed) !== null) { break; } } });
|
|
135
|
+
assert.ok(!seen.includes('d_prereqs.mjs:initial'));
|
|
136
|
+
assert.ok(resumed.notes.some((n) => n.startsWith('initial:')));
|
|
137
|
+
// recorded as resumed: a later snapshot does not archive the changed data as the handed-over one
|
|
138
|
+
const st = JSON.parse(fs.readFileSync(path.join(root, 'states.json'), 'utf8'));
|
|
139
|
+
const init = st.states.find((x) => x.id === 'initial');
|
|
140
|
+
assert.equal(init.origin, 'resumed');
|
|
141
|
+
assert.equal(init.restorable, false);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('the handed-over data is put back after the fresh pm clear and after S, before A/BC retry on it', () => {
|
|
145
|
+
const snap = path.join(root, 'snapshots'); fs.mkdirSync(snap);
|
|
146
|
+
const cfg = JSON.parse(fs.readFileSync(a.config, 'utf8'));
|
|
147
|
+
cfg.snapshot_dir = snap;
|
|
148
|
+
fs.writeFileSync(a.config, JSON.stringify(cfg));
|
|
149
|
+
const calls = [];
|
|
150
|
+
const base = fakeShFactory(root, calls, {});
|
|
151
|
+
const fake = (args) => {
|
|
152
|
+
const r = base(args);
|
|
153
|
+
if (args[0] === 'd_prereqs.mjs' && args[1] === 'snapshot') { return { created: true, mode: 'tar' }; }
|
|
154
|
+
// S scheduled a variant in another state
|
|
155
|
+
if (args[0] === 'schedule_states.mjs') { fs.writeFileSync(path.join(root, 'state_phases.txt'), 'st-x-1\n'); }
|
|
156
|
+
return r;
|
|
157
|
+
};
|
|
158
|
+
const state = { done: [], round_start_covered: 0 };
|
|
159
|
+
withSh(fake, () => { for (;;) { state.waiting = []; if (rc.step(root, a, state) !== null) { break; } } });
|
|
160
|
+
const at = (c, from = 0) => calls.indexOf(c, from);
|
|
161
|
+
const snapAt = at('d_prereqs.mjs:snapshot');
|
|
162
|
+
const back1 = at('d_prereqs.mjs:restore-initial', snapAt);
|
|
163
|
+
assert.ok(snapAt >= 0 && back1 > snapAt, 'restored right after the fresh snapshot');
|
|
164
|
+
const sched = at('schedule_states.mjs:' + root);
|
|
165
|
+
const back2 = at('d_prereqs.mjs:restore-initial', sched);
|
|
166
|
+
assert.ok(sched > back1 && back2 > sched, 'restored after S');
|
|
167
|
+
});
|
|
168
|
+
|
|
126
169
|
test('D without snapshot_dir extracts a state worklist but applies no recipe', () => {
|
|
127
170
|
const [done, state, calls] = drive({});
|
|
128
171
|
assert.equal(done, true);
|
|
@@ -338,9 +381,10 @@ describe('Cycle', () => {
|
|
|
338
381
|
let [done, state, calls] = run();
|
|
339
382
|
assert.equal(done, true);
|
|
340
383
|
assert.equal(state.round, 2);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
384
|
+
// A is extracted up front and once more after stage S ran (S can map pages A would ask about)
|
|
385
|
+
assert.equal(calls.filter((c) => c === 'recover.mjs:extract').length, 2);
|
|
386
|
+
// round 1: extracted up front, re-extracted after S-D ran; round 2: re-extracted after its S
|
|
387
|
+
assert.equal(calls.filter((c) => c === 'direct_launch.mjs:extract').length, 4);
|
|
344
388
|
assert.ok(state.skipped.some((s) => s.startsWith('r2:A-D')));
|
|
345
389
|
for (const f of fs.readdirSync(root)) { if (/_answers|cycle_state/.test(f)) { fs.rmSync(path.join(root, f)); } }
|
|
346
390
|
a.review = 'serial';
|
|
@@ -350,7 +394,8 @@ describe('Cycle', () => {
|
|
|
350
394
|
a.review = undefined;
|
|
351
395
|
a.later_rounds = 'all';
|
|
352
396
|
[done, state, calls] = run();
|
|
353
|
-
|
|
397
|
+
// each of the two rounds: up front, then refreshed after its stage S
|
|
398
|
+
assert.equal(calls.filter((c) => c === 'recover.mjs:extract').length, 4);
|
|
354
399
|
});
|
|
355
400
|
|
|
356
401
|
test('capture_pending: uncovered in-scope nodes, then only last-round launches, then none', () => {
|
|
@@ -394,10 +439,11 @@ describe('Cycle', () => {
|
|
|
394
439
|
test('A loops while a retry run surfaces new identity questions', () => {
|
|
395
440
|
// pass 1: drawer asked; its retry reaches SETTINGS, unverified -> pass 2 asks SETTINGS;
|
|
396
441
|
// pass 2's retry resolves it on its own -> pass 3 retries with nothing new to ask, then stops.
|
|
397
|
-
|
|
442
|
+
// (the second extract is the refresh after stage S: nothing new yet)
|
|
443
|
+
const keys = [['drawer'], ['drawer'], ['drawer', 'settings'], ['drawer', 'settings']];
|
|
398
444
|
let extracts = 0; let retries = 0;
|
|
399
445
|
const calls = [];
|
|
400
|
-
const base = fakeShFactory(root, calls, { recovery: () => ({ items: keys[Math.min(extracts++,
|
|
446
|
+
const base = fakeShFactory(root, calls, { recovery: () => ({ items: keys[Math.min(extracts++, 3)].map((key) => ({ key })) }) });
|
|
401
447
|
const fake = (args, r, log) => {
|
|
402
448
|
if (args[0] === 'recover_b.mjs' && args[1] === 'retry-identities') {
|
|
403
449
|
retries += 1;
|
|
@@ -451,6 +497,9 @@ describe('main', () => {
|
|
|
451
497
|
assert.ok(st.done.includes('first') && st.done.includes('r1:A-extract'), JSON.stringify(st.done));
|
|
452
498
|
assert.ok(!st.done.includes('r1:A'));
|
|
453
499
|
assert.equal(rc.deps.sh, fake, 'main restores deps.sh after a failure');
|
|
500
|
+
// the device is put back as it came before the error propagates
|
|
501
|
+
const last = seen.findLastIndex((x) => x[0] === 'recover.mjs' && x[1] === 'apply');
|
|
502
|
+
assert.ok(seen.slice(last).some((x) => x[0] === 'd_prereqs.mjs' && x[1] === 'restore-initial'), 'restore-initial after the failure');
|
|
454
503
|
} finally {
|
|
455
504
|
rc.deps.sh = saved; process.chdir(cwd); fs.rmSync(root, { recursive: true, force: true });
|
|
456
505
|
}
|
|
@@ -5,6 +5,7 @@ import assert from 'node:assert/strict';
|
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
6
|
import * as os from 'node:os';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
|
+
import { spawnSync } from 'node:child_process';
|
|
8
9
|
import * as dp from '../d_prereqs.mjs';
|
|
9
10
|
import { AdapterError, DeviceAdapter, tarProblem } from '../utg_explorer/adapters.mjs';
|
|
10
11
|
import { tinyTar } from './tar_fixture.mjs';
|
|
@@ -47,16 +48,20 @@ describe('tarProblem', () => {
|
|
|
47
48
|
});
|
|
48
49
|
});
|
|
49
50
|
|
|
50
|
-
/**
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* DeviceAdapter whose adb is a node script: logs argv, answers `ls -a`, emits `stream` for exec-out.
|
|
53
|
+
* `unpacks`: exec-in stands for a tar that finished, so the next `ls -a` shows its sentinel.
|
|
54
|
+
*/
|
|
55
|
+
function fakeDevice(root, { present = 'databases\nfiles\n', stream = tinyTar(), unpacks = false } = {}) {
|
|
52
56
|
const log = path.join(root, 'adb.log'); const out = path.join(root, 'stream.bin'); fs.writeFileSync(out, stream);
|
|
57
|
+
const flag = path.join(root, 'unpacked.flag');
|
|
53
58
|
const script = path.join(root, 'adb.mjs');
|
|
54
59
|
fs.writeFileSync(script, `import * as fs from 'node:fs';
|
|
55
60
|
const a = process.argv.slice(2).filter((x, i, all) => !(x === '-s' || all[i - 1] === '-s'));
|
|
56
61
|
fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify(a) + '\\n');
|
|
57
62
|
if (a[0] === 'exec-out') { process.stdout.write(fs.readFileSync(${JSON.stringify(out)})); }
|
|
58
|
-
else if (a[0] === 'exec-in') { fs.writeFileSync(${JSON.stringify(path.join(root, 'restored.bin'))}, fs.readFileSync(0)); }
|
|
59
|
-
else if (a.join(' ').includes('ls -a')) { process.stdout.write(${JSON.stringify(present)}); }
|
|
63
|
+
else if (a[0] === 'exec-in') { fs.writeFileSync(${JSON.stringify(path.join(root, 'restored.bin'))}, fs.readFileSync(0)); if (${unpacks}) { fs.writeFileSync(${JSON.stringify(flag)}, ''); } }
|
|
64
|
+
else if (a.join(' ').includes('ls -a')) { process.stdout.write(${JSON.stringify(present)} + (fs.existsSync(${JSON.stringify(flag)}) ? '.utg_restore.ok\\n' : '')); }
|
|
60
65
|
`);
|
|
61
66
|
const snap = path.join(root, 'snap'); fs.mkdirSync(snap, { recursive: true });
|
|
62
67
|
const dev = new DeviceAdapter({ serial: 's', package: 'p', snapshot_dir: snap, layout_backend: 'uiautomator', adb_persistent_shell: false }, path.join(root, 'art'));
|
|
@@ -78,6 +83,28 @@ describe('snapshot_app_data / restore_app_data', () => {
|
|
|
78
83
|
assert.deepEqual(tar, ['exec-out', 'run-as p tar -cf - databases files 2>/dev/null']);
|
|
79
84
|
});
|
|
80
85
|
|
|
86
|
+
test('archives every data entry by default (cache and lib left out); clear_dirs all clears the same', () => {
|
|
87
|
+
const { dev, snap, calls } = fakeDevice(root, { unpacks: true, present: ['.', '..', 'cache', 'code_cache', 'lib', 'app_webview', 'databases', 'no_backup', ''].join(String.fromCharCode(10)),
|
|
88
|
+
stream: tinyTar(['app_webview', 'databases', 'no_backup']) });
|
|
89
|
+
const archive = path.join(snap, 'initial.tar');
|
|
90
|
+
dev.act({ type: 'snapshot_app_data', archive });
|
|
91
|
+
assert.deepEqual(calls().find((c) => c[0] === 'exec-out'), ['exec-out', 'run-as p tar -cf - app_webview databases no_backup 2>/dev/null']);
|
|
92
|
+
dev.act({ type: 'restore_app_data', archive, clear_dirs: 'all' });
|
|
93
|
+
const rm = calls().find((c) => c[0] === 'shell' && c[1].includes('rm -rf app_webview'));
|
|
94
|
+
assert.match(rm[1], /rm -rf app_webview databases no_backup && for e in \.utg_restore/);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('restore unpacks into a staging dir first; an unpack tar did not finish removes no app data', () => {
|
|
98
|
+
const { dev, snap, calls } = fakeDevice(root); // its exec-in runs no tar: no sentinel
|
|
99
|
+
const archive = path.join(snap, 'fresh.tar'); fs.writeFileSync(archive, tinyTar());
|
|
100
|
+
assert.throws(() => dev.act({ type: 'restore_app_data', archive, clear_dirs: ['databases', 'files'] }),
|
|
101
|
+
(e) => e instanceof AdapterError && /before any app data was removed/.test(e.message));
|
|
102
|
+
const shells = calls().filter((c) => c[0] === 'shell').map((c) => c[1]);
|
|
103
|
+
assert.ok(!shells.some((c) => /rm -rf (?:'?databases|'?files)/.test(c)), JSON.stringify(shells));
|
|
104
|
+
const exec = calls().find((c) => c[0] === 'exec-in');
|
|
105
|
+
assert.match(exec.join(' '), /cd \.utg_restore && tar -xf - && touch \.\.\/\.utg_restore\.ok/);
|
|
106
|
+
});
|
|
107
|
+
|
|
81
108
|
test('a polluted stream is refused and nothing is written', () => {
|
|
82
109
|
const { dev, snap } = fakeDevice(root, { stream: polluted() });
|
|
83
110
|
const archive = path.join(snap, 'fresh.tar');
|
|
@@ -93,7 +120,7 @@ describe('snapshot_app_data / restore_app_data', () => {
|
|
|
93
120
|
});
|
|
94
121
|
|
|
95
122
|
test('a whole archive is restored as before', () => {
|
|
96
|
-
const { dev, snap, calls } = fakeDevice(root);
|
|
123
|
+
const { dev, snap, calls } = fakeDevice(root, { unpacks: true });
|
|
97
124
|
const archive = path.join(snap, 'fresh.tar'); fs.writeFileSync(archive, tinyTar());
|
|
98
125
|
dev.act({ type: 'restore_app_data', archive, clear_dirs: ['databases', 'files'] });
|
|
99
126
|
assert.deepEqual(fs.readFileSync(path.join(root, 'restored.bin')), tinyTar());
|
|
@@ -101,23 +128,107 @@ describe('snapshot_app_data / restore_app_data', () => {
|
|
|
101
128
|
});
|
|
102
129
|
});
|
|
103
130
|
|
|
131
|
+
/**
|
|
132
|
+
* A device whose run-as commands really run: `sh` in a temp dir that stands for the app's data dir,
|
|
133
|
+
* `tar` unpacking the archive exec-in streams. `tarFails`: the device-side tar exits non-zero.
|
|
134
|
+
*/
|
|
135
|
+
function shellDevice(root, { tarFails = false } = {}) {
|
|
136
|
+
const data = path.join(root, 'data'); fs.mkdirSync(data, { recursive: true });
|
|
137
|
+
const script = path.join(root, 'adb.mjs');
|
|
138
|
+
fs.writeFileSync(script, `import { spawnSync } from 'node:child_process';
|
|
139
|
+
import * as fs from 'node:fs';
|
|
140
|
+
const a = process.argv.slice(2).filter((x, i, all) => !(x === '-s' || all[i - 1] === '-s'));
|
|
141
|
+
const sh = (cmd, input) => { const r = spawnSync('sh', ['-c', cmd], { cwd: ${JSON.stringify(data)}, input, encoding: input ? undefined : 'utf8' }); process.stdout.write(r.stdout ?? ''); process.stderr.write(r.stderr ?? ''); process.exitCode = r.status; };
|
|
142
|
+
if (a[0] === 'exec-in') { const cmd = a.slice(3).join(' '); sh(${tarFails} ? 'cat > /dev/null; false' : cmd, fs.readFileSync(0)); }
|
|
143
|
+
else if (a[0] === 'shell') { const c = a.slice(1).join(' '); if (c.startsWith('run-as p ')) { sh(c.slice('run-as p '.length)); } }
|
|
144
|
+
`);
|
|
145
|
+
const snap = path.join(root, 'snap'); fs.mkdirSync(snap, { recursive: true });
|
|
146
|
+
const dev = new DeviceAdapter({ serial: 's', package: 'p', snapshot_dir: snap, layout_backend: 'uiautomator', adb_persistent_shell: false }, path.join(root, 'art'));
|
|
147
|
+
dev.adb = [process.execPath, script, '-s', 's'];
|
|
148
|
+
const put = (rel, text) => { const f = path.join(data, rel); fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, text); };
|
|
149
|
+
return { dev, snap, data, put };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** A real tar of `files` ({rel: text}), as snapshot_app_data writes one. */
|
|
153
|
+
function realTar(root, files) {
|
|
154
|
+
const src = fs.mkdtempSync(path.join(root, 'src-'));
|
|
155
|
+
for (const [rel, text] of Object.entries(files)) { const f = path.join(src, rel); fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, text); }
|
|
156
|
+
const tops = [...new Set(Object.keys(files).map((r) => r.split('/')[0]))];
|
|
157
|
+
return spawnSync('tar', ['-cf', '-', ...tops], { cwd: src }).stdout;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
describe('restore_app_data on a real shell', () => {
|
|
161
|
+
let root;
|
|
162
|
+
beforeEach(() => { root = tmp(); });
|
|
163
|
+
|
|
164
|
+
test('clear_dirs [] or a partial list: an archived dir replaces the one on the device, never nests inside it', () => {
|
|
165
|
+
for (const clear of [undefined, [], ['databases']]) {
|
|
166
|
+
fs.rmSync(path.join(root, 'data'), { recursive: true, force: true });
|
|
167
|
+
const { dev, snap, data, put } = shellDevice(root);
|
|
168
|
+
put('shared_prefs/a.xml', 'old'); put('shared_prefs/stale.xml', 'old'); put('databases/x.db', 'old');
|
|
169
|
+
const archive = path.join(snap, `x${clear ? clear.length : 'u'}.tar`);
|
|
170
|
+
fs.writeFileSync(archive, realTar(root, { 'shared_prefs/a.xml': 'new', 'databases/x.db': 'new' }));
|
|
171
|
+
dev.act({ type: 'restore_app_data', archive, ...(clear ? { clear_dirs: clear } : {}) });
|
|
172
|
+
const label = JSON.stringify(clear);
|
|
173
|
+
assert.equal(fs.readFileSync(path.join(data, 'shared_prefs/a.xml'), 'utf8'), 'new', label);
|
|
174
|
+
assert.equal(fs.existsSync(path.join(data, 'shared_prefs/shared_prefs')), false, label);
|
|
175
|
+
assert.equal(fs.existsSync(path.join(data, 'shared_prefs/stale.xml')), false, `${label}: the archived dir is the whole of it`);
|
|
176
|
+
assert.equal(fs.readFileSync(path.join(data, 'databases/x.db'), 'utf8'), 'new', label);
|
|
177
|
+
assert.deepEqual(fs.readdirSync(data).filter((n) => n.startsWith('.utg_restore')), [], `${label}: staging removed`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('a device-side tar that fails leaves the app data as it was and no staging behind', () => {
|
|
182
|
+
const { dev, snap, data, put } = shellDevice(root, { tarFails: true });
|
|
183
|
+
put('shared_prefs/a.xml', 'old');
|
|
184
|
+
const archive = path.join(snap, 'x.tar');
|
|
185
|
+
fs.writeFileSync(archive, realTar(root, { 'shared_prefs/a.xml': 'new' }));
|
|
186
|
+
assert.throws(() => dev.act({ type: 'restore_app_data', archive, clear_dirs: 'all' }),
|
|
187
|
+
(e) => e instanceof AdapterError && /before any app data was removed/.test(e.message));
|
|
188
|
+
assert.equal(fs.readFileSync(path.join(data, 'shared_prefs/a.xml'), 'utf8'), 'old');
|
|
189
|
+
assert.deepEqual(fs.readdirSync(data).filter((n) => n.startsWith('.utg_restore')), []);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('an unpack that times out is an AdapterError and removes the staging dir', () => {
|
|
193
|
+
const { dev, snap, data, put } = shellDevice(root);
|
|
194
|
+
put('shared_prefs/a.xml', 'old');
|
|
195
|
+
const archive = path.join(snap, 'x.tar');
|
|
196
|
+
fs.writeFileSync(archive, realTar(root, { 'shared_prefs/a.xml': 'new' }));
|
|
197
|
+
const real = dev.adb;
|
|
198
|
+
const slow = path.join(root, 'slow.mjs');
|
|
199
|
+
fs.writeFileSync(slow, `import { spawnSync } from 'node:child_process';
|
|
200
|
+
const a = process.argv.slice(2);
|
|
201
|
+
if (a.includes('exec-in')) { setTimeout(() => {}, 60000); } else { const r = spawnSync(process.execPath, [${JSON.stringify(real[1])}, ...a], { stdio: 'inherit' }); process.exitCode = r.status; }
|
|
202
|
+
`);
|
|
203
|
+
dev.adb = [process.execPath, slow, '-s', 's'];
|
|
204
|
+
dev.timeout = 1;
|
|
205
|
+
dev.config.restore_base_timeout = 0;
|
|
206
|
+
assert.throws(() => dev.act({ type: 'restore_app_data', archive, clear_dirs: 'all' }),
|
|
207
|
+
(e) => e instanceof AdapterError && /timed out/.test(e.message));
|
|
208
|
+
assert.equal(fs.readFileSync(path.join(data, 'shared_prefs/a.xml'), 'utf8'), 'old');
|
|
209
|
+
assert.deepEqual(fs.readdirSync(data).filter((n) => n.startsWith('.utg_restore')), []);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
104
213
|
describe('d_prereqs snapshot with a corrupt fresh.tar', () => {
|
|
105
214
|
test('moves it aside and takes it again from cleared data', () => {
|
|
106
215
|
const root = tmp(); const snap = path.join(root, 'snap'); fs.mkdirSync(snap);
|
|
107
216
|
const cfg = path.join(root, 'config.json');
|
|
108
217
|
fs.writeFileSync(cfg, JSON.stringify({ serial: 's', package: 'p', launch_component: 'p/.A', snapshot_dir: snap }));
|
|
109
218
|
fs.writeFileSync(path.join(snap, 'fresh.tar'), polluted());
|
|
219
|
+
fs.writeFileSync(path.join(root, 'states.json'), JSON.stringify({ schema: 'utg-states/1', states: [{ id: 'initial', origin: 'initial', archive: null, restorable: false, empty: true, landing: null }], timeline: [] }));
|
|
110
220
|
const calls = [];
|
|
111
221
|
const saved = dp.deps.DeviceAdapter;
|
|
112
222
|
dp.deps.DeviceAdapter = class {
|
|
113
223
|
runAsAvailable() { return true; }
|
|
114
224
|
act(a) { calls.push(a.type); if (a.type === 'snapshot_app_data') { fs.writeFileSync(a.archive, tinyTar()); } }
|
|
225
|
+
observe() { return { observation_id: 'o', package: 'p', activity: 'p.A', nodes: [] }; }
|
|
115
226
|
};
|
|
116
227
|
try {
|
|
117
228
|
const r = dp.snapshot(cfg, 'fresh', 0);
|
|
118
229
|
assert.equal(r.created, true);
|
|
119
230
|
} finally { dp.deps.DeviceAdapter = saved; }
|
|
120
|
-
assert.deepEqual(calls, ['clear_app_data', 'launch', 'snapshot_app_data']);
|
|
231
|
+
assert.deepEqual(calls, ['clear_app_data', 'launch', 'snapshot_app_data', 'launch']);
|
|
121
232
|
assert.equal(tarProblem(fs.readFileSync(path.join(snap, 'fresh.tar'))), null);
|
|
122
233
|
assert.equal(fs.readdirSync(snap).filter((n) => n.startsWith('fresh.tar.corrupt-')).length, 1, 'old archive kept aside');
|
|
123
234
|
});
|