@buaa_smat/hometrans 0.1.17 → 0.1.20
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 +138 -56
- package/agents/code-reviewer.md +321 -65
- package/agents/logic-coder.md +113 -88
- package/agents/logic-context-builder.md +47 -29
- package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
- package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
- package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
- package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
- package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
- package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
- package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
- package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
- package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
- package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
- package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
- package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
- package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
- package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
- package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
- package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
- package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
- package/agents/scripts/hmos-precheck/index.mjs +17 -0
- package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
- package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
- package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
- package/agents/scripts/platform_query.mjs +626 -0
- package/agents/scripts/platform_query.test.mjs +422 -0
- package/agents/self-test-fixer.md +36 -34
- package/agents/self-tester.md +35 -376
- package/agents/test-case-generation-generator.md +317 -0
- package/agents/test-case-generation-validator.md +231 -0
- package/dist/cli/config-store.js +19 -146
- package/dist/cli/config.js +6 -8
- package/dist/cli/env-vars.js +1 -3
- package/dist/cli/index.js +0 -11
- package/dist/cli/init.js +147 -235
- package/dist/cli/uninstall.js +5 -129
- package/dist/utils/regex.js +8 -0
- package/env-requirements.json +57 -55
- package/package.json +6 -8
- package/resource/convert_pipeline_process.svg +103 -0
- package/resource/project_architecture.svg +122 -0
- package/resource/title_dark.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +345 -43
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
- package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
- package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
- package/skills/hmos-convert-pipeline/SKILL.md +188 -131
- package/skills/hmos-fix-build-errors/SKILL.md +87 -67
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/README.md +57 -40
- package/skills/hmos-incremental-ui-align/SKILL.md +180 -24
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
- package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
- package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
- package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
- package/skills/hmos-integration-test/README.md +111 -79
- package/skills/hmos-integration-test/SKILL.md +216 -132
- package/skills/hmos-integration-test/scripts/report-tool.ts +791 -0
- package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +125 -0
- package/skills/hmos-integration-test/scripts/self-test-runner.ts +756 -0
- package/skills/hmos-integration-test/scripts/testcases-tool.ts +239 -0
- package/skills/hmos-resources-convert/SKILL.md +334 -66
- package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
- package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
- package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
- package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
- package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
- package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
- package/skills/hmos-spec-generate/SKILL.md +293 -214
- package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
- package/skills/hmos-spec-generate/template/REQ.txt +22 -0
- package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
- package/skills/hmos-test-case-generation/README.md +241 -0
- package/skills/hmos-test-case-generation/SKILL.md +324 -0
- package/skills/hmos-test-case-generation/references/contract.md +315 -0
- package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
- package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
- package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
- package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
- package/tools/bfs-crawl/README.md +73 -0
- package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
- package/agents/build-fixer.md +0 -385
- package/agents/logic-coder/scripts/platform_context_query.py +0 -568
- package/agents/review-fixer.md +0 -405
- package/agents/spec-generator.md +0 -541
- package/dist/cli/mcp-setup.js +0 -258
- package/dist/cli/mcp.js +0 -94
- package/dist/context/index.js +0 -694
- package/resource/migration_process.svg +0 -94
- package/resource/migration_process_transparent.svg +0 -93
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
- package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
- package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
- package/skills/hmos-resources-convert/evals/evals.json +0 -171
- package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
- package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
- package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
- package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
- package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
- package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
- package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
- package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
- package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
- package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
- package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
- package/tools/test-tools/autotest/README.md +0 -238
- package/tools/test-tools/autotest/pyproject.toml +0 -26
- package/tools/test-tools/autotest/report_tool.py +0 -759
- package/tools/test-tools/autotest/self_test_runner.py +0 -895
- package/tools/test-tools/autotest/testcases_schema.md +0 -143
- package/tools/test-tools/autotest/testcases_tool.py +0 -215
- package/tools/test-tools/autotest/uv.lock +0 -3156
- package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* BFS view-tree dump → ui_elements.json (TCG schema) + page.parsed.json (display_texts).
|
|
4
|
+
*
|
|
5
|
+
* 靠 Node 原生类型擦除运行(Node ≥ 22.18 / 23.6 直接 `node convert_to_ui_elements.ts`),无需编译、无依赖。
|
|
6
|
+
*
|
|
7
|
+
* * REAL per-edge directed flows synthesized from click_path via PREFIX reconstruction
|
|
8
|
+
* keyed on (element, center) — deterministic, collision-proof.
|
|
9
|
+
* * structural gaps[] emission (0-text-element / unresolved-flow).
|
|
10
|
+
* * app-agnostic: app_name/package/description from CLI or inferred; NO business literals.
|
|
11
|
+
* * honest locators: text / bounds only; never fabricate id / source_location / platform_path.
|
|
12
|
+
*
|
|
13
|
+
* bounds are emitted as [left, top, right, bottom] (raw Android "[x1,y1][x2,y2]").
|
|
14
|
+
* page.parsed.json (display_texts for assertion targets) written per-page into <dump>/<page>/.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as fs from "node:fs";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
|
|
20
|
+
type Dict = Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
function load(p: string): Dict {
|
|
23
|
+
return JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isDict(v: unknown): v is Dict {
|
|
27
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function commaInt(n: number): string {
|
|
31
|
+
return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---- XML parse + page extraction ----
|
|
35
|
+
|
|
36
|
+
function sortCopy(arr: string[]): string[] {
|
|
37
|
+
return [...arr].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function actSimple(meta: Dict): string {
|
|
41
|
+
const info = isDict(meta["activity_info"]) ? (meta["activity_info"] as Dict) : {};
|
|
42
|
+
const s = (info["resumed_activity"] as string) || (info["current_focus"] as string) || "";
|
|
43
|
+
const m = s.match(/[\w.]+\/([\w.]+)/);
|
|
44
|
+
if (m) {
|
|
45
|
+
const parts = m[1].split(".");
|
|
46
|
+
return parts[parts.length - 1];
|
|
47
|
+
}
|
|
48
|
+
return "unknown";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function inferPackage(meta: Dict): string | null {
|
|
52
|
+
const info = isDict(meta["activity_info"]) ? (meta["activity_info"] as Dict) : {};
|
|
53
|
+
const s = (info["resumed_activity"] as string) || (info["current_focus"] as string) || "";
|
|
54
|
+
const m = s.match(/([\w.]+)\//);
|
|
55
|
+
return m ? m[1] : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function boundsArr(b: unknown): number[] {
|
|
59
|
+
const m = (typeof b === "string" ? b : "").match(/-?\d+/g) || [];
|
|
60
|
+
return m.length === 4 ? m.map((x) => parseInt(x, 10)) : [0, 0, 0, 0];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function dedupClickables(ce: Dict[]): Dict[] {
|
|
64
|
+
const seen = new Set<string>();
|
|
65
|
+
const out: Dict[] = [];
|
|
66
|
+
for (const e of ce) {
|
|
67
|
+
const k = JSON.stringify([
|
|
68
|
+
e["class"] ?? null, e["resource-id"] ?? null, e["text"] ?? null,
|
|
69
|
+
e["content-desc"] ?? null, e["bounds"] ?? null,
|
|
70
|
+
]);
|
|
71
|
+
if (seen.has(k)) continue;
|
|
72
|
+
seen.add(k);
|
|
73
|
+
out.push(e);
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ---- 最小 XML 遍历器:前序、root 深度 0,仅取属性(uiautomator dump 把字段存为属性)----
|
|
79
|
+
const ENTITIES: Record<string, string> = {
|
|
80
|
+
"&": "&", "<": "<", ">": ">", """: '"', "'": "'",
|
|
81
|
+
};
|
|
82
|
+
function unescapeXml(s: string): string {
|
|
83
|
+
return s.replace(/&(?:amp|lt|gt|quot|apos);|&#x?[0-9A-Fa-f]+;/g, (m) => {
|
|
84
|
+
if (m in ENTITIES) return ENTITIES[m];
|
|
85
|
+
if (m[1] === "#") {
|
|
86
|
+
const hex = m[2] === "x" || m[2] === "X";
|
|
87
|
+
const code = parseInt(m.slice(hex ? 3 : 2, -1), hex ? 16 : 10);
|
|
88
|
+
return String.fromCodePoint(code);
|
|
89
|
+
}
|
|
90
|
+
return m;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface XmlNode { attrs: Record<string, string>; depth: number; }
|
|
95
|
+
|
|
96
|
+
function parseXmlNodes(xml: string): XmlNode[] {
|
|
97
|
+
const nodes: XmlNode[] = [];
|
|
98
|
+
const tagRe = /<(\/)?([A-Za-z_][\w:.\-]*)((?:\s+[\w:.\-]+\s*=\s*"[^"]*")*)\s*(\/)?>/g;
|
|
99
|
+
const attrRe = /([\w:.\-]+)\s*=\s*"([^"]*)"/g;
|
|
100
|
+
let depth = -1;
|
|
101
|
+
let m: RegExpExecArray | null;
|
|
102
|
+
while ((m = tagRe.exec(xml)) !== null) {
|
|
103
|
+
const isClose = m[1] === "/";
|
|
104
|
+
const attrStr = m[3] || "";
|
|
105
|
+
const selfClose = m[4] === "/";
|
|
106
|
+
if (isClose) {
|
|
107
|
+
depth -= 1;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
depth += 1;
|
|
111
|
+
const attrs: Record<string, string> = {};
|
|
112
|
+
let am: RegExpExecArray | null;
|
|
113
|
+
attrRe.lastIndex = 0;
|
|
114
|
+
while ((am = attrRe.exec(attrStr)) !== null) {
|
|
115
|
+
attrs[am[1]] = unescapeXml(am[2]);
|
|
116
|
+
}
|
|
117
|
+
nodes.push({ attrs, depth });
|
|
118
|
+
if (selfClose) depth -= 1;
|
|
119
|
+
}
|
|
120
|
+
return nodes;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface TextNode { text: string; bounds: string; clickable: boolean; depth: number; class: string; }
|
|
124
|
+
|
|
125
|
+
function viewTextNodes(viewPath: string): TextNode[] {
|
|
126
|
+
if (!fs.existsSync(viewPath)) return [];
|
|
127
|
+
let xml: string;
|
|
128
|
+
try {
|
|
129
|
+
xml = fs.readFileSync(viewPath, "utf-8");
|
|
130
|
+
} catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
let parsed: XmlNode[];
|
|
134
|
+
try {
|
|
135
|
+
parsed = parseXmlNodes(xml);
|
|
136
|
+
} catch {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
const out: TextNode[] = [];
|
|
140
|
+
for (const n of parsed) {
|
|
141
|
+
const t = (n.attrs["text"] || "").trim();
|
|
142
|
+
if (t) {
|
|
143
|
+
out.push({
|
|
144
|
+
text: t,
|
|
145
|
+
bounds: n.attrs["bounds"] || "",
|
|
146
|
+
clickable: n.attrs["clickable"] === "true",
|
|
147
|
+
depth: n.depth,
|
|
148
|
+
class: n.attrs["class"] || "",
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function listViewXmls(pdir: string, meta: Dict): string[] {
|
|
156
|
+
const rels = (meta["view_xmls"] as string[]) || [];
|
|
157
|
+
const paths: string[] = [];
|
|
158
|
+
for (const r of rels) {
|
|
159
|
+
const cand = path.join(pdir, path.basename(r));
|
|
160
|
+
if (fs.existsSync(cand)) paths.push(cand);
|
|
161
|
+
}
|
|
162
|
+
if (paths.length === 0) {
|
|
163
|
+
const entries = fs.existsSync(pdir) ? fs.readdirSync(pdir) : [];
|
|
164
|
+
const hits: string[] = [];
|
|
165
|
+
for (const name of entries) {
|
|
166
|
+
if (name === "view.xml" || /^view_scroll_.*\.xml$/.test(name)) {
|
|
167
|
+
hits.push(path.join(pdir, name));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return sortCopy(hits);
|
|
171
|
+
}
|
|
172
|
+
return paths;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function groupDisplayText(pdir: string, meta: Dict): Array<{ text: string; bounds: string }> {
|
|
176
|
+
const rows: Array<{ text: string; bounds: string; _y: number }> = [];
|
|
177
|
+
const seen = new Set<string>();
|
|
178
|
+
for (const vp of listViewXmls(pdir, meta)) {
|
|
179
|
+
for (const n of viewTextNodes(vp)) {
|
|
180
|
+
if (n.clickable) continue;
|
|
181
|
+
const t = n.text;
|
|
182
|
+
if (seen.has(t)) continue;
|
|
183
|
+
seen.add(t);
|
|
184
|
+
rows.push({ text: t, bounds: n.bounds, _y: boundsArr(n.bounds)[1] });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
rows.sort((a, b) => a._y - b._y);
|
|
188
|
+
return rows.map((r) => ({ text: r.text, bounds: r.bounds }));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function reprText(pdir: string, meta: Dict, k = 8): string[] {
|
|
192
|
+
let nodes: TextNode[] = [];
|
|
193
|
+
const frames = listViewXmls(pdir, meta).slice(0, 1);
|
|
194
|
+
for (const vp of frames) nodes = viewTextNodes(vp);
|
|
195
|
+
const yOf = (n: TextNode): number => boundsArr(n.bounds)[1];
|
|
196
|
+
const sorted = [...nodes].sort((a, b) => yOf(a) - yOf(b));
|
|
197
|
+
const cand = sorted.filter((n) => n.text.length > 0 && n.text.length <= 20);
|
|
198
|
+
const seen = new Set<string>();
|
|
199
|
+
const out: string[] = [];
|
|
200
|
+
for (const n of cand) {
|
|
201
|
+
if (seen.has(n.text)) continue;
|
|
202
|
+
seen.add(n.text);
|
|
203
|
+
out.push(n.text);
|
|
204
|
+
if (out.length >= k) break;
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function signature(act: string, clickables: Dict[]): string {
|
|
210
|
+
const keys = sortCopy([...new Set(
|
|
211
|
+
clickables.map((e) =>
|
|
212
|
+
(e["resource-id"] as string) || (e["text"] as string) || (e["content-desc"] as string) || ""),
|
|
213
|
+
)]);
|
|
214
|
+
return act + "|" + keys.join("|");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ---- TCG schema synthesis ----
|
|
218
|
+
|
|
219
|
+
function shortId(pid: string | null | undefined): string {
|
|
220
|
+
const m = (pid || "").match(/page_(\d+)/);
|
|
221
|
+
if (m) return "p" + m[1];
|
|
222
|
+
return (pid || "p").replace(/[^0-9A-Za-z]+/g, "_");
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function slug(t: string | null | undefined, i: number): string {
|
|
226
|
+
let s = (t || "").trim().replace(/[^0-9A-Za-z一-鿿]+/gu, "_");
|
|
227
|
+
s = s.slice(0, 24);
|
|
228
|
+
s = s.replace(/^_+/, "").replace(/_+$/, "");
|
|
229
|
+
return (s || "el") + `_${i}`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function elemType(cls: string | null | undefined, text: unknown): string {
|
|
233
|
+
cls = cls || "";
|
|
234
|
+
if (cls.includes("EditText")) return "TextInput";
|
|
235
|
+
if (cls.includes("Image") && !truthy(text)) return "Image";
|
|
236
|
+
return "Clickable";
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function truthy(v: unknown): boolean {
|
|
240
|
+
if (v === null || v === undefined) return false;
|
|
241
|
+
if (typeof v === "string") return v.length > 0;
|
|
242
|
+
if (typeof v === "number") return v !== 0;
|
|
243
|
+
if (typeof v === "boolean") return v;
|
|
244
|
+
if (Array.isArray(v)) return v.length > 0;
|
|
245
|
+
if (isDict(v)) return Object.keys(v).length > 0;
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function ctr(c: unknown): string | null {
|
|
250
|
+
if (Array.isArray(c) && c.length === 2) return `${c[0]},${c[1]}`;
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function listStr(c: unknown): string {
|
|
255
|
+
if (c === null || c === undefined) return "None";
|
|
256
|
+
if (Array.isArray(c)) return "[" + c.map((x) => String(x)).join(", ") + "]";
|
|
257
|
+
return String(c);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function pathKey(cp: unknown): string {
|
|
261
|
+
const key: Array<[string, string | null]> = [];
|
|
262
|
+
if (Array.isArray(cp)) {
|
|
263
|
+
for (const s of cp) {
|
|
264
|
+
if (!isDict(s)) continue;
|
|
265
|
+
const name = (s["element"] as string) || (s["text"] as string) || "";
|
|
266
|
+
key.push([name, ctr(s["center"])]);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return JSON.stringify(key);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function parseArgs(argv: string[]): Dict {
|
|
273
|
+
const out: Dict = {
|
|
274
|
+
dump: null, out: null, app_name: null, package: null, description: null,
|
|
275
|
+
};
|
|
276
|
+
const map: Record<string, string> = {
|
|
277
|
+
"--dump": "dump", "--out": "out", "--app-name": "app_name",
|
|
278
|
+
"--package": "package", "--description": "description",
|
|
279
|
+
};
|
|
280
|
+
for (let i = 0; i < argv.length; i++) {
|
|
281
|
+
const a = argv[i];
|
|
282
|
+
if (a in map) { out[map[a]] = argv[++i]; }
|
|
283
|
+
}
|
|
284
|
+
for (const req of ["dump", "out"]) {
|
|
285
|
+
if (!out[req]) {
|
|
286
|
+
console.error(`convert_to_ui_elements.ts: error: the following arguments are required: --${req}`);
|
|
287
|
+
process.exit(2);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return out;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
interface PageRec {
|
|
294
|
+
pid: string;
|
|
295
|
+
act: string;
|
|
296
|
+
canonical: string;
|
|
297
|
+
isDup: boolean;
|
|
298
|
+
repr_text: string[];
|
|
299
|
+
clickable_elements: Dict[];
|
|
300
|
+
click_path: unknown[];
|
|
301
|
+
display_texts: Array<{ text: string; bounds: string }>;
|
|
302
|
+
element_count: number;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function main(): void {
|
|
306
|
+
const args = parseArgs(process.argv.slice(2));
|
|
307
|
+
const dump = args.dump as string;
|
|
308
|
+
|
|
309
|
+
// ---- parse all pages in-memory ----
|
|
310
|
+
const entries = fs.existsSync(dump) ? fs.readdirSync(dump) : [];
|
|
311
|
+
const pageDirs = sortCopy(
|
|
312
|
+
entries
|
|
313
|
+
.filter((name) => name.startsWith("page_"))
|
|
314
|
+
.map((name) => path.join(dump, name))
|
|
315
|
+
.filter((d) => {
|
|
316
|
+
try { return fs.statSync(d).isDirectory() && fs.existsSync(path.join(d, "meta.json")); }
|
|
317
|
+
catch { return false; }
|
|
318
|
+
}),
|
|
319
|
+
);
|
|
320
|
+
if (pageDirs.length === 0) {
|
|
321
|
+
console.error(`no page_*/meta.json under ${dump}`);
|
|
322
|
+
process.exit(1);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const allPages: PageRec[] = [];
|
|
326
|
+
const sigCanonical = new Map<string, string>();
|
|
327
|
+
let pkg = args.package as string | null;
|
|
328
|
+
let totDisp = 0;
|
|
329
|
+
|
|
330
|
+
for (const pdir of pageDirs) {
|
|
331
|
+
const pid = path.basename(pdir);
|
|
332
|
+
const meta = load(path.join(pdir, "meta.json"));
|
|
333
|
+
if (pkg === null || pkg === undefined) pkg = inferPackage(meta);
|
|
334
|
+
const act = actSimple(meta);
|
|
335
|
+
|
|
336
|
+
const ceRaw = dedupClickables((meta["clickable_elements"] as Dict[]) || []);
|
|
337
|
+
const ce: Dict[] = ceRaw.map((e) => ({
|
|
338
|
+
class: e["class"] ?? null,
|
|
339
|
+
text: ((e["text"] as string) || "").trim(),
|
|
340
|
+
resource_id: ((e["resource-id"] as string) || "").trim(),
|
|
341
|
+
content_desc: ((e["content-desc"] as string) || "").trim(),
|
|
342
|
+
bounds: e["bounds"] ?? null,
|
|
343
|
+
center: e["center"] ?? null,
|
|
344
|
+
long_clickable: "long-clickable" in e ? e["long-clickable"] : false,
|
|
345
|
+
}));
|
|
346
|
+
const disp = groupDisplayText(pdir, meta);
|
|
347
|
+
const rep = reprText(pdir, meta);
|
|
348
|
+
totDisp += disp.length;
|
|
349
|
+
|
|
350
|
+
const sig = signature(act, ceRaw);
|
|
351
|
+
const isDup = sigCanonical.has(sig);
|
|
352
|
+
const canonical = isDup ? sigCanonical.get(sig)! : pid;
|
|
353
|
+
if (!isDup) sigCanonical.set(sig, pid);
|
|
354
|
+
|
|
355
|
+
// side-effect: page.parsed.json (display_texts for _display_texts_ref)
|
|
356
|
+
const parsed: Dict = {
|
|
357
|
+
page_id: pid,
|
|
358
|
+
activity: act,
|
|
359
|
+
clickable_elements: ce,
|
|
360
|
+
display_texts: disp,
|
|
361
|
+
display_text_count: disp.length,
|
|
362
|
+
};
|
|
363
|
+
fs.writeFileSync(path.join(pdir, "page.parsed.json"), JSON.stringify(parsed, null, 2), "utf-8");
|
|
364
|
+
|
|
365
|
+
allPages.push({
|
|
366
|
+
pid, act, canonical, isDup,
|
|
367
|
+
repr_text: rep,
|
|
368
|
+
clickable_elements: ce,
|
|
369
|
+
click_path: (meta["click_path"] as unknown[]) || [],
|
|
370
|
+
display_texts: disp,
|
|
371
|
+
element_count: ce.length,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ---- canonical short-id mapping ----
|
|
376
|
+
const canonShort: Record<string, string> = {};
|
|
377
|
+
for (const p of allPages) {
|
|
378
|
+
canonShort[p.pid] = shortId(p.canonical);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// ---- build canonical pages with honest elements ----
|
|
382
|
+
const pages: Record<string, Dict> = {};
|
|
383
|
+
const centerIndex: Record<string, Record<string, string>> = {};
|
|
384
|
+
let hasResourceId = false;
|
|
385
|
+
const acts = new Set<unknown>();
|
|
386
|
+
|
|
387
|
+
for (const p of allPages) {
|
|
388
|
+
if (p.isDup) continue;
|
|
389
|
+
const sid = shortId(p.pid);
|
|
390
|
+
acts.add(p.act);
|
|
391
|
+
const elements: Dict[] = [];
|
|
392
|
+
const cmap: Record<string, string> = {};
|
|
393
|
+
const clickables = p.clickable_elements;
|
|
394
|
+
for (let i = 0; i < clickables.length; i++) {
|
|
395
|
+
const e = clickables[i];
|
|
396
|
+
if (((e["resource_id"] as string) || "").trim()) hasResourceId = true;
|
|
397
|
+
const t = (e["text"] as string) || (e["content_desc"] as string);
|
|
398
|
+
const eid = truthy(t) ? slug(t, i) : `icon_${i}`;
|
|
399
|
+
let locator: Dict;
|
|
400
|
+
let name: string;
|
|
401
|
+
if (truthy(t)) {
|
|
402
|
+
locator = { type: "text", value: t };
|
|
403
|
+
name = t;
|
|
404
|
+
} else {
|
|
405
|
+
locator = { type: "bounds", value: (e["bounds"] as string) || "" };
|
|
406
|
+
name = `icon@${listStr(e["center"])}`;
|
|
407
|
+
}
|
|
408
|
+
const el: Dict = {
|
|
409
|
+
element_id: eid,
|
|
410
|
+
element_name: name,
|
|
411
|
+
element_type: elemType(e["class"] as string, t),
|
|
412
|
+
locator: locator,
|
|
413
|
+
bounds: boundsArr(e["bounds"]),
|
|
414
|
+
source: "bfs-runtime",
|
|
415
|
+
};
|
|
416
|
+
elements.push(el);
|
|
417
|
+
const c = ctr(e["center"]);
|
|
418
|
+
if (c !== null) cmap[c] = eid;
|
|
419
|
+
}
|
|
420
|
+
pages[sid] = {
|
|
421
|
+
page_id: sid,
|
|
422
|
+
page_name: p.pid,
|
|
423
|
+
page_name_cn: p.repr_text.length ? p.repr_text[0] : p.pid,
|
|
424
|
+
component_type: "Screen",
|
|
425
|
+
component_name: p.act,
|
|
426
|
+
description: null,
|
|
427
|
+
repr_text: p.repr_text,
|
|
428
|
+
elements: elements,
|
|
429
|
+
_bfs_page_id: p.pid,
|
|
430
|
+
_display_texts_ref: `${p.pid}/page.parsed.json#display_texts`,
|
|
431
|
+
};
|
|
432
|
+
centerIndex[sid] = cmap;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// ---- path_key index for prefix reconstruction ----
|
|
436
|
+
const pathIndex: Record<string, string> = {};
|
|
437
|
+
for (const p of allPages) {
|
|
438
|
+
const k = pathKey(p.click_path);
|
|
439
|
+
if (!(k in pathIndex)) pathIndex[k] = canonShort[p.pid];
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// ---- synthesize real per-edge directed flows ----
|
|
443
|
+
const flows: Dict[] = [];
|
|
444
|
+
const flowSeen = new Set<string>();
|
|
445
|
+
const gaps: Dict[] = [];
|
|
446
|
+
let resolved = 0;
|
|
447
|
+
let nonroot = 0;
|
|
448
|
+
for (const p of allPages) {
|
|
449
|
+
const cp = p.click_path;
|
|
450
|
+
if (!cp || cp.length === 0) continue;
|
|
451
|
+
nonroot += 1;
|
|
452
|
+
const tgt = canonShort[p.pid];
|
|
453
|
+
const trigger = cp[cp.length - 1] as Dict;
|
|
454
|
+
const prefix = cp.slice(0, -1);
|
|
455
|
+
const src = pathIndex[pathKey(prefix)];
|
|
456
|
+
if (src === undefined) {
|
|
457
|
+
gaps.push({
|
|
458
|
+
type: "flow", location: tgt,
|
|
459
|
+
reason: "parent page (click_path prefix) not present in dump; edge source unresolved",
|
|
460
|
+
});
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
resolved += 1;
|
|
464
|
+
const tname = (trigger["text"] as string) || (trigger["element"] as string) || "";
|
|
465
|
+
const tc = ctr(trigger["center"]);
|
|
466
|
+
let teid: string | undefined = tc !== null ? (centerIndex[src] || {})[tc] : undefined;
|
|
467
|
+
if (teid === undefined) {
|
|
468
|
+
const srcEls = (pages[src]?.["elements"] as Dict[]) || [];
|
|
469
|
+
teid = slug(tname, srcEls.length);
|
|
470
|
+
if (src in pages) {
|
|
471
|
+
(pages[src]["elements"] as Dict[]).push({
|
|
472
|
+
element_id: teid,
|
|
473
|
+
element_name: tname,
|
|
474
|
+
element_type: "Clickable",
|
|
475
|
+
locator: truthy(tname) ? { type: "text", value: tname } : { type: "bounds", value: "" },
|
|
476
|
+
bounds: boundsArr(trigger["bounds"]),
|
|
477
|
+
source: "bfs-runtime-clicked",
|
|
478
|
+
});
|
|
479
|
+
if (tc !== null) centerIndex[src][tc] = teid;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const edgeKey = JSON.stringify([src, teid, tgt]);
|
|
483
|
+
if (flowSeen.has(edgeKey)) continue;
|
|
484
|
+
flowSeen.add(edgeKey);
|
|
485
|
+
const n = flows.length;
|
|
486
|
+
flows.push({
|
|
487
|
+
flow_id: `${tgt}_e${n}`,
|
|
488
|
+
source_page_id: src,
|
|
489
|
+
trigger_event: {
|
|
490
|
+
event_id: `${tgt}_e${n}_click`,
|
|
491
|
+
event_type: "CLICK",
|
|
492
|
+
target_element_id: teid,
|
|
493
|
+
description: truthy(tname) ? `点击「${tname}」` : "点击",
|
|
494
|
+
},
|
|
495
|
+
target_page_id: tgt,
|
|
496
|
+
transition_type: "Navigate_compose",
|
|
497
|
+
source: "bfs-click-path",
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// ---- structural gaps: 0-text-element pages ----
|
|
502
|
+
for (const sid of Object.keys(pages)) {
|
|
503
|
+
const pg = pages[sid];
|
|
504
|
+
const els = pg["elements"] as Dict[];
|
|
505
|
+
const textLocatable = els.filter((e) => (e["locator"] as Dict)["type"] === "text").length;
|
|
506
|
+
if (textLocatable === 0) {
|
|
507
|
+
gaps.push({
|
|
508
|
+
type: "element", location: sid,
|
|
509
|
+
reason: "page has 0 text-locatable clickables after dedup; only icon-only/vision-pending controls",
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const tech = (acts.size === 1 && !hasResourceId)
|
|
515
|
+
? "Jetpack Compose (single-Activity)"
|
|
516
|
+
: "Android (runtime view-tree)";
|
|
517
|
+
|
|
518
|
+
const out: Dict = {
|
|
519
|
+
app_info: {
|
|
520
|
+
app_name: args.app_name ?? null,
|
|
521
|
+
package_name: pkg,
|
|
522
|
+
tech_stack: tech,
|
|
523
|
+
description: args.description ?? null,
|
|
524
|
+
source: "BFS view-tree (mechanical); locators are text/bounds runtime truth, no source paths",
|
|
525
|
+
},
|
|
526
|
+
pages: Object.values(pages),
|
|
527
|
+
flows: flows,
|
|
528
|
+
gaps: gaps,
|
|
529
|
+
extraction_note: "Runtime BFS-derived. No platform_path/source_location/id locator " +
|
|
530
|
+
"(view-tree has no stable resource-id). display_texts (assertion targets) " +
|
|
531
|
+
"live per-page in page.parsed.json (see _display_texts_ref).",
|
|
532
|
+
};
|
|
533
|
+
const outPath = args.out as string;
|
|
534
|
+
fs.mkdirSync(path.dirname(path.resolve(outPath)), { recursive: true });
|
|
535
|
+
fs.writeFileSync(outPath, JSON.stringify(out, null, 2), "utf-8");
|
|
536
|
+
|
|
537
|
+
const cov = nonroot ? (100.0 * resolved) / nonroot : 100.0;
|
|
538
|
+
const bytes = fs.statSync(outPath).size;
|
|
539
|
+
console.log("complete");
|
|
540
|
+
console.log(` pages total = ${allPages.length} (canonical ${sigCanonical.size}, duplicate ${allPages.length - sigCanonical.size})`);
|
|
541
|
+
console.log(` flows (edges) = ${flows.length}`);
|
|
542
|
+
console.log(` gaps = ${gaps.length}`);
|
|
543
|
+
console.log(` tech_stack = ${tech}`);
|
|
544
|
+
console.log(` edge resolution = ${resolved}/${nonroot} = ${cov.toFixed(1)}% (acceptance >=90%)`);
|
|
545
|
+
console.log(` package = ${pkg}`);
|
|
546
|
+
console.log(` display_texts = ${totDisp} (scroll-aggregated assertion targets)`);
|
|
547
|
+
console.log(` out = ${outPath} (${commaInt(bytes)} bytes)`);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
main();
|