@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,1524 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* export_ui_info.mjs — turn an a2h-utg-explorer campaign into the per-page
|
|
4
|
+
* snapshot layout this skill consumes (Step 4 onward).
|
|
5
|
+
*
|
|
6
|
+
* node export_ui_info.mjs <campaign_dir> --static-ws <utg_static_ws> --out <ui_info_root>
|
|
7
|
+
*
|
|
8
|
+
* (Node >= 22.18, ESM, zero dependencies. Behaviour-identical port of
|
|
9
|
+
* export_ui_info.py: same args, exit codes, stdout and output files.)
|
|
10
|
+
*
|
|
11
|
+
* Input : <campaign>/utg.final.json (the explorer's report.mjs output), <campaign>/campaign.json,
|
|
12
|
+
* <campaign>/artifacts/<obs>/{screen.png,layout.xml,observation.json},
|
|
13
|
+
* <static_ws>/click_paths.json.
|
|
14
|
+
* Output: <out>/page_NNNN_<Name>/{screenshot.png, view.xml, meta.json
|
|
15
|
+
* [, screenshot_scroll_N.png, view_scroll_N.xml]
|
|
16
|
+
* [, screenshot_vpN.png, view_vpN.xml]}
|
|
17
|
+
* <out>/pages.json — pages in click-path order (parent before child)
|
|
18
|
+
* <out>/deferred_human.json — blocked phases, for Step 7's manual TODOs
|
|
19
|
+
* <out>/export_manifest.json — what was exported, skipped, and why
|
|
20
|
+
*
|
|
21
|
+
* Incremental: re-run after every explorer step. A page keeps the directory
|
|
22
|
+
* an earlier export gave it; one whose observations are unchanged is left as is
|
|
23
|
+
* (its measure_pack.json survives), a changed one is rebuilt in place, and a new
|
|
24
|
+
* one numbers after every existing page_* dir. The manifest lists `new` and
|
|
25
|
+
* `changed` slugs (re-run measure_pack on those).
|
|
26
|
+
*
|
|
27
|
+
* Only static nodes whose identity the explorer VERIFIED are exported. Unmapped
|
|
28
|
+
* `dynamic:*` observations are listed in the manifest, never converted: a page
|
|
29
|
+
* of unknown identity cannot be matched to Android source in Phase 4.2.
|
|
30
|
+
*
|
|
31
|
+
* Scroll frames: when the explorer swept a page top-to-bottom (a
|
|
32
|
+
* `scroll_sweep`, final_utg `evidence.scroll`), its frames are exported in
|
|
33
|
+
* order as `view_scroll_N` / `screenshot_scroll_N` with the sweep's origin (top
|
|
34
|
+
* of page) as `view.xml`, and `meta.scroll_completeness` carries the outcome:
|
|
35
|
+
* `complete` means the end was proven; anything else (`truncated`, `aborted`,
|
|
36
|
+
* `unreached`, `no-container`, `not-swept`) means Phase 4.2 must take the rest
|
|
37
|
+
* of the page from the Android layout source. Other captures of the same screen
|
|
38
|
+
* stay `*_vpN`: they are extra observations, not a scroll sequence.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
import * as fs from 'node:fs';
|
|
42
|
+
import * as path from 'node:path';
|
|
43
|
+
import { createHash } from 'node:crypto';
|
|
44
|
+
import { pathToFileURL } from 'node:url';
|
|
45
|
+
import { _replace } from './group_watch.mjs';
|
|
46
|
+
import { coveredBy, xmlRow } from './occlusion.mjs';
|
|
47
|
+
|
|
48
|
+
// ---------------------------------------------------------------- Python 兼容层
|
|
49
|
+
// 这些输出是其它脚本与 agent 读取的契约,必须与原 Python 版逐字节一致:
|
|
50
|
+
// JSON 用 json.dumps(indent=2, ensure_ascii=False) 的格式(浮点按 repr 写、
|
|
51
|
+
// 整数大数不丢精度、对象键按插入顺序),Windows 上文本按 \r\n 写出,
|
|
52
|
+
// 排序按 Python 的比较规则(字符串按码点、元组逐项、None 不可比)。
|
|
53
|
+
|
|
54
|
+
const IS_WIN = process.platform === 'win32';
|
|
55
|
+
const EOL = IS_WIN ? '\r\n' : '\n';
|
|
56
|
+
|
|
57
|
+
/** json.loads 读到的浮点数:保留「它是 float」这一事实,写回时按 Python repr 输出。 */
|
|
58
|
+
export class PyFloat {
|
|
59
|
+
constructor(value) { this.value = value; }
|
|
60
|
+
valueOf() { return this.value; }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 解析出的对象若含整数形键("0"、"12"),JS 普通对象会把它们提前;记下原始键序。
|
|
64
|
+
const KEY_ORDER = Symbol('pyKeyOrder');
|
|
65
|
+
const INDEX_KEY = /^(?:0|[1-9][0-9]*)$/;
|
|
66
|
+
|
|
67
|
+
function floatRepr(x, json) {
|
|
68
|
+
if (!Number.isFinite(x)) {
|
|
69
|
+
if (Number.isNaN(x)) { return json ? 'NaN' : 'nan'; }
|
|
70
|
+
return x > 0 ? (json ? 'Infinity' : 'inf') : (json ? '-Infinity' : '-inf');
|
|
71
|
+
}
|
|
72
|
+
if (x === 0) { return Object.is(x, -0) ? '-0.0' : '0.0'; }
|
|
73
|
+
const [m, e] = Math.abs(x).toExponential().split('e');
|
|
74
|
+
const digits = m.replace('.', '');
|
|
75
|
+
const exp = Number(e);
|
|
76
|
+
let s;
|
|
77
|
+
if (exp >= -4 && exp < 16) {
|
|
78
|
+
if (exp >= 0) {
|
|
79
|
+
const ip = digits.slice(0, exp + 1).padEnd(exp + 1, '0');
|
|
80
|
+
s = ip + '.' + (digits.slice(exp + 1) || '0');
|
|
81
|
+
} else {
|
|
82
|
+
s = '0.' + '0'.repeat(-exp - 1) + digits;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
s = digits[0] + (digits.length > 1 ? '.' + digits.slice(1) : '') + 'e' + (exp < 0 ? '-' : '+') +
|
|
86
|
+
String(Math.abs(exp)).padStart(2, '0');
|
|
87
|
+
}
|
|
88
|
+
return (x < 0 ? '-' : '') + s;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** json.loads:浮点 → PyFloat,超出安全整数范围的整数 → BigInt,其余同 JSON.parse。 */
|
|
92
|
+
function pyJsonLoads(text) {
|
|
93
|
+
let i = 0;
|
|
94
|
+
const n = text.length;
|
|
95
|
+
const fail = (msg) => { throw new SyntaxError(`${msg}: char ${i}`); };
|
|
96
|
+
const ws = () => {
|
|
97
|
+
while (i < n) {
|
|
98
|
+
const c = text.charCodeAt(i);
|
|
99
|
+
if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d) { i++; } else { break; }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const NUM = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/y;
|
|
103
|
+
const str = () => {
|
|
104
|
+
i++;
|
|
105
|
+
let out = '';
|
|
106
|
+
let start = i;
|
|
107
|
+
for (;;) {
|
|
108
|
+
if (i >= n) { fail('Unterminated string'); }
|
|
109
|
+
const c = text.charCodeAt(i);
|
|
110
|
+
if (c === 0x22) { out += text.slice(start, i); i++; return out; }
|
|
111
|
+
if (c < 0x20) { fail('Invalid control character'); }
|
|
112
|
+
if (c === 0x5c) {
|
|
113
|
+
out += text.slice(start, i);
|
|
114
|
+
const esc = text[i + 1];
|
|
115
|
+
const simple = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }[esc];
|
|
116
|
+
if (simple !== undefined) {
|
|
117
|
+
out += simple;
|
|
118
|
+
i += 2;
|
|
119
|
+
} else if (esc === 'u') {
|
|
120
|
+
const hex = text.slice(i + 2, i + 6);
|
|
121
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) { fail('Invalid \\uXXXX escape'); }
|
|
122
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
123
|
+
i += 6;
|
|
124
|
+
} else {
|
|
125
|
+
fail('Invalid \\escape');
|
|
126
|
+
}
|
|
127
|
+
start = i;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
i++;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const value = () => {
|
|
134
|
+
ws();
|
|
135
|
+
const c = text[i];
|
|
136
|
+
if (c === '{') {
|
|
137
|
+
i++;
|
|
138
|
+
const o = {};
|
|
139
|
+
const order = [];
|
|
140
|
+
let hasIndex = false;
|
|
141
|
+
ws();
|
|
142
|
+
if (text[i] === '}') { i++; return o; }
|
|
143
|
+
for (;;) {
|
|
144
|
+
ws();
|
|
145
|
+
if (text[i] !== '"') { fail('Expecting property name enclosed in double quotes'); }
|
|
146
|
+
const k = str();
|
|
147
|
+
ws();
|
|
148
|
+
if (text[i] !== ':') { fail("Expecting ':' delimiter"); }
|
|
149
|
+
i++;
|
|
150
|
+
const v = value();
|
|
151
|
+
if (!Object.hasOwn(o, k)) {
|
|
152
|
+
order.push(k);
|
|
153
|
+
if (INDEX_KEY.test(k)) { hasIndex = true; }
|
|
154
|
+
}
|
|
155
|
+
if (k === '__proto__') {
|
|
156
|
+
Object.defineProperty(o, k, { value: v, enumerable: true, writable: true, configurable: true });
|
|
157
|
+
} else {
|
|
158
|
+
o[k] = v;
|
|
159
|
+
}
|
|
160
|
+
ws();
|
|
161
|
+
if (text[i] === ',') { i++; continue; }
|
|
162
|
+
if (text[i] === '}') { i++; break; }
|
|
163
|
+
fail("Expecting ',' delimiter");
|
|
164
|
+
}
|
|
165
|
+
if (hasIndex) { o[KEY_ORDER] = order; }
|
|
166
|
+
return o;
|
|
167
|
+
}
|
|
168
|
+
if (c === '[') {
|
|
169
|
+
i++;
|
|
170
|
+
const a = [];
|
|
171
|
+
ws();
|
|
172
|
+
if (text[i] === ']') { i++; return a; }
|
|
173
|
+
for (;;) {
|
|
174
|
+
a.push(value());
|
|
175
|
+
ws();
|
|
176
|
+
if (text[i] === ',') { i++; continue; }
|
|
177
|
+
if (text[i] === ']') { i++; break; }
|
|
178
|
+
fail("Expecting ',' delimiter");
|
|
179
|
+
}
|
|
180
|
+
return a;
|
|
181
|
+
}
|
|
182
|
+
if (c === '"') { return str(); }
|
|
183
|
+
if (text.startsWith('null', i)) { i += 4; return null; }
|
|
184
|
+
if (text.startsWith('true', i)) { i += 4; return true; }
|
|
185
|
+
if (text.startsWith('false', i)) { i += 5; return false; }
|
|
186
|
+
if (text.startsWith('NaN', i)) { i += 3; return new PyFloat(NaN); }
|
|
187
|
+
if (text.startsWith('Infinity', i)) { i += 8; return new PyFloat(Infinity); }
|
|
188
|
+
if (text.startsWith('-Infinity', i)) { i += 9; return new PyFloat(-Infinity); }
|
|
189
|
+
NUM.lastIndex = i;
|
|
190
|
+
const m = NUM.exec(text);
|
|
191
|
+
if (!m) { fail('Expecting value'); }
|
|
192
|
+
i += m[0].length;
|
|
193
|
+
if (m[1] !== undefined || m[2] !== undefined) { return new PyFloat(Number(m[0])); }
|
|
194
|
+
const num = Number(m[0]);
|
|
195
|
+
return Number.isSafeInteger(num) ? (num === 0 ? 0 : num) : BigInt(m[0]);
|
|
196
|
+
};
|
|
197
|
+
const v = value();
|
|
198
|
+
ws();
|
|
199
|
+
if (i !== n) { fail('Extra data'); }
|
|
200
|
+
return v;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function keysOf(o) {
|
|
204
|
+
const ks = Object.keys(o);
|
|
205
|
+
const ord = o[KEY_ORDER];
|
|
206
|
+
if (!ord) { return ks; }
|
|
207
|
+
const present = new Set(ks);
|
|
208
|
+
const out = ord.filter((k) => present.has(k));
|
|
209
|
+
const seen = new Set(out);
|
|
210
|
+
for (const k of ks) { if (!seen.has(k)) { out.push(k); } }
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** json.dumps(v, ensure_ascii=False, indent=indent)。undefined 视同 None(对应 dict.get 缺省)。 */
|
|
215
|
+
function pyJsonDumps(v, indent, level = 0) {
|
|
216
|
+
if (v === null || v === undefined) { return 'null'; }
|
|
217
|
+
if (v === true) { return 'true'; }
|
|
218
|
+
if (v === false) { return 'false'; }
|
|
219
|
+
if (typeof v === 'bigint') { return v.toString(); }
|
|
220
|
+
if (v instanceof PyFloat) { return floatRepr(v.value, true); }
|
|
221
|
+
if (typeof v === 'number') { return Number.isInteger(v) ? (Object.is(v, -0) ? '0' : String(v)) : floatRepr(v, true); }
|
|
222
|
+
if (typeof v === 'string') { return JSON.stringify(v); }
|
|
223
|
+
const pad = '\n' + ' '.repeat(indent * (level + 1));
|
|
224
|
+
const end = '\n' + ' '.repeat(indent * level);
|
|
225
|
+
if (Array.isArray(v)) {
|
|
226
|
+
if (v.length === 0) { return '[]'; }
|
|
227
|
+
return '[' + pad + v.map((x) => pyJsonDumps(x, indent, level + 1)).join(',' + pad) + end + ']';
|
|
228
|
+
}
|
|
229
|
+
const ks = keysOf(v);
|
|
230
|
+
if (ks.length === 0) { return '{}'; }
|
|
231
|
+
return '{' + pad + ks.map((k) => JSON.stringify(k) + ': ' + pyJsonDumps(v[k], indent, level + 1)).join(',' + pad) +
|
|
232
|
+
end + '}';
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
236
|
+
|
|
237
|
+
/** Path.read_text(encoding="utf-8"):严格解码,保留 BOM,通用换行。 */
|
|
238
|
+
function readText(p) {
|
|
239
|
+
return UTF8.decode(fs.readFileSync(p)).replace(/\r\n?/g, '\n');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
function out(s = '') { process.stdout.write(s + EOL); }
|
|
244
|
+
function err(s = '') { process.stderr.write(s + EOL); }
|
|
245
|
+
|
|
246
|
+
function isFile(p) {
|
|
247
|
+
try { return fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false; } catch { return false; }
|
|
248
|
+
}
|
|
249
|
+
function isDir(p) {
|
|
250
|
+
try { return fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false; } catch { return false; }
|
|
251
|
+
}
|
|
252
|
+
function exists(p) {
|
|
253
|
+
try { return fs.statSync(p, { throwIfNoEntry: false }) !== undefined; } catch { return false; }
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** dict.get(k, d):只有键不存在才用缺省,值为 null 时照样返回 null。 */
|
|
257
|
+
function get(o, k, d = undefined) {
|
|
258
|
+
return o !== null && typeof o === 'object' && !Array.isArray(o) && Object.hasOwn(o, k) ? o[k] : d;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function truthy(v) {
|
|
262
|
+
if (v === null || v === undefined || v === false) { return false; }
|
|
263
|
+
if (v === true) { return true; }
|
|
264
|
+
if (typeof v === 'number') { return v !== 0; }
|
|
265
|
+
if (typeof v === 'bigint') { return v !== 0n; }
|
|
266
|
+
if (v instanceof PyFloat) { return v.value !== 0; }
|
|
267
|
+
if (typeof v === 'string' || Array.isArray(v)) { return v.length > 0; }
|
|
268
|
+
if (v instanceof Map || v instanceof Set) { return v.size > 0; }
|
|
269
|
+
return Object.keys(v).length > 0;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Python 的 `a or b`。 */
|
|
273
|
+
function or(a, b) { return truthy(a) ? a : b; }
|
|
274
|
+
|
|
275
|
+
function pyLen(v) {
|
|
276
|
+
if (typeof v === 'string') { return [...v].length; }
|
|
277
|
+
if (Array.isArray(v)) { return v.length; }
|
|
278
|
+
if (v !== null && typeof v === 'object' && !(v instanceof PyFloat)) { return Object.keys(v).length; }
|
|
279
|
+
throw new TypeError(`object of type '${pyType(v)}' has no len()`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function pyType(v) {
|
|
283
|
+
if (v === null || v === undefined) { return 'NoneType'; }
|
|
284
|
+
if (typeof v === 'boolean') { return 'bool'; }
|
|
285
|
+
if (typeof v === 'number') { return Number.isInteger(v) ? 'int' : 'float'; }
|
|
286
|
+
if (typeof v === 'bigint') { return 'int'; }
|
|
287
|
+
if (v instanceof PyFloat) { return 'float'; }
|
|
288
|
+
if (typeof v === 'string') { return 'str'; }
|
|
289
|
+
if (Array.isArray(v)) { return 'list'; }
|
|
290
|
+
return 'dict';
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Python 的 `x in container`(list 判等、str 判子串、dict 判键)。 */
|
|
294
|
+
function pyIn(x, c) {
|
|
295
|
+
if (typeof c === 'string') { return typeof x === 'string' && c.includes(x); }
|
|
296
|
+
if (Array.isArray(c)) { return c.some((y) => pyEq(x, y)); }
|
|
297
|
+
if (c !== null && typeof c === 'object') { return typeof x === 'string' && Object.hasOwn(c, x); }
|
|
298
|
+
throw new TypeError(`argument of type '${pyType(c)}' is not iterable`);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function numOf(v) {
|
|
302
|
+
if (typeof v === 'boolean') { return v ? 1 : 0; }
|
|
303
|
+
if (v instanceof PyFloat) { return v.value; }
|
|
304
|
+
if (typeof v === 'number' || typeof v === 'bigint') { return v; }
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function pyEq(a, b) {
|
|
309
|
+
if (a === undefined) { a = null; }
|
|
310
|
+
if (b === undefined) { b = null; }
|
|
311
|
+
const na = numOf(a);
|
|
312
|
+
const nb = numOf(b);
|
|
313
|
+
if (na !== undefined && nb !== undefined) { return na == nb; } // eslint-disable-line eqeqeq
|
|
314
|
+
if (na !== undefined || nb !== undefined) { return false; }
|
|
315
|
+
if (a === null || b === null || typeof a === 'string' || typeof b === 'string') { return a === b; }
|
|
316
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
317
|
+
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((x, i) => pyEq(x, b[i]));
|
|
318
|
+
}
|
|
319
|
+
const ka = Object.keys(a);
|
|
320
|
+
return ka.length === Object.keys(b).length && ka.every((k) => Object.hasOwn(b, k) && pyEq(a[k], b[k]));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const SURROGATE = /[\uD800-\uDFFF]/;
|
|
324
|
+
|
|
325
|
+
function cmpStr(a, b) {
|
|
326
|
+
if (!SURROGATE.test(a) && !SURROGATE.test(b)) { return a < b ? -1 : a > b ? 1 : 0; }
|
|
327
|
+
const x = [...a];
|
|
328
|
+
const y = [...b];
|
|
329
|
+
for (let i = 0; i < Math.min(x.length, y.length); i++) {
|
|
330
|
+
const d = x[i].codePointAt(0) - y[i].codePointAt(0);
|
|
331
|
+
if (d !== 0) { return d < 0 ? -1 : 1; }
|
|
332
|
+
}
|
|
333
|
+
return x.length - y.length < 0 ? -1 : x.length > y.length ? 1 : 0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Python 的 `<` 比较(用于 sorted 的 key):数值互比、str 按码点、tuple/list 逐项;其它组合抛 TypeError。 */
|
|
337
|
+
function pyCmp(a, b) {
|
|
338
|
+
const na = numOf(a);
|
|
339
|
+
const nb = numOf(b);
|
|
340
|
+
if (na !== undefined && nb !== undefined) { return na < nb ? -1 : na > nb ? 1 : 0; }
|
|
341
|
+
if (typeof a === 'string' && typeof b === 'string') { return cmpStr(a, b); }
|
|
342
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
343
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
344
|
+
if (!pyEq(a[i], b[i])) { return pyCmp(a[i], b[i]); }
|
|
345
|
+
}
|
|
346
|
+
return a.length < b.length ? -1 : a.length > b.length ? 1 : 0;
|
|
347
|
+
}
|
|
348
|
+
throw new TypeError(`'<' not supported between instances of '${pyType(a)}' and '${pyType(b)}'`);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** sorted(items, key=key, reverse=reverse):稳定排序。 */
|
|
352
|
+
function sortedBy(items, key = (x) => x, reverse = false) {
|
|
353
|
+
const dec = [...items].map((v, i) => [key(v), i, v]);
|
|
354
|
+
dec.sort((p, q) => (reverse ? pyCmp(q[0], p[0]) : pyCmp(p[0], q[0])) || p[1] - q[1]);
|
|
355
|
+
return dec.map((d) => d[2]);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const NON_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
|
|
359
|
+
|
|
360
|
+
function strRepr(s) {
|
|
361
|
+
const q = s.includes("'") && !s.includes('"') ? '"' : "'";
|
|
362
|
+
let r = q;
|
|
363
|
+
for (const ch of s) {
|
|
364
|
+
const cp = ch.codePointAt(0);
|
|
365
|
+
if (ch === q || ch === '\\') { r += '\\' + ch; }
|
|
366
|
+
else if (ch === '\t') { r += '\\t'; }
|
|
367
|
+
else if (ch === '\n') { r += '\\n'; }
|
|
368
|
+
else if (ch === '\r') { r += '\\r'; }
|
|
369
|
+
else if (ch !== ' ' && NON_PRINTABLE.test(ch)) {
|
|
370
|
+
r += cp < 0x100 ? '\\x' + cp.toString(16).padStart(2, '0')
|
|
371
|
+
: cp < 0x10000 ? '\\u' + cp.toString(16).padStart(4, '0') : '\\U' + cp.toString(16).padStart(8, '0');
|
|
372
|
+
} else { r += ch; }
|
|
373
|
+
}
|
|
374
|
+
return r + q;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** repr(v)。 */
|
|
378
|
+
function pyRepr(v) {
|
|
379
|
+
if (v === null || v === undefined) { return 'None'; }
|
|
380
|
+
if (v === true) { return 'True'; }
|
|
381
|
+
if (v === false) { return 'False'; }
|
|
382
|
+
if (typeof v === 'bigint') { return v.toString(); }
|
|
383
|
+
if (v instanceof PyFloat) { return floatRepr(v.value, false); }
|
|
384
|
+
if (typeof v === 'number') { return Number.isInteger(v) ? String(v === 0 ? 0 : v) : floatRepr(v, false); }
|
|
385
|
+
if (typeof v === 'string') { return strRepr(v); }
|
|
386
|
+
if (Array.isArray(v)) { return '[' + v.map(pyRepr).join(', ') + ']'; }
|
|
387
|
+
return '{' + keysOf(v).map((k) => strRepr(k) + ': ' + pyRepr(v[k])).join(', ') + '}';
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** str(v) / f"{v}"。 */
|
|
391
|
+
function pyStr(v) { return typeof v === 'string' ? v : pyRepr(v); }
|
|
392
|
+
|
|
393
|
+
/** int() of a re `\d+` match (Unicode decimal digits: each Nd run is aligned blocks of ten). */
|
|
394
|
+
function pyInt(digits) {
|
|
395
|
+
let s = '';
|
|
396
|
+
for (const ch of digits) {
|
|
397
|
+
let cp = ch.codePointAt(0);
|
|
398
|
+
let k = 0;
|
|
399
|
+
while (/\p{Nd}/u.test(String.fromCodePoint(cp - 1))) { cp--; k++; }
|
|
400
|
+
s += String(k % 10);
|
|
401
|
+
}
|
|
402
|
+
const n = Number(s);
|
|
403
|
+
return Number.isSafeInteger(n) ? n : BigInt(s);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function setdefault(m, k, d) {
|
|
407
|
+
if (!m.has(k)) { m.set(k, d); }
|
|
408
|
+
return m.get(k);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// ---------------------------------------------------------------- 路径(pathlib 语义)
|
|
412
|
+
|
|
413
|
+
function splitPath(p) {
|
|
414
|
+
if (IS_WIN) {
|
|
415
|
+
const s = String(p).replace(/\//g, '\\');
|
|
416
|
+
let drive = '';
|
|
417
|
+
let rest = s;
|
|
418
|
+
const unc = /^\\\\([^\\]+)\\([^\\]+)/.exec(s);
|
|
419
|
+
if (unc) { drive = unc[0]; rest = s.slice(drive.length); }
|
|
420
|
+
else if (/^[A-Za-z]:/.test(s)) { drive = s.slice(0, 2); rest = s.slice(2); }
|
|
421
|
+
const root = rest.startsWith('\\') ? '\\' : '';
|
|
422
|
+
return { drive, root, parts: rest.split('\\').filter((x) => x !== '' && x !== '.') };
|
|
423
|
+
}
|
|
424
|
+
const s = String(p);
|
|
425
|
+
const root = s.startsWith('//') && !s.startsWith('///') ? '//' : s.startsWith('/') ? '/' : '';
|
|
426
|
+
return { drive: '', root, parts: s.split('/').filter((x) => x !== '' && x !== '.') };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** str(Path(p))。 */
|
|
430
|
+
function pathStr(p) {
|
|
431
|
+
const { drive, root, parts } = splitPath(p);
|
|
432
|
+
const s = drive + root + parts.join(IS_WIN ? '\\' : '/');
|
|
433
|
+
return s || '.';
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Path(p).name。 */
|
|
437
|
+
function pathName(p) {
|
|
438
|
+
const { parts } = splitPath(p);
|
|
439
|
+
return parts.length ? parts[parts.length - 1] : '';
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** Path(p).resolve():存在的最长前缀做 realpath,其余照抄。 */
|
|
443
|
+
function pathResolve(p) {
|
|
444
|
+
let abs = path.resolve(String(p));
|
|
445
|
+
const tail = [];
|
|
446
|
+
for (;;) {
|
|
447
|
+
try {
|
|
448
|
+
const real = fs.realpathSync.native(abs);
|
|
449
|
+
return tail.length ? path.join(real, ...tail.reverse()) : real;
|
|
450
|
+
} catch {
|
|
451
|
+
const parent = path.dirname(abs);
|
|
452
|
+
if (parent === abs) { return path.resolve(String(p)); }
|
|
453
|
+
tail.push(path.basename(abs));
|
|
454
|
+
abs = parent;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** Path(p).absolute():只补 cwd,不规整 `..`。 */
|
|
460
|
+
function pathAbsolute(p) {
|
|
461
|
+
const { drive, root, parts } = splitPath(p);
|
|
462
|
+
const sep = IS_WIN ? '\\' : '/';
|
|
463
|
+
if (IS_WIN ? (drive && root) || /^\\\\/.test(drive) : root) { return pathStr(p); }
|
|
464
|
+
const cwd = process.cwd();
|
|
465
|
+
if (root) { return splitPath(cwd).drive + root + parts.join(sep); }
|
|
466
|
+
const base = drive ? path.resolve(drive) : cwd;
|
|
467
|
+
return [base.replace(/[\\/]+$/, ''), ...parts].join(sep) || base;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** Path(dir).glob(prefix + '*'):文件系统原始顺序(os.scandir),Windows 不分大小写。 */
|
|
471
|
+
function globPrefix(dir, prefix) {
|
|
472
|
+
const names = [];
|
|
473
|
+
let d;
|
|
474
|
+
try { d = fs.opendirSync(dir); } catch { return names; }
|
|
475
|
+
try {
|
|
476
|
+
for (let e = d.readSync(); e !== null; e = d.readSync()) {
|
|
477
|
+
const nm = e.name;
|
|
478
|
+
if (IS_WIN ? nm.toLowerCase().startsWith(prefix.toLowerCase()) : nm.startsWith(prefix)) { names.push(nm); }
|
|
479
|
+
}
|
|
480
|
+
} finally { d.closeSync(); }
|
|
481
|
+
return names.map((nm) => path.join(String(dir), nm));
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// ---------------------------------------------------------------- argparse 等价物
|
|
485
|
+
// 复刻 argparse 的可观察行为:长选项唯一前缀、`--opt=value`、`--`、
|
|
486
|
+
// `-h/--help` 的排版(宽度 = 终端列数 - 2)、错误时打印 usage 到 stderr 并以 2 退出。
|
|
487
|
+
|
|
488
|
+
function termColumns() {
|
|
489
|
+
const env = Number.parseInt(process.env.COLUMNS ?? '', 10);
|
|
490
|
+
if (env > 0) { return env; }
|
|
491
|
+
// shutil.get_terminal_size(): COLUMNS, else the stdout tty, else 80.
|
|
492
|
+
return process.stdout.isTTY && process.stdout.columns ? process.stdout.columns : 80;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/** textwrap.wrap(width) 的常用子集:按空白断行,超长单词硬切。 */
|
|
496
|
+
function wrapText(text, width) {
|
|
497
|
+
const words = text.split(' ').filter((w) => w !== '');
|
|
498
|
+
const lines = [];
|
|
499
|
+
let cur = '';
|
|
500
|
+
for (let w of words) {
|
|
501
|
+
while (w.length > width && cur === '') { lines.push(w.slice(0, width)); w = w.slice(width); }
|
|
502
|
+
if (cur === '') { cur = w; }
|
|
503
|
+
else if (cur.length + 1 + w.length <= width) { cur += ' ' + w; }
|
|
504
|
+
else {
|
|
505
|
+
lines.push(cur);
|
|
506
|
+
cur = '';
|
|
507
|
+
while (w.length > width) { lines.push(w.slice(0, width)); w = w.slice(width); }
|
|
508
|
+
cur = w;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (cur !== '') { lines.push(cur); }
|
|
512
|
+
return lines;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* spec: { prog, description, args: [{ name, positional?, metavar?, help?, required?, type?: 'int', def? }] }
|
|
517
|
+
* 返回 { dest: value }(dest = 去掉前导 `--`、`-` 换成 `_`)。
|
|
518
|
+
*/
|
|
519
|
+
function parseArgs(spec, argv) {
|
|
520
|
+
const width = termColumns() - 2;
|
|
521
|
+
const actions = [{ name: '-h', alias: '--help', help: 'show this help message and exit', flag: true }, ...spec.args];
|
|
522
|
+
const dest = (a) => a.name.replace(/^-+/, '').replace(/-/g, '_');
|
|
523
|
+
const metavar = (a) => a.metavar ?? dest(a).toUpperCase();
|
|
524
|
+
const invocation = (a) => (a.positional ? a.name : a.flag ? `${a.name}, ${a.alias}` : `${a.name} ${metavar(a)}`);
|
|
525
|
+
const usagePart = (a) => {
|
|
526
|
+
if (a.positional) { return a.name; }
|
|
527
|
+
const s = a.flag ? a.name : `${a.name} ${metavar(a)}`;
|
|
528
|
+
return a.required ? s : `[${s}]`;
|
|
529
|
+
};
|
|
530
|
+
const opts = actions.filter((a) => !a.positional);
|
|
531
|
+
const poss = actions.filter((a) => a.positional);
|
|
532
|
+
|
|
533
|
+
const formatUsage = () => {
|
|
534
|
+
const prefix = 'usage: ';
|
|
535
|
+
const prog = spec.prog;
|
|
536
|
+
const optParts = opts.map(usagePart);
|
|
537
|
+
const posParts = poss.map(usagePart);
|
|
538
|
+
let usage = [prog, ...optParts, ...posParts].join(' ');
|
|
539
|
+
if (prefix.length + usage.length > width) {
|
|
540
|
+
const getLines = (parts, indent, pfx) => {
|
|
541
|
+
const lines = [];
|
|
542
|
+
let line = [];
|
|
543
|
+
let len = pfx !== undefined ? pfx.length - 1 : indent.length - 1;
|
|
544
|
+
for (const part of parts) {
|
|
545
|
+
if (len + 1 + part.length > width && line.length) {
|
|
546
|
+
lines.push(indent + line.join(' '));
|
|
547
|
+
line = [];
|
|
548
|
+
len = indent.length - 1;
|
|
549
|
+
}
|
|
550
|
+
line.push(part);
|
|
551
|
+
len += part.length + 1;
|
|
552
|
+
}
|
|
553
|
+
if (line.length) { lines.push(indent + line.join(' ')); }
|
|
554
|
+
if (pfx !== undefined) { lines[0] = lines[0].slice(indent.length); }
|
|
555
|
+
return lines;
|
|
556
|
+
};
|
|
557
|
+
let lines;
|
|
558
|
+
if (prefix.length + prog.length <= 0.75 * width) {
|
|
559
|
+
const indent = ' '.repeat(prefix.length + prog.length + 1);
|
|
560
|
+
lines = getLines([prog, ...optParts], indent, prefix);
|
|
561
|
+
lines.push(...getLines(posParts, indent));
|
|
562
|
+
} else {
|
|
563
|
+
const indent = ' '.repeat(prefix.length);
|
|
564
|
+
lines = getLines([...optParts, ...posParts], indent);
|
|
565
|
+
if (lines.length > 1) { lines = [...getLines(optParts, indent), ...getLines(posParts, indent)]; }
|
|
566
|
+
lines = [prog, ...lines];
|
|
567
|
+
}
|
|
568
|
+
usage = lines.join('\n');
|
|
569
|
+
}
|
|
570
|
+
return prefix + usage;
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
const formatHelp = () => {
|
|
574
|
+
const maxHelpPos = Math.min(24, Math.max(width - 20, 4));
|
|
575
|
+
const maxLen = Math.max(...actions.map((a) => invocation(a).length + 2));
|
|
576
|
+
const helpPos = Math.min(maxLen + 2, maxHelpPos);
|
|
577
|
+
const helpWidth = Math.max(width - helpPos, 11);
|
|
578
|
+
const actionWidth = helpPos - 2 - 2;
|
|
579
|
+
const item = (a) => {
|
|
580
|
+
const inv = invocation(a);
|
|
581
|
+
const rows = [];
|
|
582
|
+
let first;
|
|
583
|
+
if (!a.help) { rows.push(' ' + inv); return rows; }
|
|
584
|
+
if (inv.length <= actionWidth) { first = ' ' + inv.padEnd(actionWidth) + ' '; }
|
|
585
|
+
else { rows.push(' ' + inv); first = ' '.repeat(helpPos); }
|
|
586
|
+
const hl = wrapText(a.help.replace(/\s+/g, ' ').trim(), helpWidth);
|
|
587
|
+
rows.push(first + hl[0]);
|
|
588
|
+
for (const l of hl.slice(1)) { rows.push(' '.repeat(helpPos) + l); }
|
|
589
|
+
return rows;
|
|
590
|
+
};
|
|
591
|
+
const parts = [formatUsage(), ''];
|
|
592
|
+
if (spec.description) { parts.push(...wrapText(spec.description.replace(/\s+/g, ' ').trim(), width), ''); }
|
|
593
|
+
if (poss.length) { parts.push('positional arguments:', ...poss.flatMap(item), ''); }
|
|
594
|
+
parts.push('options:', ...opts.flatMap(item));
|
|
595
|
+
return parts.join('\n');
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
const fail = (msg) => {
|
|
599
|
+
err(formatUsage());
|
|
600
|
+
err(`${spec.prog}: error: ${msg}`);
|
|
601
|
+
process.exit(2);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
const result = {};
|
|
605
|
+
for (const a of spec.args) { result[dest(a)] = a.def ?? null; }
|
|
606
|
+
const seen = new Set();
|
|
607
|
+
const positionals = [];
|
|
608
|
+
const extras = [];
|
|
609
|
+
const longNames = opts.flatMap((a) => (a.alias ? [[a.name, a], [a.alias, a]] : [[a.name, a]]));
|
|
610
|
+
const looksNegative = (s) => /^-\d+$|^-\d*\.\d+$/.test(s);
|
|
611
|
+
const isOptionLike = (s) => s.startsWith('-') && s !== '-' && !looksNegative(s) && !(s.includes(' ') && !findOpt(s));
|
|
612
|
+
function findOpt(s) {
|
|
613
|
+
const [k] = s.split('=', 1);
|
|
614
|
+
const exact = longNames.find(([n]) => n === k);
|
|
615
|
+
if (exact) { return exact[1]; }
|
|
616
|
+
if (!k.startsWith('--')) { return null; }
|
|
617
|
+
const hits = longNames.filter(([n]) => n.startsWith(k));
|
|
618
|
+
const uniq = [...new Set(hits.map((h) => h[1]))];
|
|
619
|
+
if (uniq.length > 1) { fail(`ambiguous option: ${k} could match ${hits.map((h) => h[0]).join(', ')}`); }
|
|
620
|
+
return uniq[0] ?? null;
|
|
621
|
+
}
|
|
622
|
+
let i = 0;
|
|
623
|
+
let rest = false;
|
|
624
|
+
while (i < argv.length) {
|
|
625
|
+
const s = argv[i];
|
|
626
|
+
if (!rest && s === '--') { rest = true; i++; continue; }
|
|
627
|
+
if (rest || !isOptionLike(s)) { positionals.push(s); i++; continue; }
|
|
628
|
+
const a = findOpt(s);
|
|
629
|
+
if (!a) { extras.push(s); i++; continue; }
|
|
630
|
+
const eq = s.indexOf('=');
|
|
631
|
+
const name = a.name;
|
|
632
|
+
if (a.flag) {
|
|
633
|
+
if (eq >= 0) { fail(`argument -h/--help: ignored explicit argument '${s.slice(eq + 1)}'`); }
|
|
634
|
+
process.stdout.write((formatHelp() + '\n').replace(/\n/g, EOL));
|
|
635
|
+
process.exit(0);
|
|
636
|
+
}
|
|
637
|
+
let val;
|
|
638
|
+
if (eq >= 0 && s.startsWith('--')) { val = s.slice(eq + 1); i++; }
|
|
639
|
+
else if (i + 1 < argv.length && !(argv[i + 1] === '--' || isOptionLike(argv[i + 1]))) { val = argv[i + 1]; i += 2; }
|
|
640
|
+
else { fail(`argument ${name}: expected one argument`); }
|
|
641
|
+
if (a.type === 'int') {
|
|
642
|
+
const t = val.trim();
|
|
643
|
+
if (!/^[+-]?\p{Nd}+(?:_\p{Nd}+)*$/u.test(t)) { fail(`argument ${name}: invalid int value: ${pyRepr(val)}`); }
|
|
644
|
+
val = Number(pyInt(t.replace(/^[+-]|_/g, ''))) * (t.startsWith('-') ? -1 : 1);
|
|
645
|
+
}
|
|
646
|
+
result[dest(a)] = val;
|
|
647
|
+
seen.add(a);
|
|
648
|
+
}
|
|
649
|
+
poss.forEach((a, k) => { if (k < positionals.length) { result[dest(a)] = positionals[k]; seen.add(a); } });
|
|
650
|
+
extras.push(...positionals.slice(poss.length));
|
|
651
|
+
const missing = actions.filter((a) => (a.positional || a.required) && !seen.has(a)).map((a) => a.name);
|
|
652
|
+
if (missing.length) { fail(`the following arguments are required: ${missing.join(', ')}`); }
|
|
653
|
+
if (extras.length) { fail(`unrecognized arguments: ${extras.join(' ')}`); }
|
|
654
|
+
return result;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// ---------------------------------------------------------------- unquote / XML (stdlib 等价物)
|
|
658
|
+
|
|
659
|
+
const HEX2 = /(?:%[0-9a-fA-F]{2})+/g;
|
|
660
|
+
const UTF8_REPLACE = new TextDecoder('utf-8', { fatal: false, ignoreBOM: true });
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* urllib.parse.unquote(s): runs of %XX are decoded as UTF-8 with errors="replace"
|
|
664
|
+
* (maximal-subpart U+FFFD, same as TextDecoder); malformed `%` sequences are
|
|
665
|
+
* left as-is. Never throws.
|
|
666
|
+
*/
|
|
667
|
+
export function unquote(s) {
|
|
668
|
+
if (!s.includes('%')) { return s; }
|
|
669
|
+
return s.replace(HEX2, (run) => {
|
|
670
|
+
const bytes = new Uint8Array(run.length / 3);
|
|
671
|
+
for (let i = 0; i < bytes.length; i++) { bytes[i] = parseInt(run.slice(i * 3 + 1, i * 3 + 3), 16); }
|
|
672
|
+
return UTF8_REPLACE.decode(bytes);
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export class XmlElement {
|
|
677
|
+
constructor(tag, attrib) {
|
|
678
|
+
this.tag = tag;
|
|
679
|
+
this.attrib = attrib;
|
|
680
|
+
this.children = [];
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/** Element.iter(tag): pre-order walk, the element itself included. */
|
|
684
|
+
*iter(tag = null) {
|
|
685
|
+
if (tag === null || tag === '*' || this.tag === tag) { yield this; }
|
|
686
|
+
for (const c of this.children) { yield* c.iter(tag); }
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export class XmlParseError extends Error {}
|
|
691
|
+
|
|
692
|
+
const NAME = /[A-Za-z_:À-][-A-Za-z0-9._:·À-]*/y;
|
|
693
|
+
const ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'" };
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* A small non-validating XML parser, enough for uiautomator dumps: elements,
|
|
697
|
+
* attributes, self-closing tags, the XML declaration, comments, PIs, CDATA,
|
|
698
|
+
* a DOCTYPE without internal subset, and the five predefined entities plus
|
|
699
|
+
* numeric references. Like expat it rejects malformed input (mismatched tags,
|
|
700
|
+
* unknown entities, `<` in attribute values, junk after the root element) and
|
|
701
|
+
* normalises attribute whitespace (\r\n → \n, then \t \n \r → space).
|
|
702
|
+
*/
|
|
703
|
+
export function parseXml(text) {
|
|
704
|
+
let i = 0;
|
|
705
|
+
const n = text.length;
|
|
706
|
+
const fail = (msg) => { throw new XmlParseError(`${msg}: offset ${i}`); };
|
|
707
|
+
const isWs = (c) => c === ' ' || c === '\t' || c === '\n' || c === '\r';
|
|
708
|
+
const skipWs = () => { while (i < n && isWs(text[i])) { i++; } };
|
|
709
|
+
const name = () => {
|
|
710
|
+
NAME.lastIndex = i;
|
|
711
|
+
const m = NAME.exec(text);
|
|
712
|
+
if (!m) { fail('not well-formed (invalid token)'); }
|
|
713
|
+
i += m[0].length;
|
|
714
|
+
return m[0];
|
|
715
|
+
};
|
|
716
|
+
const decode = (raw, attr) => {
|
|
717
|
+
let s = raw;
|
|
718
|
+
if (attr) { s = s.replace(/\r\n?/g, '\n').replace(/[\t\n\r]/g, ' '); }
|
|
719
|
+
return s.replace(/&([^;&<]*);|&/g, (m, ent) => {
|
|
720
|
+
if (ent === undefined) { fail('not well-formed (invalid token)'); }
|
|
721
|
+
if (Object.hasOwn(ENTITIES, ent)) { return ENTITIES[ent]; }
|
|
722
|
+
const num = /^#(?:x([0-9a-fA-F]+)|([0-9]+))$/.exec(ent);
|
|
723
|
+
if (!num) { fail(`undefined entity &${ent};`); }
|
|
724
|
+
const cp = num[1] !== undefined ? parseInt(num[1], 16) : parseInt(num[2], 10);
|
|
725
|
+
const ok = cp === 0x9 || cp === 0xa || cp === 0xd || (cp >= 0x20 && cp <= 0xd7ff) ||
|
|
726
|
+
(cp >= 0xe000 && cp <= 0xfffd) || (cp >= 0x10000 && cp <= 0x10ffff);
|
|
727
|
+
if (!ok) { fail('reference to invalid character number'); }
|
|
728
|
+
return String.fromCodePoint(cp);
|
|
729
|
+
});
|
|
730
|
+
};
|
|
731
|
+
const skipMisc = (allowDecl) => {
|
|
732
|
+
for (;;) {
|
|
733
|
+
skipWs();
|
|
734
|
+
if (text.startsWith('<?', i)) {
|
|
735
|
+
const isDecl = /^<\?xml[\s?]/.test(text.slice(i, i + 6));
|
|
736
|
+
if (isDecl && !(allowDecl && i === 0)) { fail('XML or text declaration not at start of entity'); }
|
|
737
|
+
const e = text.indexOf('?>', i + 2);
|
|
738
|
+
if (e < 0) { fail('unclosed token'); }
|
|
739
|
+
i = e + 2;
|
|
740
|
+
} else if (text.startsWith('<!--', i)) {
|
|
741
|
+
const e = text.indexOf('-->', i + 4);
|
|
742
|
+
if (e < 0) { fail('unclosed token'); }
|
|
743
|
+
i = e + 3;
|
|
744
|
+
} else if (text.startsWith('<!DOCTYPE', i)) {
|
|
745
|
+
const e = text.indexOf('>', i);
|
|
746
|
+
if (e < 0 || text.slice(i, e).includes('[')) { fail('unsupported DOCTYPE'); }
|
|
747
|
+
i = e + 1;
|
|
748
|
+
} else {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
allowDecl = false;
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
if (text.charCodeAt(0) === 0xfeff) { text = text.slice(1); }
|
|
756
|
+
skipMisc(true);
|
|
757
|
+
if (text[i] !== '<') { fail(i >= n ? 'no element found' : 'syntax error'); }
|
|
758
|
+
let root = null;
|
|
759
|
+
const stack = [];
|
|
760
|
+
while (i < n) {
|
|
761
|
+
if (text.startsWith('<!--', i)) {
|
|
762
|
+
const e = text.indexOf('-->', i + 4);
|
|
763
|
+
if (e < 0) { fail('unclosed token'); }
|
|
764
|
+
i = e + 3;
|
|
765
|
+
} else if (text.startsWith('<![CDATA[', i)) {
|
|
766
|
+
if (!stack.length) { fail('syntax error'); }
|
|
767
|
+
const e = text.indexOf(']]>', i);
|
|
768
|
+
if (e < 0) { fail('unclosed CDATA section'); }
|
|
769
|
+
i = e + 3;
|
|
770
|
+
} else if (text.startsWith('<?', i)) {
|
|
771
|
+
const e = text.indexOf('?>', i + 2);
|
|
772
|
+
if (e < 0) { fail('unclosed token'); }
|
|
773
|
+
i = e + 2;
|
|
774
|
+
} else if (text.startsWith('</', i)) {
|
|
775
|
+
i += 2;
|
|
776
|
+
const tag = name();
|
|
777
|
+
skipWs();
|
|
778
|
+
if (text[i] !== '>') { fail('not well-formed (invalid token)'); }
|
|
779
|
+
i++;
|
|
780
|
+
const top = stack.pop();
|
|
781
|
+
if (!top || top.tag !== tag) { fail('mismatched tag'); }
|
|
782
|
+
if (!stack.length) { break; }
|
|
783
|
+
} else if (text[i] === '<') {
|
|
784
|
+
if (root && !stack.length) { fail('junk after document element'); }
|
|
785
|
+
i++;
|
|
786
|
+
const el = new XmlElement(name(), {});
|
|
787
|
+
for (;;) {
|
|
788
|
+
const hadWs = i < n && isWs(text[i]);
|
|
789
|
+
skipWs();
|
|
790
|
+
if (text.startsWith('/>', i) || text[i] === '>') { break; }
|
|
791
|
+
if (!hadWs) { fail('not well-formed (invalid token)'); }
|
|
792
|
+
const an = name();
|
|
793
|
+
skipWs();
|
|
794
|
+
if (text[i] !== '=') { fail('not well-formed (invalid token)'); }
|
|
795
|
+
i++;
|
|
796
|
+
skipWs();
|
|
797
|
+
const q = text[i];
|
|
798
|
+
if (q !== '"' && q !== "'") { fail('not well-formed (invalid token)'); }
|
|
799
|
+
const e = text.indexOf(q, i + 1);
|
|
800
|
+
if (e < 0) { fail('unclosed token'); }
|
|
801
|
+
const raw = text.slice(i + 1, e);
|
|
802
|
+
if (raw.includes('<')) { fail('not well-formed (invalid token)'); }
|
|
803
|
+
if (Object.hasOwn(el.attrib, an)) { fail('duplicate attribute'); }
|
|
804
|
+
el.attrib[an] = decode(raw, true);
|
|
805
|
+
i = e + 1;
|
|
806
|
+
}
|
|
807
|
+
if (stack.length) { stack[stack.length - 1].children.push(el); } else { root = el; }
|
|
808
|
+
if (text.startsWith('/>', i)) {
|
|
809
|
+
i += 2;
|
|
810
|
+
if (!stack.length) { break; }
|
|
811
|
+
} else {
|
|
812
|
+
i++;
|
|
813
|
+
stack.push(el);
|
|
814
|
+
}
|
|
815
|
+
} else {
|
|
816
|
+
// Character data: only checked for well-formedness (no tag uses text).
|
|
817
|
+
const e = text.indexOf('<', i);
|
|
818
|
+
const chunk = text.slice(i, e < 0 ? n : e);
|
|
819
|
+
if (!stack.length && chunk.trim() !== '') { fail('junk after document element'); }
|
|
820
|
+
decode(chunk, false);
|
|
821
|
+
i = e < 0 ? n : e;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
if (stack.length || !root) { fail('no element found'); }
|
|
825
|
+
skipMisc(false);
|
|
826
|
+
if (i < n) { fail('junk after document element'); }
|
|
827
|
+
return root;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** ET.parse(path).getroot(): bytes decoded as UTF-8 (uiautomator writes UTF-8). */
|
|
831
|
+
export function parseXmlFile(p) {
|
|
832
|
+
let text;
|
|
833
|
+
try {
|
|
834
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(fs.readFileSync(p));
|
|
835
|
+
} catch (e) {
|
|
836
|
+
if (e instanceof TypeError) { throw new XmlParseError('not well-formed (invalid token)'); }
|
|
837
|
+
throw e;
|
|
838
|
+
}
|
|
839
|
+
return parseXml(text);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// ---------------------------------------------------------------- export
|
|
843
|
+
|
|
844
|
+
// Containers and non-screens: nothing to convert on their own. An in-page state (`ui-state` / `mode`:
|
|
845
|
+
// a calendar's day/week/month/year tab) is exported when the explorer verified it by its anchors --
|
|
846
|
+
// its capture is the host screen in that state, which the host's own directory does not show.
|
|
847
|
+
export const SKIP_KINDS = new Set(['host-activity', 'sentinel', 'media-browse', 'unknown', 'hybrid']);
|
|
848
|
+
export const STATE_KINDS = new Set(['ui-state', 'mode']);
|
|
849
|
+
export const STATE_MERGE_OVERLAP = 0.8; // share of the smaller id set found in the larger: same screen
|
|
850
|
+
export const ARROW = ' → ';
|
|
851
|
+
|
|
852
|
+
class KeyError extends Error {}
|
|
853
|
+
|
|
854
|
+
/** d[k]: a missing key raises, as in Python, instead of yielding undefined. */
|
|
855
|
+
function req(o, k) {
|
|
856
|
+
if (o === null || typeof o !== 'object' || !Object.hasOwn(o, k)) { throw new KeyError(pyRepr(k)); }
|
|
857
|
+
return o[k];
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/** seq[0] with IndexError on an empty list. */
|
|
861
|
+
function first(a) {
|
|
862
|
+
if (!a.length) { throw new RangeError('list index out of range'); }
|
|
863
|
+
return a[0];
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** seq[:k] with Python's negative-bound semantics. */
|
|
867
|
+
function head(a, k) {
|
|
868
|
+
return a.slice(0, k < 0 ? Math.max(a.length + k, 0) : k);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function pyMin(values) {
|
|
872
|
+
if (!values.length) { throw new RangeError('min() iterable argument is empty'); }
|
|
873
|
+
return values.reduce((m, v) => (pyCmp(v, m) < 0 ? v : m));
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/** Hash key that makes JS Set/Map membership follow Python == (1 == 1.0 == True). */
|
|
877
|
+
function canon(v) {
|
|
878
|
+
if (v === null || v === undefined) { return 'N'; }
|
|
879
|
+
const nv = numOf(v);
|
|
880
|
+
if (nv !== undefined) { return 'n' + (typeof nv === 'bigint' ? nv.toString() : String(nv === 0 ? 0 : nv)); }
|
|
881
|
+
if (typeof v === 'string') { return 's' + v; }
|
|
882
|
+
return 'o' + pyRepr(v);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export function readJson(p) {
|
|
886
|
+
return pyJsonLoads(readText(p));
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Atomic (tmp + rename, Windows EPERM retried: group_watch._replace): group_queue / group_watch
|
|
891
|
+
* read these files while a refresh rewrites them, and an in-place write showed them half a file.
|
|
892
|
+
*/
|
|
893
|
+
export function writeJson(p, data) {
|
|
894
|
+
_replace(p, pyJsonDumps(data, 2));
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/** `base / rel` with pathlib's drive/root rules. */
|
|
898
|
+
function pyJoin(base, rel) {
|
|
899
|
+
const r = splitPath(rel);
|
|
900
|
+
const b = splitPath(base);
|
|
901
|
+
const sep = IS_WIN ? '\\' : '/';
|
|
902
|
+
if (IS_WIN ? (r.drive && (r.root || /^\\\\/.test(r.drive) || r.drive.toLowerCase() !== b.drive.toLowerCase())) : r.root) {
|
|
903
|
+
return pathStr(rel);
|
|
904
|
+
}
|
|
905
|
+
if (r.root) { return b.drive + r.root + r.parts.join(sep); }
|
|
906
|
+
return pathStr([b.drive + b.root + b.parts.join(sep), ...r.parts].join(sep));
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function pyIsAbsolute(p) {
|
|
910
|
+
const { drive, root } = splitPath(p);
|
|
911
|
+
return IS_WIN ? Boolean(drive && root) || /^\\\\/.test(drive) : Boolean(root);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Which static nodes the campaign has captured, as `<count>:<sha256 prefix>` of the sorted
|
|
916
|
+
* `audit.json` mapped_ids (report.mjs rewrites it with utg.final.json); null without one.
|
|
917
|
+
* An export and the plan built from it carry the digest they saw, so a later capture shows
|
|
918
|
+
* as a different digest. Measured (AntennaPod 10-15): the plan was rebuilt at 14:08 and
|
|
919
|
+
* 21:51 only, so 11 groups whose pages recovery D had captured by 17:30 were converted
|
|
920
|
+
* source-only and redone.
|
|
921
|
+
*/
|
|
922
|
+
export function captureDigest(campaign) {
|
|
923
|
+
let ids;
|
|
924
|
+
try {
|
|
925
|
+
ids = JSON.parse(fs.readFileSync(path.join(String(campaign), 'audit.json'), 'utf8')).mapped_ids;
|
|
926
|
+
} catch {
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
if (!Array.isArray(ids)) return null;
|
|
930
|
+
const sorted = [...new Set(ids.map(String))].sort();
|
|
931
|
+
return `${sorted.length}:${createHash('sha256').update(sorted.join('\n')).digest('hex').slice(0, 16)}`;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** final_utg stores `{url, exists}` with a url relative to the campaign. */
|
|
935
|
+
export function resolveAsset(asset, campaign) {
|
|
936
|
+
if (!truthy(asset) || !truthy(get(asset, 'exists'))) { return null; }
|
|
937
|
+
let url = unquote(pyStr(get(asset, 'url', '')));
|
|
938
|
+
if (url.startsWith('file:')) { url = url.replace(/^file:\/*/, ''); }
|
|
939
|
+
const p = pyIsAbsolute(url) ? pathStr(url) : pyJoin(campaign, url);
|
|
940
|
+
return isFile(p) ? p : null;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
const resourceId = (n) => or(get(n, 'resource_id'), get(n, 'resource-id'));
|
|
944
|
+
|
|
945
|
+
/** frozenset of visible resource ids, as a Map canon-key → id. */
|
|
946
|
+
export function idSet(capture) {
|
|
947
|
+
const s = new Map();
|
|
948
|
+
const hidden = coveredNodes(capture);
|
|
949
|
+
get(capture, 'nodes', []).forEach((n, i) => {
|
|
950
|
+
if (truthy(get(n, 'visible', true)) && truthy(resourceId(n)) && !hidden.has(i)) { s.set(canon(resourceId(n)), resourceId(n)); }
|
|
951
|
+
});
|
|
952
|
+
return s;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/** |a ∩ b| / min(|a|, |b|); two id-less captures (Compose, WebView) are one screen. */
|
|
956
|
+
export function containment(a, b) {
|
|
957
|
+
if (!a.size || !b.size) { return !a.size && !b.size ? 1.0 : 0.0; }
|
|
958
|
+
let inter = 0;
|
|
959
|
+
for (const k of a.keys()) { if (b.has(k)) { inter++; } }
|
|
960
|
+
return inter / Math.min(a.size, b.size);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Majority package of the dumped tree. The explorer verifies identity from
|
|
965
|
+
* the `dumpsys window` component, which can lag the tree: a capture labelled
|
|
966
|
+
* with an app Activity may hold the system file picker or the launcher.
|
|
967
|
+
*/
|
|
968
|
+
export function treePackage(capture) {
|
|
969
|
+
const counts = new Map();
|
|
970
|
+
for (const n of get(capture, 'nodes', [])) {
|
|
971
|
+
if (truthy(get(n, 'package'))) {
|
|
972
|
+
const k = canon(n.package);
|
|
973
|
+
const c = counts.get(k) ?? [n.package, 0];
|
|
974
|
+
c[1] += 1;
|
|
975
|
+
counts.set(k, c);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
let best = null;
|
|
979
|
+
for (const c of counts.values()) { if (best === null || c[1] > best[1]) { best = c; } }
|
|
980
|
+
return best ? best[0] : null;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Positions in `capture.nodes` an upper layer covers (occlusion.mjs), memoized
|
|
985
|
+
* per capture. The explorer's nodes are flat, in document order, with
|
|
986
|
+
* `parent_index` into the same list and `bounds` as `[x1, y1, x2, y2]`.
|
|
987
|
+
*/
|
|
988
|
+
const coveredMemo = new WeakMap();
|
|
989
|
+
export function coveredNodes(capture) {
|
|
990
|
+
if (capture === null || typeof capture !== 'object') return new Set();
|
|
991
|
+
if (!coveredMemo.has(capture)) {
|
|
992
|
+
// the explorer's keys, read as the dump's attributes
|
|
993
|
+
const attrOf = (n) => (k) => {
|
|
994
|
+
if (k === 'bounds') {
|
|
995
|
+
const b = get(n, 'bounds');
|
|
996
|
+
return Array.isArray(b) && b.length === 4 ? `[${b[0]},${b[1]}][${b[2]},${b[3]}]` : b;
|
|
997
|
+
}
|
|
998
|
+
if (k === 'content-desc') return or(get(n, 'content_desc'), get(n, 'content-desc'));
|
|
999
|
+
if (k === 'visible-to-user') return truthy(get(n, 'visible', true)) ? get(n, 'visible-to-user') : 'false';
|
|
1000
|
+
const v = get(n, k);
|
|
1001
|
+
return typeof v === 'boolean' ? String(v) : v;
|
|
1002
|
+
};
|
|
1003
|
+
const rows = get(capture, 'nodes', []).map((n) => {
|
|
1004
|
+
const pi = get(n, 'parent_index');
|
|
1005
|
+
return xmlRow(attrOf(n), Number.isInteger(pi) ? pi : null);
|
|
1006
|
+
});
|
|
1007
|
+
coveredMemo.set(capture, new Set(coveredBy(rows).keys()));
|
|
1008
|
+
}
|
|
1009
|
+
return coveredMemo.get(capture);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* The visible-node tuple, as a canonical string key. Covered nodes are left
|
|
1014
|
+
* out: a re-visit that differs only under an upper layer (a clock text in the
|
|
1015
|
+
* fragment below) is the same viewport, not another one to look at.
|
|
1016
|
+
*/
|
|
1017
|
+
const sigMemo = new WeakMap();
|
|
1018
|
+
export function viewSignature(capture) {
|
|
1019
|
+
if (capture === null || typeof capture !== 'object') return '';
|
|
1020
|
+
if (!sigMemo.has(capture)) {
|
|
1021
|
+
const hidden = coveredNodes(capture);
|
|
1022
|
+
sigMemo.set(capture, get(capture, 'nodes', []).filter((n, i) => truthy(get(n, 'visible', true)) && !hidden.has(i))
|
|
1023
|
+
.map((n) => [get(n, 'resource_id'), get(n, 'class'), get(n, 'text'), pyStr(get(n, 'bounds') ?? null)].map(canon).join('\u0001'))
|
|
1024
|
+
.join('\u0002'));
|
|
1025
|
+
}
|
|
1026
|
+
return sigMemo.get(capture);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Split one node's captures into screens: same node + near-equal id set.
|
|
1031
|
+
*
|
|
1032
|
+
* Environment ids are NOT a split key — retry/recovery phases re-observe the
|
|
1033
|
+
* same screen under a new environment id. A genuinely different state (empty
|
|
1034
|
+
* vs populated list, extra panel) changes the id set and lands in its own
|
|
1035
|
+
* group, which Step 4.2 then decides to merge or keep apart.
|
|
1036
|
+
*/
|
|
1037
|
+
export function groupStates(captures) {
|
|
1038
|
+
// Richest capture first, so it seeds its group and becomes the primary
|
|
1039
|
+
// viewport. Containment (not Jaccard) decides membership: controls that
|
|
1040
|
+
// auto-hide, or rows scrolled out of view, make one capture's id set a
|
|
1041
|
+
// subset of another's without making it a different screen.
|
|
1042
|
+
const states = [];
|
|
1043
|
+
for (const cap of sortedBy(captures, (c) => [-idSet(c).size, get(c, 'sequence', 0)])) {
|
|
1044
|
+
const ids = idSet(cap);
|
|
1045
|
+
const st = states.find((s) => containment(s.ids, ids) >= STATE_MERGE_OVERLAP);
|
|
1046
|
+
if (st) {
|
|
1047
|
+
if (!st.sigs.has(viewSignature(cap))) {
|
|
1048
|
+
st.sigs.add(viewSignature(cap));
|
|
1049
|
+
st.viewports.push(cap);
|
|
1050
|
+
} else {
|
|
1051
|
+
st.duplicates.push(cap);
|
|
1052
|
+
}
|
|
1053
|
+
} else {
|
|
1054
|
+
states.push({ ids, sigs: new Set([viewSignature(cap)]), viewports: [cap], duplicates: [] });
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
return states;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/** The `<node>` elements of a parsed dump an upper layer covers (occlusion.mjs). */
|
|
1061
|
+
export function occludedNodes(root) {
|
|
1062
|
+
const els = [];
|
|
1063
|
+
const rows = [];
|
|
1064
|
+
const walk = (el, parent) => {
|
|
1065
|
+
let here = parent;
|
|
1066
|
+
if (el.tag === 'node') {
|
|
1067
|
+
here = els.length;
|
|
1068
|
+
els.push(el);
|
|
1069
|
+
rows.push(xmlRow((k) => el.attrib[k], parent));
|
|
1070
|
+
}
|
|
1071
|
+
for (const c of el.children) walk(c, here);
|
|
1072
|
+
};
|
|
1073
|
+
walk(root, null);
|
|
1074
|
+
return new Set([...coveredBy(rows).keys()].map((i) => els[i]));
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Clickable controls of one view tree, in document order. A control an upper
|
|
1079
|
+
* layer covers (`occludedNodes`) carries `occluded: true`: flagged, not
|
|
1080
|
+
* dropped, since a see-through layer can misfire the rule. `res.scrollers`
|
|
1081
|
+
* maps each control inside `scrollable` nodes to those nodes' resource ids
|
|
1082
|
+
* (outermost first, '' for none): what a swipe of one of them would move.
|
|
1083
|
+
*/
|
|
1084
|
+
export function clickableElements(xmlPath, index) {
|
|
1085
|
+
let root;
|
|
1086
|
+
try {
|
|
1087
|
+
root = parseXmlFile(xmlPath);
|
|
1088
|
+
} catch (e) {
|
|
1089
|
+
if (e instanceof XmlParseError || (e && typeof e.code === 'string')) { return []; }
|
|
1090
|
+
throw e;
|
|
1091
|
+
}
|
|
1092
|
+
const hidden = occludedNodes(root);
|
|
1093
|
+
const res = [];
|
|
1094
|
+
res.scrollers = new Map();
|
|
1095
|
+
const walk = (el, scrollers) => {
|
|
1096
|
+
const a = el.attrib;
|
|
1097
|
+
const g = (k, d = null) => (Object.hasOwn(a, k) ? a[k] : d);
|
|
1098
|
+
if (el.tag === 'node' && (g('clickable') === 'true' || g('long-clickable') === 'true')) {
|
|
1099
|
+
const item = { class: g('class', ''), 'resource-id': g('resource-id', ''),
|
|
1100
|
+
text: g('text', ''), 'content-desc': g('content-desc', ''),
|
|
1101
|
+
bounds: g('bounds', ''), 'long-clickable': g('long-clickable') === 'true',
|
|
1102
|
+
scroll_index: index };
|
|
1103
|
+
if (hidden.has(el)) item.occluded = true;
|
|
1104
|
+
res.push(item);
|
|
1105
|
+
if (scrollers.length) res.scrollers.set(item, scrollers);
|
|
1106
|
+
}
|
|
1107
|
+
const below = el.tag === 'node' && g('scrollable') === 'true' ? [...scrollers, g('resource-id', '')] : scrollers;
|
|
1108
|
+
for (const c of el.children) walk(c, below);
|
|
1109
|
+
};
|
|
1110
|
+
walk(root, []);
|
|
1111
|
+
return res;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/** One on-screen control, for deduping across viewports and frames. */
|
|
1115
|
+
const controlKey = (el) => JSON.stringify([el.class, el['resource-id'], el.text, el['content-desc'], el.bounds, el['long-clickable']]);
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Accumulates one page's clickable_elements over its trees. A control an
|
|
1119
|
+
* earlier tree already listed is not listed again, unless `moves(el)`: then
|
|
1120
|
+
* the same bounds can hold a different row, and it stays per tree. One tree's
|
|
1121
|
+
* own repeats (a clickable parent and child sharing bounds) all stay. When the
|
|
1122
|
+
* earlier entry was covered and this one is not, the visible observation
|
|
1123
|
+
* takes its place: the control is on that tree's screenshot.
|
|
1124
|
+
*/
|
|
1125
|
+
function clickableList() {
|
|
1126
|
+
const slots = []; // entries in order; null where a covered one was replaced
|
|
1127
|
+
const at = new Map(); // controlKey -> slots of the tree that first listed it
|
|
1128
|
+
return {
|
|
1129
|
+
get list() { return slots.filter((e) => e !== null); },
|
|
1130
|
+
add(found, moves) {
|
|
1131
|
+
const start = slots.length;
|
|
1132
|
+
for (const el of found) {
|
|
1133
|
+
const k = controlKey(el);
|
|
1134
|
+
const prev = at.get(k);
|
|
1135
|
+
if (!moves(el) && prev && prev[0] < start) {
|
|
1136
|
+
if (!el.occluded && prev.every((i) => slots[i] === null || slots[i].occluded)) {
|
|
1137
|
+
// first seen only covered: the visible observation replaces all of
|
|
1138
|
+
// them, listed where it was seen
|
|
1139
|
+
for (const i of prev) slots[i] = null;
|
|
1140
|
+
at.set(k, [slots.length]);
|
|
1141
|
+
slots.push(el);
|
|
1142
|
+
}
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (!prev) at.set(k, [slots.length]); else if (prev[0] >= start) prev.push(slots.length);
|
|
1146
|
+
slots.push(el);
|
|
1147
|
+
}
|
|
1148
|
+
},
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
export function safeName(node) {
|
|
1153
|
+
const sid = pyStr(get(node, 'id', ''));
|
|
1154
|
+
const colon = sid.indexOf(':');
|
|
1155
|
+
const raw = or(get(node, 'name'), or(colon < 0 ? sid : sid.slice(colon + 1), 'Page'));
|
|
1156
|
+
const name = pyStr(raw).replace(/[^A-Za-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
|
|
1157
|
+
return name || 'Page';
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
export function observationDeviceInfo(treePath) {
|
|
1161
|
+
const obs = path.join(path.dirname(treePath), 'observation.json');
|
|
1162
|
+
if (isFile(obs)) {
|
|
1163
|
+
const info = get(readJson(obs), 'device_info');
|
|
1164
|
+
if (truthy(info) && truthy(get(info, 'density'))) { return info; }
|
|
1165
|
+
}
|
|
1166
|
+
return null;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/** Phases that never ran or were blocked, with the pages they hold back. */
|
|
1170
|
+
export function deferredPhases(campaignDoc, observedIds) {
|
|
1171
|
+
const items = [];
|
|
1172
|
+
for (const ph of get(campaignDoc, 'phases', [])) {
|
|
1173
|
+
if (!pyIn(get(ph, 'status') ?? null, ['blocked', 'pending'])) { continue; }
|
|
1174
|
+
// A node obligation names the page; an edge obligation holds back its target.
|
|
1175
|
+
const aff = new Map();
|
|
1176
|
+
for (const o of get(ph, 'obligations', [])) {
|
|
1177
|
+
if (pyIn(get(o, 'type') ?? null, ['node', 'edge'])) {
|
|
1178
|
+
const v = get(o, 'type') === 'node' ? req(o, 'id') : (get(o, 'target') ?? null);
|
|
1179
|
+
aff.set(canon(v), v);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
const affected = sortedBy([...aff].filter(([k]) => k !== 'N' && !observedIds.has(k)).map(([, v]) => v));
|
|
1183
|
+
if (!affected.length) { continue; }
|
|
1184
|
+
items.push({ phase: req(ph, 'id'), status: get(ph, 'status'),
|
|
1185
|
+
// retry/recovery variants re-attempt a base phase; keep them
|
|
1186
|
+
// (their failure reason is useful) but let the report fold them.
|
|
1187
|
+
derived: /^(retry\p{Nd}*|rec[A-D]\p{Nd}*)-/u.test(ph.id),
|
|
1188
|
+
axes: get(ph, 'requires', []), affected_nodes: affected,
|
|
1189
|
+
instructions: or(get(ph, 'reason'), 'phase never ran: no fixture/probe for its preconditions') });
|
|
1190
|
+
}
|
|
1191
|
+
return items;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
const sameObj = (a, b) => a === b || pyEq(a, b);
|
|
1195
|
+
const memberOf = (x, list) => list.some((y) => sameObj(x, y));
|
|
1196
|
+
|
|
1197
|
+
/** `export` is a reserved word in JS: defined as exportUiInfo, exported under both names. */
|
|
1198
|
+
function exportUiInfo(campaign, staticWs, out, maxViewports = 4, pkg = null) {
|
|
1199
|
+
// digest first: report.mjs writes audit.json before utg.final.json, so a report landing
|
|
1200
|
+
// mid-export can only make this digest older than the export (one extra rebuild later),
|
|
1201
|
+
// never newer (a capture the plan would then claim to have seen)
|
|
1202
|
+
const digest = captureDigest(campaign);
|
|
1203
|
+
const final = readJson(path.join(campaign, 'utg.final.json'));
|
|
1204
|
+
const doc = isFile(path.join(campaign, 'campaign.json')) ? readJson(path.join(campaign, 'campaign.json')) : {};
|
|
1205
|
+
const paths = new Map();
|
|
1206
|
+
const order = new Map();
|
|
1207
|
+
const cpFile = truthy(staticWs) ? path.join(staticWs, 'click_paths.json') : null;
|
|
1208
|
+
if (cpFile && isFile(cpFile)) {
|
|
1209
|
+
const raw = get(readJson(cpFile), 'paths', {});
|
|
1210
|
+
const items = Array.isArray(raw) ? raw : keysOf(raw).map((k) => [k, raw[k]]);
|
|
1211
|
+
// Sort by path length, then clicks: a parent's path is a prefix of
|
|
1212
|
+
// its child's, so this is a topological order of the click tree.
|
|
1213
|
+
const ranked = sortedBy(items, (kv) => [pyLen(get(kv[1], 'steps', [])), get(kv[1], 'clicks', 0)]);
|
|
1214
|
+
ranked.forEach(([nid, info], i) => {
|
|
1215
|
+
paths.set(nid, info);
|
|
1216
|
+
order.set(nid, i);
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
const captures = get(final, 'captures', {});
|
|
1220
|
+
const capOf = (cid) => (typeof cid === 'string' && Object.hasOwn(captures, cid) ? captures[cid] : undefined);
|
|
1221
|
+
fs.mkdirSync(out, { recursive: true });
|
|
1222
|
+
const cfg = path.join(campaign, 'config.json');
|
|
1223
|
+
const pkgName = or(pkg, isFile(cfg) ? (get(readJson(cfg), 'package') ?? null) : null);
|
|
1224
|
+
const manifest = { campaign: pathStr(campaign), package: pkgName, pages: [], skipped: [],
|
|
1225
|
+
dynamic_only: 0, missing_device_info: [], foreign_tree_captures: [],
|
|
1226
|
+
// what this export was made from: group_queue.mjs re-runs export + build when the
|
|
1227
|
+
// campaign's captures move on (captureDigest differs from the plan's)
|
|
1228
|
+
static_ws: truthy(staticWs) ? pathStr(path.resolve(staticWs)) : null, capture_digest: digest };
|
|
1229
|
+
|
|
1230
|
+
// Captures an in-page state of a page claims (its anchors hold there): they are that state's
|
|
1231
|
+
// directory, so the host keeps its other captures (its default state) when it has any.
|
|
1232
|
+
const stateClaims = new Map();
|
|
1233
|
+
for (const n of get(final, 'nodes', [])) {
|
|
1234
|
+
if (!STATE_KINDS.has(get(n, 'kind')) || !truthy(get(n, 'host_node'))) { continue; }
|
|
1235
|
+
const ids = get(get(n, 'evidence', {}), 'capture_ids', []) || [];
|
|
1236
|
+
if (!ids.length) { continue; }
|
|
1237
|
+
if (!stateClaims.has(n.host_node)) { stateClaims.set(n.host_node, new Set()); }
|
|
1238
|
+
for (const c of ids) { stateClaims.get(n.host_node).add(c); }
|
|
1239
|
+
}
|
|
1240
|
+
const candidates = [];
|
|
1241
|
+
for (const node of get(final, 'nodes', [])) {
|
|
1242
|
+
const ev = get(node, 'evidence', {});
|
|
1243
|
+
if (get(ev, 'origin') === 'dynamic-only') {
|
|
1244
|
+
manifest.dynamic_only += 1;
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
if (get(ev, 'coverage') !== 'observed') { continue; }
|
|
1248
|
+
const kind = get(node, 'kind');
|
|
1249
|
+
const reason = typeof kind === 'string' && SKIP_KINDS.has(kind) ? 'kind:' + pyStr(kind)
|
|
1250
|
+
: truthy(get(node, 'out_of_scope')) ? 'out-of-scope:' + pyStr(node.out_of_scope) : null;
|
|
1251
|
+
let caps = get(ev, 'capture_ids', []).filter((c) => capOf(c) !== undefined).map(capOf);
|
|
1252
|
+
caps = caps.filter((c) => resolveAsset(get(c, 'screenshot'), campaign) && resolveAsset(get(c, 'tree'), campaign));
|
|
1253
|
+
const claimed = stateClaims.get(get(node, 'id'));
|
|
1254
|
+
if (claimed) {
|
|
1255
|
+
const own = caps.filter((c) => !claimed.has(get(c, 'id')));
|
|
1256
|
+
if (own.length) { caps = own; }
|
|
1257
|
+
}
|
|
1258
|
+
if (truthy(pkgName)) {
|
|
1259
|
+
const foreign = caps.filter((c) => !pyIn(treePackage(c), [null, pkgName]));
|
|
1260
|
+
if (foreign.length) {
|
|
1261
|
+
const pk = new Map(foreign.map((c) => [canon(treePackage(c)), treePackage(c)]));
|
|
1262
|
+
manifest.foreign_tree_captures.push({ node: req(node, 'id'), count: foreign.length, packages: sortedBy([...pk.values()]) });
|
|
1263
|
+
caps = caps.filter((c) => !memberOf(c, foreign));
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if (reason || !caps.length) {
|
|
1267
|
+
manifest.skipped.push({ node: req(node, 'id'), reason: or(reason, 'no capture with both artifacts') });
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
const firstSeen = pyMin(caps.map((c) => get(c, 'sequence', 0)));
|
|
1271
|
+
candidates.push([order.has(node.id) ? order.get(node.id) : order.size, firstSeen, node, caps]);
|
|
1272
|
+
}
|
|
1273
|
+
// click-path order puts a parent before its children; unreached-by-path
|
|
1274
|
+
// nodes follow in capture order.
|
|
1275
|
+
const ordered = sortedBy(candidates, (t) => [t[0], t[1]]);
|
|
1276
|
+
|
|
1277
|
+
// Incremental: a page keeps the directory an earlier export gave it, so a
|
|
1278
|
+
// group already converting it (or its measure pack) is not pulled out from
|
|
1279
|
+
// under it when a later explorer step re-exports. New pages number after
|
|
1280
|
+
// every existing page_* dir, the builder's source-only ones included.
|
|
1281
|
+
const prevFile = path.join(out, 'export_manifest.json');
|
|
1282
|
+
const prev = isFile(prevFile) ? readJson(prevFile) : {};
|
|
1283
|
+
// Pages another campaign exported here (incremental: each scope explores in a new campaign)
|
|
1284
|
+
// stay listed under `earlier` while their directory exists, so a later scope still finds
|
|
1285
|
+
// them captured. A re-export of the same campaign drops what it no longer lists, as before.
|
|
1286
|
+
const sameCampaign = truthy(get(prev, 'campaign')) && path.resolve(pyStr(prev.campaign)) === path.resolve(pyStr(campaign));
|
|
1287
|
+
const prevPages = path.join(out, 'pages.json');
|
|
1288
|
+
const prevSeq = new Map(get(isFile(prevPages) ? or(readJson(prevPages), {}) : {}, 'pages', [])
|
|
1289
|
+
.map((e) => [path.basename(pyStr(get(e, 'page_dir'))), get(e, 'ui_sequence')]));
|
|
1290
|
+
const earlier = [...(sameCampaign ? [] : or(get(prev, 'pages'), [])), ...or(get(prev, 'earlier'), [])]
|
|
1291
|
+
.filter((pg) => truthy(get(pg, 'page_dir')) && isDir(path.join(out, path.basename(pyStr(pg.page_dir)))))
|
|
1292
|
+
.map((pg) => ({ ...pg, ui_sequence: or(get(pg, 'ui_sequence'), prevSeq.get(path.basename(pyStr(pg.page_dir))) ?? null) }));
|
|
1293
|
+
const prevSlug = new Map();
|
|
1294
|
+
for (const pg of [...or(get(prev, 'pages'), []), ...earlier]) {
|
|
1295
|
+
const si = Number(String(or(get(pg, 'state'), '1/1')).split('/')[0]) - 1;
|
|
1296
|
+
const k = JSON.stringify([pg.static_node, si]);
|
|
1297
|
+
if (!prevSlug.has(k)) prevSlug.set(k, pg.page_dir);
|
|
1298
|
+
}
|
|
1299
|
+
let seq = 0;
|
|
1300
|
+
for (const d of fs.readdirSync(out)) {
|
|
1301
|
+
const m = /^page_(\d+)_/.exec(d);
|
|
1302
|
+
if (m) seq = Math.max(seq, Number(m[1]));
|
|
1303
|
+
}
|
|
1304
|
+
manifest.new = [];
|
|
1305
|
+
manifest.changed = [];
|
|
1306
|
+
const pages = [];
|
|
1307
|
+
for (const [, , node, caps0] of ordered) {
|
|
1308
|
+
let caps = caps0;
|
|
1309
|
+
const scroll = or(get(get(node, 'evidence', {}), 'scroll'), {});
|
|
1310
|
+
// Sweep frames are ordered by the sweep, not grouped by id overlap: a
|
|
1311
|
+
// frame far below the fold shares few ids with the top and would
|
|
1312
|
+
// otherwise split off as a "state" of its own.
|
|
1313
|
+
const frameIds = get(scroll, 'frames', []).filter((f) => capOf(f) !== undefined);
|
|
1314
|
+
const byId = new Map(caps.map((c) => [canon(req(c, 'id')), c]));
|
|
1315
|
+
let frames = frameIds.filter((f) => byId.has(canon(f))).map((f) => byId.get(canon(f)));
|
|
1316
|
+
const frameSet = new Set(frameIds.map(canon));
|
|
1317
|
+
caps = caps.filter((c) => !frameSet.has(canon(c.id)) &&
|
|
1318
|
+
!pyIn(get(or(get(c, 'sweep'), {}), 'role') ?? null, ['probe', 'restore']));
|
|
1319
|
+
if (!caps.length && frames.length) {
|
|
1320
|
+
caps = frames.slice(0, 1);
|
|
1321
|
+
frames = frames.slice(1);
|
|
1322
|
+
}
|
|
1323
|
+
const states = groupStates(caps);
|
|
1324
|
+
const oc = or(get(scroll, 'origin_capture'), '');
|
|
1325
|
+
const origin = capOf(oc) ?? null;
|
|
1326
|
+
let sweepState = null;
|
|
1327
|
+
if (truthy(scroll)) {
|
|
1328
|
+
const dflt = states.length ? states[0] : null; // Python next(it, default): empty states -> None, not a raise
|
|
1329
|
+
sweepState = states.find((st) => truthy(origin) && st.sigs.has(viewSignature(origin))) ?? dflt;
|
|
1330
|
+
if (sweepState && truthy(origin) && byId.has(canon(get(origin, 'id') ?? null))) {
|
|
1331
|
+
// The top of the page is view.xml: view_scroll_N continue it.
|
|
1332
|
+
const vps = sweepState.viewports;
|
|
1333
|
+
const same = vps.filter((v) => viewSignature(v) === viewSignature(origin));
|
|
1334
|
+
sweepState.viewports = [origin, ...vps.filter((v) => !memberOf(v, same))];
|
|
1335
|
+
sweepState.duplicates.push(...same.filter((v) => v !== origin));
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
for (const [si, st] of states.entries()) {
|
|
1339
|
+
let slug = prevSlug.get(JSON.stringify([node.id, si]));
|
|
1340
|
+
if (!slug) {
|
|
1341
|
+
seq += 1;
|
|
1342
|
+
const suffix = states.length === 1 ? '' : `_s${si + 1}`;
|
|
1343
|
+
slug = `page_${String(seq).padStart(4, '0')}_${safeName(node)}${suffix}`;
|
|
1344
|
+
}
|
|
1345
|
+
const pdir = path.join(out, slug);
|
|
1346
|
+
const vps = head(st.viewports, maxViewports);
|
|
1347
|
+
const sweep = [];
|
|
1348
|
+
if (st === sweepState) {
|
|
1349
|
+
for (const cap of frames) {
|
|
1350
|
+
if (!(resolveAsset(get(cap, 'screenshot'), campaign) && resolveAsset(get(cap, 'tree'), campaign))) break;
|
|
1351
|
+
sweep.push(cap);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
const planned = [...vps, ...sweep].map((c) => req(c, 'observation_id'));
|
|
1355
|
+
const oldMeta = isFile(path.join(pdir, 'meta.json')) ? readJson(path.join(pdir, 'meta.json')) : {};
|
|
1356
|
+
// Same observations as last export: keep the directory as it is,
|
|
1357
|
+
// measure_pack.json and all (re-copying would drop the pack).
|
|
1358
|
+
const keep = JSON.stringify(get(get(oldMeta, 'source', {}), 'observation_ids') ?? null) === JSON.stringify(planned);
|
|
1359
|
+
if (!keep) {
|
|
1360
|
+
if (exists(pdir)) {
|
|
1361
|
+
if (!isDir(pdir)) { throw new Error(`[WinError 267] The directory name is invalid: '${pdir}'`); }
|
|
1362
|
+
fs.rmSync(pdir, { recursive: true });
|
|
1363
|
+
manifest.changed.push(slug);
|
|
1364
|
+
} else {
|
|
1365
|
+
manifest.new.push(slug);
|
|
1366
|
+
}
|
|
1367
|
+
fs.mkdirSync(pdir);
|
|
1368
|
+
}
|
|
1369
|
+
const shots = [];
|
|
1370
|
+
const trees = [];
|
|
1371
|
+
const clickable = clickableList();
|
|
1372
|
+
const obsIds = [];
|
|
1373
|
+
for (const [vi, cap] of vps.entries()) {
|
|
1374
|
+
const tail = vi === 0 ? '' : `_vp${vi}`;
|
|
1375
|
+
if (!keep) {
|
|
1376
|
+
fs.copyFileSync(resolveAsset(req(cap, 'screenshot'), campaign), path.join(pdir, `screenshot${tail}.png`));
|
|
1377
|
+
fs.copyFileSync(resolveAsset(req(cap, 'tree'), campaign), path.join(pdir, `view${tail}.xml`));
|
|
1378
|
+
}
|
|
1379
|
+
shots.push(`${slug}/screenshot${tail}.png`);
|
|
1380
|
+
trees.push(`${slug}/view${tail}.xml`);
|
|
1381
|
+
// Viewports re-observe one screen: a control they share is listed once.
|
|
1382
|
+
// Which scroll offset each was taken at is unknown, so anything inside
|
|
1383
|
+
// a scroller may be another row there and stays per viewport.
|
|
1384
|
+
const found = clickableElements(path.join(pdir, `view${tail}.xml`), st === sweepState ? 0 : vi);
|
|
1385
|
+
clickable.add(found, (el) => found.scrollers.has(el));
|
|
1386
|
+
obsIds.push(req(cap, 'observation_id'));
|
|
1387
|
+
}
|
|
1388
|
+
let scrollFrames = 0;
|
|
1389
|
+
if (st === sweepState) {
|
|
1390
|
+
const ct = or(get(scroll, 'container'), {});
|
|
1391
|
+
const sweptId = pyStr(or(get(ct, 'resource_id'), or(get(or(get(ct, 'selector'), {}), 'resource_id'), '')));
|
|
1392
|
+
// scroll_index = swipes from the top, the convention
|
|
1393
|
+
// android_parse_fast.ts and page_capture.mjs replay with.
|
|
1394
|
+
for (const [k, cap] of sweep.entries()) {
|
|
1395
|
+
const fi = k + 1;
|
|
1396
|
+
if (!keep) {
|
|
1397
|
+
fs.copyFileSync(resolveAsset(get(cap, 'screenshot'), campaign), path.join(pdir, `screenshot_scroll_${fi}.png`));
|
|
1398
|
+
fs.copyFileSync(resolveAsset(get(cap, 'tree'), campaign), path.join(pdir, `view_scroll_${fi}.xml`));
|
|
1399
|
+
}
|
|
1400
|
+
shots.splice(1 + scrollFrames, 0, `${slug}/screenshot_scroll_${fi}.png`);
|
|
1401
|
+
trees.splice(1 + scrollFrames, 0, `${slug}/view_scroll_${fi}.xml`);
|
|
1402
|
+
const found = clickableElements(path.join(pdir, `view_scroll_${fi}.xml`), fi);
|
|
1403
|
+
// Only the swept container moves between frames: its rows stay per
|
|
1404
|
+
// frame (the same bounds there are a different row); everything else
|
|
1405
|
+
// (a fixed top bar, a pinned chip strip) is listed once. Without the
|
|
1406
|
+
// container's id, any scroller counts as swept.
|
|
1407
|
+
clickable.add(found, (el) => (found.scrollers.get(el) ?? [])
|
|
1408
|
+
.some((rid) => !sweptId || rid === sweptId));
|
|
1409
|
+
obsIds.push(req(cap, 'observation_id'));
|
|
1410
|
+
scrollFrames += 1;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
let completeness;
|
|
1414
|
+
if (st === sweepState) {
|
|
1415
|
+
completeness = or(get(scroll, 'outcome'), 'not-swept');
|
|
1416
|
+
if (completeness === 'complete' && scrollFrames < frames.length) {
|
|
1417
|
+
completeness = 'truncated'; // a frame lost its artifacts
|
|
1418
|
+
}
|
|
1419
|
+
} else {
|
|
1420
|
+
completeness = 'not-swept';
|
|
1421
|
+
}
|
|
1422
|
+
const occludedCount = clickable.list.filter((e) => e.occluded).length;
|
|
1423
|
+
const primary = st.viewports[0];
|
|
1424
|
+
const p = paths.has(node.id) ? paths.get(node.id) : {};
|
|
1425
|
+
const labels = get(p, 'steps', []).map((s) => get(s, 'label')).filter(truthy);
|
|
1426
|
+
const meta = {
|
|
1427
|
+
page_id: slug, static_node: node.id, kind: get(node, 'kind'),
|
|
1428
|
+
label: get(node, 'label'), declared_at: get(node, 'declared_at'),
|
|
1429
|
+
activity_info: { activity: get(primary, 'activity'), window: get(primary, 'window') },
|
|
1430
|
+
screenshot: first(shots), view_xml: first(trees),
|
|
1431
|
+
screenshots: shots, view_xmls: trees,
|
|
1432
|
+
clickable_count: clickable.list.length, clickable_elements: clickable.list,
|
|
1433
|
+
...(occludedCount ? { clickable_occluded: occludedCount } : {}),
|
|
1434
|
+
click_path: get(p, 'steps', []),
|
|
1435
|
+
breadcrumb: labels.join(' > '),
|
|
1436
|
+
click_path_text: or(get(p, 'nl_path_text'), get(p, 'path_text', '')),
|
|
1437
|
+
came_from: get(primary, 'incoming_action'),
|
|
1438
|
+
identity: get(primary, 'resolution', {}),
|
|
1439
|
+
environment_id: get(primary, 'environment_id'),
|
|
1440
|
+
scroll_completeness: completeness,
|
|
1441
|
+
source: { backend: 'a2h-utg-explorer', observation_ids: obsIds, scroll_completeness: completeness,
|
|
1442
|
+
// captures with the same view signature as an exported viewport (covered
|
|
1443
|
+
// nodes aside), not exported: under <campaign>/artifacts/<id>/
|
|
1444
|
+
...(st.duplicates.length ? { duplicate_observation_ids: st.duplicates.map((c) => req(c, 'observation_id')) } : {}) },
|
|
1445
|
+
};
|
|
1446
|
+
if (st === sweepState) {
|
|
1447
|
+
meta.scroll = { outcome: get(scroll, 'outcome'), frames: scrollFrames,
|
|
1448
|
+
container: get(scroll, 'container'),
|
|
1449
|
+
unswept_containers: get(scroll, 'unswept_containers', []),
|
|
1450
|
+
abort_reason: get(scroll, 'abort_reason') };
|
|
1451
|
+
}
|
|
1452
|
+
const info = observationDeviceInfo(resolveAsset(req(primary, 'tree'), campaign));
|
|
1453
|
+
if (info) {
|
|
1454
|
+
meta.device_info = info;
|
|
1455
|
+
} else {
|
|
1456
|
+
manifest.missing_device_info.push(slug);
|
|
1457
|
+
}
|
|
1458
|
+
writeJson(path.join(pdir, 'meta.json'), meta);
|
|
1459
|
+
// Natural-language route when the static stage wrote one (「首页」),
|
|
1460
|
+
// else the step labels (often code names).
|
|
1461
|
+
const route = or(get(p, 'nl_path_text'), get(p, 'path_text'));
|
|
1462
|
+
pages.push({ page_dir: pathResolve(pdir),
|
|
1463
|
+
ui_sequence: ['根页面', ...(truthy(route) ? [route] : labels)].map(pyStr).join(ARROW) });
|
|
1464
|
+
manifest.pages.push({ page_dir: slug, static_node: node.id,
|
|
1465
|
+
viewports: shots.length - scrollFrames, scroll_frames: scrollFrames,
|
|
1466
|
+
scroll_completeness: completeness,
|
|
1467
|
+
state: `${si + 1}/${states.length}` });
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
const observed = new Set(manifest.pages.map((p) => canon(p.static_node)));
|
|
1472
|
+
const now = new Set(manifest.pages.map((p) => p.page_dir));
|
|
1473
|
+
const seenEarlier = new Set();
|
|
1474
|
+
manifest.earlier = earlier.filter((p) => {
|
|
1475
|
+
const k = path.basename(pyStr(p.page_dir));
|
|
1476
|
+
if (now.has(k) || seenEarlier.has(k)) { return false; }
|
|
1477
|
+
seenEarlier.add(k);
|
|
1478
|
+
return true;
|
|
1479
|
+
});
|
|
1480
|
+
writeJson(path.join(out, 'pages.json'), { pages });
|
|
1481
|
+
writeJson(path.join(out, 'deferred_human.json'), { items: deferredPhases(doc, observed) });
|
|
1482
|
+
writeJson(path.join(out, 'export_manifest.json'), manifest);
|
|
1483
|
+
return manifest;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
export { exportUiInfo, exportUiInfo as export };
|
|
1487
|
+
|
|
1488
|
+
const DESCRIPTION = 'export_ui_info.mjs — turn an a2h-utg-explorer campaign into the per-page\n' +
|
|
1489
|
+
'snapshot layout this skill consumes (Step 4 onward).';
|
|
1490
|
+
|
|
1491
|
+
export function main(argv = process.argv.slice(2)) {
|
|
1492
|
+
const a = parseArgs({
|
|
1493
|
+
prog: 'export_ui_info.mjs', description: DESCRIPTION,
|
|
1494
|
+
args: [
|
|
1495
|
+
{ name: 'campaign', positional: true },
|
|
1496
|
+
{ name: '--static-ws', help: 'a2h-utg-static workspace (click_paths.json)' },
|
|
1497
|
+
{ name: '--out', required: true, help: 'ui_info_root' },
|
|
1498
|
+
{ name: '--max-viewports', type: 'int', def: 4 },
|
|
1499
|
+
{ name: '--package', help: 'app package (default: campaign config.json `package`)' },
|
|
1500
|
+
],
|
|
1501
|
+
}, argv);
|
|
1502
|
+
if (!isFile(path.join(a.campaign, 'utg.final.json'))) {
|
|
1503
|
+
err(`[ERR] ${pathStr(a.campaign)}/utg.final.json missing — run the explorer's report.mjs first`);
|
|
1504
|
+
return 2;
|
|
1505
|
+
}
|
|
1506
|
+
const m = exportUiInfo(pathResolve(a.campaign), a.static_ws, pathResolve(a.out), a.max_viewports, a.package);
|
|
1507
|
+
out(`exported ${m.pages.length} page dirs; skipped ${m.skipped.length} observed nodes; ` +
|
|
1508
|
+
`${m.dynamic_only} unmapped dynamic nodes not exported`);
|
|
1509
|
+
if (m.foreign_tree_captures.length) {
|
|
1510
|
+
const n = m.foreign_tree_captures.reduce((s, x) => s + x.count, 0);
|
|
1511
|
+
err(`[WARN] dropped ${n} captures whose view tree belongs to another package ` +
|
|
1512
|
+
'(identity verified from a lagging foreground component)');
|
|
1513
|
+
}
|
|
1514
|
+
if (m.missing_device_info.length) {
|
|
1515
|
+
err(`[WARN] ${m.missing_device_info.length} pages lack device_info.density ` +
|
|
1516
|
+
'(campaign recorded before the adapter wrote it) — measure_pack will back-solve; ' +
|
|
1517
|
+
'pass --density from `adb shell wm density` when running it');
|
|
1518
|
+
}
|
|
1519
|
+
return 0;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
|
|
1523
|
+
process.exitCode = main();
|
|
1524
|
+
}
|