@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,1748 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* build_conversion_set.mjs — make the static UTG, not the capture, decide what
|
|
4
|
+
* gets converted.
|
|
5
|
+
*
|
|
6
|
+
* node build_conversion_set.mjs <utg_static_ws> --ui-info <ui_info_root>
|
|
7
|
+
*
|
|
8
|
+
* (Node >= 22.18, ESM, zero dependencies. Behaviour-identical port of
|
|
9
|
+
* build_conversion_set.py: same args, exit codes, stdout and output files.)
|
|
10
|
+
*
|
|
11
|
+
* Run AFTER export_ui_info.mjs. Every static node gets exactly one role:
|
|
12
|
+
*
|
|
13
|
+
* page converted on its own. Tier `captured` when export_ui_info wrote
|
|
14
|
+
* a snapshot for it, else tier `source-only`: a page_NNNN_<Name>/
|
|
15
|
+
* directory is created with a meta.json that carries source hints
|
|
16
|
+
* (declared_at, layout files, ids, widgets, edges) and no screenshot.
|
|
17
|
+
* attach a menu / ui-state / mode / panel / embedded fragment. Converted as
|
|
18
|
+
* part of its host page's unit, never as a page of its own.
|
|
19
|
+
* skip not an app screen (out of scope, container, UI-less shell,
|
|
20
|
+
* unreachable). Listed with its reason, never silently dropped.
|
|
21
|
+
*
|
|
22
|
+
* Input : <ws>/utg.json, <ws>/click_paths.json,
|
|
23
|
+
* <ui_info>/export_manifest.json, <ui_info>/pages.json (both optional:
|
|
24
|
+
* without them every page is source-only).
|
|
25
|
+
* Output: <ui_info>/page_NNNN_<Name>/meta.json (source-only pages)
|
|
26
|
+
* <ui_info>/pages.json (captured first, then source-only)
|
|
27
|
+
* <ui_info>/conversion_set.json (every node's role, tier, reason;
|
|
28
|
+
* `plan`: the Step 4.2 groups, their
|
|
29
|
+
* predicted writes, class, lane, stage,
|
|
30
|
+
* `after` / `reuse_from` dependencies)
|
|
31
|
+
*
|
|
32
|
+
* Re-runnable: a source-only directory whose node has since been captured is
|
|
33
|
+
* removed, so it is not converted twice. Everything else is stable across
|
|
34
|
+
* re-runs: a source-only page keeps its directory and a group keeps its id
|
|
35
|
+
* (keyed by anchor; `--renumber` resets), so the builder can run after every
|
|
36
|
+
* explorer step while group_queue.mjs is already converting (`--exploring` holds
|
|
37
|
+
* source-only groups until the final run without it).
|
|
38
|
+
*
|
|
39
|
+
* Incremental mode (`--scope <json>`, the user-confirmed SCOPE of
|
|
40
|
+
* references/incremental-scope.md I4): only the scope's pages are converted. Every
|
|
41
|
+
* other page becomes `skip` (`out-of-incremental-scope`), and its source-only
|
|
42
|
+
* directory, if an earlier run made one, is left alone. The entry node is still
|
|
43
|
+
* inferred over the whole graph, so a group mounted on the existing launch page
|
|
44
|
+
* keeps `ENTRY_PAGE`. `--existing <json>` lists the .ets files the Harmony
|
|
45
|
+
* project already has (I3, relative to the ETS root): a group predicted to write
|
|
46
|
+
* one is `host-chain` with `existing_writes`. With no entry group in scope, the
|
|
47
|
+
* first host-chain group (else the first group) becomes stage 0: it reads the
|
|
48
|
+
* existing conventions before anything else converts.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
import * as fs from 'node:fs';
|
|
52
|
+
import * as path from 'node:path';
|
|
53
|
+
import { pathToFileURL } from 'node:url';
|
|
54
|
+
import { _replace } from './group_watch.mjs';
|
|
55
|
+
|
|
56
|
+
// ---------------------------------------------------------------- Python compatibility layer
|
|
57
|
+
// These outputs are a contract read by other scripts and the agent and must match the original Python version byte for byte:
|
|
58
|
+
// JSON in json.dumps(indent=2, ensure_ascii=False) format (floats written by repr,
|
|
59
|
+
// big integers without precision loss, object keys in insertion order), text written with \r\n on Windows,
|
|
60
|
+
// sorting by Python comparison rules (strings by code point, tuples item by item, None not comparable).
|
|
61
|
+
|
|
62
|
+
const IS_WIN = process.platform === 'win32';
|
|
63
|
+
const EOL = IS_WIN ? '\r\n' : '\n';
|
|
64
|
+
|
|
65
|
+
/** A float read by json.loads: keeps the fact "it is a float" and is written back as Python repr. */
|
|
66
|
+
export class PyFloat {
|
|
67
|
+
constructor(value) { this.value = value; }
|
|
68
|
+
valueOf() { return this.value; }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// If a parsed object has integer-like keys ("0", "12"), plain JS objects move them first; record the original key order.
|
|
72
|
+
const KEY_ORDER = Symbol('pyKeyOrder');
|
|
73
|
+
const INDEX_KEY = /^(?:0|[1-9][0-9]*)$/;
|
|
74
|
+
|
|
75
|
+
function floatRepr(x, json) {
|
|
76
|
+
if (!Number.isFinite(x)) {
|
|
77
|
+
if (Number.isNaN(x)) { return json ? 'NaN' : 'nan'; }
|
|
78
|
+
return x > 0 ? (json ? 'Infinity' : 'inf') : (json ? '-Infinity' : '-inf');
|
|
79
|
+
}
|
|
80
|
+
if (x === 0) { return Object.is(x, -0) ? '-0.0' : '0.0'; }
|
|
81
|
+
const [m, e] = Math.abs(x).toExponential().split('e');
|
|
82
|
+
const digits = m.replace('.', '');
|
|
83
|
+
const exp = Number(e);
|
|
84
|
+
let s;
|
|
85
|
+
if (exp >= -4 && exp < 16) {
|
|
86
|
+
if (exp >= 0) {
|
|
87
|
+
const ip = digits.slice(0, exp + 1).padEnd(exp + 1, '0');
|
|
88
|
+
s = ip + '.' + (digits.slice(exp + 1) || '0');
|
|
89
|
+
} else {
|
|
90
|
+
s = '0.' + '0'.repeat(-exp - 1) + digits;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
s = digits[0] + (digits.length > 1 ? '.' + digits.slice(1) : '') + 'e' + (exp < 0 ? '-' : '+') +
|
|
94
|
+
String(Math.abs(exp)).padStart(2, '0');
|
|
95
|
+
}
|
|
96
|
+
return (x < 0 ? '-' : '') + s;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** json.loads: float → PyFloat, integers beyond the safe range → BigInt, otherwise same as JSON.parse. */
|
|
100
|
+
function pyJsonLoads(text) {
|
|
101
|
+
let i = 0;
|
|
102
|
+
const n = text.length;
|
|
103
|
+
const fail = (msg) => { throw new SyntaxError(`${msg}: char ${i}`); };
|
|
104
|
+
const ws = () => {
|
|
105
|
+
while (i < n) {
|
|
106
|
+
const c = text.charCodeAt(i);
|
|
107
|
+
if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d) { i++; } else { break; }
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const NUM = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/y;
|
|
111
|
+
const str = () => {
|
|
112
|
+
i++;
|
|
113
|
+
let out = '';
|
|
114
|
+
let start = i;
|
|
115
|
+
for (;;) {
|
|
116
|
+
if (i >= n) { fail('Unterminated string'); }
|
|
117
|
+
const c = text.charCodeAt(i);
|
|
118
|
+
if (c === 0x22) { out += text.slice(start, i); i++; return out; }
|
|
119
|
+
if (c < 0x20) { fail('Invalid control character'); }
|
|
120
|
+
if (c === 0x5c) {
|
|
121
|
+
out += text.slice(start, i);
|
|
122
|
+
const esc = text[i + 1];
|
|
123
|
+
const simple = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }[esc];
|
|
124
|
+
if (simple !== undefined) {
|
|
125
|
+
out += simple;
|
|
126
|
+
i += 2;
|
|
127
|
+
} else if (esc === 'u') {
|
|
128
|
+
const hex = text.slice(i + 2, i + 6);
|
|
129
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) { fail('Invalid \\uXXXX escape'); }
|
|
130
|
+
out += String.fromCharCode(parseInt(hex, 16));
|
|
131
|
+
i += 6;
|
|
132
|
+
} else {
|
|
133
|
+
fail('Invalid \\escape');
|
|
134
|
+
}
|
|
135
|
+
start = i;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
i++;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const value = () => {
|
|
142
|
+
ws();
|
|
143
|
+
const c = text[i];
|
|
144
|
+
if (c === '{') {
|
|
145
|
+
i++;
|
|
146
|
+
const o = {};
|
|
147
|
+
const order = [];
|
|
148
|
+
let hasIndex = false;
|
|
149
|
+
ws();
|
|
150
|
+
if (text[i] === '}') { i++; return o; }
|
|
151
|
+
for (;;) {
|
|
152
|
+
ws();
|
|
153
|
+
if (text[i] !== '"') { fail('Expecting property name enclosed in double quotes'); }
|
|
154
|
+
const k = str();
|
|
155
|
+
ws();
|
|
156
|
+
if (text[i] !== ':') { fail("Expecting ':' delimiter"); }
|
|
157
|
+
i++;
|
|
158
|
+
const v = value();
|
|
159
|
+
if (!Object.hasOwn(o, k)) {
|
|
160
|
+
order.push(k);
|
|
161
|
+
if (INDEX_KEY.test(k)) { hasIndex = true; }
|
|
162
|
+
}
|
|
163
|
+
if (k === '__proto__') {
|
|
164
|
+
Object.defineProperty(o, k, { value: v, enumerable: true, writable: true, configurable: true });
|
|
165
|
+
} else {
|
|
166
|
+
o[k] = v;
|
|
167
|
+
}
|
|
168
|
+
ws();
|
|
169
|
+
if (text[i] === ',') { i++; continue; }
|
|
170
|
+
if (text[i] === '}') { i++; break; }
|
|
171
|
+
fail("Expecting ',' delimiter");
|
|
172
|
+
}
|
|
173
|
+
if (hasIndex) { o[KEY_ORDER] = order; }
|
|
174
|
+
return o;
|
|
175
|
+
}
|
|
176
|
+
if (c === '[') {
|
|
177
|
+
i++;
|
|
178
|
+
const a = [];
|
|
179
|
+
ws();
|
|
180
|
+
if (text[i] === ']') { i++; return a; }
|
|
181
|
+
for (;;) {
|
|
182
|
+
a.push(value());
|
|
183
|
+
ws();
|
|
184
|
+
if (text[i] === ',') { i++; continue; }
|
|
185
|
+
if (text[i] === ']') { i++; break; }
|
|
186
|
+
fail("Expecting ',' delimiter");
|
|
187
|
+
}
|
|
188
|
+
return a;
|
|
189
|
+
}
|
|
190
|
+
if (c === '"') { return str(); }
|
|
191
|
+
if (text.startsWith('null', i)) { i += 4; return null; }
|
|
192
|
+
if (text.startsWith('true', i)) { i += 4; return true; }
|
|
193
|
+
if (text.startsWith('false', i)) { i += 5; return false; }
|
|
194
|
+
if (text.startsWith('NaN', i)) { i += 3; return new PyFloat(NaN); }
|
|
195
|
+
if (text.startsWith('Infinity', i)) { i += 8; return new PyFloat(Infinity); }
|
|
196
|
+
if (text.startsWith('-Infinity', i)) { i += 9; return new PyFloat(-Infinity); }
|
|
197
|
+
NUM.lastIndex = i;
|
|
198
|
+
const m = NUM.exec(text);
|
|
199
|
+
if (!m) { fail('Expecting value'); }
|
|
200
|
+
i += m[0].length;
|
|
201
|
+
if (m[1] !== undefined || m[2] !== undefined) { return new PyFloat(Number(m[0])); }
|
|
202
|
+
const num = Number(m[0]);
|
|
203
|
+
return Number.isSafeInteger(num) ? (num === 0 ? 0 : num) : BigInt(m[0]);
|
|
204
|
+
};
|
|
205
|
+
const v = value();
|
|
206
|
+
ws();
|
|
207
|
+
if (i !== n) { fail('Extra data'); }
|
|
208
|
+
return v;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function keysOf(o) {
|
|
212
|
+
const ks = Object.keys(o);
|
|
213
|
+
const ord = o[KEY_ORDER];
|
|
214
|
+
if (!ord) { return ks; }
|
|
215
|
+
const present = new Set(ks);
|
|
216
|
+
const out = ord.filter((k) => present.has(k));
|
|
217
|
+
const seen = new Set(out);
|
|
218
|
+
for (const k of ks) { if (!seen.has(k)) { out.push(k); } }
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** json.dumps(v, ensure_ascii=False, indent=indent). undefined is treated as None (matches dict.get default). */
|
|
223
|
+
function pyJsonDumps(v, indent, level = 0) {
|
|
224
|
+
if (v === null || v === undefined) { return 'null'; }
|
|
225
|
+
if (v === true) { return 'true'; }
|
|
226
|
+
if (v === false) { return 'false'; }
|
|
227
|
+
if (typeof v === 'bigint') { return v.toString(); }
|
|
228
|
+
if (v instanceof PyFloat) { return floatRepr(v.value, true); }
|
|
229
|
+
if (typeof v === 'number') { return Number.isInteger(v) ? (Object.is(v, -0) ? '0' : String(v)) : floatRepr(v, true); }
|
|
230
|
+
if (typeof v === 'string') { return JSON.stringify(v); }
|
|
231
|
+
const pad = '\n' + ' '.repeat(indent * (level + 1));
|
|
232
|
+
const end = '\n' + ' '.repeat(indent * level);
|
|
233
|
+
if (Array.isArray(v)) {
|
|
234
|
+
if (v.length === 0) { return '[]'; }
|
|
235
|
+
return '[' + pad + v.map((x) => pyJsonDumps(x, indent, level + 1)).join(',' + pad) + end + ']';
|
|
236
|
+
}
|
|
237
|
+
const ks = keysOf(v);
|
|
238
|
+
if (ks.length === 0) { return '{}'; }
|
|
239
|
+
return '{' + pad + ks.map((k) => JSON.stringify(k) + ': ' + pyJsonDumps(v[k], indent, level + 1)).join(',' + pad) +
|
|
240
|
+
end + '}';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
244
|
+
|
|
245
|
+
/** Path.read_text(encoding="utf-8"): strict decoding, BOM kept, universal newlines. */
|
|
246
|
+
function readText(p) {
|
|
247
|
+
return UTF8.decode(fs.readFileSync(p)).replace(/\r\n?/g, '\n');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
function out(s = '') { process.stdout.write(s + EOL); }
|
|
252
|
+
function err(s = '') { process.stderr.write(s + EOL); }
|
|
253
|
+
|
|
254
|
+
function isFile(p) {
|
|
255
|
+
try { return fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false; } catch { return false; }
|
|
256
|
+
}
|
|
257
|
+
function isDir(p) {
|
|
258
|
+
try { return fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false; } catch { return false; }
|
|
259
|
+
}
|
|
260
|
+
function exists(p) {
|
|
261
|
+
try { return fs.statSync(p, { throwIfNoEntry: false }) !== undefined; } catch { return false; }
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** dict.get(k, d): the default is used only when the key is missing; a null value is still returned as null. */
|
|
265
|
+
function get(o, k, d = undefined) {
|
|
266
|
+
return o !== null && typeof o === 'object' && !Array.isArray(o) && Object.hasOwn(o, k) ? o[k] : d;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function truthy(v) {
|
|
270
|
+
if (v === null || v === undefined || v === false) { return false; }
|
|
271
|
+
if (v === true) { return true; }
|
|
272
|
+
if (typeof v === 'number') { return v !== 0; }
|
|
273
|
+
if (typeof v === 'bigint') { return v !== 0n; }
|
|
274
|
+
if (v instanceof PyFloat) { return v.value !== 0; }
|
|
275
|
+
if (typeof v === 'string' || Array.isArray(v)) { return v.length > 0; }
|
|
276
|
+
if (v instanceof Map || v instanceof Set) { return v.size > 0; }
|
|
277
|
+
return Object.keys(v).length > 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Python's `a or b`. */
|
|
281
|
+
function or(a, b) { return truthy(a) ? a : b; }
|
|
282
|
+
|
|
283
|
+
function pyLen(v) {
|
|
284
|
+
if (typeof v === 'string') { return [...v].length; }
|
|
285
|
+
if (Array.isArray(v)) { return v.length; }
|
|
286
|
+
if (v !== null && typeof v === 'object' && !(v instanceof PyFloat)) { return Object.keys(v).length; }
|
|
287
|
+
throw new TypeError(`object of type '${pyType(v)}' has no len()`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function pyType(v) {
|
|
291
|
+
if (v === null || v === undefined) { return 'NoneType'; }
|
|
292
|
+
if (typeof v === 'boolean') { return 'bool'; }
|
|
293
|
+
if (typeof v === 'number') { return Number.isInteger(v) ? 'int' : 'float'; }
|
|
294
|
+
if (typeof v === 'bigint') { return 'int'; }
|
|
295
|
+
if (v instanceof PyFloat) { return 'float'; }
|
|
296
|
+
if (typeof v === 'string') { return 'str'; }
|
|
297
|
+
if (Array.isArray(v)) { return 'list'; }
|
|
298
|
+
return 'dict';
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Python's `x in container` (list by equality, str by substring, dict by key). */
|
|
302
|
+
function pyIn(x, c) {
|
|
303
|
+
if (typeof c === 'string') { return typeof x === 'string' && c.includes(x); }
|
|
304
|
+
if (Array.isArray(c)) { return c.some((y) => pyEq(x, y)); }
|
|
305
|
+
if (c !== null && typeof c === 'object') { return typeof x === 'string' && Object.hasOwn(c, x); }
|
|
306
|
+
throw new TypeError(`argument of type '${pyType(c)}' is not iterable`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function numOf(v) {
|
|
310
|
+
if (typeof v === 'boolean') { return v ? 1 : 0; }
|
|
311
|
+
if (v instanceof PyFloat) { return v.value; }
|
|
312
|
+
if (typeof v === 'number' || typeof v === 'bigint') { return v; }
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function pyEq(a, b) {
|
|
317
|
+
if (a === undefined) { a = null; }
|
|
318
|
+
if (b === undefined) { b = null; }
|
|
319
|
+
const na = numOf(a);
|
|
320
|
+
const nb = numOf(b);
|
|
321
|
+
if (na !== undefined && nb !== undefined) { return na == nb; } // eslint-disable-line eqeqeq
|
|
322
|
+
if (na !== undefined || nb !== undefined) { return false; }
|
|
323
|
+
if (a === null || b === null || typeof a === 'string' || typeof b === 'string') { return a === b; }
|
|
324
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
325
|
+
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((x, i) => pyEq(x, b[i]));
|
|
326
|
+
}
|
|
327
|
+
const ka = Object.keys(a);
|
|
328
|
+
return ka.length === Object.keys(b).length && ka.every((k) => Object.hasOwn(b, k) && pyEq(a[k], b[k]));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const SURROGATE = /[\uD800-\uDFFF]/;
|
|
332
|
+
|
|
333
|
+
function cmpStr(a, b) {
|
|
334
|
+
if (!SURROGATE.test(a) && !SURROGATE.test(b)) { return a < b ? -1 : a > b ? 1 : 0; }
|
|
335
|
+
const x = [...a];
|
|
336
|
+
const y = [...b];
|
|
337
|
+
for (let i = 0; i < Math.min(x.length, y.length); i++) {
|
|
338
|
+
const d = x[i].codePointAt(0) - y[i].codePointAt(0);
|
|
339
|
+
if (d !== 0) { return d < 0 ? -1 : 1; }
|
|
340
|
+
}
|
|
341
|
+
return x.length - y.length < 0 ? -1 : x.length > y.length ? 1 : 0;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Python `<` comparison (for sorted keys): numbers compare with each other, str by code point, tuple/list item by item; other combinations throw TypeError. */
|
|
345
|
+
function pyCmp(a, b) {
|
|
346
|
+
const na = numOf(a);
|
|
347
|
+
const nb = numOf(b);
|
|
348
|
+
if (na !== undefined && nb !== undefined) { return na < nb ? -1 : na > nb ? 1 : 0; }
|
|
349
|
+
if (typeof a === 'string' && typeof b === 'string') { return cmpStr(a, b); }
|
|
350
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
351
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
352
|
+
if (!pyEq(a[i], b[i])) { return pyCmp(a[i], b[i]); }
|
|
353
|
+
}
|
|
354
|
+
return a.length < b.length ? -1 : a.length > b.length ? 1 : 0;
|
|
355
|
+
}
|
|
356
|
+
throw new TypeError(`'<' not supported between instances of '${pyType(a)}' and '${pyType(b)}'`);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** sorted(items, key=key, reverse=reverse): stable sort. */
|
|
360
|
+
function sortedBy(items, key = (x) => x, reverse = false) {
|
|
361
|
+
const dec = [...items].map((v, i) => [key(v), i, v]);
|
|
362
|
+
dec.sort((p, q) => (reverse ? pyCmp(q[0], p[0]) : pyCmp(p[0], q[0])) || p[1] - q[1]);
|
|
363
|
+
return dec.map((d) => d[2]);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const NON_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
|
|
367
|
+
|
|
368
|
+
function strRepr(s) {
|
|
369
|
+
const q = s.includes("'") && !s.includes('"') ? '"' : "'";
|
|
370
|
+
let r = q;
|
|
371
|
+
for (const ch of s) {
|
|
372
|
+
const cp = ch.codePointAt(0);
|
|
373
|
+
if (ch === q || ch === '\\') { r += '\\' + ch; }
|
|
374
|
+
else if (ch === '\t') { r += '\\t'; }
|
|
375
|
+
else if (ch === '\n') { r += '\\n'; }
|
|
376
|
+
else if (ch === '\r') { r += '\\r'; }
|
|
377
|
+
else if (ch !== ' ' && NON_PRINTABLE.test(ch)) {
|
|
378
|
+
r += cp < 0x100 ? '\\x' + cp.toString(16).padStart(2, '0')
|
|
379
|
+
: cp < 0x10000 ? '\\u' + cp.toString(16).padStart(4, '0') : '\\U' + cp.toString(16).padStart(8, '0');
|
|
380
|
+
} else { r += ch; }
|
|
381
|
+
}
|
|
382
|
+
return r + q;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** repr(v). */
|
|
386
|
+
function pyRepr(v) {
|
|
387
|
+
if (v === null || v === undefined) { return 'None'; }
|
|
388
|
+
if (v === true) { return 'True'; }
|
|
389
|
+
if (v === false) { return 'False'; }
|
|
390
|
+
if (typeof v === 'bigint') { return v.toString(); }
|
|
391
|
+
if (v instanceof PyFloat) { return floatRepr(v.value, false); }
|
|
392
|
+
if (typeof v === 'number') { return Number.isInteger(v) ? String(v === 0 ? 0 : v) : floatRepr(v, false); }
|
|
393
|
+
if (typeof v === 'string') { return strRepr(v); }
|
|
394
|
+
if (Array.isArray(v)) { return '[' + v.map(pyRepr).join(', ') + ']'; }
|
|
395
|
+
return '{' + keysOf(v).map((k) => strRepr(k) + ': ' + pyRepr(v[k])).join(', ') + '}';
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** str(v) / f"{v}". */
|
|
399
|
+
function pyStr(v) { return typeof v === 'string' ? v : pyRepr(v); }
|
|
400
|
+
|
|
401
|
+
/** int() of a re `\d+` match (Unicode decimal digits: each Nd run is aligned blocks of ten). */
|
|
402
|
+
function pyInt(digits) {
|
|
403
|
+
let s = '';
|
|
404
|
+
for (const ch of digits) {
|
|
405
|
+
let cp = ch.codePointAt(0);
|
|
406
|
+
let k = 0;
|
|
407
|
+
while (/\p{Nd}/u.test(String.fromCodePoint(cp - 1))) { cp--; k++; }
|
|
408
|
+
s += String(k % 10);
|
|
409
|
+
}
|
|
410
|
+
const n = Number(s);
|
|
411
|
+
return Number.isSafeInteger(n) ? n : BigInt(s);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function setdefault(m, k, d) {
|
|
415
|
+
if (!m.has(k)) { m.set(k, d); }
|
|
416
|
+
return m.get(k);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// ---------------------------------------------------------------- paths (pathlib semantics)
|
|
420
|
+
|
|
421
|
+
function splitPath(p) {
|
|
422
|
+
if (IS_WIN) {
|
|
423
|
+
const s = String(p).replace(/\//g, '\\');
|
|
424
|
+
let drive = '';
|
|
425
|
+
let rest = s;
|
|
426
|
+
const unc = /^\\\\([^\\]+)\\([^\\]+)/.exec(s);
|
|
427
|
+
if (unc) { drive = unc[0]; rest = s.slice(drive.length); }
|
|
428
|
+
else if (/^[A-Za-z]:/.test(s)) { drive = s.slice(0, 2); rest = s.slice(2); }
|
|
429
|
+
const root = rest.startsWith('\\') ? '\\' : '';
|
|
430
|
+
return { drive, root, parts: rest.split('\\').filter((x) => x !== '' && x !== '.') };
|
|
431
|
+
}
|
|
432
|
+
const s = String(p);
|
|
433
|
+
const root = s.startsWith('//') && !s.startsWith('///') ? '//' : s.startsWith('/') ? '/' : '';
|
|
434
|
+
return { drive: '', root, parts: s.split('/').filter((x) => x !== '' && x !== '.') };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** str(Path(p)). */
|
|
438
|
+
function pathStr(p) {
|
|
439
|
+
const { drive, root, parts } = splitPath(p);
|
|
440
|
+
const s = drive + root + parts.join(IS_WIN ? '\\' : '/');
|
|
441
|
+
return s || '.';
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** Path(p).name. */
|
|
445
|
+
function pathName(p) {
|
|
446
|
+
const { parts } = splitPath(p);
|
|
447
|
+
return parts.length ? parts[parts.length - 1] : '';
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Path(p).resolve(): realpath on the longest existing prefix, the rest copied as is. */
|
|
451
|
+
function pathResolve(p) {
|
|
452
|
+
let abs = path.resolve(String(p));
|
|
453
|
+
const tail = [];
|
|
454
|
+
for (;;) {
|
|
455
|
+
try {
|
|
456
|
+
const real = fs.realpathSync.native(abs);
|
|
457
|
+
return tail.length ? path.join(real, ...tail.reverse()) : real;
|
|
458
|
+
} catch {
|
|
459
|
+
const parent = path.dirname(abs);
|
|
460
|
+
if (parent === abs) { return path.resolve(String(p)); }
|
|
461
|
+
tail.push(path.basename(abs));
|
|
462
|
+
abs = parent;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** Path(p).absolute(): only prepends cwd, does not normalize `..`. */
|
|
468
|
+
function pathAbsolute(p) {
|
|
469
|
+
const { drive, root, parts } = splitPath(p);
|
|
470
|
+
const sep = IS_WIN ? '\\' : '/';
|
|
471
|
+
if (IS_WIN ? (drive && root) || /^\\\\/.test(drive) : root) { return pathStr(p); }
|
|
472
|
+
const cwd = process.cwd();
|
|
473
|
+
if (root) { return splitPath(cwd).drive + root + parts.join(sep); }
|
|
474
|
+
const base = drive ? path.resolve(drive) : cwd;
|
|
475
|
+
return [base.replace(/[\\/]+$/, ''), ...parts].join(sep) || base;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** Path(dir).glob(prefix + '*'): raw file-system order (os.scandir), case-insensitive on Windows. */
|
|
479
|
+
function globPrefix(dir, prefix) {
|
|
480
|
+
const names = [];
|
|
481
|
+
let d;
|
|
482
|
+
try { d = fs.opendirSync(dir); } catch { return names; }
|
|
483
|
+
try {
|
|
484
|
+
for (let e = d.readSync(); e !== null; e = d.readSync()) {
|
|
485
|
+
const nm = e.name;
|
|
486
|
+
if (IS_WIN ? nm.toLowerCase().startsWith(prefix.toLowerCase()) : nm.startsWith(prefix)) { names.push(nm); }
|
|
487
|
+
}
|
|
488
|
+
} finally { d.closeSync(); }
|
|
489
|
+
return names.map((nm) => path.join(String(dir), nm));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// ---------------------------------------------------------------- argparse equivalent
|
|
493
|
+
// Replicates argparse's observable behavior: unique long-option prefixes, `--opt=value`, `--`,
|
|
494
|
+
// `-h/--help` layout (width = terminal columns - 2), on error prints usage to stderr and exits 2.
|
|
495
|
+
|
|
496
|
+
function termColumns() {
|
|
497
|
+
const env = Number.parseInt(process.env.COLUMNS ?? '', 10);
|
|
498
|
+
if (env > 0) { return env; }
|
|
499
|
+
// shutil.get_terminal_size(): COLUMNS, else the stdout tty, else 80.
|
|
500
|
+
return process.stdout.isTTY && process.stdout.columns ? process.stdout.columns : 80;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** Common subset of textwrap.wrap(width): break at whitespace, hard-split overlong words. */
|
|
504
|
+
function wrapText(text, width) {
|
|
505
|
+
const words = text.split(' ').filter((w) => w !== '');
|
|
506
|
+
const lines = [];
|
|
507
|
+
let cur = '';
|
|
508
|
+
for (let w of words) {
|
|
509
|
+
while (w.length > width && cur === '') { lines.push(w.slice(0, width)); w = w.slice(width); }
|
|
510
|
+
if (cur === '') { cur = w; }
|
|
511
|
+
else if (cur.length + 1 + w.length <= width) { cur += ' ' + w; }
|
|
512
|
+
else {
|
|
513
|
+
lines.push(cur);
|
|
514
|
+
cur = '';
|
|
515
|
+
while (w.length > width) { lines.push(w.slice(0, width)); w = w.slice(width); }
|
|
516
|
+
cur = w;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (cur !== '') { lines.push(cur); }
|
|
520
|
+
return lines;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* spec: { prog, description, args: [{ name, positional?, metavar?, help?, required?, type?: 'int', def? }] }
|
|
525
|
+
* Returns { dest: value } (dest = leading `--` removed, `-` replaced with `_`).
|
|
526
|
+
*/
|
|
527
|
+
function parseArgs(spec, argv) {
|
|
528
|
+
const width = termColumns() - 2;
|
|
529
|
+
const actions = [{ name: '-h', alias: '--help', help: 'show this help message and exit', flag: true }, ...spec.args];
|
|
530
|
+
const dest = (a) => a.name.replace(/^-+/, '').replace(/-/g, '_');
|
|
531
|
+
const metavar = (a) => a.metavar ?? dest(a).toUpperCase();
|
|
532
|
+
const invocation = (a) => (a.positional ? a.name : a.flag ? `${a.name}, ${a.alias}` : a.bool ? a.name : `${a.name} ${metavar(a)}`);
|
|
533
|
+
const usagePart = (a) => {
|
|
534
|
+
if (a.positional) { return a.name; }
|
|
535
|
+
const s = a.flag || a.bool ? a.name : `${a.name} ${metavar(a)}`;
|
|
536
|
+
return a.required ? s : `[${s}]`;
|
|
537
|
+
};
|
|
538
|
+
const opts = actions.filter((a) => !a.positional);
|
|
539
|
+
const poss = actions.filter((a) => a.positional);
|
|
540
|
+
|
|
541
|
+
const formatUsage = () => {
|
|
542
|
+
const prefix = 'usage: ';
|
|
543
|
+
const prog = spec.prog;
|
|
544
|
+
const optParts = opts.map(usagePart);
|
|
545
|
+
const posParts = poss.map(usagePart);
|
|
546
|
+
let usage = [prog, ...optParts, ...posParts].join(' ');
|
|
547
|
+
if (prefix.length + usage.length > width) {
|
|
548
|
+
const getLines = (parts, indent, pfx) => {
|
|
549
|
+
const lines = [];
|
|
550
|
+
let line = [];
|
|
551
|
+
let len = pfx !== undefined ? pfx.length - 1 : indent.length - 1;
|
|
552
|
+
for (const part of parts) {
|
|
553
|
+
if (len + 1 + part.length > width && line.length) {
|
|
554
|
+
lines.push(indent + line.join(' '));
|
|
555
|
+
line = [];
|
|
556
|
+
len = indent.length - 1;
|
|
557
|
+
}
|
|
558
|
+
line.push(part);
|
|
559
|
+
len += part.length + 1;
|
|
560
|
+
}
|
|
561
|
+
if (line.length) { lines.push(indent + line.join(' ')); }
|
|
562
|
+
if (pfx !== undefined) { lines[0] = lines[0].slice(indent.length); }
|
|
563
|
+
return lines;
|
|
564
|
+
};
|
|
565
|
+
let lines;
|
|
566
|
+
if (prefix.length + prog.length <= 0.75 * width) {
|
|
567
|
+
const indent = ' '.repeat(prefix.length + prog.length + 1);
|
|
568
|
+
lines = getLines([prog, ...optParts], indent, prefix);
|
|
569
|
+
lines.push(...getLines(posParts, indent));
|
|
570
|
+
} else {
|
|
571
|
+
const indent = ' '.repeat(prefix.length);
|
|
572
|
+
lines = getLines([...optParts, ...posParts], indent);
|
|
573
|
+
if (lines.length > 1) { lines = [...getLines(optParts, indent), ...getLines(posParts, indent)]; }
|
|
574
|
+
lines = [prog, ...lines];
|
|
575
|
+
}
|
|
576
|
+
usage = lines.join('\n');
|
|
577
|
+
}
|
|
578
|
+
return prefix + usage;
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
const formatHelp = () => {
|
|
582
|
+
const maxHelpPos = Math.min(24, Math.max(width - 20, 4));
|
|
583
|
+
const maxLen = Math.max(...actions.map((a) => invocation(a).length + 2));
|
|
584
|
+
const helpPos = Math.min(maxLen + 2, maxHelpPos);
|
|
585
|
+
const helpWidth = Math.max(width - helpPos, 11);
|
|
586
|
+
const actionWidth = helpPos - 2 - 2;
|
|
587
|
+
const item = (a) => {
|
|
588
|
+
const inv = invocation(a);
|
|
589
|
+
const rows = [];
|
|
590
|
+
let first;
|
|
591
|
+
if (!a.help) { rows.push(' ' + inv); return rows; }
|
|
592
|
+
if (inv.length <= actionWidth) { first = ' ' + inv.padEnd(actionWidth) + ' '; }
|
|
593
|
+
else { rows.push(' ' + inv); first = ' '.repeat(helpPos); }
|
|
594
|
+
const hl = wrapText(a.help.replace(/\s+/g, ' ').trim(), helpWidth);
|
|
595
|
+
rows.push(first + hl[0]);
|
|
596
|
+
for (const l of hl.slice(1)) { rows.push(' '.repeat(helpPos) + l); }
|
|
597
|
+
return rows;
|
|
598
|
+
};
|
|
599
|
+
const parts = [formatUsage(), ''];
|
|
600
|
+
if (spec.description) { parts.push(...wrapText(spec.description.replace(/\s+/g, ' ').trim(), width), ''); }
|
|
601
|
+
if (poss.length) { parts.push('positional arguments:', ...poss.flatMap(item), ''); }
|
|
602
|
+
parts.push('options:', ...opts.flatMap(item));
|
|
603
|
+
return parts.join('\n');
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
const fail = (msg) => {
|
|
607
|
+
err(formatUsage());
|
|
608
|
+
err(`${spec.prog}: error: ${msg}`);
|
|
609
|
+
process.exit(2);
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
const result = {};
|
|
613
|
+
for (const a of spec.args) { result[dest(a)] = a.bool ? false : (a.def ?? null); }
|
|
614
|
+
const seen = new Set();
|
|
615
|
+
const positionals = [];
|
|
616
|
+
const extras = [];
|
|
617
|
+
const longNames = opts.flatMap((a) => (a.alias ? [[a.name, a], [a.alias, a]] : [[a.name, a]]));
|
|
618
|
+
const looksNegative = (s) => /^-\d+$|^-\d*\.\d+$/.test(s);
|
|
619
|
+
const isOptionLike = (s) => s.startsWith('-') && s !== '-' && !looksNegative(s) && !(s.includes(' ') && !findOpt(s));
|
|
620
|
+
function findOpt(s) {
|
|
621
|
+
const [k] = s.split('=', 1);
|
|
622
|
+
const exact = longNames.find(([n]) => n === k);
|
|
623
|
+
if (exact) { return exact[1]; }
|
|
624
|
+
if (!k.startsWith('--')) { return null; }
|
|
625
|
+
const hits = longNames.filter(([n]) => n.startsWith(k));
|
|
626
|
+
const uniq = [...new Set(hits.map((h) => h[1]))];
|
|
627
|
+
if (uniq.length > 1) { fail(`ambiguous option: ${k} could match ${hits.map((h) => h[0]).join(', ')}`); }
|
|
628
|
+
return uniq[0] ?? null;
|
|
629
|
+
}
|
|
630
|
+
let i = 0;
|
|
631
|
+
let rest = false;
|
|
632
|
+
while (i < argv.length) {
|
|
633
|
+
const s = argv[i];
|
|
634
|
+
if (!rest && s === '--') { rest = true; i++; continue; }
|
|
635
|
+
if (rest || !isOptionLike(s)) { positionals.push(s); i++; continue; }
|
|
636
|
+
const a = findOpt(s);
|
|
637
|
+
if (!a) { extras.push(s); i++; continue; }
|
|
638
|
+
const eq = s.indexOf('=');
|
|
639
|
+
const name = a.name;
|
|
640
|
+
if (a.flag) {
|
|
641
|
+
if (eq >= 0) { fail(`argument -h/--help: ignored explicit argument '${s.slice(eq + 1)}'`); }
|
|
642
|
+
process.stdout.write((formatHelp() + '\n').replace(/\n/g, EOL));
|
|
643
|
+
process.exit(0);
|
|
644
|
+
}
|
|
645
|
+
if (a.bool) {
|
|
646
|
+
if (eq >= 0) { fail(`argument ${name}: ignored explicit argument '${s.slice(eq + 1)}'`); }
|
|
647
|
+
result[dest(a)] = true;
|
|
648
|
+
seen.add(a);
|
|
649
|
+
i++;
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
let val;
|
|
653
|
+
if (eq >= 0 && s.startsWith('--')) { val = s.slice(eq + 1); i++; }
|
|
654
|
+
else if (i + 1 < argv.length && !(argv[i + 1] === '--' || isOptionLike(argv[i + 1]))) { val = argv[i + 1]; i += 2; }
|
|
655
|
+
else { fail(`argument ${name}: expected one argument`); }
|
|
656
|
+
if (a.type === 'int') {
|
|
657
|
+
const t = val.trim();
|
|
658
|
+
if (!/^[+-]?\p{Nd}+(?:_\p{Nd}+)*$/u.test(t)) { fail(`argument ${name}: invalid int value: ${pyRepr(val)}`); }
|
|
659
|
+
val = Number(pyInt(t.replace(/^[+-]|_/g, ''))) * (t.startsWith('-') ? -1 : 1);
|
|
660
|
+
}
|
|
661
|
+
result[dest(a)] = val;
|
|
662
|
+
seen.add(a);
|
|
663
|
+
}
|
|
664
|
+
poss.forEach((a, k) => { if (k < positionals.length) { result[dest(a)] = positionals[k]; seen.add(a); } });
|
|
665
|
+
extras.push(...positionals.slice(poss.length));
|
|
666
|
+
const missing = actions.filter((a) => (a.positional || a.required) && !seen.has(a)).map((a) => a.name);
|
|
667
|
+
if (missing.length) { fail(`the following arguments are required: ${missing.join(', ')}`); }
|
|
668
|
+
if (extras.length) { fail(`unrecognized arguments: ${extras.join(' ')}`); }
|
|
669
|
+
return result;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// ---------------------------------------------------------------- roles
|
|
673
|
+
|
|
674
|
+
// Same container kinds export_ui_info refuses to export, minus the ones
|
|
675
|
+
// that are UI attached to a host (they become `attach`, not `skip`).
|
|
676
|
+
export const SKIP_KINDS = new Set(['host-activity', 'sentinel', 'media-browse', 'media-player', 'unknown', 'hybrid']);
|
|
677
|
+
export const ATTACH_KINDS = new Set(['menu', 'ui-state', 'mode', 'panel']);
|
|
678
|
+
export const PAGE_PREFIXES = ['activity:', 'fragment:', 'dialog:', 'pref-dialog:', 'overlay:'];
|
|
679
|
+
export const ARROW = ' → ';
|
|
680
|
+
export const MAX_TEMPLATES = 3;
|
|
681
|
+
export const GENERIC_BASES = new Set(['Fragment', 'DialogFragment', 'AppCompatDialogFragment', 'BottomSheetDialogFragment',
|
|
682
|
+
'Activity', 'AppCompatActivity', 'FragmentActivity', 'PreferenceFragmentCompat']);
|
|
683
|
+
|
|
684
|
+
const startsWithAny = (s, prefixes) => prefixes.some((p) => s.startsWith(p));
|
|
685
|
+
|
|
686
|
+
export function readJson(p, dflt = null) {
|
|
687
|
+
if (!isFile(p)) { return dflt; }
|
|
688
|
+
return pyJsonLoads(readText(p));
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Atomic (tmp + rename, Windows EPERM retried: group_watch._replace): group_queue / group_watch
|
|
693
|
+
* read these files while a refresh rewrites them, and an in-place write showed them half a file.
|
|
694
|
+
*/
|
|
695
|
+
export function writeJson(p, data) {
|
|
696
|
+
_replace(p, pyJsonDumps(data, 2));
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
export function safeName(node) {
|
|
700
|
+
// str(node.get("id", "")).split(":", 1)[-1]
|
|
701
|
+
const sid = pyStr(get(node, 'id', ''));
|
|
702
|
+
const colon = sid.indexOf(':');
|
|
703
|
+
const raw = or(get(node, 'name'), or(colon < 0 ? sid : sid.slice(colon + 1), 'Page'));
|
|
704
|
+
const name = raw.replace(/[^A-Za-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
|
|
705
|
+
return name || 'Page';
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/** `res/layout/x.xml:22` → `res/layout/x.xml`. */
|
|
709
|
+
export function stripLine(loc) {
|
|
710
|
+
if (!truthy(loc)) { return null; }
|
|
711
|
+
return pyStr(loc).replace(/:\p{Nd}+(?=\n?$)/u, '');
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export function layoutFiles(node) {
|
|
715
|
+
const files = [];
|
|
716
|
+
for (const w of or(get(node, 'widgets'), [])) {
|
|
717
|
+
for (const loc of [get(w, 'via'), get(w, 'at')]) {
|
|
718
|
+
const f = stripLine(loc);
|
|
719
|
+
if (f && f.endsWith('.xml') && !files.includes(f)) { files.push(f); }
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return files;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
export function shortName(nodeId) {
|
|
726
|
+
const parts = nodeId.split(':');
|
|
727
|
+
const at = parts[parts.length - 1].split('@');
|
|
728
|
+
return at[at.length - 1].split('#')[0];
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export class Graph {
|
|
732
|
+
constructor(utg) {
|
|
733
|
+
this.nodes = new Map(get(utg, 'nodes', []).map((n) => [n.id, n]));
|
|
734
|
+
this.inbound = new Map();
|
|
735
|
+
this.outbound = new Map();
|
|
736
|
+
for (const e of get(utg, 'links', get(utg, 'edges', []))) {
|
|
737
|
+
const s = get(e, 'source');
|
|
738
|
+
const t = get(e, 'target');
|
|
739
|
+
if (this.nodes.has(s) && this.nodes.has(t)) {
|
|
740
|
+
setdefault(this.inbound, t, []).push(e);
|
|
741
|
+
setdefault(this.outbound, s, []).push(e);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
this.byShort = new Map();
|
|
745
|
+
for (const nid of this.nodes.keys()) {
|
|
746
|
+
if (startsWithAny(nid, PAGE_PREFIXES)) { setdefault(this.byShort, shortName(nid), nid); }
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/** Where an attachable node lives. None when the node is page-level. */
|
|
751
|
+
directHost(node) {
|
|
752
|
+
for (const key of ['embedded_in', 'host_node']) {
|
|
753
|
+
const h = get(node, key);
|
|
754
|
+
if (this.nodes.has(h)) { return h; }
|
|
755
|
+
}
|
|
756
|
+
if (!ATTACH_KINDS.has(get(node, 'kind'))) { return null; }
|
|
757
|
+
const nid = node.id;
|
|
758
|
+
if (nid.includes('@')) { // menu:queue@QueueFragment
|
|
759
|
+
const h = this.byShort.get(nid.slice(nid.lastIndexOf('@') + 1));
|
|
760
|
+
if (truthy(h)) { return h; }
|
|
761
|
+
}
|
|
762
|
+
for (const e of this.inbound.get(nid) ?? []) { // mode entered from a menu, etc.
|
|
763
|
+
if (e.source !== nid) { return e.source; }
|
|
764
|
+
}
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/** (role, reason) before host resolution; role in page|attach|skip. */
|
|
770
|
+
export function classify(g, node) {
|
|
771
|
+
if (get(node, 'status') === 'unreachable') {
|
|
772
|
+
return ['skip', 'unreachable' + (truthy(get(node, 'unreachable_reason')) ? `: ${pyStr(node.unreachable_reason)}` : '')];
|
|
773
|
+
}
|
|
774
|
+
if (truthy(get(node, 'out_of_scope'))) { return ['skip', `out-of-scope: ${pyStr(node.out_of_scope)}`]; }
|
|
775
|
+
if (truthy(get(node, 'ui_less_shell'))) { return ['skip', 'ui-less-shell']; }
|
|
776
|
+
if (SKIP_KINDS.has(get(node, 'kind'))) {
|
|
777
|
+
return ['skip', `kind:${pyStr(get(node, 'kind'))} (container, its pages are converted individually)`];
|
|
778
|
+
}
|
|
779
|
+
if (truthy(g.directHost(node))) { return ['attach', null]; }
|
|
780
|
+
if (ATTACH_KINDS.has(get(node, 'kind'))) { return ['skip', 'attachable node with no resolvable host']; }
|
|
781
|
+
if (get(node, 'denominator') === false) { return ['skip', 'denominator:false (static stage marked it not-a-page)']; }
|
|
782
|
+
return ['page', null];
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
export function resolveRoles(g) {
|
|
786
|
+
const roles = new Map([...g.nodes].map(([nid, n]) => [nid, classify(g, n)]));
|
|
787
|
+
const roleOf = (x) => (roles.has(x) ? roles.get(x)[0] : 'skip');
|
|
788
|
+
const res = new Map();
|
|
789
|
+
for (const [nid, [role, reason]] of roles) {
|
|
790
|
+
if (role !== 'attach') {
|
|
791
|
+
res.set(nid, { role, reason });
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
// Walk up until a page; a host chain may pass through other attach nodes.
|
|
795
|
+
let cur = nid;
|
|
796
|
+
const seen = new Set();
|
|
797
|
+
while (truthy(cur) && roleOf(cur) === 'attach' && !seen.has(cur)) {
|
|
798
|
+
seen.add(cur);
|
|
799
|
+
cur = g.directHost(g.nodes.get(cur));
|
|
800
|
+
}
|
|
801
|
+
if (truthy(cur) && roleOf(cur) === 'page') {
|
|
802
|
+
res.set(nid, { role: 'attach', host: cur });
|
|
803
|
+
} else {
|
|
804
|
+
res.set(nid, { role: 'skip', reason: `attachable node whose host chain ends at ${pyStr(or(cur, 'nothing'))}` });
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return res;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
export function templateKeys(node) {
|
|
811
|
+
const keys = [];
|
|
812
|
+
if (truthy(get(node, 'extends_base'))) { keys.push(['base', node.extends_base]); }
|
|
813
|
+
for (const f of layoutFiles(node)) { keys.push(['layout', f]); }
|
|
814
|
+
if (node.id.startsWith('pref-dialog:')) { keys.push(['family', 'pref-dialog']); }
|
|
815
|
+
// `fragment;base:ItemFilterDialog` names a real shared base; `base:Fragment`
|
|
816
|
+
// names the framework class every page shares, which is no template at all.
|
|
817
|
+
const m = /base:([A-Za-z0-9_]+)/.exec(pyStr(or(get(node, 'launch_hint'), '')));
|
|
818
|
+
if (m && !GENERIC_BASES.has(m[1])) { keys.push(['base', m[1]]); }
|
|
819
|
+
return keys;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
const tkey = (k) => pyRepr(k[0]) + '\u0000' + pyRepr(k[1]);
|
|
823
|
+
|
|
824
|
+
export function edgeView(e, end) {
|
|
825
|
+
return { [end]: e[end], mechanism: get(e, 'mechanism'), trigger: get(e, 'trigger') };
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
const isEmptyish = (v) => v === null || v === undefined || (Array.isArray(v) && v.length === 0) ||
|
|
829
|
+
(typeof v === 'object' && !Array.isArray(v) && !(v instanceof PyFloat) && Object.keys(v).length === 0);
|
|
830
|
+
|
|
831
|
+
export function hintsOf(node) {
|
|
832
|
+
const widgets = (or(get(node, 'widgets'), [])).map((w) => {
|
|
833
|
+
const o = {};
|
|
834
|
+
for (const k of ['widget', 'kind', 'view_id', 'text', 'placeholder', 'preference_type', 'at']) {
|
|
835
|
+
const v = get(w, k);
|
|
836
|
+
if (v !== null && v !== undefined) { o[k] = w[k]; }
|
|
837
|
+
}
|
|
838
|
+
return o;
|
|
839
|
+
});
|
|
840
|
+
const h = {
|
|
841
|
+
declared_at: get(node, 'declared_at'), layout_files: layoutFiles(node),
|
|
842
|
+
layout_ids: or(get(node, 'layout_ids'), []), layout_hidden_ids: or(get(node, 'layout_hidden_ids'), []),
|
|
843
|
+
widgets, extends_base: get(node, 'extends_base'), launch_hint: get(node, 'launch_hint'),
|
|
844
|
+
required_state: or(get(node, 'required_state'), []),
|
|
845
|
+
content_state_evidence: get(node, 'content_state_evidence'),
|
|
846
|
+
login_interceptor: get(node, 'login_interceptor'),
|
|
847
|
+
observable: get(node, 'observable'), expected: get(node, 'expected'),
|
|
848
|
+
};
|
|
849
|
+
const res = {};
|
|
850
|
+
for (const [k, v] of Object.entries(h)) { if (!isEmptyish(v)) { res[k] = v; } }
|
|
851
|
+
return res;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// ---------------------------------------------------------------- grouping
|
|
855
|
+
// A group is the unit one sub-agent converts. It is built around an *anchor*
|
|
856
|
+
// page; a member joins its anchor only when splitting them would make two
|
|
857
|
+
// agents write one file: an embedded child is instantiated inside the
|
|
858
|
+
// parent's build(), and a single-host overlay is mounted in its host page.
|
|
859
|
+
// A routed child (tap → pushUrl) gets its own group — the Step 5.5 wiring
|
|
860
|
+
// sub-agent registers the route, so nothing is shared.
|
|
861
|
+
|
|
862
|
+
export const OVERLAY_PREFIXES = ['dialog:', 'pref-dialog:', 'overlay:'];
|
|
863
|
+
export const EMBED_VIA = ['pager-', 'child-fragment', 'layout-inflate'];
|
|
864
|
+
export const MOUNT_VIA = ['drawer-panel', 'bottom-sheet'];
|
|
865
|
+
export const MAX_GROUP = 8;
|
|
866
|
+
|
|
867
|
+
const BIG = 10 ** 6;
|
|
868
|
+
|
|
869
|
+
export function isOverlay(node) {
|
|
870
|
+
return pyIn(get(node, 'kind'), ['dialog', 'panel', 'window']) || startsWithAny(node.id, OVERLAY_PREFIXES);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export function edgeArgs(e) {
|
|
874
|
+
return or(get(e, 'args'), {});
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export function isMount(e) {
|
|
878
|
+
return MOUNT_VIA.includes(pyStr(get(edgeArgs(e), 'via')));
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/** The edge renders the target inside the source, with no navigation. */
|
|
882
|
+
export function isEmbed(e) {
|
|
883
|
+
const a = edgeArgs(e);
|
|
884
|
+
const via = pyStr(get(a, 'via'));
|
|
885
|
+
const scope = pyStr(get(a, 'commit_scope'));
|
|
886
|
+
const action = get(a, 'action');
|
|
887
|
+
if (get(e, 'mechanism') === 'fragment-embed' || startsWithAny(via, EMBED_VIA)) { return true; }
|
|
888
|
+
const auto = via === 'auto-load' || pyIn('auto-load', or(get(a, 'also_via'), []));
|
|
889
|
+
if (auto && scope.startsWith('lifecycle-fn')) { return true; }
|
|
890
|
+
if (via === 'instantiation' && scope.startsWith('lifecycle-fn') && pyIn(action ?? null, [null, 'default'])) { return true; }
|
|
891
|
+
// A section a host dispatches into its own layout: no gesture on the edge.
|
|
892
|
+
return via === 'dispatch-table' && (action === null || action === undefined) && get(e, 'mechanism') === 'fragment-transaction';
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* roles: Map nid → role row; rows: Map nid → conversion_set node row;
|
|
897
|
+
* pageOrder: Map page-dir name → pages.json index; ranked: click-path order.
|
|
898
|
+
*/
|
|
899
|
+
export function planGroups(g, roles, rows, pageOrder, ranked, entryOverride = null, prevIds = null, fullRoles = null) {
|
|
900
|
+
const roleOf = (nid) => (roles.get(nid) ?? {}).role; // roles.get(nid, {}).get("role")
|
|
901
|
+
const pageIds = [...roles].filter(([, r]) => r.role === 'page').map(([nid]) => nid);
|
|
902
|
+
|
|
903
|
+
const pindex = (nid) => {
|
|
904
|
+
let best = BIG;
|
|
905
|
+
for (const d of get(rows.get(nid), 'page_dirs', [])) {
|
|
906
|
+
const v = pageOrder.has(d) ? pageOrder.get(d) : BIG;
|
|
907
|
+
if (v < best) { best = v; }
|
|
908
|
+
}
|
|
909
|
+
return best;
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
// Launcher host = the first host-activity on a click path; entry = its
|
|
913
|
+
// first page in pages.json order that it reaches without a mount/embed.
|
|
914
|
+
const rank = new Map(ranked.map((nid, i) => [nid, i]));
|
|
915
|
+
const hosts = sortedBy([...g.nodes].filter(([nid, n]) => get(n, 'kind') === 'host-activity' && rank.has(nid))
|
|
916
|
+
.map(([nid]) => nid), (nid) => rank.get(nid));
|
|
917
|
+
const launcher = hosts.length ? hosts[0] : null;
|
|
918
|
+
let entry = entryOverride ?? null;
|
|
919
|
+
let how = truthy(entry) ? '--entry' : '';
|
|
920
|
+
if (!truthy(entry) && truthy(launcher)) {
|
|
921
|
+
let cands = (g.outbound.get(launcher) ?? []).filter((e) => roleOf(e.target) === 'page' && !isMount(e) &&
|
|
922
|
+
!isEmbed(e) && !isOverlay(g.nodes.get(e.target))).map((e) => e.target);
|
|
923
|
+
// Key is total (ends with the id), so set order does not matter.
|
|
924
|
+
cands = sortedBy([...new Set(cands)], (n) => [pindex(n), rank.has(n) ? rank.get(n) : BIG, n]);
|
|
925
|
+
if (cands.length) {
|
|
926
|
+
entry = cands[0];
|
|
927
|
+
how = `first page of launcher host ${launcher} in pages.json order`;
|
|
928
|
+
} else {
|
|
929
|
+
entry = null;
|
|
930
|
+
how = '';
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
// No host-activity (e.g. a single-Activity app whose launcher Activity is
|
|
934
|
+
// itself a page): fall back to the manifest launcher. Without it the entry
|
|
935
|
+
// stays null and no group is placed in the entry lane.
|
|
936
|
+
if (!truthy(entry)) {
|
|
937
|
+
const isLauncher = (n) => get(n, 'is_launcher') === true || get(n, 'entry_kind') === 'launcher' ||
|
|
938
|
+
get(or(get(n, 'launch_hint'), {}), 'is_launcher') === true;
|
|
939
|
+
const asPage = (nid) => {
|
|
940
|
+
const r = roles.get(nid) ?? {};
|
|
941
|
+
if (r.role === 'page') { return nid; }
|
|
942
|
+
if (r.role === 'attach' && (roles.get(r.host) ?? {}).role === 'page') { return r.host; }
|
|
943
|
+
return null;
|
|
944
|
+
};
|
|
945
|
+
const launchers = sortedBy([...g.nodes].filter(([nid, n]) => isLauncher(n) && truthy(asPage(nid)))
|
|
946
|
+
.map(([nid]) => nid), (nid) => [rank.has(nid) ? rank.get(nid) : BIG, nid]);
|
|
947
|
+
if (launchers.length) {
|
|
948
|
+
entry = asPage(launchers[0]);
|
|
949
|
+
how = `manifest launcher ${launchers[0]}`;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
const defaultPage = (host) => {
|
|
954
|
+
if (host === launcher) { return entry; }
|
|
955
|
+
for (const e of g.outbound.get(host) ?? []) {
|
|
956
|
+
const a = edgeArgs(e);
|
|
957
|
+
if ((pyIn('auto-load', or(get(a, 'also_via'), [])) || get(a, 'via') === 'auto-load') &&
|
|
958
|
+
pyStr(get(a, 'commit_scope')).startsWith('lifecycle-fn') && roleOf(e.target) === 'page') {
|
|
959
|
+
return e.target;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
return null;
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
/** An edge source as a page id: attach → its host, host-activity → its default page. */
|
|
966
|
+
const resolve = (src) => {
|
|
967
|
+
const r = roles.get(src) ?? {};
|
|
968
|
+
if (r.role === 'attach') { return r.host; }
|
|
969
|
+
if (r.role === 'page') { return src; }
|
|
970
|
+
if (get(g.nodes.get(src) ?? {}, 'kind') === 'host-activity') { return defaultPage(src); }
|
|
971
|
+
return null;
|
|
972
|
+
};
|
|
973
|
+
// What a member is mounted on, over the whole app: an incremental scope leaves the existing
|
|
974
|
+
// launch page outside, and a drawer mounted on it still writes into it (ENTRY_PAGE).
|
|
975
|
+
const mountHost = (src) => {
|
|
976
|
+
const own = resolve(src);
|
|
977
|
+
if (truthy(own) || !fullRoles) { return own; }
|
|
978
|
+
const r = fullRoles.get(src) ?? {};
|
|
979
|
+
if (r.role === 'attach') { return r.host; }
|
|
980
|
+
if (r.role === 'page') { return src; }
|
|
981
|
+
if (src === launcher) { return entry; }
|
|
982
|
+
return null;
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
const parent = new Map();
|
|
986
|
+
const rel = new Map();
|
|
987
|
+
const mountedOn = new Map();
|
|
988
|
+
for (const nid of pageIds) {
|
|
989
|
+
const node = g.nodes.get(nid);
|
|
990
|
+
const inbound = (g.inbound.get(nid) ?? []).filter((e) => e.source !== nid);
|
|
991
|
+
for (const e of inbound) {
|
|
992
|
+
if (isMount(e) && truthy(mountHost(e.source))) { mountedOn.set(nid, mountHost(e.source)); }
|
|
993
|
+
}
|
|
994
|
+
// Only its size and (when size 1) its single element are used: order-free.
|
|
995
|
+
const srcs = new Set(inbound.map((e) => resolve(e.source)).filter((s) => truthy(s) && s !== nid));
|
|
996
|
+
const explicit = or(get(node, 'embedded_in'), get(node, 'host_node'));
|
|
997
|
+
if (roles.has(explicit) && roles.get(explicit).role === 'page') {
|
|
998
|
+
parent.set(nid, explicit);
|
|
999
|
+
rel.set(nid, 'embedded');
|
|
1000
|
+
} else if (isOverlay(node)) {
|
|
1001
|
+
if (srcs.size === 1) {
|
|
1002
|
+
parent.set(nid, [...srcs][0]);
|
|
1003
|
+
rel.set(nid, 'overlay');
|
|
1004
|
+
}
|
|
1005
|
+
} else if (srcs.size === 1 && inbound.length && inbound.every(isEmbed) && !mountedOn.has(nid)) {
|
|
1006
|
+
parent.set(nid, [...srcs][0]);
|
|
1007
|
+
rel.set(nid, 'embedded');
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
const anchor = (nid) => {
|
|
1012
|
+
const seen = [];
|
|
1013
|
+
while (parent.has(nid) && !seen.includes(nid)) {
|
|
1014
|
+
seen.push(nid);
|
|
1015
|
+
nid = parent.get(nid);
|
|
1016
|
+
}
|
|
1017
|
+
return nid;
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
const members = new Map();
|
|
1021
|
+
for (const nid of pageIds) { setdefault(members, anchor(nid), []).push(nid); }
|
|
1022
|
+
|
|
1023
|
+
const base = (nid) => {
|
|
1024
|
+
const name = shortName(nid);
|
|
1025
|
+
return name.replace(/(Fragment|Activity|DialogFragment|Dialog)(?=\n?$)/, '') || name;
|
|
1026
|
+
};
|
|
1027
|
+
// One class mounted as several destinations (`view-page:InformationQueryPage#courses` / `#query`,
|
|
1028
|
+
// instantiated twice with different modes) gives anchors with the same base name. They are separate
|
|
1029
|
+
// pages, not a host and its default child: without the instance suffix both predicted the same files,
|
|
1030
|
+
// the later group became verify_only and its destination was never converted (where2study 11-11:
|
|
1031
|
+
// the 查询 tab mounted the 课程 page). The same holds when the instances are embedded members (two
|
|
1032
|
+
// pager tabs of one class) rather than anchors. Only non-overlay page nodes that all carry a
|
|
1033
|
+
// `#instance` qualify; a collision with an unqualified node (MainActivity / MainFragment) keeps the
|
|
1034
|
+
// shared name and verify_only.
|
|
1035
|
+
const instanceOf = (nid) => {
|
|
1036
|
+
const last = nid.split(':').pop().split('@').pop();
|
|
1037
|
+
const at = last.indexOf('#');
|
|
1038
|
+
// everything after the first `#`: `X#tab#a` / `X#tab#b` are two instances, not one
|
|
1039
|
+
return at < 0 ? '' : last.slice(at + 1);
|
|
1040
|
+
};
|
|
1041
|
+
const pascal = (s) => s.split(/[^A-Za-z0-9]+/).filter(Boolean).map((p) => p[0].toUpperCase() + p.slice(1)).join('');
|
|
1042
|
+
const peersByBase = new Map();
|
|
1043
|
+
for (const nid of pageIds) {
|
|
1044
|
+
if (!isOverlay(g.nodes.get(nid))) { setdefault(peersByBase, base(nid), []).push(nid); }
|
|
1045
|
+
}
|
|
1046
|
+
// A suffix per instance, unique within its base: the PascalCase instance name, or `I<n>` when that is
|
|
1047
|
+
// empty or shared — `#课程` / `#查询` and `#my-tab` / `#my_tab` would otherwise collapse to one file and
|
|
1048
|
+
// bring the bug back. n counts up past every suffix already taken (`#i2` keeps `I2`).
|
|
1049
|
+
const suffixOf = new Map();
|
|
1050
|
+
for (const peers of peersByBase.values()) {
|
|
1051
|
+
const insts = sortedBy([...new Set(peers.map(instanceOf))]);
|
|
1052
|
+
if (insts.length < 2 || insts.includes('')) { continue; }
|
|
1053
|
+
const named = new Map(insts.map((i) => [i, pascal(i)]));
|
|
1054
|
+
const counts = new Map();
|
|
1055
|
+
for (const v of named.values()) { counts.set(v, (counts.get(v) ?? 0) + 1); }
|
|
1056
|
+
const chosen = new Map();
|
|
1057
|
+
const taken = new Set();
|
|
1058
|
+
for (const i of insts) {
|
|
1059
|
+
const v = named.get(i);
|
|
1060
|
+
if (v && counts.get(v) === 1) { chosen.set(i, v); taken.add(v); }
|
|
1061
|
+
}
|
|
1062
|
+
let n = 0;
|
|
1063
|
+
for (const i of insts) {
|
|
1064
|
+
if (chosen.has(i)) { continue; }
|
|
1065
|
+
do { n += 1; } while (taken.has(`I${n}`));
|
|
1066
|
+
chosen.set(i, `I${n}`);
|
|
1067
|
+
taken.add(`I${n}`);
|
|
1068
|
+
}
|
|
1069
|
+
for (const p of peers) { suffixOf.set(p, chosen.get(instanceOf(p))); }
|
|
1070
|
+
}
|
|
1071
|
+
const pageBase = (nid) => `${base(nid)}${suffixOf.get(nid) ?? ''}`;
|
|
1072
|
+
|
|
1073
|
+
let groups = [];
|
|
1074
|
+
for (let [anc, mem] of members) {
|
|
1075
|
+
mem = sortedBy(mem, (n) => [n !== anc, pindex(n), n]);
|
|
1076
|
+
const tiers = new Set(mem.map((n) => rows.get(n).tier));
|
|
1077
|
+
const writes = new Set();
|
|
1078
|
+
const aNode = g.nodes.get(anc);
|
|
1079
|
+
if (isOverlay(aNode)) {
|
|
1080
|
+
writes.add(`components/${base(anc)}Dialog.ets`);
|
|
1081
|
+
} else {
|
|
1082
|
+
writes.add(`pages/${pageBase(anc)}Page.ets`);
|
|
1083
|
+
writes.add(`viewmodel/${pageBase(anc)}ViewModel.ets`);
|
|
1084
|
+
}
|
|
1085
|
+
for (const n of mem.slice(1)) {
|
|
1086
|
+
writes.add(`components/${pageBase(n)}${isOverlay(g.nodes.get(n)) ? 'Dialog' : 'Component'}.ets`);
|
|
1087
|
+
}
|
|
1088
|
+
// The shared name each per-instance write had before the split: an incremental run on a project
|
|
1089
|
+
// converted before it finds its files under that name (applyIncremental).
|
|
1090
|
+
const legacy = {};
|
|
1091
|
+
for (const n of mem) {
|
|
1092
|
+
if (!suffixOf.has(n)) { continue; }
|
|
1093
|
+
if (n === anc && !isOverlay(aNode)) {
|
|
1094
|
+
legacy[`pages/${pageBase(n)}Page.ets`] = `pages/${base(n)}Page.ets`;
|
|
1095
|
+
legacy[`viewmodel/${pageBase(n)}ViewModel.ets`] = `viewmodel/${base(n)}ViewModel.ets`;
|
|
1096
|
+
} else if (n !== anc) {
|
|
1097
|
+
const kind = isOverlay(g.nodes.get(n)) ? 'Dialog' : 'Component';
|
|
1098
|
+
legacy[`components/${pageBase(n)}${kind}.ets`] = `components/${base(n)}${kind}.ets`;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
// With no entry, an unmounted member used to compare equal to it (null ===
|
|
1102
|
+
// null), making every group an entry hit and the whole plan one serial lane.
|
|
1103
|
+
const entryHit = truthy(entry) &&
|
|
1104
|
+
(mem.includes(entry) || mem.some((n) => mountedOn.has(n) && mountedOn.get(n) === entry));
|
|
1105
|
+
if (entryHit) { writes.add('ENTRY_PAGE'); }
|
|
1106
|
+
const fam = new Set();
|
|
1107
|
+
for (const n of mem) {
|
|
1108
|
+
for (const k of templateKeys(g.nodes.get(n))) { fam.add(`${pyStr(k[0])}:${pyStr(k[1])}`); }
|
|
1109
|
+
}
|
|
1110
|
+
groups.push({
|
|
1111
|
+
anchor: anc,
|
|
1112
|
+
members: mem.map((n) => ({ node: n, tier: rows.get(n).tier, relation: n === anc ? 'anchor' : (rel.get(n) ?? 'embedded') })),
|
|
1113
|
+
page_dirs: mem.flatMap((n) => get(rows.get(n), 'page_dirs', [])),
|
|
1114
|
+
tier: tiers.has('captured') ? 'captured' : 'source-only',
|
|
1115
|
+
mixed_tier: tiers.size > 1,
|
|
1116
|
+
predicted_writes: sortedBy([...writes]),
|
|
1117
|
+
...(Object.keys(legacy).length ? { legacy_writes: legacy } : {}),
|
|
1118
|
+
_fam: fam, _entry: entryHit, _is_entry: mem.includes(entry),
|
|
1119
|
+
_order: Math.min(...mem.map(pindex)),
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// Captured attach nodes (a menu or panel that was screenshotted as its own
|
|
1124
|
+
// page dir) are evidence for their host's group, never a group of their own.
|
|
1125
|
+
const byMember = new Map();
|
|
1126
|
+
for (const gr of groups) { for (const m of gr.members) { byMember.set(m.node, gr); } }
|
|
1127
|
+
for (const [nid, r] of roles) {
|
|
1128
|
+
if (r.role === 'attach' && truthy(get(rows.get(nid), 'page_dirs')) && byMember.has(r.host)) {
|
|
1129
|
+
const gr = byMember.get(r.host);
|
|
1130
|
+
gr.members.push({ node: nid, tier: 'captured', relation: 'attached' });
|
|
1131
|
+
gr.page_dirs.push(...rows.get(nid).page_dirs);
|
|
1132
|
+
gr._order = Math.min(gr._order, pindex(nid));
|
|
1133
|
+
const tiers = new Set(gr.members.map((m) => m.tier));
|
|
1134
|
+
gr.tier = tiers.has('captured') ? 'captured' : 'source-only';
|
|
1135
|
+
gr.mixed_tier = tiers.size > 1;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// Stage: 0 = the entry group alone (it sets the conventions), 1 = groups
|
|
1140
|
+
// with a capture, 2 = source-only. Within a stage, pages.json order.
|
|
1141
|
+
for (const gr of groups) { gr.stage = gr._is_entry ? 0 : (gr.tier === 'captured' ? 1 : 2); }
|
|
1142
|
+
groups = sortedBy(groups, (gr) => [gr.stage, gr._order, gr.anchor]);
|
|
1143
|
+
// Stable ids across re-runs: a re-export during exploration must not
|
|
1144
|
+
// renumber groups whose prompts, queue state and reports already exist.
|
|
1145
|
+
// A known anchor keeps its id (its stage may change); a new one numbers on.
|
|
1146
|
+
const known = prevIds ?? new Map();
|
|
1147
|
+
let nxt = 0;
|
|
1148
|
+
for (const v of known.values()) {
|
|
1149
|
+
const m = /^G(\d+)$/.exec(v);
|
|
1150
|
+
if (m) nxt = Math.max(nxt, Number(m[1]));
|
|
1151
|
+
}
|
|
1152
|
+
for (const gr of groups) {
|
|
1153
|
+
if (known.has(gr.anchor)) gr.id = known.get(gr.anchor);
|
|
1154
|
+
else { nxt += 1; gr.id = `G${String(nxt).padStart(3, '0')}`; }
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// Lanes: groups sharing a predicted write run serially; ENTRY_PAGE is the
|
|
1158
|
+
// host chain. Union-find over write tokens.
|
|
1159
|
+
const owner = new Map();
|
|
1160
|
+
const laneOf = new Map();
|
|
1161
|
+
for (const gr of groups) { laneOf.set(gr.id, gr.id); }
|
|
1162
|
+
const find = (x) => {
|
|
1163
|
+
while (laneOf.get(x) !== x) {
|
|
1164
|
+
laneOf.set(x, laneOf.get(laneOf.get(x)));
|
|
1165
|
+
x = laneOf.get(x);
|
|
1166
|
+
}
|
|
1167
|
+
return x;
|
|
1168
|
+
};
|
|
1169
|
+
for (const gr of groups) {
|
|
1170
|
+
for (const w of gr.predicted_writes) {
|
|
1171
|
+
if (owner.has(w)) {
|
|
1172
|
+
// Python evaluates the right-hand side first, then the subscript.
|
|
1173
|
+
const rhs = find(owner.get(w));
|
|
1174
|
+
laneOf.set(find(gr.id), rhs);
|
|
1175
|
+
} else {
|
|
1176
|
+
owner.set(w, gr.id);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
const lanes = new Map();
|
|
1181
|
+
for (const gr of groups) { setdefault(lanes, find(gr.id), []).push(gr.id); }
|
|
1182
|
+
// A group whose every predicted write is owned by an earlier group of its
|
|
1183
|
+
// lane converts nothing of its own: a source-only host Activity whose
|
|
1184
|
+
// name collides with its default child (MainActivity -> MainPage.ets,
|
|
1185
|
+
// written by the MainFragment group). It verifies the host shell and
|
|
1186
|
+
// reports. Its files exist before it is dispatched, so "nothing written"
|
|
1187
|
+
// is its normal outcome, not a failure to redispatch.
|
|
1188
|
+
for (const gr of groups) {
|
|
1189
|
+
const ws = gr.predicted_writes.filter((w) => w !== 'ENTRY_PAGE');
|
|
1190
|
+
gr.verify_only = ws.length > 0 && ws.every((w) => owner.has(w) && owner.get(w) !== gr.id);
|
|
1191
|
+
}
|
|
1192
|
+
// The queue serialises only groups whose lane NAMES are equal (Step 5.3 rule c),
|
|
1193
|
+
// so a lane is named once for all its peers. A lane holding an entry group is the
|
|
1194
|
+
// host chain: its peers write the entry group's files and must carry 'entry' too.
|
|
1195
|
+
// Measured (WeatherApp 11-10): MainActivity (entry) got 'entry', MainFragment,
|
|
1196
|
+
// sharing MainPage.ets / MainViewModel.ets with it, got 'lane-G001'; with a shell
|
|
1197
|
+
// contract the two ran at once on the same files.
|
|
1198
|
+
const isEntry = new Map(groups.map((gr) => [gr.id, Boolean(gr._entry)]));
|
|
1199
|
+
for (const gr of groups) {
|
|
1200
|
+
const peers = lanes.get(find(gr.id));
|
|
1201
|
+
if (gr._entry || peers.some((id) => isEntry.get(id))) {
|
|
1202
|
+
gr.class = 'host-chain';
|
|
1203
|
+
gr.lane = 'entry';
|
|
1204
|
+
} else if (peers.length > 1) {
|
|
1205
|
+
gr.class = 'serial';
|
|
1206
|
+
gr.lane = `lane-${peers[0]}`;
|
|
1207
|
+
} else {
|
|
1208
|
+
gr.class = 'self-contained';
|
|
1209
|
+
gr.lane = null;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
// Families: a shared base class / layout / pref-dialog family. The first
|
|
1214
|
+
// group to convert one builds the shared component; later groups reuse it
|
|
1215
|
+
// (read-only) and, inside the same stage, wait for it.
|
|
1216
|
+
const leader = new Map();
|
|
1217
|
+
for (const gr of groups) {
|
|
1218
|
+
const reuse = [];
|
|
1219
|
+
const after = [];
|
|
1220
|
+
for (const f of sortedBy([...gr._fam])) {
|
|
1221
|
+
const holders = groups.filter((o) => o._fam.has(f));
|
|
1222
|
+
if (holders.length < 2) { continue; }
|
|
1223
|
+
const lead = setdefault(leader, f, gr);
|
|
1224
|
+
if (lead !== gr) {
|
|
1225
|
+
reuse.push({ family: f, from: lead.id });
|
|
1226
|
+
if (lead.stage === gr.stage && !after.includes(lead.id)) { after.push(lead.id); }
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
gr.reuse_from = reuse;
|
|
1230
|
+
gr.after = after;
|
|
1231
|
+
if (gr.members.length > MAX_GROUP) {
|
|
1232
|
+
gr.warning = `${gr.members.length} members > ${MAX_GROUP}: review in Step 4.2, split routed-looking members`;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
for (const gr of groups) {
|
|
1236
|
+
for (const k of ['_fam', '_entry', '_is_entry', '_order']) { delete gr[k]; }
|
|
1237
|
+
}
|
|
1238
|
+
return { entry_node: entry, entry_chosen_by: how, launcher_host: launcher, groups };
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// ---------------------------------------------------------------- build
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Remove source-only dirs whose node is now captured (or no longer a page);
|
|
1245
|
+
* return [removed, Map node -> slug] of the ones kept, so a re-run reuses the
|
|
1246
|
+
* same directory name for a group that may already be converting it.
|
|
1247
|
+
*/
|
|
1248
|
+
/**
|
|
1249
|
+
* Mark the groups whose pages live inside a shell host (shell_contract.json `shell_hosts`:
|
|
1250
|
+
* an Activity that swaps Fragments or Views inside a persistent chrome). Such a group is content the
|
|
1251
|
+
* shell mounts, not a routed page: no @Entry, no chrome of its own, and it is reached through
|
|
1252
|
+
* the shell rather than router.pushUrl. The entry group writes the shell itself.
|
|
1253
|
+
*
|
|
1254
|
+
* Adds `host_activity` + `presentation` (`shell` | `shell-content`) to those groups only.
|
|
1255
|
+
* Without shell_hosts (no shell_contract.json yet, or an app with no such Activity) nothing is
|
|
1256
|
+
* added, so the plan is identical to the one written before this existed.
|
|
1257
|
+
*
|
|
1258
|
+
* A host's reach is its own fragment-transaction / view-swap targets plus, transitively, the
|
|
1259
|
+
* fragments / view-pages those swap in: all of them render inside the host's container. Whether a given one is a chrome tab or a
|
|
1260
|
+
* pushed child is the host's dispatch code and the shell's business, not the plan's.
|
|
1261
|
+
*/
|
|
1262
|
+
export function annotateShellContent(g, plan, contract) {
|
|
1263
|
+
const hosts = get(or(contract, {}), 'shell_hosts', null);
|
|
1264
|
+
if (!truthy(hosts)) { return; }
|
|
1265
|
+
const hostOf = new Map();
|
|
1266
|
+
for (const hid of keysOf(hosts)) {
|
|
1267
|
+
const queue = [...get(hosts[hid], 'host_destinations', [])];
|
|
1268
|
+
while (queue.length) {
|
|
1269
|
+
const nid = queue.shift();
|
|
1270
|
+
if (hostOf.has(nid)) { continue; }
|
|
1271
|
+
hostOf.set(nid, hid);
|
|
1272
|
+
for (const e of g.outbound.get(nid) ?? []) {
|
|
1273
|
+
const mech = get(e, 'mechanism');
|
|
1274
|
+
const t = pyStr(get(e, 'target'));
|
|
1275
|
+
if ((mech === 'fragment-transaction' && t.startsWith('fragment:')) ||
|
|
1276
|
+
(mech === 'view-swap' && t.startsWith('view-page:'))) {
|
|
1277
|
+
queue.push(e.target);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
for (const gr of plan.groups) {
|
|
1283
|
+
const hid = hostOf.get(gr.anchor);
|
|
1284
|
+
if (!hid) { continue; }
|
|
1285
|
+
gr.host_activity = hid;
|
|
1286
|
+
gr.presentation = gr.anchor === plan.entry_node ? 'shell' : 'shell-content';
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
export function clearPrevious(uiInfo, keep = new Set(), protect = new Set()) {
|
|
1291
|
+
let n = 0;
|
|
1292
|
+
const kept = new Map();
|
|
1293
|
+
for (const d of sortedBy(globPrefix(uiInfo, 'page_'))) {
|
|
1294
|
+
const meta = isDir(d) ? readJson(path.join(d, 'meta.json'), {}) : {};
|
|
1295
|
+
if (get(meta, 'evidence_tier') !== 'source-only') continue;
|
|
1296
|
+
const nid = get(meta, 'static_node');
|
|
1297
|
+
if (protect.has(nid)) continue; // outside an incremental scope: not this run's to judge
|
|
1298
|
+
if (keep.has(nid) && !kept.has(nid)) kept.set(nid, pathName(d));
|
|
1299
|
+
else {
|
|
1300
|
+
fs.rmSync(d, { recursive: true });
|
|
1301
|
+
n += 1;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
return [n, kept];
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/** --scope / --existing file: a JSON list, or an object holding it under one of `keys`. */
|
|
1308
|
+
export function readList(p, keys) {
|
|
1309
|
+
const v = readJson(p, null);
|
|
1310
|
+
let xs = Array.isArray(v) ? v : null;
|
|
1311
|
+
for (const k of keys) { if (xs === null && Array.isArray(get(v, k))) { xs = v[k]; } }
|
|
1312
|
+
if (xs === null) { throw new Error(`${pathStr(p)}: expected a JSON list, or an object with ${keys.map((k) => `"${k}"`).join(' / ')}`); }
|
|
1313
|
+
return xs.map((x) => (typeof x === 'string' ? x : or(get(x, 'node'), get(x, 'id')))).filter(truthy);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/** An existing .ets path as a predicted write: relative to the ETS root, forward slashes. */
|
|
1317
|
+
export function etsRel(p) {
|
|
1318
|
+
const s = pyStr(p).replace(/\\/g, '/');
|
|
1319
|
+
const i = s.lastIndexOf('/src/main/ets/');
|
|
1320
|
+
const rel = i >= 0 ? s.slice(i + '/src/main/ets/'.length) : s.startsWith('src/main/ets/') ? s.slice('src/main/ets/'.length) : s;
|
|
1321
|
+
return rel.replace(/^\.\//, '');
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Restrict roles to an incremental scope: a page outside it, and a node attached to such a
|
|
1326
|
+
* page, become `skip`. Throws on ids the graph does not have (a typo would scope to nothing).
|
|
1327
|
+
*/
|
|
1328
|
+
export function scopeRoles(g, roles, scopeIds) {
|
|
1329
|
+
const unknown = sortedBy([...new Set(scopeIds.filter((x) => !g.nodes.has(x)))]);
|
|
1330
|
+
if (unknown.length) { throw new Error(`--scope names nodes the static UTG does not have: ${unknown.join(', ')}`); }
|
|
1331
|
+
const want = new Set(scopeIds);
|
|
1332
|
+
const res = new Map();
|
|
1333
|
+
for (const [nid, r] of roles) {
|
|
1334
|
+
// an attach node lives in its host's group: named without its host, there is no group for it
|
|
1335
|
+
if (r.role === 'attach' && want.has(nid) && !want.has(r.host)) {
|
|
1336
|
+
res.set(nid, { role: 'skip', reason: `out-of-incremental-scope: its host ${pyStr(r.host)} is not in the scope` });
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
const inScope = r.role === 'page' ? want.has(nid) : r.role === 'attach' ? want.has(r.host) : true;
|
|
1340
|
+
res.set(nid, inScope ? r : { role: 'skip', reason: 'out-of-incremental-scope' });
|
|
1341
|
+
}
|
|
1342
|
+
if (![...res.values()].some((r) => r.role === 'page')) {
|
|
1343
|
+
throw new Error('--scope holds no convertible page (every id is a container, skipped or attached elsewhere)');
|
|
1344
|
+
}
|
|
1345
|
+
return res;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/** Incremental: mark groups that write existing files, and make sure one group goes first. */
|
|
1349
|
+
export function applyIncremental(plan, existing) {
|
|
1350
|
+
const have = new Set([...existing].map(etsRel));
|
|
1351
|
+
for (const gr of plan.groups) {
|
|
1352
|
+
// A per-instance write that does not exist yet, while the shared name it replaced does: the project
|
|
1353
|
+
// was converted before the split, so the group edits that file (and shares it, serialised, with the
|
|
1354
|
+
// other instances) instead of creating a parallel one next to it.
|
|
1355
|
+
const legacy = gr.legacy_writes ?? {};
|
|
1356
|
+
gr.predicted_writes = sortedBy([...new Set(gr.predicted_writes.map((w) =>
|
|
1357
|
+
(!have.has(w) && legacy[w] !== undefined && have.has(legacy[w]) ? legacy[w] : w)))]);
|
|
1358
|
+
const hits = gr.predicted_writes.filter((w) => have.has(w));
|
|
1359
|
+
if (!hits.length) { continue; }
|
|
1360
|
+
gr.existing_writes = hits;
|
|
1361
|
+
if (gr.class === 'host-chain') { continue; }
|
|
1362
|
+
// its lane serialises shared writes: move the whole lane, or a peer left behind
|
|
1363
|
+
// would run alongside it on the same file
|
|
1364
|
+
const peers = truthy(gr.lane) ? plan.groups.filter((o) => o.lane === gr.lane) : [gr];
|
|
1365
|
+
for (const o of peers) {
|
|
1366
|
+
o.class = 'host-chain';
|
|
1367
|
+
o.lane = 'entry';
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
if (plan.groups.some((gr) => gr.stage === 0)) { return; }
|
|
1371
|
+
// What a group builds on: the family leaders it reuses a component from and the captured
|
|
1372
|
+
// groups it borrows measurements from. Promoted alone, such a group would convert before
|
|
1373
|
+
// them while they wait (stage >= 1) for stage 0: the dependency inverted.
|
|
1374
|
+
const needs = (gr) => [...new Set([...(gr.reuse_from ?? []).map((r) => r.from), ...(gr.template_groups ?? [])])]
|
|
1375
|
+
.filter((id) => id !== gr.id);
|
|
1376
|
+
const hosts = plan.groups.filter((gr) => gr.class === 'host-chain');
|
|
1377
|
+
const first = hosts.find((gr) => !needs(gr).length) ?? hosts[0]
|
|
1378
|
+
?? plan.groups.find((gr) => !needs(gr).length) ?? plan.groups[0];
|
|
1379
|
+
if (!first) { return; }
|
|
1380
|
+
// stage 0 = the chosen group and, transitively, everything it builds on
|
|
1381
|
+
const byId = new Map(plan.groups.map((gr) => [gr.id, gr]));
|
|
1382
|
+
const pulled = [first];
|
|
1383
|
+
for (let i = 0; i < pulled.length; i += 1) {
|
|
1384
|
+
for (const id of needs(pulled[i])) {
|
|
1385
|
+
const o = byId.get(id);
|
|
1386
|
+
if (o && !pulled.includes(o)) { pulled.push(o); }
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
// `after` is same-stage only: inside stage 0 each pulled group waits for what it builds on.
|
|
1390
|
+
// reuse_from points at a family's first holder in plan order, so those waits never cycle;
|
|
1391
|
+
// a measurement borrow can point back (leader L borrows from its own reuser P), and a wait
|
|
1392
|
+
// that would close a cycle is dropped, or group_queue would never find either ready.
|
|
1393
|
+
const inPulled = new Set(pulled.map((gr) => gr.id));
|
|
1394
|
+
const waits = new Map(pulled.map((gr) => [gr.id,
|
|
1395
|
+
[...new Set((gr.reuse_from ?? []).map((r) => r.from))].filter((id) => id !== gr.id && inPulled.has(id))]));
|
|
1396
|
+
const reaches = (from, to) => {
|
|
1397
|
+
const stack = [from];
|
|
1398
|
+
const seen = new Set();
|
|
1399
|
+
while (stack.length) {
|
|
1400
|
+
const x = stack.pop();
|
|
1401
|
+
if (x === to) { return true; }
|
|
1402
|
+
if (seen.has(x)) { continue; }
|
|
1403
|
+
seen.add(x);
|
|
1404
|
+
stack.push(...(waits.get(x) ?? []));
|
|
1405
|
+
}
|
|
1406
|
+
return false;
|
|
1407
|
+
};
|
|
1408
|
+
for (const gr of pulled) {
|
|
1409
|
+
for (const id of gr.template_groups ?? []) {
|
|
1410
|
+
const w = waits.get(gr.id);
|
|
1411
|
+
if (id !== gr.id && inPulled.has(id) && !w.includes(id) && !reaches(id, gr.id)) { w.push(id); }
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
for (const gr of pulled) {
|
|
1415
|
+
gr.stage = 0;
|
|
1416
|
+
gr.after = waits.get(gr.id);
|
|
1417
|
+
}
|
|
1418
|
+
plan.stage0_chosen_by = (first.class === 'host-chain'
|
|
1419
|
+
? 'incremental: first host-chain group (the launch page is outside the scope)'
|
|
1420
|
+
: 'incremental: first group (no group touches the existing shared surface)')
|
|
1421
|
+
+ (pulled.length > 1 ? `; with ${pulled.slice(1).map((gr) => gr.id).join(', ')} it builds on` : '');
|
|
1422
|
+
// the groups it builds on first, in dependency order (`waits` is acyclic)
|
|
1423
|
+
const head = [];
|
|
1424
|
+
const visit = (gr) => {
|
|
1425
|
+
if (head.includes(gr)) { return; }
|
|
1426
|
+
for (const id of waits.get(gr.id)) { visit(byId.get(id)); }
|
|
1427
|
+
head.push(gr);
|
|
1428
|
+
};
|
|
1429
|
+
for (const gr of [...pulled].reverse()) { visit(gr); }
|
|
1430
|
+
plan.groups = [...head, ...plan.groups.filter((gr) => !head.includes(gr))];
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* True when the capture directory has view trees but no screenshot at all because every frame was
|
|
1435
|
+
* FLAG_SECURE-blocked (export_ui_info writes `screenshots_blocked` and drops the black PNGs).
|
|
1436
|
+
* Such a page stays `captured` (the tree is real device evidence) but nothing can check pixels.
|
|
1437
|
+
*/
|
|
1438
|
+
export function pixelsBlocked(uiInfo, dir) {
|
|
1439
|
+
const meta = readJson(path.join(uiInfo, pathName(String(dir)), 'meta.json'));
|
|
1440
|
+
if (!meta || typeof meta !== 'object') return false;
|
|
1441
|
+
const shots = Array.isArray(meta.screenshots) ? meta.screenshots.filter(Boolean) : [];
|
|
1442
|
+
const blocked = Array.isArray(meta.screenshots_blocked) ? meta.screenshots_blocked : [];
|
|
1443
|
+
return blocked.length > 0 && shots.length === 0 && !meta.screenshot;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
export function build(ws, uiInfo, entry = null, renumber = false, exploring = false,
|
|
1447
|
+
{ scope = null, existing = null } = {}) {
|
|
1448
|
+
const g = new Graph(readJson(path.join(ws, 'utg.json')));
|
|
1449
|
+
const prevSet = or(readJson(path.join(uiInfo, 'conversion_set.json'), {}), {});
|
|
1450
|
+
const rawPaths = get(or(readJson(path.join(ws, 'click_paths.json'), {}), {}), 'paths', {});
|
|
1451
|
+
// Map, not a plain object: node ids are keys and insertion order is the contract.
|
|
1452
|
+
const paths = new Map(Array.isArray(rawPaths) ? rawPaths : keysOf(rawPaths).map((k) => [k, rawPaths[k]]));
|
|
1453
|
+
const ranked = sortedBy([...paths.keys()],
|
|
1454
|
+
(k) => [pyLen(get(paths.get(k), 'steps', [])), get(paths.get(k), 'clicks', 0)]);
|
|
1455
|
+
const order = new Map(ranked.map((nid, i) => [nid, i]));
|
|
1456
|
+
|
|
1457
|
+
fs.mkdirSync(uiInfo, { recursive: true });
|
|
1458
|
+
const manifest = or(readJson(path.join(uiInfo, 'export_manifest.json'), {}), {});
|
|
1459
|
+
const scopeIds = truthy(scope) ? readList(scope, ['scope', 'nodes']) : null;
|
|
1460
|
+
// Incremental: each scope explores in a new campaign, and its export rewrites the manifest.
|
|
1461
|
+
// export_ui_info carries an earlier campaign's pages over as `earlier`; a node this campaign
|
|
1462
|
+
// did not capture again keeps that capture instead of turning source-only.
|
|
1463
|
+
const manifestPages = [...get(manifest, 'pages', [])];
|
|
1464
|
+
const listed = new Set(manifestPages.map((p) => p.static_node));
|
|
1465
|
+
for (const p of scopeIds ? get(manifest, 'earlier', []) : []) {
|
|
1466
|
+
if (!listed.has(p.static_node) && isDir(path.join(uiInfo, pathName(p.page_dir)))) { manifestPages.push(p); }
|
|
1467
|
+
}
|
|
1468
|
+
const captured = new Map();
|
|
1469
|
+
for (const p of manifestPages) { setdefault(captured, p.static_node, []).push(p.page_dir); }
|
|
1470
|
+
|
|
1471
|
+
const fullRoles = resolveRoles(g);
|
|
1472
|
+
const roles = scopeIds ? scopeRoles(g, fullRoles, scopeIds) : fullRoles;
|
|
1473
|
+
const keepIds = new Set([...roles].filter(([nid, r]) => r.role === 'page' && !captured.has(nid)).map(([nid]) => nid));
|
|
1474
|
+
const protect = new Set(scopeIds ? [...fullRoles].filter(([nid, r]) => r.role === 'page' && roles.get(nid).role === 'skip')
|
|
1475
|
+
.map(([nid]) => nid) : []);
|
|
1476
|
+
const [removed, prevUnit] = clearPrevious(uiInfo, keepIds, protect);
|
|
1477
|
+
const attached = new Map();
|
|
1478
|
+
for (const [nid, r] of roles) {
|
|
1479
|
+
if (r.role === 'attach') { setdefault(attached, r.host, []).push(nid); }
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
const tmplIndex = new Map();
|
|
1483
|
+
for (const [nid, dirs] of captured) {
|
|
1484
|
+
if (g.nodes.has(nid)) {
|
|
1485
|
+
for (const k of templateKeys(g.nodes.get(nid))) { setdefault(tmplIndex, tkey(k), []).push(...dirs); }
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
const attachedView = (host) => sortedBy(attached.get(host) ?? []).map((a) => ({
|
|
1490
|
+
id: a, kind: get(g.nodes.get(a), 'kind'), label: get(g.nodes.get(a), 'label'),
|
|
1491
|
+
captured_page_dirs: captured.get(a) ?? [], ...hintsOf(g.nodes.get(a)),
|
|
1492
|
+
}));
|
|
1493
|
+
|
|
1494
|
+
// Captured entries keep export_ui_info's order; drop stale source-only rows.
|
|
1495
|
+
// A scoped run writes only its scope to pages.json; pages_captured.json keeps every
|
|
1496
|
+
// capture, so a later run (another scope, or none) without export_ui_info still sees them.
|
|
1497
|
+
const old = [];
|
|
1498
|
+
const oldNames = new Set();
|
|
1499
|
+
const inPages = new Set(get(or(readJson(path.join(uiInfo, 'pages.json'), {}), {}), 'pages', []).map((e) => pathName(e.page_dir)));
|
|
1500
|
+
for (const f of ['pages.json', 'pages_captured.json']) {
|
|
1501
|
+
for (const e of get(or(readJson(path.join(uiInfo, f), {}), {}), 'pages', [])) {
|
|
1502
|
+
if (!oldNames.has(pathName(e.page_dir))) { oldNames.add(pathName(e.page_dir)); old.push(e); }
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
const pages = [];
|
|
1506
|
+
const allCaptured = [];
|
|
1507
|
+
const slugNode = new Map(manifestPages.map((p) => [p.page_dir, p.static_node]));
|
|
1508
|
+
// an earlier campaign's capture no pages file lists any more (a full run deleted
|
|
1509
|
+
// pages_captured.json, then this campaign's export rewrote pages.json)
|
|
1510
|
+
for (const p of manifestPages.slice(get(manifest, 'pages', []).length)) {
|
|
1511
|
+
if (!oldNames.has(pathName(p.page_dir))) {
|
|
1512
|
+
oldNames.add(pathName(p.page_dir));
|
|
1513
|
+
old.push({ page_dir: p.page_dir, ui_sequence: or(get(p, 'ui_sequence'), "Root page") });
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
for (let e of old) {
|
|
1517
|
+
// Rebase onto this ui_info: a copied project still holds the original's
|
|
1518
|
+
// absolute page_dir, which would silently point every page at the source.
|
|
1519
|
+
const pdir = path.join(uiInfo, pathName(e.page_dir));
|
|
1520
|
+
if (get(e, 'evidence_tier') === 'source-only' || !isDir(pdir)) { continue; }
|
|
1521
|
+
const nodeId = slugNode.get(pathName(pdir));
|
|
1522
|
+
// a remembered capture the current export no longer lists is stale
|
|
1523
|
+
if (!truthy(nodeId) && slugNode.size && !inPages.has(pathName(pdir))) { continue; }
|
|
1524
|
+
allCaptured.push({ ...e, page_dir: pathResolve(pdir), evidence_tier: 'captured' });
|
|
1525
|
+
// incremental: a capture of a node outside the scope stays on disk, out of pages.json
|
|
1526
|
+
if (scopeIds && (!truthy(nodeId) || get(roles.get(nodeId), 'role', 'skip') === 'skip')) { continue; }
|
|
1527
|
+
e = { ...e, page_dir: pathResolve(pdir), evidence_tier: 'captured' };
|
|
1528
|
+
if (truthy(nodeId) && truthy(attached.get(nodeId))) { e.attached_nodes = attachedView(nodeId); }
|
|
1529
|
+
pages.push(e);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
const nums = [];
|
|
1533
|
+
for (const d of globPrefix(uiInfo, 'page_')) {
|
|
1534
|
+
const m = /^page_(\p{Nd}+)_/u.exec(pathName(d));
|
|
1535
|
+
if (m) { nums.push(pyInt(m[1])); }
|
|
1536
|
+
}
|
|
1537
|
+
let seq = nums.reduce((a, b) => (b > a ? b : a), 0);
|
|
1538
|
+
const todo = sortedBy([...roles].filter(([nid, r]) => r.role === 'page' && !captured.has(nid)).map(([nid]) => nid),
|
|
1539
|
+
(nid) => [order.has(nid) ? order.get(nid) : order.size, nid]);
|
|
1540
|
+
const units = new Map();
|
|
1541
|
+
const tmplOf = new Map();
|
|
1542
|
+
for (const nid of todo) {
|
|
1543
|
+
const node = g.nodes.get(nid);
|
|
1544
|
+
let slug = prevUnit.get(nid);
|
|
1545
|
+
if (!slug) {
|
|
1546
|
+
seq += 1;
|
|
1547
|
+
slug = `page_${String(seq).padStart(4, '0')}_${safeName(node)}`;
|
|
1548
|
+
}
|
|
1549
|
+
const pdir = path.join(uiInfo, slug);
|
|
1550
|
+
fs.mkdirSync(pdir, { recursive: true });
|
|
1551
|
+
const templates = [];
|
|
1552
|
+
for (const k of templateKeys(node)) {
|
|
1553
|
+
for (const d of tmplIndex.get(tkey(k)) ?? []) {
|
|
1554
|
+
if (!pyIn(d, templates)) { templates.push(d); }
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
const p = or(paths.get(nid), {});
|
|
1558
|
+
const labels = get(p, 'steps', []).map((s) => get(s, 'label')).filter(truthy);
|
|
1559
|
+
const route = or(get(p, 'nl_path_text'), get(p, 'path_text'));
|
|
1560
|
+
const meta = {
|
|
1561
|
+
page_id: slug, static_node: nid, kind: get(node, 'kind'), label: get(node, 'label'),
|
|
1562
|
+
declared_at: get(node, 'declared_at'),
|
|
1563
|
+
evidence_tier: 'source-only',
|
|
1564
|
+
// Deliberately empty: there is no capture. Step 4.1 must not treat
|
|
1565
|
+
// this as a failed read, and no agent may invent one.
|
|
1566
|
+
screenshots: [], view_xmls: [],
|
|
1567
|
+
source_hints: hintsOf(node),
|
|
1568
|
+
attached_nodes: attachedView(nid),
|
|
1569
|
+
reached_from: (g.inbound.get(nid) ?? []).map((e) => edgeView(e, 'source')),
|
|
1570
|
+
navigates_to: (g.outbound.get(nid) ?? []).map((e) => edgeView(e, 'target')),
|
|
1571
|
+
template_pages: templates.slice(0, MAX_TEMPLATES),
|
|
1572
|
+
click_path: get(p, 'steps', []),
|
|
1573
|
+
breadcrumb: labels.join(' > '),
|
|
1574
|
+
click_path_text: or(route, ''),
|
|
1575
|
+
source: { backend: 'a2h-utg-static', builder: 'build_conversion_set.mjs' },
|
|
1576
|
+
};
|
|
1577
|
+
writeJson(path.join(pdir, 'meta.json'), meta);
|
|
1578
|
+
pages.push({
|
|
1579
|
+
page_dir: pathResolve(pdir),
|
|
1580
|
+
ui_sequence: ["Root page", ...(truthy(route) ? [route] : labels)].join(ARROW),
|
|
1581
|
+
evidence_tier: 'source-only',
|
|
1582
|
+
});
|
|
1583
|
+
units.set(nid, slug);
|
|
1584
|
+
tmplOf.set(nid, templates.slice(0, MAX_TEMPLATES));
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
const nodesOut = [];
|
|
1588
|
+
for (const nid of sortedBy([...g.nodes.keys()])) {
|
|
1589
|
+
const r = roles.get(nid);
|
|
1590
|
+
const row = { node: nid, kind: get(g.nodes.get(nid), 'kind'), role: r.role };
|
|
1591
|
+
if (r.role === 'page') {
|
|
1592
|
+
row.tier = captured.has(nid) ? 'captured' : 'source-only';
|
|
1593
|
+
row.page_dirs = or(captured.get(nid), [units.get(nid)]);
|
|
1594
|
+
// captured but every frame FLAG_SECURE-blocked: view tree only, no pixel verification possible
|
|
1595
|
+
if (row.tier === 'captured' && row.page_dirs.every((d) => pixelsBlocked(uiInfo, d))) { row.pixels = 'blocked'; }
|
|
1596
|
+
} else if (r.role === 'attach') {
|
|
1597
|
+
row.host = r.host;
|
|
1598
|
+
if (captured.has(nid)) { row.page_dirs = captured.get(nid); }
|
|
1599
|
+
} else {
|
|
1600
|
+
row.reason = r.reason;
|
|
1601
|
+
if (captured.has(nid)) { row.page_dirs = captured.get(nid); }
|
|
1602
|
+
}
|
|
1603
|
+
nodesOut.push(row);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
const count = (pred) => nodesOut.filter(pred).length;
|
|
1607
|
+
const summary = {
|
|
1608
|
+
static_nodes: nodesOut.length,
|
|
1609
|
+
pages_captured: count((r) => r.tier === 'captured'),
|
|
1610
|
+
pages_tree_only: count((r) => r.pixels === 'blocked'),
|
|
1611
|
+
pages_source_only: count((r) => r.tier === 'source-only'),
|
|
1612
|
+
attached: count((r) => r.role === 'attach'),
|
|
1613
|
+
skipped: count((r) => r.role === 'skip'),
|
|
1614
|
+
page_dirs_total: pages.length,
|
|
1615
|
+
stale_source_only_removed: removed,
|
|
1616
|
+
...(scopeIds ? { out_of_scope: [...roles.values()].filter((r) => pyStr(r.reason).startsWith('out-of-incremental-scope')).length,
|
|
1617
|
+
scoped_without_host: sortedBy([...roles].filter(([, r]) => / its host .* is not in the scope$/.test(pyStr(r.reason))).map(([nid]) => nid)) } : {}),
|
|
1618
|
+
};
|
|
1619
|
+
const pageOrder = new Map(pages.map((p, i) => [pathName(p.page_dir), i]));
|
|
1620
|
+
let prevPlan = renumber ? {} : or(get(prevSet, 'plan'), {});
|
|
1621
|
+
if (truthy(entry) && truthy(prevPlan) && entry !== get(prevPlan, 'entry_node')) {
|
|
1622
|
+
prevPlan = {}; // a new entry reshapes the plan: done before the queue starts
|
|
1623
|
+
}
|
|
1624
|
+
const prevIds = new Map(get(prevPlan, 'groups', []).map((gr) => [gr.anchor, gr.id]));
|
|
1625
|
+
// Keep the entry chosen last time (often an --entry override): an early,
|
|
1626
|
+
// partial export would otherwise re-infer it on every re-run.
|
|
1627
|
+
entry = or(entry, get(prevPlan, 'entry_node') ?? null);
|
|
1628
|
+
if (scopeIds && !truthy(entry)) {
|
|
1629
|
+
// the launch page exists already and is usually outside the scope: infer it over the whole app
|
|
1630
|
+
const full = new Map([...fullRoles].filter(([, r]) => r.role === 'page')
|
|
1631
|
+
.map(([nid]) => [nid, { tier: captured.has(nid) ? 'captured' : 'source-only', page_dirs: captured.get(nid) ?? [] }]));
|
|
1632
|
+
// ordered by the unfiltered pages.json: the scoped one dropped the captures outside the scope
|
|
1633
|
+
const fullOrder = new Map(old.map((p, i) => [pathName(p.page_dir), i]));
|
|
1634
|
+
entry = planGroups(g, fullRoles, full, fullOrder, ranked, null, null).entry_node;
|
|
1635
|
+
}
|
|
1636
|
+
const plan = planGroups(g, roles, new Map(nodesOut.map((r) => [r.node, r])), pageOrder, ranked, entry, prevIds,
|
|
1637
|
+
scopeIds ? fullRoles : null);
|
|
1638
|
+
const gs = plan.groups;
|
|
1639
|
+
// The captured groups a source-only group borrows measurements from: it
|
|
1640
|
+
// waits for exactly those (group_queue), not for every captured group.
|
|
1641
|
+
const owner = new Map();
|
|
1642
|
+
for (const gr of gs) for (const d of gr.page_dirs) owner.set(d, gr.id);
|
|
1643
|
+
for (const gr of gs) {
|
|
1644
|
+
const tg = new Set();
|
|
1645
|
+
for (const m of gr.members) {
|
|
1646
|
+
for (const d of tmplOf.get(m.node) ?? []) {
|
|
1647
|
+
const o = owner.get(pathName(d));
|
|
1648
|
+
if (o && o !== gr.id) tg.add(o);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
gr.template_groups = sortedBy([...tg]);
|
|
1652
|
+
}
|
|
1653
|
+
// Exploration still running: captured groups may start, source-only ones
|
|
1654
|
+
// are held -- their tier is not final until the explorer settles.
|
|
1655
|
+
if (scopeIds) {
|
|
1656
|
+
applyIncremental(plan, truthy(existing) ? readList(existing, ['existing', 'files']) : []);
|
|
1657
|
+
plan.mode = 'incremental';
|
|
1658
|
+
plan.scope = sortedBy([...new Set(scopeIds)]);
|
|
1659
|
+
}
|
|
1660
|
+
annotateShellContent(g, plan, readJson(path.join(path.dirname(path.resolve(ws)), 'shell_contract.json'), null));
|
|
1661
|
+
plan.exploring = truthy(exploring);
|
|
1662
|
+
// The captures this plan's tiers reflect, and how it was built: group_queue.mjs
|
|
1663
|
+
// rebuilds the plan the same way when the campaign's captures have moved on.
|
|
1664
|
+
plan.capture_digest = manifest.capture_digest ?? null;
|
|
1665
|
+
plan.built_from = { static_ws: pathStr(ws), entry: entry ?? null,
|
|
1666
|
+
...(scopeIds ? { scope: pathStr(pathResolve(scope)), existing: truthy(existing) ? pathStr(pathResolve(existing)) : null } : {}) };
|
|
1667
|
+
const byClass = {};
|
|
1668
|
+
for (const c of ['host-chain', 'serial', 'self-contained']) { byClass[c] = gs.filter((x) => x.class === c).length; }
|
|
1669
|
+
const byStage = {};
|
|
1670
|
+
for (const st of [0, 1, 2]) { byStage[String(st)] = gs.filter((x) => x.stage === st).length; }
|
|
1671
|
+
Object.assign(summary, {
|
|
1672
|
+
groups: gs.length, entry_node: plan.entry_node,
|
|
1673
|
+
groups_by_class: byClass,
|
|
1674
|
+
groups_by_stage: byStage,
|
|
1675
|
+
group_warnings: gs.filter((x) => truthy(x.warning)).length,
|
|
1676
|
+
});
|
|
1677
|
+
writeJson(path.join(uiInfo, 'pages.json'), { pages });
|
|
1678
|
+
if (scopeIds) {
|
|
1679
|
+
writeJson(path.join(uiInfo, 'pages_captured.json'), { pages: allCaptured });
|
|
1680
|
+
} else {
|
|
1681
|
+
fs.rmSync(path.join(uiInfo, 'pages_captured.json'), { force: true }); // pages.json holds them all again
|
|
1682
|
+
}
|
|
1683
|
+
writeJson(path.join(uiInfo, 'conversion_set.json'), { summary, nodes: nodesOut, plan });
|
|
1684
|
+
return summary;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
const DESCRIPTION = 'build_conversion_set.mjs — make the static UTG, not the capture, decide what\ngets converted.';
|
|
1688
|
+
|
|
1689
|
+
export function main(argv = process.argv.slice(2)) {
|
|
1690
|
+
const a = parseArgs({
|
|
1691
|
+
prog: 'build_conversion_set.mjs', description: DESCRIPTION,
|
|
1692
|
+
args: [
|
|
1693
|
+
{ name: 'static_ws', positional: true, help: 'a2h-utg-static workspace (utg.json, click_paths.json)' },
|
|
1694
|
+
{ name: '--ui-info', required: true, help: 'ui_info_root (export_ui_info.mjs output)' },
|
|
1695
|
+
{ name: '--entry', help: "static node rendered by the app's launch page (default: inferred, see plan.entry_chosen_by)" },
|
|
1696
|
+
{ name: '--exploring', bool: true, help: 'explorer still running: mark the plan so group_queue holds source-only groups' },
|
|
1697
|
+
{ name: '--renumber', bool: true, help: "assign group ids afresh instead of keeping the previous run's ids per anchor" },
|
|
1698
|
+
{ name: '--scope', help: 'incremental: JSON list of the static node ids to convert (the confirmed SCOPE); every other page is skipped' },
|
|
1699
|
+
{ name: '--existing', help: 'incremental: JSON list of the .ets files the Harmony project already has (relative to the ETS root)' },
|
|
1700
|
+
],
|
|
1701
|
+
}, argv);
|
|
1702
|
+
if (!isFile(path.join(a.static_ws, 'utg.json'))) {
|
|
1703
|
+
err(`[ERR] ${pathStr(a.static_ws)}/utg.json missing — run Step 3.1 first`);
|
|
1704
|
+
return 2;
|
|
1705
|
+
}
|
|
1706
|
+
if (a.existing && !a.scope) {
|
|
1707
|
+
err('[ERR] --existing needs --scope');
|
|
1708
|
+
return 2;
|
|
1709
|
+
}
|
|
1710
|
+
for (const k of ['scope', 'existing']) {
|
|
1711
|
+
if (a[k] && !isFile(a[k])) {
|
|
1712
|
+
err(`[ERR] --${k} ${pathStr(a[k])}: no such file`);
|
|
1713
|
+
return 2;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
let s;
|
|
1717
|
+
try {
|
|
1718
|
+
s = build(pathResolve(a.static_ws), pathResolve(a.ui_info), a.entry, a.renumber, a.exploring,
|
|
1719
|
+
{ scope: a.scope, existing: a.existing });
|
|
1720
|
+
} catch (e) {
|
|
1721
|
+
if (!a.scope || !/^--scope|: expected a JSON list/.test(e.message)) { throw e; }
|
|
1722
|
+
err(`[ERR] ${e.message}`);
|
|
1723
|
+
return 2;
|
|
1724
|
+
}
|
|
1725
|
+
out(`static nodes ${s.static_nodes}: pages ${s.pages_captured} captured + ` +
|
|
1726
|
+
`${s.pages_source_only} source-only, ${s.attached} attached to a host, ${s.skipped} skipped` +
|
|
1727
|
+
(s.out_of_scope !== undefined ? ` (${s.out_of_scope} outside the incremental scope)` : '') + '; ' +
|
|
1728
|
+
`pages.json has ${s.page_dirs_total} entries`);
|
|
1729
|
+
out(`groups ${s.groups} (entry ${pyStr(s.entry_node)}): ${pyRepr(s.groups_by_class)}, by stage ${pyRepr(s.groups_by_stage)}` +
|
|
1730
|
+
(s.group_warnings ? `; ${s.group_warnings} oversized — review` : ''));
|
|
1731
|
+
if (!truthy(s.entry_node)) {
|
|
1732
|
+
err('[WARN] no entry page inferred (no launcher host-activity, no manifest launcher page): ' +
|
|
1733
|
+
'no group carries ENTRY_PAGE — re-run with --entry <static node of the launch page>');
|
|
1734
|
+
}
|
|
1735
|
+
if (truthy(s.scoped_without_host)) {
|
|
1736
|
+
err(`[WARN] --scope names ${s.scoped_without_host.join(', ')} without its host page: not converted — ` +
|
|
1737
|
+
'add the host page to the scope (an attached node is converted inside its host group)');
|
|
1738
|
+
}
|
|
1739
|
+
if (s.pages_captured === 0) {
|
|
1740
|
+
err('[WARN] no captured page: every page would be source-only and no project token ' +
|
|
1741
|
+
"(colour, density, spacing) can be measured — see Step 3.3's gate");
|
|
1742
|
+
}
|
|
1743
|
+
return 0;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
|
|
1747
|
+
process.exitCode = main();
|
|
1748
|
+
}
|