@buaa_smat/hometrans 0.1.17 → 0.1.19
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 +120 -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 +123 -143
- package/agents/test-case-generation-generator.md +317 -0
- package/agents/test-case-generation-validator.md +231 -0
- package/dist/cli/config-store.js +16 -63
- package/dist/cli/env-vars.js +1 -3
- package/dist/cli/index.js +0 -11
- package/dist/cli/init.js +123 -204
- package/dist/cli/uninstall.js +3 -127
- package/dist/utils/regex.js +8 -0
- package/env-requirements.json +55 -54
- package/package.json +6 -6
- 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 +168 -121
- 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 +53 -36
- package/skills/hmos-incremental-ui-align/SKILL.md +179 -23
- 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 +61 -70
- package/skills/hmos-integration-test/SKILL.md +128 -111
- 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/tools/test-tools/autotest/config.ts +175 -0
- package/tools/test-tools/autotest/deps/autotest-agent-0.1.1.tgz +0 -0
- package/tools/test-tools/autotest/docs/README.md +266 -0
- package/tools/test-tools/autotest/{testcases_schema.md → docs/testcases_schema.md} +1 -1
- package/tools/test-tools/autotest/engine/batch-launcher.ts +327 -0
- package/tools/test-tools/autotest/engine/report-tool.ts +773 -0
- package/tools/test-tools/autotest/engine/self-test-runner.ts +961 -0
- package/tools/test-tools/autotest/engine/testcases-tool.ts +246 -0
- package/tools/test-tools/autotest/paths.ts +41 -0
- package/tools/test-tools/autotest/resolve-metadata-tool.ts +143 -0
- package/tools/test-tools/autotest/runner/logger.ts +45 -0
- package/tools/test-tools/autotest/runner/process-utils.ts +41 -0
- package/tools/test-tools/autotest/validate.ts +167 -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_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
package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc
DELETED
|
Binary file
|
|
@@ -1,542 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# /// script
|
|
4
|
-
# requires-python = ">=3.12"
|
|
5
|
-
# dependencies = [
|
|
6
|
-
# "openpyxl",
|
|
7
|
-
# "phone-agent",
|
|
8
|
-
# ]
|
|
9
|
-
# [[tool.uv.index]]
|
|
10
|
-
# url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
11
|
-
# ///
|
|
12
|
-
"""
|
|
13
|
-
应用页面导航工具 —— 使用 PhoneAgent 按指定路径操作设备,导航到目标页面。
|
|
14
|
-
|
|
15
|
-
支持 Android (ADB) 和 HarmonyOS (HDC) 两种设备类型。
|
|
16
|
-
|
|
17
|
-
依赖: openpyxl、phone-agent —— 已在文件顶部 PEP 723 元数据声明,`uv run` 自动安装(无需手动 pip install)
|
|
18
|
-
运行前需确保: 设备已连接 (HDC/ADB)、模型 API 可用
|
|
19
|
-
|
|
20
|
-
用法:
|
|
21
|
-
# 自由 prompt 导航
|
|
22
|
-
uv run app_feature_verify.py --device adb --app Gallery --package com.example.gallery --prompt "打开相册,进入设置页面"
|
|
23
|
-
|
|
24
|
-
# 按功能路径导航
|
|
25
|
-
uv run app_feature_verify.py --app 简单图库 --package com.simplemobiletools.gallery.pro --task "L1相册详情L2更多L3筛选媒体文件"
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
import argparse
|
|
29
|
-
import json
|
|
30
|
-
import re
|
|
31
|
-
import sys
|
|
32
|
-
import os
|
|
33
|
-
from pathlib import Path
|
|
34
|
-
|
|
35
|
-
# 强制设置 UTF-8 编码以避免 Windows GBK 编码问题
|
|
36
|
-
if sys.platform == 'win32':
|
|
37
|
-
import io
|
|
38
|
-
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
39
|
-
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# ---------------------------------------------------------------------------
|
|
43
|
-
# Excel 功能清单解析
|
|
44
|
-
# ---------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
def parse_app_feature(
|
|
47
|
-
file_path: str | Path | None = None,
|
|
48
|
-
sheet_name: str | int = 0,
|
|
49
|
-
) -> list[dict]:
|
|
50
|
-
"""解析功能清单 Excel,返回功能清单列表。"""
|
|
51
|
-
import openpyxl
|
|
52
|
-
|
|
53
|
-
file_path = Path(file_path)
|
|
54
|
-
if not file_path.exists():
|
|
55
|
-
raise FileNotFoundError(f"文件不存在: {file_path}")
|
|
56
|
-
|
|
57
|
-
wb = openpyxl.load_workbook(file_path, read_only=True, data_only=True)
|
|
58
|
-
|
|
59
|
-
if isinstance(sheet_name, int):
|
|
60
|
-
sheet = wb.worksheets[sheet_name]
|
|
61
|
-
else:
|
|
62
|
-
sheet = wb[sheet_name]
|
|
63
|
-
|
|
64
|
-
rows = list(sheet.iter_rows(values_only=True))
|
|
65
|
-
wb.close()
|
|
66
|
-
|
|
67
|
-
if not rows:
|
|
68
|
-
return []
|
|
69
|
-
|
|
70
|
-
headers = [str(h) if h is not None else f"col_{i}" for i, h in enumerate(rows[0])]
|
|
71
|
-
|
|
72
|
-
result = []
|
|
73
|
-
for row in rows[1:]:
|
|
74
|
-
row_dict = {}
|
|
75
|
-
for i, val in enumerate(row):
|
|
76
|
-
key = headers[i] if i < len(headers) else f"col_{i}"
|
|
77
|
-
row_dict[key] = val
|
|
78
|
-
result.append(row_dict)
|
|
79
|
-
|
|
80
|
-
return result
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
# ---------------------------------------------------------------------------
|
|
84
|
-
# Markdown 功能清单解析
|
|
85
|
-
# ---------------------------------------------------------------------------
|
|
86
|
-
|
|
87
|
-
def parse_app_feature_md(file_path: str | Path) -> list[dict]:
|
|
88
|
-
"""解析 Markdown 测试用例文件,返回场景列表。"""
|
|
89
|
-
file_path = Path(file_path)
|
|
90
|
-
if not file_path.exists():
|
|
91
|
-
raise FileNotFoundError(f"文件不存在: {file_path}")
|
|
92
|
-
|
|
93
|
-
text = file_path.read_text(encoding="utf-8")
|
|
94
|
-
lines = text.splitlines()
|
|
95
|
-
|
|
96
|
-
results: list[dict] = []
|
|
97
|
-
current_feature = ""
|
|
98
|
-
current_scenario: dict | None = None
|
|
99
|
-
collecting_sub_items: str | None = None
|
|
100
|
-
|
|
101
|
-
for line in lines:
|
|
102
|
-
stripped = line.strip()
|
|
103
|
-
|
|
104
|
-
feat_match = re.match(r"^##\s+Feature:\s*(.+)$", stripped)
|
|
105
|
-
if feat_match:
|
|
106
|
-
if current_scenario is not None:
|
|
107
|
-
results.append(current_scenario)
|
|
108
|
-
current_scenario = None
|
|
109
|
-
current_feature = feat_match.group(1).strip()
|
|
110
|
-
collecting_sub_items = None
|
|
111
|
-
continue
|
|
112
|
-
|
|
113
|
-
scen_match = re.match(r"^###\s+Scenario:\s*(.+)$", stripped)
|
|
114
|
-
if scen_match:
|
|
115
|
-
if current_scenario is not None:
|
|
116
|
-
results.append(current_scenario)
|
|
117
|
-
scenario_name = scen_match.group(1).strip()
|
|
118
|
-
feature_name = re.sub(r"^FEA-\d+\s*", "", current_feature)
|
|
119
|
-
current_scenario = {
|
|
120
|
-
"feature": current_feature,
|
|
121
|
-
"scenario": scenario_name,
|
|
122
|
-
"preconditions": [],
|
|
123
|
-
"actions": [],
|
|
124
|
-
"expectations": [],
|
|
125
|
-
"L1": feature_name,
|
|
126
|
-
"L2": scenario_name,
|
|
127
|
-
"L3": "",
|
|
128
|
-
}
|
|
129
|
-
collecting_sub_items = None
|
|
130
|
-
continue
|
|
131
|
-
|
|
132
|
-
if current_scenario is None:
|
|
133
|
-
continue
|
|
134
|
-
|
|
135
|
-
if re.match(r"^-\s*前置条件[::]", stripped):
|
|
136
|
-
collecting_sub_items = "preconditions"
|
|
137
|
-
continue
|
|
138
|
-
|
|
139
|
-
action_match = re.match(r"^-\s*动作[::]\s*(.+)$", stripped)
|
|
140
|
-
if action_match:
|
|
141
|
-
collecting_sub_items = None
|
|
142
|
-
current_scenario["actions"].append(action_match.group(1).strip())
|
|
143
|
-
continue
|
|
144
|
-
|
|
145
|
-
expect_match = re.match(r"^-\s*预期结果[::]\s*(.+)$", stripped)
|
|
146
|
-
if expect_match:
|
|
147
|
-
collecting_sub_items = None
|
|
148
|
-
current_scenario["expectations"].append(expect_match.group(1).strip())
|
|
149
|
-
continue
|
|
150
|
-
|
|
151
|
-
sub_match = re.match(r"^\s+-\s+(.+)$", line)
|
|
152
|
-
if sub_match and collecting_sub_items == "preconditions":
|
|
153
|
-
current_scenario["preconditions"].append(sub_match.group(1).strip())
|
|
154
|
-
continue
|
|
155
|
-
|
|
156
|
-
if stripped and not stripped.startswith("-"):
|
|
157
|
-
collecting_sub_items = None
|
|
158
|
-
|
|
159
|
-
if current_scenario is not None:
|
|
160
|
-
results.append(current_scenario)
|
|
161
|
-
|
|
162
|
-
return results
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
# ---------------------------------------------------------------------------
|
|
166
|
-
# 应用注册
|
|
167
|
-
# ---------------------------------------------------------------------------
|
|
168
|
-
|
|
169
|
-
def register_app(app_name: str, package: str, device_type: str, ability: str = "EntryAbility") -> None:
|
|
170
|
-
"""将应用注册到 phone-agent 的配置中。"""
|
|
171
|
-
if device_type == "hdc":
|
|
172
|
-
from phone_agent.config import apps_harmonyos
|
|
173
|
-
apps_harmonyos.APP_PACKAGES[app_name] = package
|
|
174
|
-
apps_harmonyos.APP_ABILITIES[package] = ability
|
|
175
|
-
else:
|
|
176
|
-
from phone_agent.config import apps
|
|
177
|
-
apps.APP_PACKAGES[app_name] = package
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
# ---------------------------------------------------------------------------
|
|
181
|
-
# 功能路径提取
|
|
182
|
-
# ---------------------------------------------------------------------------
|
|
183
|
-
|
|
184
|
-
def _get_feature_path(item: dict) -> tuple[str, str]:
|
|
185
|
-
"""从功能项提取层级路径和叶子节点名称。"""
|
|
186
|
-
keys = [k for k in ("L1", "L2", "L3") if k in item]
|
|
187
|
-
if not keys:
|
|
188
|
-
keys = [k for k in ("一级", "二级", "三级") if k in item]
|
|
189
|
-
if not keys:
|
|
190
|
-
keys = list(item.keys())[:3]
|
|
191
|
-
|
|
192
|
-
parts = []
|
|
193
|
-
for k in keys:
|
|
194
|
-
v = item.get(k)
|
|
195
|
-
if v is not None and str(v).strip():
|
|
196
|
-
parts.append(str(v).strip())
|
|
197
|
-
|
|
198
|
-
if not parts:
|
|
199
|
-
return "", ""
|
|
200
|
-
return " > ".join(parts), parts[-1]
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
# ---------------------------------------------------------------------------
|
|
204
|
-
# 构建导航 prompt
|
|
205
|
-
# ---------------------------------------------------------------------------
|
|
206
|
-
|
|
207
|
-
def _build_navigate_prompt(app_name: str, path_str: str, leaf: str, app_hints: str | None = None) -> str:
|
|
208
|
-
"""构建导航到目标页面的 prompt。"""
|
|
209
|
-
prompt = (
|
|
210
|
-
f"打开{app_name},按照以下路径依次点击导航到目标页面:{path_str}。"
|
|
211
|
-
f"最终目标是到达「{leaf}」所在的页面。"
|
|
212
|
-
"注意:"
|
|
213
|
-
"1. 鸿蒙手机浅色/深色模式切换路径:设置->显示与亮度"
|
|
214
|
-
"2. '更多'组件可能表示为 三横 或者 三点。"
|
|
215
|
-
"3. '设置'组件可能表示为 齿轮。"
|
|
216
|
-
"到达目标页面后请回复'已到达',无法到达请回复'未找到'。"
|
|
217
|
-
)
|
|
218
|
-
if app_hints:
|
|
219
|
-
prompt += f"\n补充提示: {app_hints}"
|
|
220
|
-
return prompt
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
# ---------------------------------------------------------------------------
|
|
224
|
-
# 判断是否到达目标页面
|
|
225
|
-
# ---------------------------------------------------------------------------
|
|
226
|
-
|
|
227
|
-
def _judge_reached(msg: str) -> bool:
|
|
228
|
-
"""根据 agent 回复判断是否到达了目标页面。"""
|
|
229
|
-
if not msg:
|
|
230
|
-
return False
|
|
231
|
-
reached_keywords = ("已到达", "到达", "存在", "找到", "完成", "成功", "已确认", "已进入", "已打开")
|
|
232
|
-
failed_keywords = ("未找到", "不存在", "无法找到", "无法到达", "没有", "失败", "未到达")
|
|
233
|
-
first_line = msg.split('\n')[0]
|
|
234
|
-
if any(kw in first_line for kw in failed_keywords):
|
|
235
|
-
return False
|
|
236
|
-
if any(kw in first_line for kw in reached_keywords):
|
|
237
|
-
return True
|
|
238
|
-
return False
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
# ---------------------------------------------------------------------------
|
|
242
|
-
# phone-agent runtime patches (idempotent)
|
|
243
|
-
# ---------------------------------------------------------------------------
|
|
244
|
-
|
|
245
|
-
def _apply_phone_agent_patches():
|
|
246
|
-
"""Monkey-patch phone_agent bugs so the skill works on an unpatched install."""
|
|
247
|
-
if getattr(_apply_phone_agent_patches, '_done', False):
|
|
248
|
-
return
|
|
249
|
-
_apply_phone_agent_patches._done = True
|
|
250
|
-
|
|
251
|
-
import math
|
|
252
|
-
import time as _time
|
|
253
|
-
|
|
254
|
-
# Patch 1: HarmonyOS swipe — last arg should be velocity (pps), not duration (ms)
|
|
255
|
-
import phone_agent.hdc.device as _hdc
|
|
256
|
-
if not getattr(_hdc.swipe, '_patched', False):
|
|
257
|
-
def _swipe(start_x, start_y, end_x, end_y,
|
|
258
|
-
duration_ms=None, device_id=None, delay=None):
|
|
259
|
-
if delay is None:
|
|
260
|
-
delay = _hdc.TIMING_CONFIG.device.default_swipe_delay
|
|
261
|
-
hdc_prefix = _hdc._get_hdc_prefix(device_id)
|
|
262
|
-
distance = math.sqrt((start_x - end_x) ** 2 + (start_y - end_y) ** 2)
|
|
263
|
-
if duration_ms is None:
|
|
264
|
-
duration_ms = int(distance ** 2 / 1000)
|
|
265
|
-
duration_ms = max(500, min(duration_ms, 1000))
|
|
266
|
-
velocity = int((distance / duration_ms) * 4000)
|
|
267
|
-
velocity = max(500, min(velocity, 40000))
|
|
268
|
-
_hdc._run_hdc_command(
|
|
269
|
-
hdc_prefix + [
|
|
270
|
-
"shell", "uitest", "uiInput", "swipe",
|
|
271
|
-
str(start_x), str(start_y), str(end_x), str(end_y),
|
|
272
|
-
str(velocity),
|
|
273
|
-
],
|
|
274
|
-
capture_output=True,
|
|
275
|
-
)
|
|
276
|
-
_time.sleep(delay)
|
|
277
|
-
_swipe._patched = True
|
|
278
|
-
_hdc.swipe = _swipe
|
|
279
|
-
|
|
280
|
-
# Patch 2: _parse_response — strip <think>/<answer> tags before splitting by do()/finish()
|
|
281
|
-
import phone_agent.model.client as _client
|
|
282
|
-
if not getattr(_client.ModelClient._parse_response, '_patched', False):
|
|
283
|
-
_orig_parse_response = _client.ModelClient._parse_response
|
|
284
|
-
|
|
285
|
-
def _patched_parse_response(self, content: str):
|
|
286
|
-
# Strip <think>...</think> and <answer>...</answer> wrappers first
|
|
287
|
-
cleaned = re.sub(r'<think>.*?</think>\s*', '', content, flags=re.DOTALL)
|
|
288
|
-
m = re.search(r'<answer>\s*(.*?)\s*</answer>', cleaned, re.DOTALL)
|
|
289
|
-
if m:
|
|
290
|
-
cleaned = m.group(1)
|
|
291
|
-
# Also strip trailing </answer> if only opening was consumed by rule 2
|
|
292
|
-
cleaned = cleaned.replace('</answer>', '').strip()
|
|
293
|
-
if cleaned:
|
|
294
|
-
return _orig_parse_response(self, cleaned)
|
|
295
|
-
return _orig_parse_response(self, content)
|
|
296
|
-
|
|
297
|
-
_patched_parse_response._patched = True
|
|
298
|
-
_client.ModelClient._parse_response = _patched_parse_response
|
|
299
|
-
|
|
300
|
-
# Patch 3: parse_action — strip thinking tags + regex fallback for malformed do()
|
|
301
|
-
import phone_agent.actions.handler as _handler
|
|
302
|
-
if not getattr(_handler.parse_action, '_patched', False):
|
|
303
|
-
_orig_parse = _handler.parse_action
|
|
304
|
-
_THINK_RE = re.compile(r'<think>.*?</think>\s*', re.DOTALL)
|
|
305
|
-
_ANSWER_RE = re.compile(r'<answer>\s*(.*?)\s*</answer>', re.DOTALL)
|
|
306
|
-
|
|
307
|
-
def _strip_llm_tags(text: str) -> str:
|
|
308
|
-
text = _THINK_RE.sub('', text)
|
|
309
|
-
m = _ANSWER_RE.search(text)
|
|
310
|
-
if m:
|
|
311
|
-
text = m.group(1)
|
|
312
|
-
return text.strip()
|
|
313
|
-
|
|
314
|
-
def _parse_action(response):
|
|
315
|
-
cleaned = _strip_llm_tags(response)
|
|
316
|
-
try:
|
|
317
|
-
return _orig_parse(cleaned)
|
|
318
|
-
except ValueError:
|
|
319
|
-
pass
|
|
320
|
-
# regex fallback for do() with unescaped quotes
|
|
321
|
-
for text in (cleaned, response.strip()):
|
|
322
|
-
m = re.search(
|
|
323
|
-
r'do\s*\(\s*action\s*=\s*"([^"]*)"\s*,\s*message\s*="(.*)"\s*\)\s*$',
|
|
324
|
-
text, re.DOTALL,
|
|
325
|
-
)
|
|
326
|
-
if m:
|
|
327
|
-
msg = m.group(2)
|
|
328
|
-
msg = msg.replace("\\n", "\x0a").replace("\\t", "\x09").replace("\\r", "\x0d")
|
|
329
|
-
msg = msg.replace('\\"', '"')
|
|
330
|
-
return {"_metadata": "do", "action": m.group(1), "message": msg}
|
|
331
|
-
# fallback: extract bare do() from anywhere in the text
|
|
332
|
-
m = re.search(r'do\s*\(\s*action\s*=\s*"([^"]*)".*?\)', cleaned)
|
|
333
|
-
if m:
|
|
334
|
-
return _orig_parse(m.group(0))
|
|
335
|
-
return _orig_parse(response)
|
|
336
|
-
_parse_action._patched = True
|
|
337
|
-
_handler.parse_action = _parse_action
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
# ---------------------------------------------------------------------------
|
|
341
|
-
# 核心导航逻辑
|
|
342
|
-
# ---------------------------------------------------------------------------
|
|
343
|
-
|
|
344
|
-
def navigate(
|
|
345
|
-
model_config,
|
|
346
|
-
app_name: str,
|
|
347
|
-
package: str,
|
|
348
|
-
device_type: str = "hdc",
|
|
349
|
-
prompt: str | None = None,
|
|
350
|
-
single_task: str | None = None,
|
|
351
|
-
feature_file: str | Path = "",
|
|
352
|
-
sheet_name: int = 0,
|
|
353
|
-
offset: int = 1,
|
|
354
|
-
limit: int | None = None,
|
|
355
|
-
max_steps: int = 30,
|
|
356
|
-
verbose: bool = True,
|
|
357
|
-
app_hints: str | None = None,
|
|
358
|
-
) -> None:
|
|
359
|
-
"""按指定路径操作设备导航到目标页面,输出是否到达。"""
|
|
360
|
-
_apply_phone_agent_patches()
|
|
361
|
-
register_app(app_name, package, device_type)
|
|
362
|
-
|
|
363
|
-
from phone_agent import PhoneAgent
|
|
364
|
-
from phone_agent.agent import AgentConfig
|
|
365
|
-
from phone_agent.device_factory import set_device_type, DeviceType
|
|
366
|
-
|
|
367
|
-
agent_config = AgentConfig(max_steps=max_steps, verbose=verbose)
|
|
368
|
-
set_device_type(DeviceType.HDC if device_type == "hdc" else DeviceType.ADB)
|
|
369
|
-
agent = PhoneAgent(model_config=model_config, agent_config=agent_config)
|
|
370
|
-
|
|
371
|
-
# 收集要导航的目标列表: [(prompt_text, display_label), ...]
|
|
372
|
-
tasks: list[tuple[str, str]] = []
|
|
373
|
-
|
|
374
|
-
if prompt:
|
|
375
|
-
full_prompt = f"打开{app_name},{prompt}"
|
|
376
|
-
tasks.append((full_prompt, prompt))
|
|
377
|
-
elif single_task:
|
|
378
|
-
level_parts = re.split(r'(L[123])', single_task)
|
|
379
|
-
item = {}
|
|
380
|
-
for j in range(1, len(level_parts) - 1, 2):
|
|
381
|
-
key = level_parts[j]
|
|
382
|
-
val = level_parts[j + 1].strip()
|
|
383
|
-
if val:
|
|
384
|
-
item[key] = val
|
|
385
|
-
path_str, leaf = _get_feature_path(item)
|
|
386
|
-
if path_str:
|
|
387
|
-
tasks.append((_build_navigate_prompt(app_name, path_str, leaf, app_hints), path_str))
|
|
388
|
-
else:
|
|
389
|
-
feature_path = Path(feature_file)
|
|
390
|
-
if feature_path.suffix.lower() == ".md":
|
|
391
|
-
features = parse_app_feature_md(file_path=feature_file)
|
|
392
|
-
else:
|
|
393
|
-
features = parse_app_feature(file_path=feature_file, sheet_name=sheet_name)
|
|
394
|
-
if offset > 1:
|
|
395
|
-
features = features[offset - 1:]
|
|
396
|
-
if limit is not None:
|
|
397
|
-
features = features[:limit]
|
|
398
|
-
for item in features:
|
|
399
|
-
path_str, leaf = _get_feature_path(item)
|
|
400
|
-
if path_str:
|
|
401
|
-
tasks.append((_build_navigate_prompt(app_name, path_str, leaf, app_hints), path_str))
|
|
402
|
-
|
|
403
|
-
for i, (task_prompt, label) in enumerate(tasks):
|
|
404
|
-
if len(tasks) > 1:
|
|
405
|
-
print(f"\n[{i + 1}/{len(tasks)}] 导航: {label}")
|
|
406
|
-
else:
|
|
407
|
-
print(f"导航: {label}")
|
|
408
|
-
|
|
409
|
-
try:
|
|
410
|
-
result_msg = agent.run(task_prompt)
|
|
411
|
-
reached = _judge_reached(result_msg)
|
|
412
|
-
except Exception:
|
|
413
|
-
reached = False
|
|
414
|
-
|
|
415
|
-
if reached:
|
|
416
|
-
print("到达目标页面")
|
|
417
|
-
else:
|
|
418
|
-
print("未找到目标页面")
|
|
419
|
-
|
|
420
|
-
if i < len(tasks) - 1:
|
|
421
|
-
agent.reset()
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
# ---------------------------------------------------------------------------
|
|
425
|
-
# 模型配置加载:UI 对齐与自测共用同一个多模态模型。
|
|
426
|
-
# 优先级:CLI --api-key > HOMETRANS_MODEL_* 环境变量 > ~/.hometrans/config.json
|
|
427
|
-
# 的 autotest.unified_model(由 `ht init` 写入,两端共用)> 老版本 GLM_API_KEY(兼容)。
|
|
428
|
-
# ---------------------------------------------------------------------------
|
|
429
|
-
|
|
430
|
-
def _load_model_config(cli_api_key: str = ""):
|
|
431
|
-
"""加载统一多模态模型配置(UI 对齐 + 自测共用)。
|
|
432
|
-
|
|
433
|
-
`ht init` 把模型四要素(api_key / name / base_url / provider)写入
|
|
434
|
-
`autotest.unified_model`,并导出为 HOMETRANS_MODEL_* 环境变量。这里优先读
|
|
435
|
-
环境变量,缺字段时回落到 config.json,单个字段可被 CLI/环境变量覆盖;
|
|
436
|
-
都没有时再兼容老版本的 GLM_API_KEY(走智谱 GLM 端点)。
|
|
437
|
-
"""
|
|
438
|
-
from phone_agent.model import ModelConfig
|
|
439
|
-
|
|
440
|
-
# 1) 环境变量(ht init 导出)+ CLI 覆盖
|
|
441
|
-
api_key = (cli_api_key or os.environ.get("HOMETRANS_MODEL_API_KEY", "")).strip()
|
|
442
|
-
base_url = os.environ.get("HOMETRANS_MODEL_BASE_URL", "").strip()
|
|
443
|
-
model_name = os.environ.get("HOMETRANS_MODEL_NAME", "").strip()
|
|
444
|
-
temperature = 0.1
|
|
445
|
-
|
|
446
|
-
# 2) 回落 ~/.hometrans/config.json 的 autotest.unified_model(补齐缺失字段)
|
|
447
|
-
config_path = Path.home() / ".hometrans" / "config.json"
|
|
448
|
-
if config_path.exists():
|
|
449
|
-
try:
|
|
450
|
-
cfg = json.loads(config_path.read_text(encoding="utf-8"))
|
|
451
|
-
um = cfg.get("autotest", {}).get("unified_model", {})
|
|
452
|
-
api_key = api_key or str(um.get("api_key", "")).strip()
|
|
453
|
-
base_url = base_url or str(um.get("base_url", "")).strip()
|
|
454
|
-
model_name = model_name or str(um.get("name", "")).strip()
|
|
455
|
-
if um.get("temperature") is not None:
|
|
456
|
-
temperature = um.get("temperature")
|
|
457
|
-
except (json.JSONDecodeError, KeyError):
|
|
458
|
-
pass
|
|
459
|
-
|
|
460
|
-
if api_key:
|
|
461
|
-
return ModelConfig(
|
|
462
|
-
base_url=base_url or "http://localhost:8000/v1",
|
|
463
|
-
api_key=api_key,
|
|
464
|
-
model_name=model_name,
|
|
465
|
-
temperature=temperature,
|
|
466
|
-
)
|
|
467
|
-
|
|
468
|
-
# 3) 向后兼容老版本:仅设置了 GLM_API_KEY 时,回落到智谱 GLM 端点。
|
|
469
|
-
glm_key = os.environ.get("GLM_API_KEY", "").strip()
|
|
470
|
-
if glm_key:
|
|
471
|
-
return ModelConfig(
|
|
472
|
-
base_url="https://open.bigmodel.cn/api/paas/v4",
|
|
473
|
-
api_key=glm_key,
|
|
474
|
-
model_name="autoglm-phone",
|
|
475
|
-
temperature=0.1,
|
|
476
|
-
)
|
|
477
|
-
|
|
478
|
-
return ModelConfig(temperature=temperature)
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
# ---------------------------------------------------------------------------
|
|
482
|
-
# CLI 入口
|
|
483
|
-
# ---------------------------------------------------------------------------
|
|
484
|
-
|
|
485
|
-
def main():
|
|
486
|
-
parser = argparse.ArgumentParser(
|
|
487
|
-
description="按指定路径操作设备导航到目标页面(支持 Android / HarmonyOS)"
|
|
488
|
-
)
|
|
489
|
-
parser.add_argument("--device", choices=["hdc", "adb"], default="hdc",
|
|
490
|
-
help="设备类型: hdc=HarmonyOS, adb=Android(默认 hdc)")
|
|
491
|
-
parser.add_argument("--app", type=str, required=True, help="应用名称")
|
|
492
|
-
parser.add_argument("--package", type=str, required=True, help="应用包名")
|
|
493
|
-
parser.add_argument("--task", type=str, default=None,
|
|
494
|
-
help="功能路径,格式: 'L1xxxL2xxxL3xxx'")
|
|
495
|
-
parser.add_argument("--prompt", type=str, default=None,
|
|
496
|
-
help="直接注入给 Agent 的自然语言导航指令")
|
|
497
|
-
parser.add_argument("--feature", type=str, default=None,
|
|
498
|
-
help="功能清单文件路径(.xlsx / .md)")
|
|
499
|
-
parser.add_argument("--limit", type=int, default=None, help="仅导航前 N 条")
|
|
500
|
-
parser.add_argument("--offset", type=int, default=1, help="从第几条开始(1-based)")
|
|
501
|
-
parser.add_argument("--sheet", type=int, default=0, help="Excel 工作表索引")
|
|
502
|
-
parser.add_argument("--api-key", type=str, default="", help="API Key(可选,不传则读取 HOMETRANS_MODEL_* 环境变量 / ~/.hometrans/config.json)")
|
|
503
|
-
parser.add_argument("--max-steps", type=int, default=30, help="Agent 最大步数")
|
|
504
|
-
parser.add_argument("--app-hints", type=str, default=None, help="应用上下文提示")
|
|
505
|
-
parser.add_argument("-q", "--quiet", action="store_true", help="减少输出")
|
|
506
|
-
args = parser.parse_args()
|
|
507
|
-
|
|
508
|
-
if not args.prompt and not args.task and not args.feature:
|
|
509
|
-
parser.error("必须指定 --feature、--task 或 --prompt 之一")
|
|
510
|
-
|
|
511
|
-
from phone_agent.model import ModelConfig
|
|
512
|
-
|
|
513
|
-
model_config = _load_model_config(args.api_key)
|
|
514
|
-
if not model_config.api_key or model_config.api_key == "EMPTY":
|
|
515
|
-
if not args.quiet:
|
|
516
|
-
print("提示: 未找到可用的模型配置。请运行 `ht init` 配置统一模型(UI 对齐 + 自测共用),")
|
|
517
|
-
print("它会写入 ~/.hometrans/config.json 的 autotest.unified_model 并导出 HOMETRANS_MODEL_* 环境变量;")
|
|
518
|
-
print("或通过 --api-key 传入 API Key。\n")
|
|
519
|
-
|
|
520
|
-
device_label = "ADB (Android)" if args.device == "adb" else "HDC (HarmonyOS)"
|
|
521
|
-
print(f"设备: {device_label}, 应用: {args.app} ({args.package})")
|
|
522
|
-
print("-" * 50)
|
|
523
|
-
|
|
524
|
-
navigate(
|
|
525
|
-
model_config=model_config,
|
|
526
|
-
app_name=args.app,
|
|
527
|
-
package=args.package,
|
|
528
|
-
device_type=args.device,
|
|
529
|
-
prompt=args.prompt,
|
|
530
|
-
single_task=args.task,
|
|
531
|
-
feature_file=args.feature or "",
|
|
532
|
-
sheet_name=args.sheet,
|
|
533
|
-
offset=args.offset,
|
|
534
|
-
limit=args.limit,
|
|
535
|
-
max_steps=args.max_steps,
|
|
536
|
-
verbose=not args.quiet,
|
|
537
|
-
app_hints=args.app_hints,
|
|
538
|
-
)
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
if __name__ == "__main__":
|
|
542
|
-
sys.exit(main())
|