@buaa_smat/hometrans 26.0.2 → 26.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/agents/code-reviewer.md +25 -138
- package/dist/cli/index.js +4 -1
- package/dist/cli/init.js +131 -26
- package/dist/cli/uninstall.js +5 -5
- package/dist/platform/language.js +77 -0
- package/env-requirements.json +30 -5
- package/i18n/FILE-NAMES.md +9 -0
- package/i18n/agents/code-reviewer.md +364 -0
- package/i18n/agents/model-render-worker.md +38 -0
- package/i18n/agents/specgen-worker.md +18 -0
- package/i18n/commands/hometrans.md +17 -0
- package/i18n/skills/a2h-app-migrate/SKILL.md +198 -0
- package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
- package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
- package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +1760 -0
- package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
- package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1588 -0
- package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +657 -0
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
- package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +131 -0
- package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
- package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
- package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
- package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
- package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +698 -0
- package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
- package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
- package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
- package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +219 -0
- package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +196 -0
- package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
- package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +488 -0
- package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
- package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +146 -0
- package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +161 -0
- package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
- package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
- package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +171 -0
- package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
- package/i18n/skills/a2h-arch-generate/SKILL.md +375 -0
- package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
- package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
- package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
- package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
- package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
- package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
- package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
- package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
- package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
- package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
- package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +120 -0
- package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
- package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
- package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
- package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
- package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
- package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +9 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +192 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +303 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +587 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +352 -0
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +323 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +31 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +80 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +22 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +87 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +57 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +29 -0
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +705 -0
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +417 -0
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
- package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2549 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +148 -0
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +220 -0
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +216 -0
- package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +203 -0
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +210 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1748 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1787 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1836 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1406 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1226 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1220 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +412 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +173 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +629 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +67 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +551 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +374 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +119 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +80 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +97 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +123 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +427 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +560 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +324 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +325 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +48 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +387 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
- package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +59 -0
- package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
- package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
- package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
- package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
- package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
- package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
- package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2048 -0
- package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
- package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
- package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
- package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
- package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
- package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
- package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
- package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
- package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
- package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
- package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
- package/i18n/skills/a2h-module-semantic-docs/SKILL.md +227 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
- package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
- package/i18n/skills/a2h-page-specgen/SKILL.md +136 -0
- package/i18n/skills/a2h-page-specgen/references/body-language.md +177 -0
- package/i18n/skills/a2h-page-specgen/references/gates.md +262 -0
- package/i18n/skills/a2h-page-specgen/references/page-inventory.md +173 -0
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +207 -0
- package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1504 -0
- package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1528 -0
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +576 -0
- package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +138 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +262 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +176 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +248 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
- package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +506 -0
- package/i18n/skills/a2h-page-specgen/scripts/render.mjs +299 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +616 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +234 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1166 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +74 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +758 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +54 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +271 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +54 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +171 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +301 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +83 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +139 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +774 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1011 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +77 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +419 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +323 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +546 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +511 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +701 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1765 -0
- package/i18n/skills/a2h-resource-convert/SKILL.md +367 -0
- package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +335 -0
- package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
- package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +219 -0
- package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
- package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
- package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2532 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +278 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +260 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +163 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +44 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
- package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +589 -0
- package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +506 -0
- package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
- package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
- package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
- package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
- package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
- package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
- package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
- package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
- package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
- package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
- package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
- package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
- package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
- package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
- package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
- package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
- package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
- package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
- package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
- package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
- package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
- package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
- package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
- package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
- package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
- package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
- package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
- package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
- package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
- package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
- package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
- package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
- package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
- package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
- package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
- package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
- package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
- package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
- package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
- package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
- package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
- package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
- package/i18n/skills/a2h-utg-explorer/SKILL.md +120 -0
- package/i18n/skills/a2h-utg-explorer/references/architecture.md +279 -0
- package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +918 -0
- package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
- package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
- package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +380 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +492 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +199 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1412 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2037 -0
- package/i18n/skills/a2h-utg-static/SKILL.md +368 -0
- package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
- package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
- package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2120 -0
- package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
- package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +609 -0
- package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
- package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
- package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
- package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
- package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
- package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
- package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +913 -0
- package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +517 -0
- package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
- package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
- package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1351 -0
- package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
- package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
- package/package.json +13 -160
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
- package/skills/a2h-app-migrate/SKILL.md +17 -6
- package/skills/a2h-app-migrate/references/config.example.json +1 -0
- package/skills/a2h-app-migrate/references/stage-map.md +3 -1
- package/skills/a2h-app-migrate/references/workflow.yaml +138 -47
- package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +1 -2
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +105 -39
- package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +7 -8
- package/skills/a2h-app-migrate/scripts/ledger.mjs +17 -5
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +43 -7
- package/skills/a2h-app-migrate/scripts/run_dir.mjs +127 -41
- package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
- package/skills/a2h-app-migrate/test/test_android_index.mjs +131 -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 +98 -0
- package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
- package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
- package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
- package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
- package/skills/a2h-app-migrate/test/test_env_requirements.mjs +698 -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_i18n_engine_mirror.mjs +51 -0
- package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -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 +111 -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 +93 -0
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +219 -0
- package/skills/a2h-app-migrate/test/test_resume_summary.mjs +196 -0
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
- package/skills/a2h-app-migrate/test/test_run_dir.mjs +488 -0
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
- package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
- package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +147 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +146 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +161 -0
- package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +344 -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_uniapp_preflight.mjs +83 -0
- package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
- package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +178 -0
- package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
- package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
- package/skills/a2h-arch-generate/SKILL.md +1 -1
- package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
- package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
- package/skills/a2h-arch-generate/references/homegraph-workflow.md +15 -6
- package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
- package/skills/a2h-arch-generate/references/source-baseline.md +2 -2
- package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
- package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
- package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
- 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 +1260 -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_module_templates.mjs +70 -0
- package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
- package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
- package/skills/a2h-arkts-logic-coder/SKILL.md +21 -2
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -0
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +62 -0
- package/skills/a2h-arkts-logic-coder/references/spec-design.md +4 -0
- package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
- package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +583 -0
- package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
- package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
- package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
- package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
- package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
- package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
- package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
- package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
- package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +352 -0
- package/skills/a2h-batch-ui-align/SKILL.md +6 -4
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +1 -1
- package/skills/a2h-batch-ui-align/references/cards/resources.md +4 -0
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +22 -3
- package/skills/a2h-batch-ui-align/references/checker-rules.md +66 -3
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +45 -8
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +7 -5
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +4 -2
- package/skills/a2h-batch-ui-align/references/step5-convert.md +7 -5
- package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +84 -7
- package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
- package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +229 -0
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1 -2
- package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +88 -26
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +305 -12
- package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +8 -9
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +18 -5
- package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +103 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +14 -8
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +66 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +119 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +123 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +6 -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_a11y.test.mjs +598 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +427 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +235 -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_scroll_padding_raster.test.mjs +262 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +567 -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/detect_paradigm.test.mjs +260 -0
- package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
- package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +420 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -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 +363 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1628 -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/image_probe.test.mjs +243 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +324 -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 +325 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +297 -0
- package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +48 -0
- package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +387 -0
- package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
- package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
- package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
- package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
- package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
- 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 +168 -0
- package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -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 +411 -0
- package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
- package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -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-page-specgen/SKILL.md +136 -0
- package/skills/a2h-page-specgen/references/body-language.md +177 -0
- package/skills/a2h-page-specgen/references/evidence.md +70 -0
- package/skills/a2h-page-specgen/references/execution-model.md +255 -0
- package/skills/a2h-page-specgen/references/footprint-and-grouping.md +250 -0
- package/skills/a2h-page-specgen/references/gates.md +255 -0
- package/skills/a2h-page-specgen/references/page-inventory.md +173 -0
- package/skills/a2h-page-specgen/references/spec-template.md +207 -0
- package/skills/a2h-page-specgen/scripts/dispatch.mjs +209 -0
- package/skills/a2h-page-specgen/scripts/facts-build.mjs +1504 -0
- package/skills/a2h-page-specgen/scripts/finalize.mjs +422 -0
- package/skills/a2h-page-specgen/scripts/footprint.mjs +1528 -0
- package/skills/a2h-page-specgen/scripts/gate.mjs +558 -0
- package/skills/a2h-page-specgen/scripts/interactions.mjs +137 -0
- package/skills/a2h-page-specgen/scripts/inventory.mjs +269 -0
- package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +255 -0
- package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
- package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +137 -0
- package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
- package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
- package/skills/a2h-page-specgen/scripts/lib/hg.mjs +175 -0
- package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +355 -0
- package/skills/a2h-page-specgen/scripts/lib/prose.mjs +234 -0
- package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
- package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +391 -0
- package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
- package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
- package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
- package/skills/a2h-page-specgen/scripts/prepare.mjs +492 -0
- package/skills/a2h-page-specgen/scripts/render.mjs +317 -0
- package/skills/a2h-page-specgen/scripts/report.mjs +7 -0
- package/skills/a2h-page-specgen/scripts/submission.mjs +532 -0
- package/skills/a2h-page-specgen/scripts/submit.mjs +79 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +590 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
- package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +207 -0
- package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
- package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1164 -0
- package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +74 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +94 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +758 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
- package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
- package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +54 -0
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +222 -0
- package/skills/a2h-page-specgen/scripts/test/helpers.mjs +54 -0
- package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +171 -0
- package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +301 -0
- package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +45 -0
- package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +139 -0
- package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +774 -0
- package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
- package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1011 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +120 -0
- package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +68 -0
- package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +390 -0
- package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +167 -0
- package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
- package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +323 -0
- package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +546 -0
- package/skills/a2h-page-specgen/scripts/test/render.test.mjs +503 -0
- package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
- package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +701 -0
- package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
- package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
- package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1765 -0
- package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1979 -0
- package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +313 -0
- package/skills/a2h-page-specgen/scripts/waker.mjs +1234 -0
- package/skills/a2h-page-specgen/scripts/watchdog.mjs +298 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +49 -51
- 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-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +79 -78
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +51 -12
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +24 -6
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +3 -2
- package/skills/a2h-spec-design-pipeline/references/initialization.md +15 -4
- package/skills/a2h-spec-design-pipeline/references/merge-queue.md +82 -41
- package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +61 -0
- package/skills/a2h-spec-design-pipeline/references/scripts.md +19 -10
- package/skills/a2h-spec-design-pipeline/references/shared-layer.md +267 -0
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +61 -8
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +62 -13
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +8 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +8 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-cn.md +55 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-en.md +60 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/HttpExtraDataEmptyStringCheck.js +488 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +11 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +17 -0
- package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +40 -5
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +18 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +74 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +128 -5
- package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +98 -35
- package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +218 -37
- package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +6 -7
- package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
- package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +348 -0
- package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +15 -5
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +7 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +104 -1
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +24 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +394 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +24 -1
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +14 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +163 -5
- package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +15 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +350 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +121 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
- package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
- package/skills/a2h-spec-generate/SKILL.md +87 -21
- package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
- package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
- package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
- package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
- package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
- package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
- package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
- package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
- package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
- package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
- 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/fixtures/fusion-run.ts +243 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -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 +1253 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -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 +411 -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 +300 -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/test/zip.test.ts +61 -0
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
- package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
- package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
- package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
- package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
- package/skills/a2h-spec-generate/test/ensure-index.test.mjs +230 -0
- package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -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/prepare-facts.test.mjs +41 -0
- package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
- package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
- package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
- package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
- package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
- package/skills/a2h-utg-explorer/references/architecture.md +4 -0
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +64 -80
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
- package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
- package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
- package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
- package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
- package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
- package/skills/a2h-utg-explorer/scripts/tests/content_wait.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 +231 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -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 +137 -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/fresh_state_plan.test.mjs +78 -0
- package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
- package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
- package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
- package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +492 -0
- package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +199 -0
- package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -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 +327 -0
- package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
- package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
- package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -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 +280 -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 +454 -0
- package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
- package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
- package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
- package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
- package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
- package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
- package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
- package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -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/adapters.mjs +13 -3
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +107 -65
- package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +155 -0
- package/skills/a2h-utg-static/scripts/assemble.mjs +28 -3
- package/skills/a2h-utg-static/scripts/click_paths.mjs +19 -20
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +102 -2
- package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
- package/skills/a2h-utg-static/scripts/nl_hints.mjs +2 -3
- package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
- package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
- package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
- package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
- package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
- package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
- package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
- package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
- package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
- package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
- package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
- package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
- package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
|
@@ -0,0 +1,2120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* assemble.mjs — port of assemble.py: merge nodes.jsonl + edges.jsonl into the UTG deliverables.
|
|
4
|
+
*
|
|
5
|
+
* assemble.mjs <workspace> [--project P]
|
|
6
|
+
*
|
|
7
|
+
* Writes utg.json (node-link MultiDiGraph), utg.mermaid, utg.graphml.
|
|
8
|
+
*
|
|
9
|
+
* Exports:
|
|
10
|
+
* HERE _LOGIN_TEST_RE _FUN_DECL_RE load sid _SOURCE_CALLSITE _compressSourcePath slug _GUARD_KINDS
|
|
11
|
+
* normalizeGuard _inferGuardKind _INSTANCE_ROUTE_SUFFIXES _PAY_ROUTE_TOKENS _ENV_ROUTE_TOKENS
|
|
12
|
+
* _LOGIN_ROUTE_TOKENS _AUTH_ENTRY_ROUTE_TOKENS _isAuthEntryRoute _identWords _hasToken _cjk _CODE_NAME_TAIL_A _isCodeName _isScreenText
|
|
13
|
+
* _buildFnDeclarationIndex(-> Map name -> [path, offset]) _TOOLBAR_TAG_RE _XML_TITLE_ATTR_RE
|
|
14
|
+
* _XML_TEXT_ATTR_RE _STRING_REF_RE_A _resolveXmlString _findLayoutFiles(-> Map) _layoutTitle
|
|
15
|
+
* _viewOwnTitle _BARE_LAYOUT_TAGS _LAYOUT_HOST_TAGS _XML_TAG_RE _isBareContainerLayout
|
|
16
|
+
* _nodeLayoutPaths _TRANSPARENT_WRAPPERS _CONTAINER_COMPOSABLES _OWN_CHROME_RE _SET_CONTENT_RE
|
|
17
|
+
* _balancedBlock _sourceIndex _statementCalls _isBareComposeHost _isLauncherShell _foldUilessHosts
|
|
18
|
+
* _TIME_CALL_RE _TIME_CMP_RE _IF_HEAD _extractBalanced _pagerPositionZero DEFENSIVE_FILTER(get/set
|
|
19
|
+
* via setDefensiveFilter) _RANGES_CACHE _defensive _INTENT_TEST_RE _BUILD_CALL_RE _CONTENT_TEST_RE
|
|
20
|
+
* _enclosingFunName _FN_HEAD_RE _LEAVES_RE _fnBodyStart _fnDeclPos _fnBodyEnd _negateCond
|
|
21
|
+
* _earlyReturnConditions _enclosingIfConditions _CALLER_SCAN_MAX_FILES _CALLER_AGREE_MAX
|
|
22
|
+
* _KT_SRC_RE _CALLER_CACHE _projectSources _crossFileGate _disabledExpr _branchGuard _ROLE_KINDS
|
|
23
|
+
* _DECL_RE_TMPL _markOutOfScope _GETTER_CALL_RE _PREF_READ_RE _resolveAppSetting
|
|
24
|
+
* _promoteAppSettings mergeNodeRecords enrichNodesAndEdges _backfillFrameworkLabels
|
|
25
|
+
* _loadBaseStrings _stampLabelVariants _MENTION_TRIGGER_PREFIXES lintEdgeProvenance _parseArgs main
|
|
26
|
+
*
|
|
27
|
+
* Node/edge records are plain objects (Python dicts, insertion order kept via dset/keysOf).
|
|
28
|
+
* `nodes` passed between helpers is an object {id: node} (Python dict). `file_text_cache` is a
|
|
29
|
+
* Map (path -> text, plus the '__project__' / '__src__' sentinels). Text offsets are JS UTF-16
|
|
30
|
+
* internally; none are written to files.
|
|
31
|
+
*/
|
|
32
|
+
import * as fs from 'node:fs';
|
|
33
|
+
import * as path from 'node:path';
|
|
34
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
35
|
+
import {
|
|
36
|
+
pyRe, reSearch, reMatch, reFindall, reSub, reEscape, reFullmatch, jsonLoads, jsonDumps, get, dset, keysOf,
|
|
37
|
+
truthy, pyStrip, pyRstrip, pyRsplit, pySplit, cpLen, cpSlice, md5Hex, pyPrintErr, pyPrintBuf, pyPrint, sortedBy,
|
|
38
|
+
sortedStr, pyCmp, pyEq, pyIn, pyStr, pyRepr, counter, tupleKey, readText, writeText, splitlines,
|
|
39
|
+
pyStrSetOrder, pySetIter, deepCopy, isFloat, PyFloat, asFloat, floatRepr, time, IS_WIN, SP, W, WC, osRelpath,
|
|
40
|
+
} from './_py.mjs';
|
|
41
|
+
import { readTextSmart } from './io_utils.mjs';
|
|
42
|
+
import { decodeAndroidString, loadProjectStrings, pageOwnTitle } from './label_resolve.mjs';
|
|
43
|
+
import { allLayoutNames, declaresOwnLayout, _osWalk } from './layout_resolve.mjs';
|
|
44
|
+
import { fnRanges } from './scope_utils.mjs';
|
|
45
|
+
import { isDefensive } from './guard_subjects.mjs';
|
|
46
|
+
import { parse as parseExtras } from './launch_extras.mjs';
|
|
47
|
+
import { ActivityChain, HostResolver, buildClassIndex } from './host_resolve.mjs';
|
|
48
|
+
import { walkSources, manifestActivityNames } from './fragment_nav.mjs';
|
|
49
|
+
import { findLoginInterceptor, applyLoginInterceptor, loginPolarity, routeResolver } from './route_interceptor.mjs';
|
|
50
|
+
|
|
51
|
+
export const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
52
|
+
const SEP = IS_WIN ? '\\' : '/';
|
|
53
|
+
/** os.path.join(a, b) for a single relative segment. */
|
|
54
|
+
const osJoin = (a, b) => (a.endsWith('/') || a.endsWith(SEP) || a === '' ? a + b : a + SEP + b);
|
|
55
|
+
const osExists = (p) => { try { fs.statSync(p); return true; } catch { return false; } };
|
|
56
|
+
const osIsDir = (p) => { try { return fs.statSync(p).isDirectory(); } catch { return false; } };
|
|
57
|
+
const isObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) && !(v instanceof Map) && !(v instanceof Set);
|
|
58
|
+
/** isinstance(v, int) (bool counts, like Python). */
|
|
59
|
+
const isInt = (v) => typeof v === 'boolean' || typeof v === 'bigint' || (typeof v === 'number' && Number.isInteger(v) && !(v instanceof PyFloat));
|
|
60
|
+
/** str.isalnum() for one character. */
|
|
61
|
+
const isAlnumCh = (c) => /^[\p{L}\p{N}]$/u.test(c);
|
|
62
|
+
/** str.isupper() for one character. */
|
|
63
|
+
const isUpperCh = (c) => /^\p{Lu}$/u.test(c);
|
|
64
|
+
/** str.isupper() for a string: has a cased char and all cased chars upper. */
|
|
65
|
+
const strIsUpper = (s) => s !== s.toLowerCase() && s === s.toUpperCase();
|
|
66
|
+
/** Advance `n` code points from UTF-16 offset `pos` (Python text[pos:pos+n]). */
|
|
67
|
+
export function _cpFwd(text, pos, n) {
|
|
68
|
+
let i = pos; let k = 0;
|
|
69
|
+
while (i < text.length && k < n) { const c = text.charCodeAt(i); i += (c >= 0xd800 && c < 0xdc00 && i + 1 < text.length) ? 2 : 1; k++; }
|
|
70
|
+
return i;
|
|
71
|
+
}
|
|
72
|
+
/** Step back `n` code points from UTF-16 offset `pos` (max(0, pos-n) in Python). */
|
|
73
|
+
export function _cpBack(text, pos, n) {
|
|
74
|
+
let i = pos; let k = 0;
|
|
75
|
+
while (i > 0 && k < n) { const c = text.charCodeAt(i - 1); i -= (c >= 0xdc00 && c < 0xe000 && i - 2 >= 0) ? 2 : 1; k++; }
|
|
76
|
+
return i;
|
|
77
|
+
}
|
|
78
|
+
/** All matches of a global RegExp (finditer). */
|
|
79
|
+
function* finditer(re, s, pos = 0) {
|
|
80
|
+
const g = new RegExp(re.source, re.flags.includes('g') ? re.flags : re.flags + 'g');
|
|
81
|
+
g.lastIndex = pos; let m;
|
|
82
|
+
while ((m = g.exec(s)) !== null) { yield m; if (m[0] === '') { g.lastIndex++; } }
|
|
83
|
+
}
|
|
84
|
+
/** int(s) for a str (whitespace, sign, underscores), or null on ValueError. */
|
|
85
|
+
function pyIntOrNull(s) {
|
|
86
|
+
const t = pyStrip(String(s));
|
|
87
|
+
if (!/^[+-]?\d+(?:_\d+)*$/u.test(t)) { return null; }
|
|
88
|
+
return Number(t.replace(/_/g, ''));
|
|
89
|
+
}
|
|
90
|
+
/** os.path.isabs (CPython 3.13 on Windows: needs drive+root or UNC). */
|
|
91
|
+
export function pIsAbs(p) {
|
|
92
|
+
if (!IS_WIN) { return p.startsWith('/'); }
|
|
93
|
+
return /^[A-Za-z]:[\\/]/.test(p) || /^[\\/]{2}[^\\/]/.test(p);
|
|
94
|
+
}
|
|
95
|
+
const SKIP_WALK = ['build', '.git', 'test', 'androidTest'];
|
|
96
|
+
|
|
97
|
+
export const _LOGIN_TEST_RE = pyRe(
|
|
98
|
+
String.raw`\b(?:is|has|get|check)\w*(?:Login|LoggedIn|SignedIn|Session|Token|` +
|
|
99
|
+
String.raw`Account|Auth)\w*\s*\(|` +
|
|
100
|
+
String.raw`\b\w*(?:login|loggedIn|signedIn)\w*\s*(?:!=|==|<|>)\s*\w+|` +
|
|
101
|
+
// a bare login flag read as a property: `!appState.isLoggedIn.value` (StateFlow/LiveData),
|
|
102
|
+
// `if (isLogin)`. The whole identifier must be the flag: `isLoggedInRequired` is not one.
|
|
103
|
+
String.raw`\b_?(?:is|has)(?:logged|signed)in\b|\b_?islogin\b`, 'i');
|
|
104
|
+
// Rebound below (line 869 of the Python) — the later definition is the live one.
|
|
105
|
+
const _FUN_DECL_RE_EARLY = pyRe( // eslint-disable-line no-unused-vars
|
|
106
|
+
String.raw`(?:@\w+\s+)*(?:private\s+|internal\s+|public\s+|inline\s+)*` +
|
|
107
|
+
String.raw`fun\s+([A-Za-z_]\w*)\s*\(`);
|
|
108
|
+
|
|
109
|
+
/** Read a JSONL file into a list (missing file -> []). */
|
|
110
|
+
export function load(p) {
|
|
111
|
+
if (!osExists(p)) { return []; }
|
|
112
|
+
const out = [];
|
|
113
|
+
for (let ln of splitKeepLines(readText(p))) {
|
|
114
|
+
ln = pyStrip(ln);
|
|
115
|
+
if (ln) { out.push(jsonLoads(ln)); }
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
/** Python file iteration lines (universal newlines already applied by readText). */
|
|
120
|
+
function splitKeepLines(s) { return s.split('\n'); }
|
|
121
|
+
|
|
122
|
+
export function sid(s) {
|
|
123
|
+
let out = '';
|
|
124
|
+
for (const c of String(s)) { out += isAlnumCh(c) ? c : '_'; }
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const _SOURCE_CALLSITE = pyRe(
|
|
129
|
+
String.raw`^(?P<head>.*@)(?P<dirs>(?:[^@\s]*/)+)(?P<file>[^/@\s]+\.[A-Za-z0-9]+)(?P<line>:\d+)?$`);
|
|
130
|
+
|
|
131
|
+
export function _compressSourcePath(s) {
|
|
132
|
+
const m = reMatch(_SOURCE_CALLSITE, s);
|
|
133
|
+
if (!m) { return [s, false]; }
|
|
134
|
+
return [`${m.groups.head}${m.groups.file}${m.groups.line || ''}`, true];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function slug(nodeId) {
|
|
138
|
+
let s = pyStr(nodeId);
|
|
139
|
+
if (s.startsWith('activity:')) {
|
|
140
|
+
const parts = s.slice('activity:'.length).split('.');
|
|
141
|
+
return `activity_${parts[parts.length - 1]}`;
|
|
142
|
+
}
|
|
143
|
+
s = s.split('compose-route:').join('route_').split('overlay:').join('overlay_').split('mode:').join('mode_');
|
|
144
|
+
let lossy;
|
|
145
|
+
[s, lossy] = _compressSourcePath(s);
|
|
146
|
+
s = s.split('@').join('_at_');
|
|
147
|
+
for (const ch of '#:./\\ ') { s = s.split(ch).join('_'); }
|
|
148
|
+
if (cpLen(s) <= 80 && !lossy) { return s; }
|
|
149
|
+
const digest = md5Hex(Buffer.from(pyStr(nodeId), 'utf8')).slice(0, 8);
|
|
150
|
+
if (cpLen(s) + 9 <= 80) { return `${s}_${digest}`; }
|
|
151
|
+
return `${cpSlice(s, 0, 71)}_${digest}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const _GUARD_KINDS = [
|
|
155
|
+
[['scan', 'songs', 'library', 'empty', 'populated', 'scan', 'music library', '!= null', 'isnotempty', 'isempty', 'imported', 'content'], 'data-state'],
|
|
156
|
+
[['oauth', 'authorize', 'authorization', 'third party', 'third-party', 'access token'], 'oauth'],
|
|
157
|
+
[['login', 'login', 'sign in', 'register', 'signin', 'logged in', 'account', 'account', 'logged in'], 'login'],
|
|
158
|
+
[['payment', 'pay', 'payment', 'top up', 'vip', 'purchase', 'premium', 'subscription', 'subscribe', 'paid'], 'pay'],
|
|
159
|
+
[['baseurl', 'base_url', 'server', 'server', 'endpoint', 'host', 'webdav', 'smb', 'self-hosted', 'configure address'], 'server-config'],
|
|
160
|
+
[['role', 'default app', 'default sms', 'default dialer', 'assistant', 'rolemanager', 'inputmethod', 'input method',
|
|
161
|
+
'accessibility', 'accessibility', 'notification listener', 'default app', 'write_settings', 'device admin'], 'system-role'],
|
|
162
|
+
[['bluetooth', 'bluetooth', 'telephony', 'sensor', 'sensor', 'camera', 'camera', 'nfc', 'gps', 'location hardware'], 'hardware'],
|
|
163
|
+
[['network', 'connected', 'network', 'online', 'http', 'retrofit', 'okhttp', 'connectivity', 'no network'], 'network'],
|
|
164
|
+
[['flavor', 'build', 'google', 'flyme', 'meizu', 'channel', 'gplay'], 'build-flavor'],
|
|
165
|
+
[['device', 'device model', 'tablet', 'car', 'tablet', 'in-vehicle', 'usb', 'sdk'], 'device-env'],
|
|
166
|
+
[['currenttimemillis', 'time-window', 'expired', 'expired', 'seasonal'], 'time-window'],
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
export function normalizeGuard(guard) {
|
|
170
|
+
if (!truthy(guard)) { return null; }
|
|
171
|
+
if (isObj(guard)) {
|
|
172
|
+
const gg = {}; for (const k of keysOf(guard)) { dset(gg, k, guard[k]); }
|
|
173
|
+
if (!Object.hasOwn(gg, 'text')) { dset(gg, 'text', ''); }
|
|
174
|
+
if (!truthy(get(gg, 'kind'))) { dset(gg, 'kind', _inferGuardKind(get(gg, 'text', ''))); }
|
|
175
|
+
return gg;
|
|
176
|
+
}
|
|
177
|
+
const text = pyStr(guard);
|
|
178
|
+
return { text, kind: _inferGuardKind(text) };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Python str.lower() (JS toLowerCase is close enough; differs only for İ). */
|
|
182
|
+
const lower = (s) => s.toLowerCase();
|
|
183
|
+
|
|
184
|
+
export function _inferGuardKind(text) {
|
|
185
|
+
const low = lower(truthy(text) ? text : '');
|
|
186
|
+
for (const [terms, kind] of _GUARD_KINDS) {
|
|
187
|
+
if (terms.some((t) => low.includes(t))) { return kind; }
|
|
188
|
+
}
|
|
189
|
+
return 'condition';
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const _INSTANCE_ROUTE_SUFFIXES = ['_CONTENT', '_DETAIL', '_PATH', '_INFO'];
|
|
193
|
+
export const _PAY_ROUTE_TOKENS = ['PRO', 'PAY', 'PAYMENT', 'PAYWALL', 'ACTIVATE', 'PURCHASE', 'PREMIUM', 'VIP',
|
|
194
|
+
'DONATE', 'DONATION', 'SUBSCRIBE', 'SUBSCRIPTION'];
|
|
195
|
+
export const _ENV_ROUTE_TOKENS = ['GOOGLE_PLAY', 'GPLAY', 'FLYME', 'MEIZU', 'WINDOWS_PLATFORM'];
|
|
196
|
+
export const _LOGIN_ROUTE_TOKENS = ['LOGIN', 'REGISTER', 'SIGN_IN', 'SIGNIN', 'ACCOUNT'];
|
|
197
|
+
/** Auth-entry words: a route named this way IS the login / sign-up flow, shown to a logged-out user,
|
|
198
|
+
* so its in-edge guard is `logged-out` (a fresh install reaches it). `ACCOUNT` alone (`account_settings`)
|
|
199
|
+
* stays a needs-login page. Matched only as the name's LAST word (see _isAuthEntryRoute). */
|
|
200
|
+
export const _AUTH_ENTRY_ROUTE_TOKENS = ['LOGIN', 'REGISTER', 'SIGN_IN', 'SIGNIN'];
|
|
201
|
+
const _PAGE_SUFFIX_WORDS = new Set(['SCREEN', 'ROUTE', 'ACTIVITY', 'FRAGMENT', 'PAGE', 'VIEW']);
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Whether `routeKey` names the login / sign-up page itself: an auth-entry token must END the last
|
|
205
|
+
* dotted member, after dropping page suffixes (`Screen`, `Route`, `Activity`, …). `AccountLogin`,
|
|
206
|
+
* `SmsLoginScreen`, `AuthRoutes.Register` qualify; `LoginHistory`, `LoginDevices`, `ChangeLoginPassword`,
|
|
207
|
+
* `RegisterDevice`, `SignInCalendar` (daily check-in) do not — the word only qualifies what they are,
|
|
208
|
+
* and they need a logged-in user. A bare `DailySignIn` check-in page is indistinguishable by name.
|
|
209
|
+
*/
|
|
210
|
+
export function _isAuthEntryRoute(routeKey) {
|
|
211
|
+
const words = _identWords(pyStr(truthy(routeKey) ? routeKey : '').split('.').at(-1), true);
|
|
212
|
+
while (words.length > 1 && _PAGE_SUFFIX_WORDS.has(words.at(-1))) { words.pop(); }
|
|
213
|
+
return _AUTH_ENTRY_ROUTE_TOKENS.some((t) => {
|
|
214
|
+
const tw = _identWords(t, false);
|
|
215
|
+
return words.length >= tw.length && tw.every((w, j) => words[words.length - tw.length + j] === w);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Upper-cased words of an identifier: split on every non-alphanumeric run (snake_case, kebab-case,
|
|
221
|
+
* dots, slashes) and, unless `camel` is false, on camelCase/PascalCase humps (`VIPCenter` -> VIP, CENTER).
|
|
222
|
+
*/
|
|
223
|
+
export function _identWords(s, camel = true) {
|
|
224
|
+
let t = truthy(s) ? String(s) : '';
|
|
225
|
+
if (camel) { t = t.replace(/([a-z0-9])([A-Z])/g, '$1_$2').replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2'); }
|
|
226
|
+
return t.toUpperCase().split(/[^A-Z0-9]+/).filter((w) => w);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Whether `routeKey` contains one of `tokens` as WHOLE words (a multi-word token such as GOOGLE_PLAY
|
|
231
|
+
* matches consecutive words; a trailing plural `S` is tolerated). Substring hits do not count:
|
|
232
|
+
* `chinese_proverb` / `Profile` contain "PRO" but are not pay pages. A token written `_X` (an instance
|
|
233
|
+
* suffix like `_DETAIL`) must follow a real `_`/`-` separator inside the last dotted member (never a camel
|
|
234
|
+
* hump nor the first word), with no plural.
|
|
235
|
+
*/
|
|
236
|
+
export function _hasToken(routeKey, tokens) {
|
|
237
|
+
const camelWords = _identWords(routeKey, true);
|
|
238
|
+
// instance suffixes read the member only: a `Holder.` qualifier (`GoodsRoutes.Detail`) is not a `_DETAIL`
|
|
239
|
+
const sepWords = _identWords(pyStr(truthy(routeKey) ? routeKey : '').split('.').at(-1), false);
|
|
240
|
+
return tokens.some((t) => {
|
|
241
|
+
const suffix = t.startsWith('_');
|
|
242
|
+
const tw = _identWords(t, false);
|
|
243
|
+
const words = suffix ? sepWords : camelWords;
|
|
244
|
+
if (!tw.length) { return false; }
|
|
245
|
+
for (let i = suffix ? 1 : 0; i + tw.length <= words.length; i++) {
|
|
246
|
+
if (tw.every((w, j) => {
|
|
247
|
+
const x = words[i + j];
|
|
248
|
+
return x === w || (!suffix && j === tw.length - 1 && x === w + 'S');
|
|
249
|
+
})) { return true; }
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function _cjk(s) {
|
|
256
|
+
for (const c of (truthy(s) ? s : '')) { if (c >= '\u4e00' && c <= '\u9fff') { return true; } }
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export const _CODE_NAME_TAIL_A = pyRe('(Fragment|Activity|Screen|Dialog|Sheet|Menu)$');
|
|
261
|
+
|
|
262
|
+
export function _isCodeName(s) {
|
|
263
|
+
if (!truthy(s)) { return true; }
|
|
264
|
+
if (_cjk(s)) { return false; }
|
|
265
|
+
if (reSearch(_CODE_NAME_TAIL_A, s)) { return true; }
|
|
266
|
+
if (strIsUpper(s) || s.includes('_')) { return true; }
|
|
267
|
+
if (reMatch(pyRe(String.raw`^[A-Za-z]\w*$`), s) && [...s].slice(1).some(isUpperCh)) { return true; }
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function _isScreenText(s) {
|
|
272
|
+
if (!truthy(s) || cpLen(s) > 30) { return false; }
|
|
273
|
+
return _cjk(s) || !_isCodeName(s);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export const _FUN_DECL_RE = pyRe(String.raw`\bfun\s+(?:<[^>]*>\s*)?(?:[\w.]+\.)?(\w+)\s*\(`);
|
|
277
|
+
|
|
278
|
+
/** {fn_name: [absolute_file_path, decl_offset]} (Map) for every fun in the project. */
|
|
279
|
+
export function _buildFnDeclarationIndex(project) {
|
|
280
|
+
const index = new Map();
|
|
281
|
+
if (!truthy(project) || !osIsDir(project)) { return index; }
|
|
282
|
+
for (const [dirpath, dirs, files] of _osWalk(project)) {
|
|
283
|
+
const keep = dirs.filter((d) => !SKIP_WALK.includes(d));
|
|
284
|
+
dirs.length = 0; dirs.push(...keep);
|
|
285
|
+
for (const fn of files) {
|
|
286
|
+
if (!(fn.endsWith('.kt') || fn.endsWith('.java'))) { continue; }
|
|
287
|
+
const p = osJoin(dirpath, fn);
|
|
288
|
+
let text;
|
|
289
|
+
try { text = readTextSmart(p); } catch { continue; }
|
|
290
|
+
for (const m of finditer(_FUN_DECL_RE, text)) {
|
|
291
|
+
if (!index.has(m[1])) { index.set(m[1], [p, m.index]); }
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return index;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// --- View-based (non-Compose) page-title resolution ---------------------- //
|
|
299
|
+
export const _TOOLBAR_TAG_RE = pyRe(String.raw`<[\w.]*(?:Toolbar|AppBarLayout|ActionBar)\b[^>]*>`, 's');
|
|
300
|
+
export const _XML_TITLE_ATTR_RE = pyRe(String.raw`(?:app|android):title\s*=\s*"([^"]+)"`);
|
|
301
|
+
export const _XML_TEXT_ATTR_RE = pyRe(String.raw`android:text\s*=\s*"([^"]+)"`);
|
|
302
|
+
export const _STRING_REF_RE_A = pyRe(String.raw`^@string/(\w+)$`);
|
|
303
|
+
|
|
304
|
+
export function _resolveXmlString(val, strings) {
|
|
305
|
+
const m = reMatch(_STRING_REF_RE_A, pyStrip(truthy(val) ? val : ''));
|
|
306
|
+
if (m) { return get(strings, m[1]); }
|
|
307
|
+
if (truthy(val) && !val.startsWith('@') && !val.includes('%')) { return val; }
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** os.path.splitext(fn)[0] for a bare file name. */
|
|
312
|
+
function splitextStem(fn) {
|
|
313
|
+
const i = fn.lastIndexOf('.');
|
|
314
|
+
if (i <= 0) { return fn; }
|
|
315
|
+
let j = 0; while (j < fn.length && fn[j] === '.') { j++; }
|
|
316
|
+
return i < j ? fn : fn.slice(0, i);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** {layout_name: absolute_path} (Map) for every res/layout* xml. */
|
|
320
|
+
export function _findLayoutFiles(project) {
|
|
321
|
+
const out = new Map();
|
|
322
|
+
if (!truthy(project) || !osIsDir(project)) { return out; }
|
|
323
|
+
for (const [dirpath, dirs, files] of _osWalk(project)) {
|
|
324
|
+
const keep = dirs.filter((d) => !SKIP_WALK.includes(d));
|
|
325
|
+
dirs.length = 0; dirs.push(...keep);
|
|
326
|
+
const norm = dirpath.split('\\').join('/');
|
|
327
|
+
if (!norm.includes('/res/layout')) { continue; }
|
|
328
|
+
for (const fn of files) {
|
|
329
|
+
if (fn.endsWith('.xml')) {
|
|
330
|
+
const stem = splitextStem(fn);
|
|
331
|
+
if (!out.has(stem)) { out.set(stem, osJoin(dirpath, fn)); }
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return out;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function _layoutTitle(layoutPath, strings) {
|
|
339
|
+
let text;
|
|
340
|
+
try { text = readTextSmart(layoutPath); } catch { return null; }
|
|
341
|
+
const tm = reSearch(_TOOLBAR_TAG_RE, text);
|
|
342
|
+
if (tm) {
|
|
343
|
+
const window = text.slice(tm.index, _cpFwd(text, tm.index, 800));
|
|
344
|
+
const am = reSearch(_XML_TITLE_ATTR_RE, window);
|
|
345
|
+
if (am) { const v = _resolveXmlString(am[1], strings); if (truthy(v)) { return v; } }
|
|
346
|
+
const txt = reSearch(_XML_TEXT_ATTR_RE, window);
|
|
347
|
+
if (txt) { const v = _resolveXmlString(txt[1], strings); if (truthy(v)) { return v; } }
|
|
348
|
+
}
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Python `a or b`. */
|
|
353
|
+
const or0 = (a, b) => (truthy(a) ? a : b);
|
|
354
|
+
|
|
355
|
+
/** [path, text] of a node's declared_at source (cached in file_text_cache), or [null, null]. */
|
|
356
|
+
function _nodeSourceText(node, fileTextCache) {
|
|
357
|
+
const da = pyStr(or0(get(node, 'declared_at'), ''));
|
|
358
|
+
const srcRel = pySplit(da, ':', 1)[0];
|
|
359
|
+
if (!srcRel || !(srcRel.endsWith('.java') || srcRel.endsWith('.kt'))) { return [null, null]; }
|
|
360
|
+
const proj = fileTextCache.get('__project__');
|
|
361
|
+
if (!truthy(proj)) { return [null, null]; }
|
|
362
|
+
const cand = osJoin(proj, srcRel.split('/').join(SEP));
|
|
363
|
+
if (!osExists(cand)) { return [null, null]; }
|
|
364
|
+
let text = fileTextCache.has(cand) ? fileTextCache.get(cand) : null;
|
|
365
|
+
if (text === null || text === undefined) {
|
|
366
|
+
try { text = readTextSmart(cand); } catch { text = ''; }
|
|
367
|
+
fileTextCache.set(cand, text);
|
|
368
|
+
}
|
|
369
|
+
return [cand, text];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export function _viewOwnTitle(node, layouts, strings, fileTextCache) {
|
|
373
|
+
const [p, text] = _nodeSourceText(node, fileTextCache);
|
|
374
|
+
if (!p || !text) { return null; }
|
|
375
|
+
const seen = new Set();
|
|
376
|
+
for (const ln of allLayoutNames(text)) {
|
|
377
|
+
if (seen.has(ln)) { continue; }
|
|
378
|
+
seen.add(ln);
|
|
379
|
+
const lp = layouts.get(ln);
|
|
380
|
+
if (!lp) { continue; }
|
|
381
|
+
const t = _layoutTitle(lp, strings);
|
|
382
|
+
if (truthy(t)) { return t; }
|
|
383
|
+
}
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export const _BARE_LAYOUT_TAGS = new Set(['FrameLayout', 'FragmentContainerView', 'fragment',
|
|
388
|
+
'ConstraintLayout', 'LinearLayout', 'RelativeLayout', 'CoordinatorLayout', 'merge']);
|
|
389
|
+
export const _LAYOUT_HOST_TAGS = new Set(['FrameLayout', 'FragmentContainerView', 'fragment']);
|
|
390
|
+
export const _XML_TAG_RE = pyRe(String.raw`<([\w.]+)[\s/>]`);
|
|
391
|
+
|
|
392
|
+
export function _isBareContainerLayout(layoutPath) {
|
|
393
|
+
let text;
|
|
394
|
+
try { text = readTextSmart(layoutPath); } catch { return false; }
|
|
395
|
+
text = reSub(pyRe('<!--.*?-->', 's'), '', text);
|
|
396
|
+
const tags = reFindall(_XML_TAG_RE, text);
|
|
397
|
+
if (!tags.length) { return false; }
|
|
398
|
+
let sawHost = false;
|
|
399
|
+
for (const t of tags) {
|
|
400
|
+
const tail = pyRsplit(t, '.', 1).at(-1);
|
|
401
|
+
if (!_BARE_LAYOUT_TAGS.has(tail)) { return false; }
|
|
402
|
+
if (_LAYOUT_HOST_TAGS.has(tail)) { sawHost = true; }
|
|
403
|
+
}
|
|
404
|
+
return sawHost;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export function _nodeLayoutPaths(node, layouts, fileTextCache) {
|
|
408
|
+
const [p, text] = _nodeSourceText(node, fileTextCache);
|
|
409
|
+
if (!p || !text) { return []; }
|
|
410
|
+
const out = []; const seen = new Set();
|
|
411
|
+
for (const ln of allLayoutNames(text)) {
|
|
412
|
+
if (seen.has(ln)) { continue; }
|
|
413
|
+
seen.add(ln);
|
|
414
|
+
const lp = layouts.get(ln);
|
|
415
|
+
if (lp) { out.push(lp); }
|
|
416
|
+
}
|
|
417
|
+
return out;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export const _TRANSPARENT_WRAPPERS = new Set(['CompositionLocalProvider', 'MaterialTheme', 'AppTheme', 'Theme',
|
|
421
|
+
'BoxWithConstraints', 'Box', 'Surface', 'ProvideTextStyle', 'SharedTransitionLayout', 'KoinContext']);
|
|
422
|
+
export const _CONTAINER_COMPOSABLES = new Set(['NavHost', 'AnimatedNavHost', 'HorizontalPager', 'VerticalPager',
|
|
423
|
+
'Navigator', 'CurrentScreen', 'SlideTransition', 'FadeTransition']);
|
|
424
|
+
export const _OWN_CHROME_RE = pyRe(
|
|
425
|
+
String.raw`\b(?:TopAppBar|BottomAppBar|NavigationBar|BottomNavigation|` +
|
|
426
|
+
String.raw`ModalNavigationDrawer|PermanentNavigationDrawer|NavigationRail)\s*\(`);
|
|
427
|
+
export const _SET_CONTENT_RE = pyRe(String.raw`\bsetContent\s*(?:\([^)]*\))?\s*\{`);
|
|
428
|
+
|
|
429
|
+
export function _balancedBlock(text, bracePos) {
|
|
430
|
+
let depth = 0; let i = bracePos; const n = text.length;
|
|
431
|
+
while (i < n) {
|
|
432
|
+
const c = text[i];
|
|
433
|
+
if (c === '{') { depth++; } else if (c === '}') { depth--; if (depth === 0) { return text.slice(bracePos + 1, i); } }
|
|
434
|
+
i++;
|
|
435
|
+
}
|
|
436
|
+
return '';
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** {simple class name: source text} (Map) for .kt/.java, built once (cache key '__src__'). */
|
|
440
|
+
export function _sourceIndex(project, cache) {
|
|
441
|
+
if (cache.has('__src__')) { return cache.get('__src__'); }
|
|
442
|
+
const idx = new Map();
|
|
443
|
+
if (truthy(project)) {
|
|
444
|
+
for (const [dp, dirs, files] of _osWalk(project)) {
|
|
445
|
+
const keep = dirs.filter((d) => !SKIP_WALK.includes(d));
|
|
446
|
+
dirs.length = 0; dirs.push(...keep);
|
|
447
|
+
for (const fn of files) {
|
|
448
|
+
if (fn.endsWith('.kt') || fn.endsWith('.java')) {
|
|
449
|
+
const stem = pyRsplit(fn, '.', 1)[0];
|
|
450
|
+
if (idx.has(stem)) { continue; }
|
|
451
|
+
try { idx.set(stem, readText(osJoin(dp, fn), { errors: 'replace' })); } catch { /* OSError */ }
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
cache.set('__src__', idx);
|
|
457
|
+
return idx;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export function _statementCalls(body) {
|
|
461
|
+
const out = []; let depth = 0; let i = 0; const n = body.length;
|
|
462
|
+
const capRe = pyRe(String.raw`[A-Z]\w*`, 'y');
|
|
463
|
+
while (i < n) {
|
|
464
|
+
const c = body[i];
|
|
465
|
+
if (c === '(') { depth++; } else if (c === ')') { depth = Math.max(0, depth - 1); }
|
|
466
|
+
else if (depth === 0 && isUpperCh(c) && (i === 0 || !(isAlnumCh(body[i - 1]) || '_.'.includes(body[i - 1])))) {
|
|
467
|
+
capRe.lastIndex = i;
|
|
468
|
+
const m = capRe.exec(body);
|
|
469
|
+
if (m) {
|
|
470
|
+
let j = i + m[0].length;
|
|
471
|
+
while (j < n && ' \t\r\n'.includes(body[j])) { j++; }
|
|
472
|
+
if (j < n && '({'.includes(body[j])) { out.push(m[0]); }
|
|
473
|
+
i += m[0].length;
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
i++;
|
|
478
|
+
}
|
|
479
|
+
return out;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export function _isBareComposeHost(node, project, cache) {
|
|
483
|
+
let short = get(node, 'name');
|
|
484
|
+
if (!truthy(short)) { short = pyRsplit(pyStr(or0(get(node, 'fqn'), '')), '.', 1).at(-1); }
|
|
485
|
+
if (!truthy(short)) { short = pySplit(pyStr(or0(get(node, 'id'), '')), ':', 1).at(-1); }
|
|
486
|
+
const src = _sourceIndex(project, cache).get(or0(short, ''));
|
|
487
|
+
if (!truthy(src)) { return false; }
|
|
488
|
+
const m = reSearch(_SET_CONTENT_RE, src);
|
|
489
|
+
if (!m) { return false; }
|
|
490
|
+
const body = _balancedBlock(src, src.indexOf('{', m.index));
|
|
491
|
+
if (!body || reSearch(_OWN_CHROME_RE, body)) { return false; }
|
|
492
|
+
const calls = _statementCalls(body);
|
|
493
|
+
if (!calls.length) { return false; }
|
|
494
|
+
return calls.some((c) => !_TRANSPARENT_WRAPPERS.has(c));
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export function _isLauncherShell(n) {
|
|
498
|
+
if (truthy(get(n, 'is_launcher'))) { return true; }
|
|
499
|
+
const hint = get(n, 'launch_hint');
|
|
500
|
+
return !!(isObj(hint) && truthy(get(hint, 'is_launcher')));
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** Python setdefault on a plain object. */
|
|
504
|
+
function setdefault(o, k, v) { if (!Object.hasOwn(o, k)) { dset(o, k, v); } return o[k]; }
|
|
505
|
+
/** d.get(k) or {} as an object (Python `e.get("args") or {}`). */
|
|
506
|
+
const argsOf = (e) => { const a = get(e, 'args'); return truthy(a) ? a : {}; };
|
|
507
|
+
/** Remove key k from object (Python `del d[k]`, keeping KEY_ORDER coherent). */
|
|
508
|
+
function delKey(o, k) { delete o[k]; }
|
|
509
|
+
|
|
510
|
+
export function _foldUilessHosts(nodes, edges, layouts, fileTextCache, project = null) {
|
|
511
|
+
if (!truthy(project) && !truthy(layouts)) { return; }
|
|
512
|
+
const trace = truthy(process.env.UTG_FOLD_TRACE);
|
|
513
|
+
for (const nid of keysOf(nodes)) {
|
|
514
|
+
const n = get(nodes, nid);
|
|
515
|
+
if (!truthy(n) || !['activity', 'host-activity'].includes(get(n, 'kind'))) { continue; }
|
|
516
|
+
if (get(n, 'status') === 'unreachable') { continue; }
|
|
517
|
+
const bareView = _nodeLayoutPaths(n, layouts, fileTextCache).some((lp) => _isBareContainerLayout(lp));
|
|
518
|
+
const bareCompose = _isBareComposeHost(n, project, fileTextCache);
|
|
519
|
+
if (trace) {
|
|
520
|
+
pyPrintErr(`[fold] ${nid} kind=${pyStr(get(n, 'kind'))} status=${pyStr(get(n, 'status'))} ` +
|
|
521
|
+
`bare_view=${pyStr(bareView)} bare_compose=${pyStr(bareCompose)}`);
|
|
522
|
+
}
|
|
523
|
+
if (!(bareView || bareCompose)) { continue; }
|
|
524
|
+
const content = []; let entryEdge = null;
|
|
525
|
+
for (const e of edges) {
|
|
526
|
+
if (get(e, 'source') !== nid) { continue; }
|
|
527
|
+
const args = argsOf(e);
|
|
528
|
+
const mech = pyStr(get(e, 'mechanism', ''));
|
|
529
|
+
const trig = pyStr(or0(get(e, 'trigger'), ''));
|
|
530
|
+
const tnode = get(nodes, get(e, 'target'), {});
|
|
531
|
+
const kind = pyStr(get(tnode, 'kind', ''));
|
|
532
|
+
const isAuto = mech === 'fragment-transaction' && (get(args, 'via') === 'auto-load' || get(args, 'action') === 'default');
|
|
533
|
+
const isStartDest = mech.startsWith('compose-navigate') && trig.startsWith('startDestination@');
|
|
534
|
+
const isPager = mech === 'pager-swipe';
|
|
535
|
+
if (!(isAuto || isStartDest || isPager)) { continue; }
|
|
536
|
+
if (!['fragment', 'compose-route', 'compose-route-variant', 'pager-page', 'voyager-screen'].includes(kind)) { continue; }
|
|
537
|
+
content.push(e);
|
|
538
|
+
if (isAuto || isStartDest) {
|
|
539
|
+
if (truthy(get(e, 'guard'))) { continue; }
|
|
540
|
+
if (entryEdge !== null && entryEdge !== false && entryEdge !== e) { entryEdge = false; }
|
|
541
|
+
else if (entryEdge !== false) { entryEdge = e; }
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (trace) {
|
|
545
|
+
const ent = entryEdge === null ? 'None' : entryEdge === false ? 'False' : pyStr(get(entryEdge, 'target'));
|
|
546
|
+
pyPrintErr(`[fold] ${nid} content=${pyRepr(content.map((e) => get(e, 'target')))} entry=${ent}`);
|
|
547
|
+
}
|
|
548
|
+
if (!content.length) { continue; }
|
|
549
|
+
if (entryEdge === null || entryEdge === false) {
|
|
550
|
+
if (entryEdge === false) { continue; }
|
|
551
|
+
const _idx = (e) => {
|
|
552
|
+
const a = argsOf(e);
|
|
553
|
+
for (const k of ['pager_index', 'index', 'page_index']) { if (isInt(get(a, k))) { return get(a, k); } }
|
|
554
|
+
return null;
|
|
555
|
+
};
|
|
556
|
+
const pagers = content.filter((e) => get(e, 'mechanism') === 'pager-swipe' && _idx(e) !== null);
|
|
557
|
+
if (!pagers.length) { continue; }
|
|
558
|
+
let best = pagers[0];
|
|
559
|
+
for (const e of pagers.slice(1)) { if (pyCmp(_idx(e), _idx(best)) < 0) { best = e; } }
|
|
560
|
+
entryEdge = best;
|
|
561
|
+
}
|
|
562
|
+
const contentEdge = entryEdge;
|
|
563
|
+
const fid = get(contentEdge, 'target');
|
|
564
|
+
const f = get(nodes, fid);
|
|
565
|
+
if (f === null || f === undefined || fid === nid) { continue; }
|
|
566
|
+
const host = {};
|
|
567
|
+
for (const k of ['id', 'declared_at', 'exported', 'deep_links', 'launch_hint', 'is_launcher', 'fqn']) {
|
|
568
|
+
const v = get(n, k);
|
|
569
|
+
if (v !== null && v !== undefined) { dset(host, k, v); }
|
|
570
|
+
}
|
|
571
|
+
setdefault(host, 'id', nid);
|
|
572
|
+
dset(f, 'host_activity', host);
|
|
573
|
+
if (_isLauncherShell(n)) { dset(f, 'entry', true); }
|
|
574
|
+
const contentIds = new Set(content);
|
|
575
|
+
const rewired = [];
|
|
576
|
+
for (const e of edges) {
|
|
577
|
+
if (e === contentEdge) { continue; }
|
|
578
|
+
if (get(e, 'source') === nid) {
|
|
579
|
+
dset(e, 'source', fid);
|
|
580
|
+
if (contentIds.has(e)) { dset(setdefault(e, 'args', {}), 'via_host', nid); }
|
|
581
|
+
}
|
|
582
|
+
if (get(e, 'target') === nid) { dset(e, 'target', fid); }
|
|
583
|
+
if (pyEq(get(e, 'source'), get(e, 'target'))) { continue; }
|
|
584
|
+
rewired.push(e);
|
|
585
|
+
}
|
|
586
|
+
edges.length = 0; edges.push(...rewired);
|
|
587
|
+
delKey(nodes, nid);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* An entry page that leaves by itself and removes itself from the back stack (a splash whose
|
|
593
|
+
* ViewModel navigates from `init` with `popUpTo(self, inclusive)`) is never on screen once the
|
|
594
|
+
* app is ready: it can be converted from source but not captured. Stamp `transient: true` (the
|
|
595
|
+
* node stays in the denominator of the static graph; the explorer does not wait for a capture).
|
|
596
|
+
* Every out-edge must be non-gesture and close the source; one tap-driven edge keeps it a page.
|
|
597
|
+
*/
|
|
598
|
+
export function _markTransientEntries(nodes, edges) {
|
|
599
|
+
const NON_GESTURE = ['lifecycle', 'startDestination'];
|
|
600
|
+
for (const nid of keysOf(nodes)) {
|
|
601
|
+
const n = get(nodes, nid);
|
|
602
|
+
if (!truthy(n) || !truthy(get(n, 'entry'))) { continue; }
|
|
603
|
+
const out = edges.filter((e) => get(e, 'source') === nid && get(e, 'target') !== nid);
|
|
604
|
+
if (!out.length) { continue; }
|
|
605
|
+
const auto = out.every((e) => NON_GESTURE.includes(pyStr(or0(get(e, 'trigger'), '')).split('@')[0])
|
|
606
|
+
&& truthy(get(argsOf(e), 'closes_source')));
|
|
607
|
+
if (!auto) { continue; }
|
|
608
|
+
dset(n, 'transient', true);
|
|
609
|
+
dset(n, 'transient_evidence', out.map((e) => pyStr(get(e, 'trigger'))));
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export const _TIME_CALL_RE = pyRe(
|
|
614
|
+
String.raw`(?:System\.currentTimeMillis\(\)|Instant\.now\(\)\.toEpochMilli\(\)|` +
|
|
615
|
+
String.raw`Date\(\)\.getTime\(\)|System\.nanoTime\(\))`);
|
|
616
|
+
export const _TIME_CMP_RE = pyRe(
|
|
617
|
+
String.raw`(?:System\.currentTimeMillis\(\)|Instant\.now\(\)\.toEpochMilli\(\)|` +
|
|
618
|
+
String.raw`Date\(\)\.getTime\(\))\s*(<=?|>=?)\s*(\d{12,14})[Ll]?`);
|
|
619
|
+
export const _IF_HEAD = pyRe(String.raw`\bif\s*\(`);
|
|
620
|
+
|
|
621
|
+
export function _extractBalanced(text, start, openCh = '(', closeCh = ')', cap = 40000) {
|
|
622
|
+
if (start >= text.length || text[start] !== openCh) { return null; }
|
|
623
|
+
let depth = 0; let i = start; const end = Math.min(text.length, start + cap);
|
|
624
|
+
while (i < end) {
|
|
625
|
+
const c = text[i];
|
|
626
|
+
if (c === openCh) { depth++; } else if (c === closeCh) { depth--; if (depth === 0) { return text.slice(start + 1, i); } }
|
|
627
|
+
i++;
|
|
628
|
+
}
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export function _pagerPositionZero(edges, src, project, pagerFns) {
|
|
633
|
+
const sites = edges.filter((e) => e.source === src &&
|
|
634
|
+
pagerFns.some((f) => pyStr(get(argsOf(e), 'commit_scope', '')).endsWith(':' + f)));
|
|
635
|
+
if (!sites.length) { return null; }
|
|
636
|
+
const m = reSearch(pyRe('@(.+?):(\\d+)$'), pyStr(or0(get(sites[0], 'trigger'), '')));
|
|
637
|
+
if (!m) { return null; }
|
|
638
|
+
const p = osJoin(project, m[1].split('/').join(SEP));
|
|
639
|
+
let text;
|
|
640
|
+
try { text = readTextSmart(p); } catch { return null; }
|
|
641
|
+
const zero = new Set(reFindall(pyRe(String.raw`\b([A-Z][A-Z0-9_]*)\s*=\s*0\s*[;\n]`), text));
|
|
642
|
+
const targets = new Map();
|
|
643
|
+
for (const e of sites) { targets.set(pySplit(e.target, ':', 1).at(-1), e.target); }
|
|
644
|
+
const armRe = pyRe(String.raw`(?:\bcase\s+([\w.]+)\s*:|^\s*([\w.]+)\s*->)((?:.|\n)*?)(?=\bcase\b|^\s*[\w.]+\s*->|\bdefault\b|\belse\s*->|\Z)`, 'm');
|
|
645
|
+
for (const fn of pagerFns) {
|
|
646
|
+
for (const fm of finditer(pyRe(String.raw`\b` + fn + String.raw`\s*\([^)]*\)\s*(?::\s*\w+\s*)?\{`), text)) {
|
|
647
|
+
const fe = fm.index + fm[0].length;
|
|
648
|
+
const body = text.slice(fe, _cpFwd(text, fe, 3000));
|
|
649
|
+
for (const arm of finditer(armRe, body)) {
|
|
650
|
+
const label = (arm[1] || arm[2] || '').split('.').at(-1);
|
|
651
|
+
if (label !== '0' && !zero.has(label)) { continue; }
|
|
652
|
+
for (const [cls, ident] of targets) {
|
|
653
|
+
if (reSearch(pyRe(String.raw`\b` + reEscape(cls) + String.raw`\b`), arm[3])) { return ident; }
|
|
654
|
+
}
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// Demote defensive null tests (guard_subjects). A module flag so the corpus harness can
|
|
663
|
+
// compare verdicts with it off; always on in the pipeline.
|
|
664
|
+
export let DEFENSIVE_FILTER = true;
|
|
665
|
+
/** Set DEFENSIVE_FILTER (ESM bindings are read-only for importers). */
|
|
666
|
+
export function setDefensiveFilter(v) { DEFENSIVE_FILTER = !!v; }
|
|
667
|
+
export const _RANGES_CACHE = new Map();
|
|
668
|
+
|
|
669
|
+
export function _defensive(cond, text, pos, p) {
|
|
670
|
+
const key = tupleKey(p, text.length);
|
|
671
|
+
if (!_RANGES_CACHE.has(key)) { _RANGES_CACHE.set(key, fnRanges(text, p)); }
|
|
672
|
+
return isDefensive(cond, text, pos, _RANGES_CACHE.get(key));
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export const _INTENT_TEST_RE = pyRe(
|
|
676
|
+
String.raw`\b(?:getIntent\s*\(\s*\)|intent)\s*\.\s*(?:hasExtra|get\w*Extra|getAction|` +
|
|
677
|
+
String.raw`getData|getDataString|hasCategory|action|data)\b`);
|
|
678
|
+
export const _BUILD_CALL_RE = pyRe(
|
|
679
|
+
String.raw`\bBuildConfig\.\w+|\b(?:is|has)\w*(?:GooglePlay|Gplay|Fdroid|Flavor|` +
|
|
680
|
+
String.raw`Channel|Debug|Release|Pro|Premium)\w*\s*\(`);
|
|
681
|
+
export const _CONTENT_TEST_RE = pyRe(
|
|
682
|
+
String.raw`\b(?!on[A-Z])(\w+(?:\.\w+)*)\s*\.\s*(?:isNotEmpty|isEmpty)\b\s*(?:\(\s*\))?|` +
|
|
683
|
+
String.raw`\b(?!on[A-Z])(\w+(?:\.\w+)*)\s*\.\s*(?:size|count)\b\s*[<>=!]|` +
|
|
684
|
+
String.raw`\b(?!on[A-Z])(\w+(?:\.\w+)*)\s*(?:!=|==)\s*null`);
|
|
685
|
+
|
|
686
|
+
export function _enclosingFunName(text, pos) {
|
|
687
|
+
let name = null;
|
|
688
|
+
for (const m of finditer(_FUN_DECL_RE, text)) {
|
|
689
|
+
if (m.index > pos) { break; }
|
|
690
|
+
name = m[1];
|
|
691
|
+
}
|
|
692
|
+
return name;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
export const _FN_HEAD_RE = pyRe(
|
|
696
|
+
String.raw`(?:^|\n)[ \t]*(?:@\w+[ \t]*\n[ \t]*)*` +
|
|
697
|
+
String.raw`(?:public|private|protected|internal|final|static|override|suspend|fun|` +
|
|
698
|
+
String.raw`[\w<>\[\]., ?]+?)[ \t]+(\w+)[ \t]*\([^;{)]*\)[^;{]*\{`);
|
|
699
|
+
export const _LEAVES_RE = pyRe(String.raw`\b(?:return|throw)\b`);
|
|
700
|
+
|
|
701
|
+
export function _fnBodyStart(text, pos) {
|
|
702
|
+
let best = null;
|
|
703
|
+
for (const m of finditer(_FN_HEAD_RE, text)) {
|
|
704
|
+
if (m.index > pos) { break; }
|
|
705
|
+
const brace = text.indexOf('{', m.index + m[0].length - 1);
|
|
706
|
+
if (brace === -1) { continue; }
|
|
707
|
+
const body = _extractBalanced(text, brace, '{', '}');
|
|
708
|
+
if (body === null) { continue; }
|
|
709
|
+
const end = brace + 1 + body.length + 1;
|
|
710
|
+
if (brace < pos && pos < end) { best = brace + 1; }
|
|
711
|
+
}
|
|
712
|
+
return best;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export function _fnDeclPos(text, name) {
|
|
716
|
+
const hits = [...finditer(_FN_HEAD_RE, text)].filter((m) => m[1] === name);
|
|
717
|
+
return hits.length === 1 ? hits[0].index : null;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
export function _fnBodyEnd(text, bodyLo) {
|
|
721
|
+
const body = _extractBalanced(text, bodyLo - 1, '{', '}');
|
|
722
|
+
return body !== null ? bodyLo + body.length : bodyLo;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
export function _negateCond(cond) {
|
|
726
|
+
const c = pyStrip(cond);
|
|
727
|
+
if (c.startsWith('!') && !c.startsWith('!=')) {
|
|
728
|
+
let inner = pyStrip(c.slice(1));
|
|
729
|
+
if (inner.startsWith('(') && inner.endsWith(')')) { inner = pyStrip(inner.slice(1, -1)); }
|
|
730
|
+
return inner;
|
|
731
|
+
}
|
|
732
|
+
const m = reFullmatch(pyRe(String.raw`(.+?)\s*!=\s*(.+)`), c);
|
|
733
|
+
if (m) { return `${pyStrip(m[1])} == ${pyStrip(m[2])}`; }
|
|
734
|
+
return `not (${c})`;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/** Python text.rfind(sub, 0, end). */
|
|
738
|
+
const rfind0 = (text, sub, end) => (end <= 0 ? (sub === '' ? 0 : -1) : text.lastIndexOf(sub, end - sub.length));
|
|
739
|
+
/** " ".join(s.split()). */
|
|
740
|
+
const flatWs = (s) => pySplit(s).join(' ');
|
|
741
|
+
const _STMT_LEAVES_RE = pyRe(String.raw`\s*(?:return|throw)\b`);
|
|
742
|
+
const _ELSE_RE = pyRe(String.raw`\s*else\s*(\{)`);
|
|
743
|
+
|
|
744
|
+
export function _earlyReturnConditions(text, pos, limit = 6) {
|
|
745
|
+
const out = [];
|
|
746
|
+
const fnLo = _fnBodyStart(text, pos);
|
|
747
|
+
if (fnLo === null) { return out; }
|
|
748
|
+
for (const hm of finditer(_IF_HEAD, text, fnLo)) {
|
|
749
|
+
if (hm.index >= pos) { break; }
|
|
750
|
+
const paren = hm.index + hm[0].length - 1;
|
|
751
|
+
const cond = _extractBalanced(text, paren, '(', ')');
|
|
752
|
+
if (cond === null) { continue; }
|
|
753
|
+
const after = paren + 1 + cond.length + 1;
|
|
754
|
+
const seg = text.slice(after, _cpFwd(text, after, 160));
|
|
755
|
+
const bm = seg.indexOf('{');
|
|
756
|
+
if (bm === -1) {
|
|
757
|
+
const stmt = pySplit(seg, ';', 1)[0];
|
|
758
|
+
if (reMatch(_STMT_LEAVES_RE, stmt)) { out.push(_negateCond(pyStrip(cond))); }
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
const bodyStart = after + bm;
|
|
762
|
+
const body = _extractBalanced(text, bodyStart, '{', '}');
|
|
763
|
+
if (body === null) { continue; }
|
|
764
|
+
const bodyEnd = bodyStart + 1 + body.length + 1;
|
|
765
|
+
if (bodyEnd > pos) { continue; }
|
|
766
|
+
if (!reSearch(_LEAVES_RE, body)) { continue; }
|
|
767
|
+
out.push(_negateCond(pyStrip(cond)));
|
|
768
|
+
if (out.length >= limit) { break; }
|
|
769
|
+
}
|
|
770
|
+
return out;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
export function _enclosingIfConditions(text, pos, limit = 6) {
|
|
774
|
+
const out = [];
|
|
775
|
+
for (const hm of finditer(_IF_HEAD, text)) {
|
|
776
|
+
if (hm.index > pos) { break; }
|
|
777
|
+
const paren = hm.index + hm[0].length - 1;
|
|
778
|
+
const cond = _extractBalanced(text, paren, '(', ')');
|
|
779
|
+
if (cond === null) { continue; }
|
|
780
|
+
const after = paren + 1 + cond.length + 1;
|
|
781
|
+
const seg = text.slice(after, _cpFwd(text, after, 160));
|
|
782
|
+
const bm = seg.indexOf('{');
|
|
783
|
+
if (bm === -1) { continue; }
|
|
784
|
+
const bodyStart = after + bm;
|
|
785
|
+
const body = _extractBalanced(text, bodyStart, '{', '}');
|
|
786
|
+
if (body === null) { continue; }
|
|
787
|
+
const bodyEnd = bodyStart + 1 + body.length + 1;
|
|
788
|
+
if (bodyStart <= pos && pos < bodyEnd) { out.push(pyStrip(cond)); continue; }
|
|
789
|
+
const tail = text.slice(bodyEnd, _cpFwd(text, bodyEnd, 40));
|
|
790
|
+
const em = reMatch(_ELSE_RE, tail);
|
|
791
|
+
if (!em) { continue; }
|
|
792
|
+
const ebodyStart = bodyEnd + em[0].length - 1;
|
|
793
|
+
const ebody = _extractBalanced(text, ebodyStart, '{', '}');
|
|
794
|
+
if (ebody === null) { continue; }
|
|
795
|
+
if (ebodyStart <= pos && pos < ebodyStart + 1 + ebody.length + 1) { out.push('!(' + pyStrip(cond) + ')'); }
|
|
796
|
+
}
|
|
797
|
+
return out.slice(-limit);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
export const _CALLER_SCAN_MAX_FILES = 4000;
|
|
801
|
+
export const _CALLER_AGREE_MAX = 6;
|
|
802
|
+
export const _KT_SRC_RE = pyRe(String.raw`\.(?:kt|java)$`);
|
|
803
|
+
export const _CALLER_CACHE = new Map();
|
|
804
|
+
|
|
805
|
+
export function _projectSources(project) {
|
|
806
|
+
if (_CALLER_CACHE.has(project)) { return _CALLER_CACHE.get(project); }
|
|
807
|
+
const skip = new Set(['build', '.git', '.gradle', '.idea', 'node_modules', 'generated']);
|
|
808
|
+
const out = [];
|
|
809
|
+
for (const [dirpath, dirnames, filenames] of _osWalk(project)) {
|
|
810
|
+
const keep = dirnames.filter((d) => !skip.has(d));
|
|
811
|
+
dirnames.length = 0; dirnames.push(...keep);
|
|
812
|
+
for (const fn of filenames) {
|
|
813
|
+
if (reSearch(_KT_SRC_RE, fn)) {
|
|
814
|
+
out.push(osJoin(dirpath, fn));
|
|
815
|
+
if (out.length >= _CALLER_SCAN_MAX_FILES) { _CALLER_CACHE.set(project, out); return out; }
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
_CALLER_CACHE.set(project, out);
|
|
820
|
+
return out;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
export function _crossFileGate(fname, project) {
|
|
824
|
+
if (!truthy(fname) || !truthy(project)) { return []; }
|
|
825
|
+
const callRe = pyRe(String.raw`\b` + reEscape(fname) + String.raw`\s*\(`);
|
|
826
|
+
const declRe = pyRe(String.raw`\bfun\s+(?:<[^>]*>\s*)?(?:[\w.]+\.)?` + reEscape(fname) + String.raw`\s*\(`);
|
|
827
|
+
const found = [];
|
|
828
|
+
for (const p of _projectSources(project)) {
|
|
829
|
+
let txt;
|
|
830
|
+
try { txt = readTextSmart(p); } catch { continue; }
|
|
831
|
+
if (!txt || !txt.includes(fname)) { continue; }
|
|
832
|
+
for (const m of finditer(callRe, txt)) {
|
|
833
|
+
const lineStart = rfind0(txt, '\n', m.index) + 1;
|
|
834
|
+
if (reSearch(declRe, txt.slice(lineStart, m.index + m[0].length))) { continue; }
|
|
835
|
+
found.push([txt, m.index]);
|
|
836
|
+
if (found.length > _CALLER_AGREE_MAX) { return []; }
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (!found.length) { return []; }
|
|
840
|
+
const verdicts = new Set(); let first = null;
|
|
841
|
+
for (const [txt, at] of found) {
|
|
842
|
+
const conds = _enclosingIfConditions(txt, at);
|
|
843
|
+
let kind = null;
|
|
844
|
+
for (const cond of [...conds].reverse()) {
|
|
845
|
+
const flat = flatWs(cond);
|
|
846
|
+
if (reSearch(_BUILD_CALL_RE, flat)) { kind = 'build-flavor'; break; }
|
|
847
|
+
if (reSearch(_CONTENT_TEST_RE, flat)) { kind = 'data-state'; break; }
|
|
848
|
+
}
|
|
849
|
+
verdicts.add(kind);
|
|
850
|
+
if (first === null) { first = conds; }
|
|
851
|
+
}
|
|
852
|
+
if (verdicts.size !== 1 || verdicts.has(null)) { return []; }
|
|
853
|
+
return first;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
const _ENABLED_TOK_RE = pyRe(String.raw`[(){}\[\]]|\benabled\s*=\s*([^,\n]+)`);
|
|
857
|
+
const _IDENT_RE = pyRe(String.raw`\b([A-Za-z_]\w*)\b`);
|
|
858
|
+
|
|
859
|
+
export function _disabledExpr(text, pos) {
|
|
860
|
+
let depth = 0; let openAt = -1;
|
|
861
|
+
for (let i = pos - 1; i > Math.max(0, pos - 4000) - 1; i--) {
|
|
862
|
+
const c = text[i];
|
|
863
|
+
if (c === ')') { depth++; } else if (c === '(') {
|
|
864
|
+
if (depth === 0) { openAt = i; break; }
|
|
865
|
+
depth--;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
if (openAt < 0) { return ''; }
|
|
869
|
+
const args = _extractBalanced(text, openAt);
|
|
870
|
+
if (!truthy(args)) { return ''; }
|
|
871
|
+
let d = 0;
|
|
872
|
+
for (const m of finditer(_ENABLED_TOK_RE, args)) {
|
|
873
|
+
const tok = m[0];
|
|
874
|
+
if (m[1] !== undefined) {
|
|
875
|
+
if (d === 0) {
|
|
876
|
+
let expr = pyRstrip(pyStrip(m[1]), ',');
|
|
877
|
+
for (const nm of reFindall(_IDENT_RE, expr)) {
|
|
878
|
+
const am = reSearch(pyRe(String.raw`\bval\s+` + reEscape(nm) + String.raw`\s*(?::[^=\n]+)?=\s*([^\n]+)`), text);
|
|
879
|
+
if (am) { expr += ' || ' + pyStrip(am[1]); }
|
|
880
|
+
}
|
|
881
|
+
return expr;
|
|
882
|
+
}
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
d += '({['.includes(tok) ? 1 : -1;
|
|
886
|
+
}
|
|
887
|
+
return '';
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/** str.splitlines(True) (Python line boundaries). */
|
|
891
|
+
function splitlinesKeep(s) {
|
|
892
|
+
const out = []; const re = /\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
893
|
+
let last = 0; let m;
|
|
894
|
+
while ((m = re.exec(s)) !== null) { out.push(s.slice(last, m.index + m[0].length)); last = m.index + m[0].length; }
|
|
895
|
+
if (last < s.length) { out.push(s.slice(last)); }
|
|
896
|
+
return out;
|
|
897
|
+
}
|
|
898
|
+
const _TRIG_AT_RE = pyRe(String.raw`@(.+?):(\d+)$`);
|
|
899
|
+
const _FUN_LINE_RE = pyRe(String.raw`\s*(?:private\s+|internal\s+)?fun\b`);
|
|
900
|
+
/** Seconds since epoch -> 'YYYY-MM-DD' (time.strftime('%Y-%m-%d', time.gmtime(s))). */
|
|
901
|
+
const gmDate = (ms) => new Date(Math.floor(ms / 1000) * 1000).toISOString().slice(0, 10);
|
|
902
|
+
const head100 = (s) => cpSlice(s, 0, 100);
|
|
903
|
+
|
|
904
|
+
export function _branchGuard(edge, project) {
|
|
905
|
+
if (!truthy(project)) { return null; }
|
|
906
|
+
const trig = or0(get(edge, 'trigger'), '');
|
|
907
|
+
const m = reSearch(_TRIG_AT_RE, trig);
|
|
908
|
+
if (!m) { return null; }
|
|
909
|
+
const relPath = m[1]; const lineNo = Number(m[2]);
|
|
910
|
+
const hop = pyStr(or0(get(argsOf(edge), 'hop'), ''));
|
|
911
|
+
const hopFn = hop.startsWith('helper:') ? pyStrip(pySplit(hop, ':', 1)[1]) : '';
|
|
912
|
+
const p = osJoin(project, relPath.split('/').join(SEP));
|
|
913
|
+
let st; try { st = fs.statSync(p); } catch { st = null; }
|
|
914
|
+
if (!st || !st.isFile()) { return null; }
|
|
915
|
+
let text;
|
|
916
|
+
try { text = readTextSmart(p); } catch { return null; }
|
|
917
|
+
if (!text) { return null; }
|
|
918
|
+
const lines = splitlinesKeep(text);
|
|
919
|
+
if (lineNo > lines.length) { return null; }
|
|
920
|
+
let pos = 0;
|
|
921
|
+
for (const l of lines.slice(0, lineNo - 1)) { pos += l.length; }
|
|
922
|
+
let conds = _enclosingIfConditions(text, pos);
|
|
923
|
+
for (const cond of conds) {
|
|
924
|
+
const flat = flatWs(cond);
|
|
925
|
+
if (reSearch(_INTENT_TEST_RE, flat)) {
|
|
926
|
+
const guard = { text: `launch-intent:${head100(flat)}`, kind: 'device-env' };
|
|
927
|
+
const extras = parseExtras(flat, project);
|
|
928
|
+
if (truthy(extras)) { dset(guard, 'launch_extras', extras); }
|
|
929
|
+
return guard;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (!conds.length) {
|
|
933
|
+
const fname = _enclosingFunName(text, pos);
|
|
934
|
+
if (truthy(fname)) {
|
|
935
|
+
const sites = [...finditer(pyRe(String.raw`\b` + reEscape(fname) + String.raw`\s*\(`), text)]
|
|
936
|
+
.filter((mm) => !reMatch(_FUN_LINE_RE, text.slice(Math.max(0, rfind0(text, '\n', mm.index)), mm.index)))
|
|
937
|
+
.map((mm) => mm.index);
|
|
938
|
+
if (sites.length === 1) { conds = _enclosingIfConditions(text, sites[0]); }
|
|
939
|
+
else if (!sites.length) { conds = _crossFileGate(fname, project); }
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
conds = [...conds, ..._earlyReturnConditions(text, pos)];
|
|
943
|
+
if (hopFn && !conds.length) {
|
|
944
|
+
const hpos = _fnDeclPos(text, hopFn);
|
|
945
|
+
if (hpos !== null) {
|
|
946
|
+
const brace = text.indexOf('{', hpos);
|
|
947
|
+
if (brace !== -1) { conds = _earlyReturnConditions(text, _fnBodyEnd(text, brace + 1)); }
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
const dis = _disabledExpr(text, pos);
|
|
951
|
+
if (dis) { conds = [...conds, dis]; }
|
|
952
|
+
const nowMs = Math.trunc(time() * 1000);
|
|
953
|
+
for (const cond of conds) {
|
|
954
|
+
if (!reSearch(_TIME_CALL_RE, cond)) { continue; }
|
|
955
|
+
const cm = reSearch(_TIME_CMP_RE, cond);
|
|
956
|
+
if (!cm) { continue; }
|
|
957
|
+
const op = cm[1]; const bound = Number(cm[2]);
|
|
958
|
+
const openNow = op.startsWith('<') ? nowMs < bound : nowMs > bound;
|
|
959
|
+
if (openNow) { return null; }
|
|
960
|
+
const when = gmDate(bound);
|
|
961
|
+
return { text: `time-window closed ${when}: ${head100(flatWs(cond))}`, kind: 'time-window' };
|
|
962
|
+
}
|
|
963
|
+
for (const cond of [...conds].reverse()) {
|
|
964
|
+
if (reSearch(_TIME_CALL_RE, cond)) { continue; }
|
|
965
|
+
const flat = flatWs(cond);
|
|
966
|
+
if (reSearch(_BUILD_CALL_RE, flat)) { return { text: `branch:${head100(flat)}`, kind: 'build-flavor' }; }
|
|
967
|
+
if (reSearch(_CONTENT_TEST_RE, flat)) {
|
|
968
|
+
if (DEFENSIVE_FILTER && _defensive(flat, text, pos, p)) { continue; }
|
|
969
|
+
return { text: `branch:${head100(flat)}`, kind: 'data-state' };
|
|
970
|
+
}
|
|
971
|
+
if (reSearch(_LOGIN_TEST_RE, flat)) {
|
|
972
|
+
// `if (!isLoggedIn()) navigate(Login)` holds only while logged OUT — the state a fresh install
|
|
973
|
+
// is in — so it must not read as "needs login" (static_prior._axisOf drops it).
|
|
974
|
+
const guard = { text: `branch:${head100(flat)}`, kind: 'login' };
|
|
975
|
+
if (loginPolarity(flat, _LOGIN_TEST_RE) === 'logged-out') { dset(guard, 'polarity', 'logged-out'); }
|
|
976
|
+
return guard;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return null;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
export const _ROLE_KINDS = new Set(['pager-page']);
|
|
983
|
+
export const _DECL_RE_TMPL = String.raw`\b(?:class|interface|object|enum)\s+%s\b`;
|
|
984
|
+
|
|
985
|
+
/** {**a, **b, ...}: Python dict-merge order (first-seen key position, last value). */
|
|
986
|
+
function merge(...objs) {
|
|
987
|
+
const o = {};
|
|
988
|
+
for (const x of objs) { for (const k of keysOf(x)) { dset(o, k, x[k]); } }
|
|
989
|
+
return o;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
export function _markOutOfScope(nodes, edges, project) {
|
|
993
|
+
for (const n of Object.values(nodes)) {
|
|
994
|
+
if (get(n, 'denominator') === false) { continue; }
|
|
995
|
+
const hint = isObj(get(n, 'launch_hint')) ? get(n, 'launch_hint') : {};
|
|
996
|
+
const surface = or0(get(n, 'surface'), get(hint, 'surface'));
|
|
997
|
+
if (truthy(surface)) {
|
|
998
|
+
dset(n, 'denominator', false);
|
|
999
|
+
dset(n, 'out_of_scope', 'external-surface:' + (Array.isArray(surface) ? surface[0] : pyStr(surface)));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
if (!truthy(project)) { return; }
|
|
1003
|
+
const sources = new Map();
|
|
1004
|
+
for (const p of _projectSources(project)) {
|
|
1005
|
+
try { sources.set(p, readTextSmart(p)); } catch { /* OSError */ }
|
|
1006
|
+
}
|
|
1007
|
+
const blob = [...sources.values()].join('\n');
|
|
1008
|
+
const declared = (name) => reSearch(pyRe(_DECL_RE_TMPL.replace('%s', reEscape(name))), blob) !== null;
|
|
1009
|
+
const nodeOrder = keysOf(nodes);
|
|
1010
|
+
for (const nid of nodeOrder) {
|
|
1011
|
+
const n = nodes[nid];
|
|
1012
|
+
if (get(n, 'denominator') === false) { continue; }
|
|
1013
|
+
if (!['dialog', 'overlay'].includes(get(n, 'kind')) || get(n, 'provenance') !== 'static:llm') { continue; }
|
|
1014
|
+
const own = pySplit(pySplit(nid, ':', 1).at(-1), '@', 1)[0];
|
|
1015
|
+
if (!reFullmatch(pyRe(String.raw`[A-Za-z_]\w*`), own) || declared(own)) { continue; }
|
|
1016
|
+
const at = pyStr(or0(get(n, 'declared_at'), ''));
|
|
1017
|
+
const m = reMatch(pyRe(String.raw`(.+?):(\d+)$`), at);
|
|
1018
|
+
if (!m) { continue; }
|
|
1019
|
+
const p = osJoin(project, m[1]);
|
|
1020
|
+
let text = sources.has(p) ? sources.get(p) : null;
|
|
1021
|
+
if (text === null) {
|
|
1022
|
+
try { text = readTextSmart(p); } catch { continue; }
|
|
1023
|
+
}
|
|
1024
|
+
const lines = splitlines(text);
|
|
1025
|
+
const i = Number(m[2]) - 1;
|
|
1026
|
+
const window = (i >= 0 && i < lines.length) ? lines.slice(Math.max(0, i), i + 2).join(' ') : '';
|
|
1027
|
+
if (reSearch(pyRe(String.raw`\b` + reEscape(own) + String.raw`\s*\(`), window) &&
|
|
1028
|
+
reSearch(pyRe(String.raw`\b(?:private|public|protected|static|fun|override|suspend)\b`), window) &&
|
|
1029
|
+
!reSearch(pyRe(String.raw`\b(?:show|Builder|Dialog)\b`), window)) {
|
|
1030
|
+
dset(n, 'denominator', false);
|
|
1031
|
+
dset(n, 'out_of_scope', 'pseudo-page: declared_at is method ' + own + '()');
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
for (const nid of nodeOrder) {
|
|
1035
|
+
const n = nodes[nid];
|
|
1036
|
+
if (get(n, 'denominator') === false || !['dialog', 'fragment'].includes(get(n, 'kind'))) { continue; }
|
|
1037
|
+
const simple = pySplit(nid, ':', 1).at(-1);
|
|
1038
|
+
if (!reFullmatch(pyRe(String.raw`[A-Z]\w*`), simple)) { continue; }
|
|
1039
|
+
const q = reEscape(simple);
|
|
1040
|
+
const sub = reSearch(pyRe(String.raw`\b(?:extends\s+|:\s*)` + q + String.raw`\s*[({]` +
|
|
1041
|
+
String.raw`|\bextends\s+` + q + String.raw`\b`), blob);
|
|
1042
|
+
if (!sub) { continue; }
|
|
1043
|
+
if (reSearch(pyRe(`\\bnew\\s+${q}\\s*[(<]|\\b${q}\\s*\\.\\s*(?:newInstance|Companion)\\b|\\b${q}::class|\\b${q}\\.class\\b`), blob)) { continue; }
|
|
1044
|
+
let ktBuilt = false;
|
|
1045
|
+
const beforeRe = pyRe(String.raw`(?::|extends|class|fun|public|private|protected|super)\s*$`);
|
|
1046
|
+
for (const mm of finditer(pyRe(String.raw`\b` + q + String.raw`\s*\(`), blob)) {
|
|
1047
|
+
const before = blob.slice(_cpBack(blob, mm.index, 24), mm.index);
|
|
1048
|
+
if (reSearch(beforeRe, before)) { continue; }
|
|
1049
|
+
ktBuilt = true; break;
|
|
1050
|
+
}
|
|
1051
|
+
if (ktBuilt) { continue; }
|
|
1052
|
+
dset(n, 'denominator', false);
|
|
1053
|
+
dset(n, 'out_of_scope', 'base-only: ' + simple + ' is only subclassed, never shown itself');
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
const _GETTER_CALL_SRC = String.raw`(?:\b([A-Z]\w*)\.)?\b(\w+)\s*\(\s*\)`;
|
|
1058
|
+
export const _GETTER_CALL_RE = pyRe(_GETTER_CALL_SRC);
|
|
1059
|
+
export const _PREF_READ_RE = String.raw`\bget(Boolean|String|Int|Long)\s*\(\s*([\w.]+|\"[^\"]+\")\s*,\s*([^)]*)\)`;
|
|
1060
|
+
|
|
1061
|
+
export function _resolveAppSetting(cond, need, project, nodes) {
|
|
1062
|
+
const m = reFullmatch(pyRe(String.raw`\s*(!?)\s*` + _GETTER_CALL_SRC + String.raw`\s*`), pyStr(or0(cond, '')));
|
|
1063
|
+
if (!m || !truthy(project)) { return null; }
|
|
1064
|
+
const negated = m[1] === '!'; const owner = m[2] ?? null; const getter = m[3];
|
|
1065
|
+
const want = negated ? !truthy(need) : truthy(need);
|
|
1066
|
+
const bodies = [];
|
|
1067
|
+
for (const p of _projectSources(project)) {
|
|
1068
|
+
const fwd = p.split('\\').join('/');
|
|
1069
|
+
if (owner && !fwd.endsWith('/' + owner + '.java') && !fwd.endsWith('/' + owner + '.kt')) { continue; }
|
|
1070
|
+
let text;
|
|
1071
|
+
try { text = readTextSmart(p); } catch { continue; }
|
|
1072
|
+
for (const fm of finditer(pyRe(String.raw`\b` + reEscape(getter) + String.raw`\s*\(\s*\)\s*(?::\s*\w+\s*)?\{`), text)) {
|
|
1073
|
+
const fe = fm.index + fm[0].length;
|
|
1074
|
+
const end = text.indexOf('}', fe);
|
|
1075
|
+
bodies.push([text, end === -1 ? text.slice(fe, -1) : text.slice(fe, end)]);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
if (bodies.length !== 1) { return null; }
|
|
1079
|
+
const [text, body] = bodies[0];
|
|
1080
|
+
const rm = reFullmatch(pyRe(String.raw`\s*return\s+\w+\s*\.\s*` + _PREF_READ_RE + String.raw`\s*;?\s*`), body);
|
|
1081
|
+
if (!rm || rm[1] !== 'Boolean') { return null; }
|
|
1082
|
+
let key = rm[2];
|
|
1083
|
+
if (!key.startsWith('"')) {
|
|
1084
|
+
const km = reSearch(pyRe(String.raw`\b` + reEscape(key.split('.').at(-1)) + String.raw`\s*=\s*\"([^\"]+)\"`), text);
|
|
1085
|
+
if (!km) { return null; }
|
|
1086
|
+
key = km[1];
|
|
1087
|
+
}
|
|
1088
|
+
key = pyStrip(key, '"');
|
|
1089
|
+
const rows = [];
|
|
1090
|
+
const keyRe = pyRe(String.raw`android:key\s*=\s*\"` + reEscape(key) + String.raw`\"`);
|
|
1091
|
+
for (const [dirpath, dirs, files] of _osWalk(project)) {
|
|
1092
|
+
const keep = dirs.filter((d) => !['build', '.git', '.gradle'].includes(d));
|
|
1093
|
+
dirs.length = 0; dirs.push(...keep);
|
|
1094
|
+
if (!dirpath.split('\\').join('/').endsWith('/res/xml')) { continue; }
|
|
1095
|
+
for (const fn of files) {
|
|
1096
|
+
if (!fn.endsWith('.xml')) { continue; }
|
|
1097
|
+
let xml;
|
|
1098
|
+
try { xml = readTextSmart(osJoin(dirpath, fn)); } catch { continue; }
|
|
1099
|
+
for (const el of finditer(pyRe(String.raw`<([\w.]*(?:Switch|CheckBox)\w*)\b([^>]*?)/?>`, 's'), xml)) {
|
|
1100
|
+
if (reSearch(keyRe, el[2])) {
|
|
1101
|
+
const title = reSearch(pyRe(String.raw`android:title\s*=\s*\"([^\"]+)\"`), el[2]);
|
|
1102
|
+
const dflt = reSearch(pyRe(String.raw`android:defaultValue\s*=\s*\"(\w+)\"`), el[2]);
|
|
1103
|
+
rows.push([cpSlice(fn, 0, -4), title ? title[1] : null, dflt ? dflt[1] : null]);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
if (rows.length !== 1 || !truthy(rows[0][1])) { return null; }
|
|
1109
|
+
const [xmlName, titleRef, dflt] = rows[0];
|
|
1110
|
+
const hosts = [];
|
|
1111
|
+
const hostRe = pyRe(String.raw`PreferencesFromResource\s*\(\s*R\.xml\.` + reEscape(xmlName) + String.raw`\b`);
|
|
1112
|
+
for (const p of _projectSources(project)) {
|
|
1113
|
+
let t;
|
|
1114
|
+
try { t = readTextSmart(p); } catch { continue; }
|
|
1115
|
+
if (reSearch(hostRe, t)) {
|
|
1116
|
+
const cls = reSearch(pyRe(String.raw`\bclass\s+([A-Z]\w*)`), t);
|
|
1117
|
+
if (cls) { hosts.push(cls[1]); }
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
const screen = keysOf(nodes).filter((nid) => hosts.includes(pySplit(nid, ':', 1).at(-1)));
|
|
1121
|
+
if (screen.length !== 1) { return null; }
|
|
1122
|
+
const isStr = titleRef.startsWith('@string/');
|
|
1123
|
+
const strings = isStr ? loadProjectStrings(project) : {};
|
|
1124
|
+
const title = isStr ? get(strings, pySplit(titleRef, '/', 1)[1]) : titleRef;
|
|
1125
|
+
return { kind: 'app-setting', pref_key: key, value: want, control: 'toggle', row_title: title,
|
|
1126
|
+
row_title_key: titleRef, screen: screen[0], default: dflt,
|
|
1127
|
+
basis: [`${owner || ''}.${getter}()`, `res/xml/${xmlName}.xml#${key}`] };
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
export function _promoteAppSettings(nodes, edges, project) {
|
|
1131
|
+
for (const e of edges) {
|
|
1132
|
+
const g = get(e, 'guard');
|
|
1133
|
+
if (!isObj(g) || get(g, 'kind') !== 'device-env' || !Object.hasOwn(g, 'condition')) { continue; }
|
|
1134
|
+
const facts = _resolveAppSetting(g.condition, get(g, 'need', true), project, nodes);
|
|
1135
|
+
if (truthy(facts)) { dset(e, 'guard', merge(facts, { text: get(g, 'text', '') })); }
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
export function mergeNodeRecords(prev, cur, collisions = null) {
|
|
1140
|
+
if (!truthy(prev)) { return cur; }
|
|
1141
|
+
const pk = pyStr(get(prev, 'kind', '')); const ck = pyStr(get(cur, 'kind', ''));
|
|
1142
|
+
if (pk === ck || !pk || !ck) { return merge(prev, cur); }
|
|
1143
|
+
let role = null; let ident = null;
|
|
1144
|
+
if (_ROLE_KINDS.has(pk) && !_ROLE_KINDS.has(ck)) { role = prev; ident = cur; }
|
|
1145
|
+
else if (_ROLE_KINDS.has(ck) && !_ROLE_KINDS.has(pk)) { role = cur; ident = prev; }
|
|
1146
|
+
if (role !== null) {
|
|
1147
|
+
const merged = merge(role, ident);
|
|
1148
|
+
dset(merged, 'kind', ident.kind);
|
|
1149
|
+
dset(merged, 'pager_child', true);
|
|
1150
|
+
if (truthy(get(role, 'declared_at'))) { dset(merged, 'pager_declared_at', role.declared_at); }
|
|
1151
|
+
if (collisions !== null) {
|
|
1152
|
+
collisions.push([pyStr(get(cur, 'id', '')), `${pyStr(role.kind)}+${pyStr(ident.kind)}`, 'role folded to attribute']);
|
|
1153
|
+
}
|
|
1154
|
+
return merged;
|
|
1155
|
+
}
|
|
1156
|
+
if (collisions !== null) { collisions.push([pyStr(get(cur, 'id', '')), `${pk}+${ck}`, 'UNRESOLVED']); }
|
|
1157
|
+
return merge(cur, prev);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/** Python str(x).partition(sep). */
|
|
1161
|
+
function partition(s, sep) {
|
|
1162
|
+
const i = s.indexOf(sep);
|
|
1163
|
+
return i < 0 ? [s, '', ''] : [s.slice(0, i), sep, s.slice(i + sep.length)];
|
|
1164
|
+
}
|
|
1165
|
+
/** os.path.splitext(os.path.basename(p))[0] (Windows: both separators). */
|
|
1166
|
+
function baseStem(p) {
|
|
1167
|
+
const parts = p.split(IS_WIN ? /[\\/]/ : /\//);
|
|
1168
|
+
let b = parts.at(-1);
|
|
1169
|
+
if (IS_WIN && /^[A-Za-z]:/.test(b) && parts.length === 1) { b = b.slice(2); }
|
|
1170
|
+
return splitextStem(b);
|
|
1171
|
+
}
|
|
1172
|
+
const startsWithAny = (s, prefixes) => prefixes.some((p) => s.startsWith(p));
|
|
1173
|
+
const _PAGE_CLASS_RE = pyRe('[A-Z][A-Za-z0-9]*');
|
|
1174
|
+
const _SETCONTENT_ANY_RE = pyRe(String.raw`\b(?:setContentView|setContent)\s*[({]`);
|
|
1175
|
+
|
|
1176
|
+
export function enrichNodesAndEdges(nodes, edges, project = null, strings = null) {
|
|
1177
|
+
const _fileTextCache = new Map();
|
|
1178
|
+
const _layouts = truthy(project) ? _findLayoutFiles(project) : new Map();
|
|
1179
|
+
if (truthy(project)) { _fileTextCache.set('__project__', project); }
|
|
1180
|
+
|
|
1181
|
+
// --- 0. cross-extractor node alias merge (ONE class = ONE node) ----------
|
|
1182
|
+
const _aliasGroups = new Map();
|
|
1183
|
+
for (const nid of keysOf(nodes)) {
|
|
1184
|
+
const n = nodes[nid];
|
|
1185
|
+
const [prefix, , rest] = partition(pyStr(nid), ':');
|
|
1186
|
+
if (!['fragment', 'dialog', 'overlay'].includes(prefix) || !rest) { continue; }
|
|
1187
|
+
const simple = rest.split('@')[0];
|
|
1188
|
+
if (!reFullmatch(_PAGE_CLASS_RE, simple)) { continue; }
|
|
1189
|
+
const k = tupleKey(simple, pyStr(get(n, 'kind')));
|
|
1190
|
+
if (!_aliasGroups.has(k)) { _aliasGroups.set(k, [simple, []]); }
|
|
1191
|
+
_aliasGroups.get(k)[1].push(nid);
|
|
1192
|
+
}
|
|
1193
|
+
const _aliasOf = new Map();
|
|
1194
|
+
for (const [simple, ids] of _aliasGroups.values()) {
|
|
1195
|
+
if (ids.length < 2) { continue; }
|
|
1196
|
+
const _declFile = (i) => pyRsplit(pyStr(or0(get(nodes[i], 'declared_at'), '')), ':', 1)[0];
|
|
1197
|
+
const own = ids.filter((i) => baseStem(_declFile(i)) === simple);
|
|
1198
|
+
const files = new Set(ids.map(_declFile));
|
|
1199
|
+
let canon;
|
|
1200
|
+
if (own.length) {
|
|
1201
|
+
const _rank = { fragment: 0, dialog: 1, overlay: 2 };
|
|
1202
|
+
canon = sortedBy(own, (i) => get(_rank, pyStr(i).split(':')[0], 9))[0];
|
|
1203
|
+
} else if (files.size === 1) {
|
|
1204
|
+
canon = sortedStr(ids)[0];
|
|
1205
|
+
} else { continue; }
|
|
1206
|
+
for (const i of ids) { if (i !== canon) { _aliasOf.set(i, canon); } }
|
|
1207
|
+
}
|
|
1208
|
+
if (_aliasOf.size) {
|
|
1209
|
+
for (const e of edges) {
|
|
1210
|
+
for (const end of ['source', 'target']) {
|
|
1211
|
+
if (_aliasOf.has(get(e, end))) { dset(e, end, _aliasOf.get(e[end])); }
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
for (const [dup, canon] of _aliasOf) {
|
|
1215
|
+
for (const k of keysOf(nodes[dup])) {
|
|
1216
|
+
const v = nodes[dup][k];
|
|
1217
|
+
if (k !== 'id' && k !== 'kind' && !truthy(get(nodes[canon], k)) && truthy(v)) { dset(nodes[canon], k, v); }
|
|
1218
|
+
}
|
|
1219
|
+
delete nodes[dup];
|
|
1220
|
+
}
|
|
1221
|
+
const al = sortedStr(_aliasOf.keys());
|
|
1222
|
+
pyPrintErr(`[assemble] merged ${_aliasOf.size} duplicate node(s) emitted for the ` +
|
|
1223
|
+
`same class under different id prefixes (edges re-pointed): ` +
|
|
1224
|
+
`${pyRepr(al.slice(0, 8))}${_aliasOf.size > 8 ? ' …' : ''}`);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// --- 1. host-activity downgrade -----------------------------------------
|
|
1228
|
+
const _CONTENT_MECHANISMS = ['fragment-transaction', 'fragment-embed', 'compose-navigate',
|
|
1229
|
+
'compose-navigate-param', 'nav-component-action', 'voyager-push', 'view-swap'];
|
|
1230
|
+
const _CONTENT_KINDS = ['compose-route', 'fragment', 'voyager-screen', 'view-page'];
|
|
1231
|
+
const _hosted = new Map();
|
|
1232
|
+
for (const e of edges) {
|
|
1233
|
+
const src = get(e, 'source'); const tgt = get(e, 'target');
|
|
1234
|
+
if (!pyIn(src, nodes) || !pyIn(tgt, nodes) || src === tgt) { continue; }
|
|
1235
|
+
if (pyStr(get(nodes[src], 'kind', '')) !== 'activity') { continue; }
|
|
1236
|
+
if (!_CONTENT_MECHANISMS.includes(get(e, 'mechanism'))) { continue; }
|
|
1237
|
+
if (startsWithAny(pyStr(get(nodes[tgt], 'kind', '')), _CONTENT_KINDS)) {
|
|
1238
|
+
if (!_hosted.has(src)) { _hosted.set(src, new Set()); }
|
|
1239
|
+
_hosted.get(src).add(tgt);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
for (const nid of keysOf(nodes)) {
|
|
1243
|
+
const n = nodes[nid];
|
|
1244
|
+
if (get(n, 'kind') !== 'activity') { continue; }
|
|
1245
|
+
if ((_hosted.get(nid)?.size ?? 0) >= 3) {
|
|
1246
|
+
dset(n, 'kind', 'host-activity');
|
|
1247
|
+
dset(n, 'denominator', false);
|
|
1248
|
+
dset(n, 'page_like', false);
|
|
1249
|
+
dset(n, 'hosts_pages', _hosted.get(nid).size);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// --- 1a-pre. UI-less LAUNCH SHELL (splash) ------------------------------
|
|
1254
|
+
if (truthy(project)) {
|
|
1255
|
+
const _shellSrc = _sourceIndex(project, _fileTextCache);
|
|
1256
|
+
const _shells = [];
|
|
1257
|
+
for (const nid of keysOf(nodes)) {
|
|
1258
|
+
const n = nodes[nid];
|
|
1259
|
+
if (!['activity', 'host-activity'].includes(get(n, 'kind'))) { continue; }
|
|
1260
|
+
if (get(n, 'denominator') === false) { continue; }
|
|
1261
|
+
const short = pySplit(pyStr(nid), ':', 1).at(-1);
|
|
1262
|
+
const src = _shellSrc.get(short);
|
|
1263
|
+
if (!truthy(src)) { continue; }
|
|
1264
|
+
if (reSearch(_SETCONTENT_ANY_RE, src)) { continue; }
|
|
1265
|
+
if (declaresOwnLayout(src)) { continue; }
|
|
1266
|
+
if (!edges.some((e) => get(e, 'source') === nid)) { continue; }
|
|
1267
|
+
dset(n, 'denominator', false);
|
|
1268
|
+
dset(n, 'page_like', false);
|
|
1269
|
+
dset(n, 'ui_less_shell', true);
|
|
1270
|
+
_shells.push(nid);
|
|
1271
|
+
}
|
|
1272
|
+
if (_shells.length) {
|
|
1273
|
+
pyPrintErr(`[assemble] ${_shells.length} UI-less launch shell(s) excluded from the ` +
|
|
1274
|
+
`denominator (renders no layout of its own — nothing to ` +
|
|
1275
|
+
`screenshot): ${pyRepr(sortedStr(_shells))}`);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// --- 1a. dead Activity: non-launcher, not exported, with NO inbound edge --
|
|
1280
|
+
const indeg = new Map();
|
|
1281
|
+
for (const e of edges) { indeg.set(e.target, (indeg.get(e.target) ?? 0) + 1); }
|
|
1282
|
+
for (const nid of keysOf(nodes)) {
|
|
1283
|
+
const n = nodes[nid];
|
|
1284
|
+
if (get(n, 'kind') !== 'activity') { continue; }
|
|
1285
|
+
if (get(n, 'status') === 'unreachable') { continue; }
|
|
1286
|
+
const hint = or0(get(n, 'launch_hint'), {});
|
|
1287
|
+
const isLauncher = (isObj(hint) && Object.hasOwn(hint, 'is_launcher')) ? truthy(hint.is_launcher)
|
|
1288
|
+
: pyStr(hint).toUpperCase().includes('LAUNCHER');
|
|
1289
|
+
let exported = get(n, 'exported');
|
|
1290
|
+
if (isObj(hint) && (exported === null || exported === undefined)) { exported = get(hint, 'exported'); }
|
|
1291
|
+
if (!isLauncher && !truthy(exported) && (indeg.get(nid) ?? 0) === 0) {
|
|
1292
|
+
dset(n, 'status', 'unreachable');
|
|
1293
|
+
dset(n, 'unreachable_reason', 'non-launcher, not exported, no inbound edge (only in-app ' +
|
|
1294
|
+
'launch site removed/commented in current source)');
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// --- 1b. multi-page container Activities (ViewPager2 / pager fragments) ---
|
|
1300
|
+
const pagerChildCount = new Map();
|
|
1301
|
+
for (const e of edges) {
|
|
1302
|
+
if (get(e, 'mechanism') === 'pager-swipe') {
|
|
1303
|
+
const tgt = get(nodes, get(e, 'target'), {});
|
|
1304
|
+
if (pyStr(get(tgt, 'kind', '')) === 'pager-page' || get(tgt, 'pager_child') === true) {
|
|
1305
|
+
const s = get(e, 'source');
|
|
1306
|
+
pagerChildCount.set(s, (pagerChildCount.get(s) ?? 0) + 1);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
for (const [nid, cnt] of pagerChildCount) {
|
|
1311
|
+
const n = get(nodes, nid);
|
|
1312
|
+
if (truthy(n) && get(n, 'kind') === 'activity' && cnt >= 2) {
|
|
1313
|
+
dset(n, 'kind', 'host-activity');
|
|
1314
|
+
dset(n, 'denominator', false);
|
|
1315
|
+
dset(n, 'page_like', false);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// --- 1c. shared dialog-host Activities (host-indirection architecture) ---
|
|
1320
|
+
const dialogPageCount = Object.values(nodes).filter((n) => ['dialog', 'sheet', 'menu'].includes(pyStr(get(n, 'kind', '')))).length;
|
|
1321
|
+
if (dialogPageCount >= 3) {
|
|
1322
|
+
for (const nid of keysOf(nodes)) {
|
|
1323
|
+
const n = nodes[nid];
|
|
1324
|
+
if (get(n, 'kind') !== 'activity') { continue; }
|
|
1325
|
+
const name = pyStr(get(n, 'id', '')) + ' ' + pyStr(get(n, 'launch_hint', ''));
|
|
1326
|
+
if (nid.includes('DialogActivity') || lower(name).includes('host-indirection')) {
|
|
1327
|
+
dset(n, 'kind', 'host-activity');
|
|
1328
|
+
dset(n, 'denominator', false);
|
|
1329
|
+
dset(n, 'page_like', false);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
// --- 1d. abstract Fragment nodes: NOT a page — remove, record as attribute -
|
|
1335
|
+
const _abstractIds = new Set(keysOf(nodes).filter((nid) => truthy(get(nodes[nid], 'abstract')) &&
|
|
1336
|
+
['fragment', 'dialog'].includes(pyStr(get(nodes[nid], 'kind', '')))));
|
|
1337
|
+
if (_abstractIds.size) {
|
|
1338
|
+
const _baseSimple = new Set([..._abstractIds].map((nid) => pySplit(nid, ':', 1).at(-1)));
|
|
1339
|
+
for (const nid of keysOf(nodes)) {
|
|
1340
|
+
if (_abstractIds.has(nid)) { continue; }
|
|
1341
|
+
const n = nodes[nid];
|
|
1342
|
+
const hint = get(n, 'launch_hint');
|
|
1343
|
+
if (typeof hint !== 'string' || !hint.includes('base:')) { continue; }
|
|
1344
|
+
const base = pyStrip(pySplit(hint, 'base:', 1).at(-1).split(';')[0]);
|
|
1345
|
+
if (_baseSimple.has(base)) { dset(n, 'extends_base', base); }
|
|
1346
|
+
}
|
|
1347
|
+
const _keptEdges = []; let _dropped = 0;
|
|
1348
|
+
for (const e of edges) {
|
|
1349
|
+
if (_abstractIds.has(get(e, 'source')) || _abstractIds.has(get(e, 'target'))) {
|
|
1350
|
+
_dropped++;
|
|
1351
|
+
pyPrintErr(`[assemble] drop CHA-noise edge touching abstract ` +
|
|
1352
|
+
`${pyStr(get(e, 'source'))} -> ${pyStr(get(e, 'target'))} (${pyStr(get(e, 'mechanism'))})`);
|
|
1353
|
+
continue;
|
|
1354
|
+
}
|
|
1355
|
+
_keptEdges.push(e);
|
|
1356
|
+
}
|
|
1357
|
+
edges.length = 0; edges.push(..._keptEdges);
|
|
1358
|
+
for (const nid of _abstractIds) { delete nodes[nid]; }
|
|
1359
|
+
pyPrintErr(`[assemble] removed ${_abstractIds.size} abstract Fragment node(s) ` +
|
|
1360
|
+
`(not a page); dropped ${_dropped} edge(s) touching them`);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
_markOutOfScope(nodes, edges, project);
|
|
1364
|
+
_promoteAppSettings(nodes, edges, project);
|
|
1365
|
+
|
|
1366
|
+
// --- 1e. fragment containment fold (embedded child = same screen) --------
|
|
1367
|
+
for (const e of edges) {
|
|
1368
|
+
if (get(e, 'mechanism') !== 'fragment-embed') { continue; }
|
|
1369
|
+
if (pyStr(get(argsOf(e), 'relation')) !== 'containment') { continue; }
|
|
1370
|
+
const hostId = get(e, 'source'); const childId = get(e, 'target');
|
|
1371
|
+
const host = get(nodes, hostId); const child = get(nodes, childId);
|
|
1372
|
+
if (child !== null && child !== undefined) {
|
|
1373
|
+
dset(child, 'role', 'embedded');
|
|
1374
|
+
dset(child, 'denominator', false);
|
|
1375
|
+
dset(child, 'page_like', false);
|
|
1376
|
+
dset(child, 'fullscreen', false);
|
|
1377
|
+
dset(child, 'embedded_in', hostId);
|
|
1378
|
+
}
|
|
1379
|
+
if (host !== null && host !== undefined) {
|
|
1380
|
+
setdefault(host, 'contains', []);
|
|
1381
|
+
if (!pyIn(childId, host.contains)) { host.contains.push(childId); }
|
|
1382
|
+
dset(host, 'fullscreen', true);
|
|
1383
|
+
if (['fragment', 'activity'].includes(pyStr(get(host, 'kind', ''))) && get(host, 'denominator') !== false) {
|
|
1384
|
+
dset(host, 'role', 'screen');
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// --- 1f. UI-less container Activity fold --------------------------------
|
|
1390
|
+
_foldUilessHosts(nodes, edges, _layouts, _fileTextCache, project);
|
|
1391
|
+
_markTransientEntries(nodes, edges);
|
|
1392
|
+
|
|
1393
|
+
// --- 1g. shared-primitive overlay fold (wrapper != page) ------------------
|
|
1394
|
+
const _MANDATORY_COMPOSABLE_PARAM_RE = pyRe(String.raw`^\s*\w+\s*:\s*@Composable\b`);
|
|
1395
|
+
const _splitTopLevelParams = (params) => {
|
|
1396
|
+
const segs = []; let depth = 0; let start = 0;
|
|
1397
|
+
for (let i = 0; i < params.length; i++) {
|
|
1398
|
+
const c = params[i];
|
|
1399
|
+
if ('([{'.includes(c)) { depth++; } else if (')]}'.includes(c)) { depth--; }
|
|
1400
|
+
else if (c === ',' && depth === 0) { segs.push(params.slice(start, i)); start = i + 1; }
|
|
1401
|
+
}
|
|
1402
|
+
segs.push(params.slice(start));
|
|
1403
|
+
return segs;
|
|
1404
|
+
};
|
|
1405
|
+
const _paramIsMandatoryComposable = (seg) => {
|
|
1406
|
+
if (!reMatch(_MANDATORY_COMPOSABLE_PARAM_RE, seg)) { return false; }
|
|
1407
|
+
let depth = 0;
|
|
1408
|
+
for (const c of seg) {
|
|
1409
|
+
if ('([{'.includes(c)) { depth++; } else if (')]}'.includes(c)) { depth--; }
|
|
1410
|
+
else if (c === '=' && depth === 0) { return false; }
|
|
1411
|
+
}
|
|
1412
|
+
return true;
|
|
1413
|
+
};
|
|
1414
|
+
const _isContentWrapper = (n) => {
|
|
1415
|
+
const decl = or0(get(n, 'declared_at'), '');
|
|
1416
|
+
if (!decl.includes(':')) { return false; }
|
|
1417
|
+
const ci = decl.lastIndexOf(':');
|
|
1418
|
+
const p = decl.slice(0, ci); const lineS = decl.slice(ci + 1);
|
|
1419
|
+
const line = pyIntOrNull(lineS);
|
|
1420
|
+
if (line === null) { return false; }
|
|
1421
|
+
const fullPath = pIsAbs(p) ? p : (truthy(project) ? osJoin(project, p) : null);
|
|
1422
|
+
if (!fullPath || !osExists(fullPath)) { return false; }
|
|
1423
|
+
let text = _fileTextCache.has(fullPath) ? _fileTextCache.get(fullPath) : null;
|
|
1424
|
+
if (text === null || text === undefined) {
|
|
1425
|
+
try { text = readTextSmart(fullPath); } catch { text = ''; }
|
|
1426
|
+
_fileTextCache.set(fullPath, text);
|
|
1427
|
+
}
|
|
1428
|
+
if (!text) { return false; }
|
|
1429
|
+
const lines = text.split('\n');
|
|
1430
|
+
if (line < 1 || line > lines.length) { return false; }
|
|
1431
|
+
let charPos = 0;
|
|
1432
|
+
for (const l of lines.slice(0, line - 1)) { charPos += l.length + 1; }
|
|
1433
|
+
const paren = text.indexOf('(', charPos);
|
|
1434
|
+
if (paren === -1) { return false; }
|
|
1435
|
+
let depth = 0; let i = paren; let params = null;
|
|
1436
|
+
while (i < text.length) {
|
|
1437
|
+
if (text[i] === '(') { depth++; } else if (text[i] === ')') {
|
|
1438
|
+
depth--;
|
|
1439
|
+
if (depth === 0) { params = text.slice(paren + 1, i); break; }
|
|
1440
|
+
}
|
|
1441
|
+
i++;
|
|
1442
|
+
}
|
|
1443
|
+
if (params === null) { return false; }
|
|
1444
|
+
return _splitTopLevelParams(params).some(_paramIsMandatoryComposable);
|
|
1445
|
+
};
|
|
1446
|
+
const _primitiveFolded = [];
|
|
1447
|
+
for (const nid of keysOf(nodes)) {
|
|
1448
|
+
const n = nodes[nid];
|
|
1449
|
+
if (!['dialog', 'sheet', 'menu'].includes(pyStr(get(n, 'kind', '')))) { continue; }
|
|
1450
|
+
if (_isContentWrapper(n)) {
|
|
1451
|
+
dset(n, 'role', 'primitive');
|
|
1452
|
+
dset(n, 'denominator', false);
|
|
1453
|
+
dset(n, 'page_like', false);
|
|
1454
|
+
_primitiveFolded.push(nid);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
if (_primitiveFolded.length) {
|
|
1458
|
+
pyPrintErr(`[assemble] folded ${_primitiveFolded.length} shared-primitive ` +
|
|
1459
|
+
`overlay node(s) (wrapper, not a page): ${pyRepr(_primitiveFolded)}`);
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// --- 2. parameterized-route instance metadata ---------------------------
|
|
1463
|
+
for (const nid of keysOf(nodes)) {
|
|
1464
|
+
const n = nodes[nid];
|
|
1465
|
+
const kind = get(n, 'kind', '');
|
|
1466
|
+
if (!pyStr(kind).startsWith('compose-route')) { continue; }
|
|
1467
|
+
const routeKey = pySplit(pyStr(nid), ':', 1).at(-1).split('#')[0];
|
|
1468
|
+
if (_hasToken(routeKey, _INSTANCE_ROUTE_SUFFIXES)) {
|
|
1469
|
+
dset(n, 'requires_instance', true);
|
|
1470
|
+
dset(n, 'do_not_crawl_directly', true);
|
|
1471
|
+
const base = routeKey.split('_CONTENT').join('').split('_DETAIL').join('').split('_PATH').join('').split('_INFO').join('');
|
|
1472
|
+
dset(n, 'instance_collection', lower(base));
|
|
1473
|
+
setdefault(n, 'required_state', []);
|
|
1474
|
+
if (!pyIn('content', n.required_state)) { n.required_state.push('content'); }
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
// --- 2b. the View/Activity form of the same fact -------------------------
|
|
1479
|
+
for (const e of edges) {
|
|
1480
|
+
const args = argsOf(e);
|
|
1481
|
+
if (!truthy(get(args, 'passes_item_data'))) { continue; }
|
|
1482
|
+
const tgt = get(nodes, get(e, 'target'));
|
|
1483
|
+
if (!truthy(tgt) || truthy(get(tgt, 'requires_instance'))) { continue; }
|
|
1484
|
+
dset(tgt, 'requires_instance', true);
|
|
1485
|
+
dset(tgt, 'do_not_crawl_directly', true);
|
|
1486
|
+
const coll = pyStr(or0(get(args, 'item_collection'), ''));
|
|
1487
|
+
if (coll) { dset(tgt, 'instance_collection', coll); }
|
|
1488
|
+
dset(tgt, 'instance_evidence', or0(get(e, 'trigger'), or0(get(args, 'trigger'), '')));
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// --- 3. page-identity invariant -----------------------------------------
|
|
1492
|
+
const inboundLabels = new Map();
|
|
1493
|
+
for (const e of edges) {
|
|
1494
|
+
const tgt = get(e, 'target');
|
|
1495
|
+
const args = argsOf(e);
|
|
1496
|
+
const lab = get(args, 'label');
|
|
1497
|
+
if (truthy(get(args, 'label_ambiguous')) || pyStr(or0(get(args, 'label_source'), '')).endsWith('-ambiguous')) { continue; }
|
|
1498
|
+
if (truthy(tgt) && truthy(lab) && _isScreenText(lab)) {
|
|
1499
|
+
if (!inboundLabels.has(tgt)) { inboundLabels.set(tgt, []); }
|
|
1500
|
+
if (!pyIn(lab, inboundLabels.get(tgt))) { inboundLabels.get(tgt).push(lab); }
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
const fnIndex = truthy(project) ? _buildFnDeclarationIndex(project) : new Map();
|
|
1505
|
+
strings = strings !== null && strings !== undefined ? strings : (truthy(project) ? loadProjectStrings(project) : {});
|
|
1506
|
+
|
|
1507
|
+
const _ownTitle = (n) => {
|
|
1508
|
+
const label = or0(get(n, 'label'), '');
|
|
1509
|
+
const loc = fnIndex.get(label);
|
|
1510
|
+
if (!truthy(loc)) { return null; }
|
|
1511
|
+
const [p, declPos] = loc;
|
|
1512
|
+
let text = _fileTextCache.has(p) ? _fileTextCache.get(p) : null;
|
|
1513
|
+
if (text === null || text === undefined) {
|
|
1514
|
+
try { text = readTextSmart(p); } catch { text = ''; }
|
|
1515
|
+
_fileTextCache.set(p, text);
|
|
1516
|
+
}
|
|
1517
|
+
if (!text) { return null; }
|
|
1518
|
+
const [val] = pageOwnTitle(text, declPos, strings);
|
|
1519
|
+
return val;
|
|
1520
|
+
};
|
|
1521
|
+
const _ownTitleAny = (n) => {
|
|
1522
|
+
const v = _ownTitle(n);
|
|
1523
|
+
if (truthy(v)) { return v; }
|
|
1524
|
+
return _viewOwnTitle(n, _layouts, strings, _fileTextCache);
|
|
1525
|
+
};
|
|
1526
|
+
const _declaredTitleClaim = new Map();
|
|
1527
|
+
const expOf = (n) => or0(get(n, 'expected'), {});
|
|
1528
|
+
const listOf = (v) => (truthy(v) ? v : []);
|
|
1529
|
+
|
|
1530
|
+
for (const nid of keysOf(nodes)) {
|
|
1531
|
+
const n = nodes[nid];
|
|
1532
|
+
const kind = get(n, 'kind', '');
|
|
1533
|
+
if (['host-activity', 'unknown', 'sentinel'].includes(kind)) { continue; }
|
|
1534
|
+
const existing = listOf(get(expOf(n), 'title_any'));
|
|
1535
|
+
const pos = [];
|
|
1536
|
+
const own = _ownTitleAny(n);
|
|
1537
|
+
if (truthy(own) && cpLen(own) <= 30) {
|
|
1538
|
+
pos.push(own);
|
|
1539
|
+
if (!_declaredTitleClaim.has(own)) { _declaredTitleClaim.set(own, new Set()); }
|
|
1540
|
+
_declaredTitleClaim.get(own).add(nid);
|
|
1541
|
+
}
|
|
1542
|
+
for (const e of existing) { if (!pyIn(e, pos)) { pos.push(e); } }
|
|
1543
|
+
let lab = or0(get(n, 'label'), '');
|
|
1544
|
+
if (truthy(get(n, 'label_synthetic'))) { lab = ''; }
|
|
1545
|
+
if (_isScreenText(lab) && !pyIn(lab, pos)) { pos.push(lab); }
|
|
1546
|
+
for (const tok of listOf(get(n, 'identity_text'))) {
|
|
1547
|
+
if (_isScreenText(tok) && !pyIn(tok, pos)) { pos.push(tok); }
|
|
1548
|
+
}
|
|
1549
|
+
const hints = [];
|
|
1550
|
+
for (const il of listOf(get(expOf(n), 'hint_any'))) {
|
|
1551
|
+
if (truthy(il) && !pyIn(il, pos) && !pyIn(il, hints)) { hints.push(il); }
|
|
1552
|
+
}
|
|
1553
|
+
for (const il of (inboundLabels.get(nid) ?? [])) {
|
|
1554
|
+
if (!pyIn(il, pos) && !pyIn(il, hints)) { hints.push(il); }
|
|
1555
|
+
}
|
|
1556
|
+
if (pos.length || hints.length) {
|
|
1557
|
+
const exp = {};
|
|
1558
|
+
if (pos.length) { exp.title_any = pos; }
|
|
1559
|
+
if (hints.length) { exp.hint_any = hints; }
|
|
1560
|
+
dset(n, 'expected', exp);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// --- 3c. STRONG-tier uniqueness -----------------------------------------
|
|
1565
|
+
const _claims = new Map();
|
|
1566
|
+
for (const nid of keysOf(nodes)) {
|
|
1567
|
+
for (const tok of listOf(get(expOf(nodes[nid]), 'title_any'))) {
|
|
1568
|
+
if (!_claims.has(tok)) { _claims.set(tok, []); }
|
|
1569
|
+
_claims.get(tok).push(nid);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
let _demotedTokens = 0; const _demotedNodes = new Set();
|
|
1573
|
+
for (const [tok, claimants] of _claims) {
|
|
1574
|
+
if (claimants.length < 2) { continue; }
|
|
1575
|
+
const owners = _declaredTitleClaim.get(tok) ?? new Set();
|
|
1576
|
+
const keeper = owners.size === 1 ? [...owners][0] : null;
|
|
1577
|
+
for (const nid of claimants) {
|
|
1578
|
+
if (nid === keeper) { continue; }
|
|
1579
|
+
const n = nodes[nid];
|
|
1580
|
+
const exp = copyDict(expOf(n));
|
|
1581
|
+
const strong = listOf(get(exp, 'title_any')).filter((t) => !pyEq(t, tok));
|
|
1582
|
+
const hints = [...listOf(get(exp, 'hint_any'))];
|
|
1583
|
+
if (!pyIn(tok, hints)) { hints.push(tok); }
|
|
1584
|
+
if (strong.length) { dset(exp, 'title_any', strong); } else { delete exp.title_any; }
|
|
1585
|
+
dset(exp, 'hint_any', hints);
|
|
1586
|
+
dset(n, 'expected', exp);
|
|
1587
|
+
_demotedTokens++;
|
|
1588
|
+
_demotedNodes.add(nid);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
if (_demotedTokens) {
|
|
1592
|
+
pyPrintErr(` [identity] demoted ${_demotedTokens} non-unique STRONG token(s) ` +
|
|
1593
|
+
`across ${_demotedNodes.size} node(s) to hint_any`);
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
// --- 3b. identity inheritance for variant / parameterized routes --------
|
|
1597
|
+
const _titleAny = (nodeId) => [...listOf(get(expOf(or0(get(nodes, nodeId), {})), 'title_any'))];
|
|
1598
|
+
const _baseRouteId = (nid) => {
|
|
1599
|
+
const n = or0(get(nodes, nid), {});
|
|
1600
|
+
const vof = get(n, 'variant_of');
|
|
1601
|
+
if (truthy(vof)) { return vof; }
|
|
1602
|
+
if (pyStr(nid).startsWith('compose-route:')) {
|
|
1603
|
+
const key = pySplit(pyStr(nid), ':', 1).at(-1).split('#')[0];
|
|
1604
|
+
let baseKey = key;
|
|
1605
|
+
for (const suf of _INSTANCE_ROUTE_SUFFIXES) {
|
|
1606
|
+
if (baseKey.endsWith(suf)) { baseKey = baseKey.slice(0, -suf.length); break; }
|
|
1607
|
+
}
|
|
1608
|
+
if (baseKey !== key) {
|
|
1609
|
+
const cand = 'compose-route:' + baseKey;
|
|
1610
|
+
if (pyIn(cand, nodes)) { return cand; }
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
return null;
|
|
1614
|
+
};
|
|
1615
|
+
for (const nid of keysOf(nodes)) {
|
|
1616
|
+
const n = nodes[nid];
|
|
1617
|
+
const ownTokens = listOf(get(expOf(n), 'title_any'));
|
|
1618
|
+
if (ownTokens.length && !truthy(get(n, 'label_synthetic'))) { continue; }
|
|
1619
|
+
const base = _baseRouteId(nid);
|
|
1620
|
+
if (!truthy(base)) { continue; }
|
|
1621
|
+
const inherited = _titleAny(base);
|
|
1622
|
+
if (inherited.length) {
|
|
1623
|
+
const exp = copyDict(expOf(n));
|
|
1624
|
+
const hints = [...listOf(get(exp, 'hint_any'))];
|
|
1625
|
+
for (const tok of inherited) { if (!pyIn(tok, hints) && !pyIn(tok, ownTokens)) { hints.push(tok); } }
|
|
1626
|
+
if (hints.length) { dset(exp, 'hint_any', hints); }
|
|
1627
|
+
dset(n, 'expected', exp);
|
|
1628
|
+
setdefault(n, 'expected_from', base);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
// --- 3z. uniform pager page ---------------------------------------------
|
|
1633
|
+
const _pagerFns = ['createFragment', 'getItem', 'instantiateItem'];
|
|
1634
|
+
const _bySrc = new Map();
|
|
1635
|
+
for (const e of edges) {
|
|
1636
|
+
const scope = pyStr(get(argsOf(e), 'commit_scope', ''));
|
|
1637
|
+
if (_pagerFns.some((f) => scope.endsWith(':' + f))) {
|
|
1638
|
+
if (!_bySrc.has(e.source)) { _bySrc.set(e.source, new Set()); }
|
|
1639
|
+
_bySrc.get(e.source).add(e.target);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
let _uniform = 0; const _pos0 = new Map();
|
|
1643
|
+
for (const src of _bySrc.keys()) {
|
|
1644
|
+
if (_bySrc.get(src).size > 1 && truthy(project)) {
|
|
1645
|
+
const first = _pagerPositionZero(edges, src, project, _pagerFns);
|
|
1646
|
+
if (truthy(first)) { _pos0.set(src, first); }
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
for (const e of edges) {
|
|
1650
|
+
const a = argsOf(e);
|
|
1651
|
+
const scope = pyStr(get(a, 'commit_scope', ''));
|
|
1652
|
+
if (!_pagerFns.some((f) => scope.endsWith(':' + f)) || get(a, 'action') === 'default') { continue; }
|
|
1653
|
+
if ((_bySrc.get(e.source)?.size ?? 0) === 1) { dset(a, 'via', 'pager-uniform'); }
|
|
1654
|
+
else if (_pos0.get(e.source) === e.target) { dset(a, 'via', 'pager-position-0'); }
|
|
1655
|
+
else { continue; }
|
|
1656
|
+
dset(a, 'action', 'default');
|
|
1657
|
+
delete a.needs_trigger;
|
|
1658
|
+
dset(e, 'args', a);
|
|
1659
|
+
_uniform++;
|
|
1660
|
+
}
|
|
1661
|
+
if (_uniform) { pyPrintErr(`[assemble] pager default pages marked: ${_uniform}`); }
|
|
1662
|
+
|
|
1663
|
+
// --- 4. guard backfill from route key -----------------------------------
|
|
1664
|
+
const _MODAL_KINDS = ['sheet-screen', 'dialog', 'sheet', 'menu', 'mode'];
|
|
1665
|
+
for (const e of edges) {
|
|
1666
|
+
if (truthy(get(e, 'guard'))) { continue; }
|
|
1667
|
+
const tw = _branchGuard(e, project);
|
|
1668
|
+
if (truthy(tw)) { dset(e, 'guard', tw); continue; }
|
|
1669
|
+
const mech = get(e, 'mechanism');
|
|
1670
|
+
if (mech === 'enter-mode') {
|
|
1671
|
+
dset(e, 'guard', { text: 'inferred:selection-mode-needs-content', kind: 'data-state' });
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
if (mech === 'pager-swipe') {
|
|
1675
|
+
const srcKind = pyStr(get(get(nodes, get(e, 'source'), {}), 'kind', ''));
|
|
1676
|
+
if (_MODAL_KINDS.includes(srcKind)) {
|
|
1677
|
+
dset(e, 'guard', { text: 'inferred:media-session-pager', kind: 'data-state' });
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
const tgt = get(e, 'target', '');
|
|
1682
|
+
const routeKey = pySplit(pyStr(tgt), ':', 1).at(-1).split('#')[0];
|
|
1683
|
+
let kind = null;
|
|
1684
|
+
if (_hasToken(routeKey, _PAY_ROUTE_TOKENS)) { kind = 'pay'; }
|
|
1685
|
+
else if (_hasToken(routeKey, _ENV_ROUTE_TOKENS)) { kind = 'build-flavor'; }
|
|
1686
|
+
else if (_hasToken(routeKey, _LOGIN_ROUTE_TOKENS)) { kind = 'login'; }
|
|
1687
|
+
else if (_hasToken(routeKey, _INSTANCE_ROUTE_SUFFIXES)) { kind = 'data-state'; }
|
|
1688
|
+
if (kind) {
|
|
1689
|
+
const guard = { text: `inferred:${routeKey}`, kind };
|
|
1690
|
+
if (kind === 'login' && _isAuthEntryRoute(routeKey)) { dset(guard, 'polarity', 'logged-out'); }
|
|
1691
|
+
dset(e, 'guard', guard);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// --- 4b. centralized login interceptor (route_interceptor.mjs) ----------
|
|
1696
|
+
// Runs after the backfill so a pay / data-state guard an edge already earned is kept; the login
|
|
1697
|
+
// precondition then rides on the protected node's required_state instead.
|
|
1698
|
+
if (truthy(project)) {
|
|
1699
|
+
const found = findLoginInterceptor(_projectSources(project), _LOGIN_TEST_RE, readTextSmart, routeResolver(nodes), project);
|
|
1700
|
+
if (found && found.refused) {
|
|
1701
|
+
pyPrintErr(`[assemble] login interceptor refused: ${found.refused}`);
|
|
1702
|
+
} else if (found) {
|
|
1703
|
+
const r = applyLoginInterceptor(nodes, edges, found, project);
|
|
1704
|
+
if (r.skipped) { pyPrintErr(`[assemble] login interceptor skipped: ${r.skipped}`); }
|
|
1705
|
+
else {
|
|
1706
|
+
pyPrintErr(`[assemble] login interceptor: ${r.nodes.length} protected route(s), ${r.edges} edge guard(s)` +
|
|
1707
|
+
(r.unmatched.length ? `, unmatched: ${r.unmatched.join(', ')}` : ''));
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
// --- 5. label backfill from framework-declared sources -------------------
|
|
1713
|
+
_backfillFrameworkLabels(nodes, edges, project);
|
|
1714
|
+
// --- 6. locale variants --------------------------------------------------
|
|
1715
|
+
_stampLabelVariants(edges, project);
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
/** Shallow dict(d) keeping Python key order. */
|
|
1719
|
+
function copyDict(d) { const o = {}; for (const k of keysOf(d)) { dset(o, k, d[k]); } return o; }
|
|
1720
|
+
|
|
1721
|
+
export function _backfillFrameworkLabels(nodes, edges, project) {
|
|
1722
|
+
const strings = truthy(project) ? _loadBaseStrings(project) : {};
|
|
1723
|
+
let localized = {};
|
|
1724
|
+
if (truthy(project)) {
|
|
1725
|
+
try { localized = or0(loadProjectStrings(project), {}); } catch { localized = {}; }
|
|
1726
|
+
}
|
|
1727
|
+
const actLabel = new Map();
|
|
1728
|
+
if (truthy(project)) {
|
|
1729
|
+
const actRe = pyRe(String.raw`<activity\b(.*?)(?:/>|</activity>)`, 's');
|
|
1730
|
+
for (const [dp, dirs, files] of _osWalk(project)) {
|
|
1731
|
+
const keep = dirs.filter((d) => !SKIP_WALK.includes(d));
|
|
1732
|
+
dirs.length = 0; dirs.push(...keep);
|
|
1733
|
+
if (!files.includes('AndroidManifest.xml')) { continue; }
|
|
1734
|
+
let t;
|
|
1735
|
+
try { t = readTextSmart(osJoin(dp, 'AndroidManifest.xml')); } catch { continue; }
|
|
1736
|
+
for (const m of finditer(actRe, t)) {
|
|
1737
|
+
const b = m[1];
|
|
1738
|
+
const nm = reSearch(pyRe('android:name="([^"]+)"'), b);
|
|
1739
|
+
const lb = reSearch(pyRe(String.raw`android:label="@string/(\w+)"`), b);
|
|
1740
|
+
if (!nm || !lb) { continue; }
|
|
1741
|
+
const key = lb[1];
|
|
1742
|
+
const val = or0(get(localized, key), get(strings, key));
|
|
1743
|
+
if (truthy(val)) { actLabel.set(pyRsplit(nm[1], '.', 1).at(-1), [val, key]); }
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
let nOf = 0; let nAc = 0;
|
|
1748
|
+
for (const e of edges) {
|
|
1749
|
+
const a = setdefault(e, 'args', {});
|
|
1750
|
+
if (truthy(get(a, 'label'))) { continue; }
|
|
1751
|
+
const tgt = pyStr(get(e, 'target', ''));
|
|
1752
|
+
const tnode = or0(get(nodes, tgt), {});
|
|
1753
|
+
if (pyStr(get(tnode, 'kind', '')) === 'menu' || tgt.startsWith('menu:')) {
|
|
1754
|
+
dset(a, 'label', or0(get(localized, 'abc_action_menu_overflow_description'), 'More options'));
|
|
1755
|
+
dset(a, 'label_base', 'More options');
|
|
1756
|
+
dset(a, 'label_source', 'framework:abc_action_menu_overflow_description');
|
|
1757
|
+
nOf++;
|
|
1758
|
+
continue;
|
|
1759
|
+
}
|
|
1760
|
+
if (pyStr(get(e, 'mechanism', '')).startsWith('startActivity') && tgt.startsWith('activity:')) {
|
|
1761
|
+
const hit = actLabel.get(pySplit(tgt, ':', 1)[1]);
|
|
1762
|
+
if (truthy(hit)) {
|
|
1763
|
+
dset(a, 'label', hit[0]); dset(a, 'label_key', hit[1]);
|
|
1764
|
+
dset(a, 'label_source', 'manifest:android:label');
|
|
1765
|
+
nAc++;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
if (nOf || nAc) { pyPrintErr(`[assemble] framework labels backfilled: overflow=${nOf} manifest-activity=${nAc}`); }
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
const _WS_RUN_RE = pyRe(String.raw`\s+`);
|
|
1773
|
+
const squash = (s) => pyStrip(reSub(_WS_RUN_RE, ' ', s));
|
|
1774
|
+
|
|
1775
|
+
export function _loadBaseStrings(project) {
|
|
1776
|
+
if (!truthy(project)) { return {}; }
|
|
1777
|
+
const merged = {};
|
|
1778
|
+
const strRe = pyRe('<string name="([^"]+)"[^>]*>(.*?)</string>', 's');
|
|
1779
|
+
for (const [dirpath, dirs, files] of _osWalk(project)) {
|
|
1780
|
+
const keep = dirs.filter((d) => !['build', '.git', 'test', 'androidTest', '.gradle', '.idea'].includes(d));
|
|
1781
|
+
dirs.length = 0; dirs.push(...keep);
|
|
1782
|
+
if (!files.includes('strings.xml')) { continue; }
|
|
1783
|
+
const norm = dirpath.split('\\').join('/');
|
|
1784
|
+
if (norm.split('/').at(-1) !== 'values' || !(norm + '/').includes('/res/')) { continue; }
|
|
1785
|
+
let t;
|
|
1786
|
+
try { t = readTextSmart(osJoin(dirpath, 'strings.xml')); } catch { continue; }
|
|
1787
|
+
for (const [k, v] of reFindall(strRe, t)) { setdefault(merged, k, squash(decodeAndroidString(v))); }
|
|
1788
|
+
}
|
|
1789
|
+
return merged;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
export function _stampLabelVariants(edges, project) {
|
|
1793
|
+
const base = _loadBaseStrings(project);
|
|
1794
|
+
if (!truthy(base)) { return; }
|
|
1795
|
+
let localized;
|
|
1796
|
+
try { localized = truthy(project) ? loadProjectStrings(project) : {}; } catch { localized = {}; }
|
|
1797
|
+
const rev = new Map();
|
|
1798
|
+
const loc = or0(localized, {});
|
|
1799
|
+
for (const k of keysOf(loc)) {
|
|
1800
|
+
const v = loc[k];
|
|
1801
|
+
if (truthy(v)) { const s = squash(pyStr(v)); if (!rev.has(s)) { rev.set(s, k); } }
|
|
1802
|
+
}
|
|
1803
|
+
let stamped = 0;
|
|
1804
|
+
for (const e of edges) {
|
|
1805
|
+
const a = get(e, 'args');
|
|
1806
|
+
if (!isObj(a)) { continue; }
|
|
1807
|
+
const lab = get(a, 'label');
|
|
1808
|
+
if (!truthy(lab) || truthy(get(a, 'label_base'))) { continue; }
|
|
1809
|
+
const key = or0(get(a, 'label_key'), rev.get(squash(pyStr(lab))) ?? null);
|
|
1810
|
+
if (!truthy(key)) { continue; }
|
|
1811
|
+
const bv = get(base, key);
|
|
1812
|
+
if (truthy(bv) && !pyEq(bv, lab)) {
|
|
1813
|
+
dset(a, 'label_base', bv);
|
|
1814
|
+
setdefault(a, 'label_key', key);
|
|
1815
|
+
stamped++;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (stamped) { pyPrintErr(`[assemble] label_base stamped on ${stamped} edge(s) (device-language independence)`); }
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
// --- provenance lint ------------------------------------------------------
|
|
1822
|
+
export const _MENTION_TRIGGER_PREFIXES = ['ref@'];
|
|
1823
|
+
|
|
1824
|
+
/** Counter.most_common(n) over a Map built in insertion order. */
|
|
1825
|
+
function mostCommon(c, n) {
|
|
1826
|
+
return sortedBy([...c], (kv) => kv[1], true).slice(0, n);
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
export function lintEdgeProvenance(edges, nodes) {
|
|
1830
|
+
const kept = []; const quarantined = [];
|
|
1831
|
+
for (const e of edges) {
|
|
1832
|
+
const trig = pyStr(or0(get(e, 'trigger'), ''));
|
|
1833
|
+
if (_MENTION_TRIGGER_PREFIXES.some((p) => trig.startsWith(p))) { quarantined.push(e); continue; }
|
|
1834
|
+
kept.push(e);
|
|
1835
|
+
}
|
|
1836
|
+
if (quarantined.length) {
|
|
1837
|
+
const byTarget = counter(quarantined.map((e) => e.target));
|
|
1838
|
+
const top = new Map(mostCommon(byTarget, 5));
|
|
1839
|
+
pyPrintBuf(`[assemble] LINT dropped ${quarantined.length} mention-derived ` +
|
|
1840
|
+
`edge(s) (trigger not a call site — likely built from ` +
|
|
1841
|
+
`\`refs-to\`; see SKILL.md step 3.1). Top targets: ${pyRepr(top)}`);
|
|
1842
|
+
}
|
|
1843
|
+
const entryIds = new Set(keysOf(nodes).filter((nid) => {
|
|
1844
|
+
const n = nodes[nid];
|
|
1845
|
+
return truthy(get(n, 'entry')) || truthy(get(n, 'is_launcher')) ||
|
|
1846
|
+
(isObj(get(n, 'launch_hint')) && truthy(get(n.launch_hint, 'is_launcher')));
|
|
1847
|
+
}));
|
|
1848
|
+
const forward = ['startActivity-explicit', 'startActivity-implicit', 'compose-navigate', 'compose-navigate-param',
|
|
1849
|
+
'voyager-push', 'fragment-transaction', 'nav-component-action'];
|
|
1850
|
+
const fanIn = counter(kept.filter((e) => entryIds.has(e.target) && forward.includes(get(e, 'mechanism'))).map((e) => e.target));
|
|
1851
|
+
for (const [nid, cnt] of fanIn) {
|
|
1852
|
+
if (cnt >= 3) {
|
|
1853
|
+
pyPrintBuf(`[assemble] LINT WARN ${nid} is an entry/launcher node but ` +
|
|
1854
|
+
`has ${cnt} inbound forward-navigation edge(s). A launcher ` +
|
|
1855
|
+
`is where you START, not somewhere you tap into — verify ` +
|
|
1856
|
+
`these are real CLEAR_TOP returns, not mention-derived.`);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
return kept;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
export function _parseArgs(argv) {
|
|
1863
|
+
let ws = '.'; let project = null; const positional = [];
|
|
1864
|
+
let i = 0;
|
|
1865
|
+
while (i < argv.length) {
|
|
1866
|
+
if (argv[i] === '--project' && i + 1 < argv.length) { project = argv[i + 1]; i += 2; continue; }
|
|
1867
|
+
positional.push(argv[i]); i++;
|
|
1868
|
+
}
|
|
1869
|
+
if (positional.length) { ws = positional[0]; }
|
|
1870
|
+
return [ws, project];
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/** xml.sax.saxutils.escape(data): & < > only. */
|
|
1874
|
+
const xmlEscape = (s) => s.split('&').join('&').split('>').join('>').split('<').join('<');
|
|
1875
|
+
/** repr of {k: v for k, v in sorted(d.items())} for a str->str Map. */
|
|
1876
|
+
const sortedDictRepr = (m) => pyRepr(new Map(sortedBy([...m], (kv) => kv)));
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* Edges whose SOURCE is an id no extractor declared, named after a project class that is not a
|
|
1880
|
+
* page: several extractors fall back to `activity:<owner>` for any non-fragment owner, so a
|
|
1881
|
+
* listener written in an adapter / helper / abstract base Activity became an `unknown` node no
|
|
1882
|
+
* path can reach. Re-credit by the owner's supertype chain: a BASE Activity (abstract, or not in
|
|
1883
|
+
* the manifest and extended by other Activities) fans out to its concrete subclass pages; any
|
|
1884
|
+
* other non-page class goes through the HostResolver (the page that constructs it / dispatches
|
|
1885
|
+
* its override / calls its static helper). Unresolvable ones are dropped and counted rather than
|
|
1886
|
+
* left on a fabricated endpoint. Ids that are Activities the manifest missed are left untouched.
|
|
1887
|
+
* Returns [edges, stats].
|
|
1888
|
+
*/
|
|
1889
|
+
export function _recreditNonPageSources(nodes, edgesIn, project, ws) {
|
|
1890
|
+
const stats = { base_subclassed: 0, host_resolved: 0, dropped: 0, dropped_owners: new Set() };
|
|
1891
|
+
if (!truthy(project)) { return [edgesIn, stats]; }
|
|
1892
|
+
const undeclared = (id) => !Object.hasOwn(nodes, id);
|
|
1893
|
+
const ownerOf = (id) => { const s = pyStr(id); return /^(?:activity:)?[A-Z]\w*$/.test(s) ? s.replace(/^activity:/, '') : null; };
|
|
1894
|
+
const cands = edgesIn.filter((e) => undeclared(e.source) && ownerOf(e.source) !== null);
|
|
1895
|
+
if (!cands.length) { return [edgesIn, stats]; }
|
|
1896
|
+
const sources = walkSources(project);
|
|
1897
|
+
const chain = new ActivityChain(buildClassIndex(sources), manifestActivityNames(ws));
|
|
1898
|
+
const byName = new Map();
|
|
1899
|
+
for (const id of keysOf(nodes)) {
|
|
1900
|
+
const m = /^(activity|fragment|dialog|voyager-screen|host-activity):([\w.$]+)$/.exec(pyStr(id));
|
|
1901
|
+
if (!m) { continue; }
|
|
1902
|
+
const nm = m[2].split('.').at(-1);
|
|
1903
|
+
if (!byName.has(nm) || m[1] === 'activity') { byName.set(nm, id); }
|
|
1904
|
+
}
|
|
1905
|
+
const resolver = new HostResolver(sources, (o) => byName.has(o), (o) => byName.get(o));
|
|
1906
|
+
const out = [];
|
|
1907
|
+
for (const e of edgesIn) {
|
|
1908
|
+
const owner = undeclared(e.source) ? ownerOf(e.source) : null;
|
|
1909
|
+
if (owner === null || !chain.idx.has(owner)) { out.push(e); continue; }
|
|
1910
|
+
let hosts; let via;
|
|
1911
|
+
if (chain.isBase(owner)) {
|
|
1912
|
+
hosts = chain.concretePages(owner).filter((n) => byName.has(n)).map((n) => byName.get(n));
|
|
1913
|
+
via = 'base-activity-subclass';
|
|
1914
|
+
} else if (chain.isActivity(owner)) {
|
|
1915
|
+
out.push(e); continue; // a real Activity page no manifest record declared: not ours to move
|
|
1916
|
+
} else {
|
|
1917
|
+
hosts = resolver.sourcesFor(owner);
|
|
1918
|
+
via = 'host-resolve';
|
|
1919
|
+
}
|
|
1920
|
+
hosts = [...new Set(hosts)].filter((h) => h !== e.target);
|
|
1921
|
+
if (!hosts.length) { stats.dropped++; stats.dropped_owners.add(owner); continue; }
|
|
1922
|
+
if (via === 'base-activity-subclass') { stats.base_subclassed++; } else { stats.host_resolved++; }
|
|
1923
|
+
for (const h of hosts) {
|
|
1924
|
+
out.push({ ...e, source: h, args: { ...argsOf(e), written_in: owner, credited_via: via } });
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
return [out, stats];
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
export function main(argv = process.argv.slice(2)) {
|
|
1931
|
+
const [ws, project] = _parseArgs(argv);
|
|
1932
|
+
const nodesIn = load(osJoin(ws, 'nodes.jsonl'));
|
|
1933
|
+
const _kindCollisions = [];
|
|
1934
|
+
const nodes = {};
|
|
1935
|
+
for (const n of nodesIn) {
|
|
1936
|
+
setdefault(n, 'status', 'static-only');
|
|
1937
|
+
setdefault(n, 'provenance', []);
|
|
1938
|
+
dset(nodes, n.id, mergeNodeRecords(get(nodes, n.id), n, _kindCollisions));
|
|
1939
|
+
}
|
|
1940
|
+
const [edgesIn, _rc] = _recreditNonPageSources(nodes, load(osJoin(ws, 'edges.jsonl')), project, ws);
|
|
1941
|
+
if (_rc.base_subclassed || _rc.host_resolved || _rc.dropped) {
|
|
1942
|
+
pyPrintBuf(`[assemble] nonpage_source base_subclassed=${_rc.base_subclassed} ` +
|
|
1943
|
+
`host_resolved=${_rc.host_resolved} dropped=${_rc.dropped}`);
|
|
1944
|
+
if (_rc.dropped) {
|
|
1945
|
+
pyPrintBuf(`# edges written in a non-page class no page owns — DROPPED (no fabricated source): ${pyRepr(sortedStr(_rc.dropped_owners))}`);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
for (const [cid, kinds, how] of _kindCollisions) {
|
|
1949
|
+
pyPrintBuf(`[assemble] LINT id-collision ${cid} kinds=${kinds} (${how})`);
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
const _gestureKey = (e) => { const a = argsOf(e); return or0(get(a, 'trigger_id'), get(a, 'trigger_receiver')); };
|
|
1953
|
+
const baseKey = (e) => tupleKey(e.source, e.target, get(e, 'mechanism'), get(e, 'trigger'));
|
|
1954
|
+
const _tidSeen = new Set();
|
|
1955
|
+
for (const e of edgesIn) { if (truthy(_gestureKey(e))) { _tidSeen.add(baseKey(e)); } }
|
|
1956
|
+
let edges = []; const seen = new Set();
|
|
1957
|
+
for (const e of edgesIn) {
|
|
1958
|
+
const base = baseKey(e);
|
|
1959
|
+
const tid = _gestureKey(e);
|
|
1960
|
+
if (!truthy(tid) && _tidSeen.has(base)) { continue; }
|
|
1961
|
+
const key = tupleKey(e.source, e.target, get(e, 'mechanism'), get(e, 'trigger'), tid);
|
|
1962
|
+
if (seen.has(key)) { continue; }
|
|
1963
|
+
seen.add(key);
|
|
1964
|
+
setdefault(e, 'status', 'static-only');
|
|
1965
|
+
setdefault(e, 'confidence', asFloat(1.0));
|
|
1966
|
+
dset(e, 'guard', normalizeGuard(get(e, 'guard')));
|
|
1967
|
+
edges.push(e);
|
|
1968
|
+
for (const end of [e.source, e.target]) {
|
|
1969
|
+
if (!Object.hasOwn(nodes, end)) {
|
|
1970
|
+
dset(nodes, end, {
|
|
1971
|
+
id: end, kind: 'unknown', label: end, status: 'unreachable', provenance: 'auto-endpoint',
|
|
1972
|
+
denominator: false,
|
|
1973
|
+
audit_note: 'endpoint auto-created by assemble.py: no extractor declared this id as a page',
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
// --- resolve *Starter endpoints to the Activity they actually launch -------
|
|
1980
|
+
const _starterAction = new Map(); const _actionActivity = new Map();
|
|
1981
|
+
for (const rec of load(osJoin(ws, 'starters.jsonl'))) {
|
|
1982
|
+
if (get(rec, 'type') === 'starter' && truthy(get(rec, 'class')) && truthy(get(rec, 'action'))) {
|
|
1983
|
+
_starterAction.set(rec.class, rec.action);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
for (const rec of load(osJoin(ws, 'manifest.jsonl'))) {
|
|
1987
|
+
if (get(rec, 'type') !== 'activity') { continue; }
|
|
1988
|
+
for (const act of or0(get(rec, 'actions'), [])) {
|
|
1989
|
+
if (!_actionActivity.has(act)) { _actionActivity.set(act, new Set()); }
|
|
1990
|
+
_actionActivity.get(act).add(or0(get(rec, 'node_id'), 'activity:' + pyStr(rec.name).split('.').at(-1)));
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
const _starterFix = new Map();
|
|
1994
|
+
for (const nid of keysOf(nodes)) {
|
|
1995
|
+
const simple = pyStr(nid).split(':').at(-1);
|
|
1996
|
+
const act = _starterAction.get(simple);
|
|
1997
|
+
if (!truthy(act)) { continue; }
|
|
1998
|
+
const cands = _actionActivity.get(act) ?? new Set();
|
|
1999
|
+
if (cands.size === 1) {
|
|
2000
|
+
const tgt = [...cands][0];
|
|
2001
|
+
if (Object.hasOwn(nodes, tgt) && tgt !== nid) { _starterFix.set(nid, tgt); }
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
if (_starterFix.size) {
|
|
2005
|
+
for (const e of edges) {
|
|
2006
|
+
for (const end of ['source', 'target']) {
|
|
2007
|
+
if (_starterFix.has(get(e, end))) {
|
|
2008
|
+
dset(e, end, _starterFix.get(e[end]));
|
|
2009
|
+
if (end === 'target') { dset(e, 'mechanism', 'startActivity-implicit'); }
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
for (const nid of _starterFix.keys()) { delete nodes[nid]; }
|
|
2014
|
+
pyPrintErr(`[assemble] resolved ${_starterFix.size} *Starter pseudo-page(s) to the ` +
|
|
2015
|
+
`Activity their intent action launches: ${sortedDictRepr(_starterFix)}`);
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
// --- re-point an edge whose SOURCE is a RecyclerView adapter --------------
|
|
2019
|
+
if (truthy(project)) {
|
|
2020
|
+
const _undeclared = keysOf(nodes).filter((nid) => get(nodes[nid], 'provenance') === 'auto-endpoint');
|
|
2021
|
+
const _pageFile = new Map();
|
|
2022
|
+
for (const nid of keysOf(nodes)) {
|
|
2023
|
+
const n = nodes[nid];
|
|
2024
|
+
const da = pyStr(or0(get(n, 'declared_at'), ''));
|
|
2025
|
+
if (da && get(n, 'provenance') !== 'auto-endpoint') {
|
|
2026
|
+
const k = pyRsplit(da, ':', 1)[0].split('\\').join('/');
|
|
2027
|
+
if (!_pageFile.has(k)) { _pageFile.set(k, []); }
|
|
2028
|
+
_pageFile.get(k).push(nid);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
const _hosts = new Map(_undeclared.map((nid) => [nid, new Set()]));
|
|
2032
|
+
if (_undeclared.length) {
|
|
2033
|
+
const _pat = new Map(_undeclared.map((nid) => {
|
|
2034
|
+
const s = reEscape(pyStr(nid).split(':').at(-1));
|
|
2035
|
+
return [nid, pyRe(String.raw`\b(?:new\s+` + s + String.raw`\s*[\(<]|extends\s+` + s + String.raw`\b|:\s*` + s + String.raw`\s*\()`)];
|
|
2036
|
+
}));
|
|
2037
|
+
for (const [dirpath, dirs, files] of _osWalk(project)) {
|
|
2038
|
+
const keep = dirs.filter((d) => !['build', '.git', '.gradle', '.idea', 'test', 'androidTest', 'node_modules'].includes(d));
|
|
2039
|
+
dirs.length = 0; dirs.push(...keep);
|
|
2040
|
+
for (const fn of files) {
|
|
2041
|
+
if (!(fn.endsWith('.java') || fn.endsWith('.kt'))) { continue; }
|
|
2042
|
+
const full = osJoin(dirpath, fn);
|
|
2043
|
+
const key = osRelpath(full, project).split('\\').join('/');
|
|
2044
|
+
const pagesHere = _pageFile.get(key);
|
|
2045
|
+
if (!pagesHere || !pagesHere.length) { continue; }
|
|
2046
|
+
let txt;
|
|
2047
|
+
try { txt = readTextSmart(full); } catch { continue; }
|
|
2048
|
+
for (const [nid, rx] of _pat) {
|
|
2049
|
+
if (reSearch(rx, txt)) { for (const p of pagesHere) { _hosts.get(nid).add(p); } }
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
const _adapterFix = new Map();
|
|
2055
|
+
for (const [nid, h] of _hosts) { if (h.size === 1) { _adapterFix.set(nid, [...h][0]); } }
|
|
2056
|
+
if (_adapterFix.size) {
|
|
2057
|
+
for (const e of edges) {
|
|
2058
|
+
for (const end of ['source', 'target']) {
|
|
2059
|
+
if (_adapterFix.has(get(e, end))) { dset(e, end, _adapterFix.get(e[end])); }
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
for (const nid of _adapterFix.keys()) { delete nodes[nid]; }
|
|
2063
|
+
pyPrintErr(`[assemble] re-pointed ${_adapterFix.size} adapter pseudo-page(s) to ` +
|
|
2064
|
+
`the single page that instantiates them: ${sortedDictRepr(_adapterFix)}`);
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
const _touched = new Set([...edges.map((e) => get(e, 'source')), ...edges.map((e) => get(e, 'target'))]);
|
|
2069
|
+
for (const nid of keysOf(nodes).filter((k) => get(nodes[k], 'provenance') === 'auto-endpoint' && !_touched.has(k))) {
|
|
2070
|
+
delete nodes[nid];
|
|
2071
|
+
}
|
|
2072
|
+
const autoEps = sortedStr(keysOf(nodes).filter((nid) => get(nodes[nid], 'provenance') === 'auto-endpoint'));
|
|
2073
|
+
if (autoEps.length) {
|
|
2074
|
+
pyPrintErr(`[assemble] ${autoEps.length} auto-created endpoint node(s) ` +
|
|
2075
|
+
`(kind=unknown, excluded from the denominator) — these are ` +
|
|
2076
|
+
`edge endpoints no extractor declared, usually non-page ` +
|
|
2077
|
+
`classes: ${pyRepr(autoEps.slice(0, 12))}`);
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
edges = lintEdgeProvenance(edges, nodes);
|
|
2081
|
+
for (const nid of keysOf(nodes)) { dset(nodes[nid], 'slug', slug(nid)); }
|
|
2082
|
+
enrichNodesAndEdges(nodes, edges, project);
|
|
2083
|
+
|
|
2084
|
+
const nodeList = keysOf(nodes).map((k) => nodes[k]);
|
|
2085
|
+
const doc = { directed: true, multigraph: true, nodes: nodeList, links: edges };
|
|
2086
|
+
writeText(osJoin(ws, 'utg.json'), jsonDumps(doc, { ensure_ascii: false, indent: 2 }));
|
|
2087
|
+
|
|
2088
|
+
// Labels come from decoded string resources: a `"` would end the quoted label and a newline the
|
|
2089
|
+
// line. Mermaid takes `#quot;` / `<br/>` inside a quoted label.
|
|
2090
|
+
const mermaidLabel = (s) => pyStr(s).replace(/"/g, '#quot;').replace(/\r?\n/g, '<br/>');
|
|
2091
|
+
const lines = ['graph LR'];
|
|
2092
|
+
for (const n of nodeList) { lines.push(` ${sid(n.id)}["${mermaidLabel(get(n, 'label', n.id))}"]`); }
|
|
2093
|
+
for (const e of edges) { lines.push(` ${sid(e.source)} -->|${pyStr(get(e, 'mechanism', ''))}| ${sid(e.target)}`); }
|
|
2094
|
+
writeText(osJoin(ws, 'utg.mermaid'), lines.join('\n'));
|
|
2095
|
+
|
|
2096
|
+
const gm = ['<?xml version="1.0" encoding="UTF-8"?>',
|
|
2097
|
+
'<graphml xmlns="http://graphml.graphdrawing.org/xmlns">',
|
|
2098
|
+
'<key id="label" for="node" attr.name="label" attr.type="string"/>',
|
|
2099
|
+
'<key id="mech" for="edge" attr.name="mechanism" attr.type="string"/>',
|
|
2100
|
+
'<graph edgedefault="directed">'];
|
|
2101
|
+
for (const n of nodeList) {
|
|
2102
|
+
gm.push(`<node id="${xmlEscape(n.id)}"><data key="label">${xmlEscape(pyStr(get(n, 'label', n.id)))}</data></node>`);
|
|
2103
|
+
}
|
|
2104
|
+
for (const e of edges) {
|
|
2105
|
+
gm.push(`<edge source="${xmlEscape(e.source)}" target="${xmlEscape(e.target)}">` +
|
|
2106
|
+
`<data key="mech">${xmlEscape(pyStr(get(e, 'mechanism', '')))}</data></edge>`);
|
|
2107
|
+
}
|
|
2108
|
+
gm.push('</graph>', '</graphml>');
|
|
2109
|
+
writeText(osJoin(ws, 'utg.graphml'), gm.join('\n'));
|
|
2110
|
+
|
|
2111
|
+
const byKind = counter(nodeList.map((n) => get(n, 'kind')));
|
|
2112
|
+
const byMech = counter(edges.map((e) => get(e, 'mechanism')));
|
|
2113
|
+
const llm = edges.filter((e) => get(e, 'provenance') === 'static:llm').length;
|
|
2114
|
+
pyPrintBuf(`nodes=${keysOf(nodes).length} edges=${edges.length} llm_inferred=${llm}`);
|
|
2115
|
+
pyPrintBuf(' by kind:', byKind);
|
|
2116
|
+
pyPrintBuf(' by mechanism:', byMech);
|
|
2117
|
+
pyPrintBuf(` written to ${ws}/utg.json, utg.mermaid, utg.graphml`);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) { main(); }
|