@buaa_smat/hometrans 0.1.16 → 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 +162 -54
- 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 +127 -144
- package/dist/cli/uninstall.js +76 -110
- 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 -41
- 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.bat +0 -85
- 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
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { clearArtifacts, exists, runProcess } from "../core/process_adapter.mjs";
|
|
4
|
+
import { collectEtsFiles } from "../core/project_catalog.mjs";
|
|
5
|
+
import { candidateRoots, findJson5Parser as harmonyJson5Parser, readStructuredConfig as readConfig } from "../core/sdk_context.mjs";
|
|
6
|
+
const toolCache = new Map();
|
|
7
|
+
const hmsSdkCache = new Map();
|
|
8
|
+
const systemResourceCache = new Map();
|
|
9
|
+
const CHECKER_SCRIPT = String.raw`
|
|
10
|
+
'use strict';
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
function parseArgs(argv) {
|
|
14
|
+
const args = { project: '', moduleRoot: '', moduleJson: '', etsLoader: '', output: '', cacheDir: '', apiType: 'stageMode', compatibleSdkVersion: 12, permissions: [], hmsSdkEts: '', sysResourceFile: '', files: [] };
|
|
15
|
+
let i = 2;
|
|
16
|
+
while (i < argv.length) {
|
|
17
|
+
if (argv[i] === '--project' && argv[i + 1]) args.project = path.resolve(argv[++i]);
|
|
18
|
+
else if (argv[i] === '--module-root' && argv[i + 1]) args.moduleRoot = path.resolve(argv[++i]);
|
|
19
|
+
else if (argv[i] === '--module-json' && argv[i + 1]) args.moduleJson = path.resolve(argv[++i]);
|
|
20
|
+
else if (argv[i] === '--ets-loader' && argv[i + 1]) args.etsLoader = path.resolve(argv[++i]);
|
|
21
|
+
else if (argv[i] === '--output' && argv[i + 1]) args.output = path.resolve(argv[++i]);
|
|
22
|
+
else if (argv[i] === '--cache-dir' && argv[i + 1]) args.cacheDir = path.resolve(argv[++i]);
|
|
23
|
+
else if (argv[i] === '--api-type' && argv[i + 1]) args.apiType = argv[++i];
|
|
24
|
+
else if (argv[i] === '--compatible-sdk-version' && argv[i + 1]) args.compatibleSdkVersion = Number.parseInt(argv[++i], 10);
|
|
25
|
+
else if (argv[i] === '--permission' && argv[i + 1]) args.permissions.push(argv[++i]);
|
|
26
|
+
else if (argv[i] === '--hms-sdk-ets' && argv[i + 1]) args.hmsSdkEts = path.resolve(argv[++i]);
|
|
27
|
+
else if (argv[i] === '--sys-resource-file' && argv[i + 1]) args.sysResourceFile = path.resolve(argv[++i]);
|
|
28
|
+
else if (argv[i] === '--files') {
|
|
29
|
+
i++;
|
|
30
|
+
while (i < argv.length && !argv[i].startsWith('--')) args.files.push(argv[i++]);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
return args;
|
|
36
|
+
}
|
|
37
|
+
function parseDiagnosticLine(line) {
|
|
38
|
+
const match = line.match(/ArkTS:(ERROR|WARN)\s+File:\s+(.+?):(\d+):(\d+)/);
|
|
39
|
+
if (!match) return null;
|
|
40
|
+
return { severity: match[1].toLowerCase() === 'error' ? 'error' : 'warning', file: match[2], line: Number.parseInt(match[3], 10), column: Number.parseInt(match[4], 10) };
|
|
41
|
+
}
|
|
42
|
+
function parseMessageLine(line) {
|
|
43
|
+
const trimmed = line.trim();
|
|
44
|
+
const match = trimmed.match(/^(.+?)\s*\(([@a-z][\w./-]*)\)\s*$/i);
|
|
45
|
+
if (!match) return { message: trimmed, rule: '' };
|
|
46
|
+
return { message: match[1].trim(), rule: match[2] };
|
|
47
|
+
}
|
|
48
|
+
function loadSystemResourceNames(resourceFile) {
|
|
49
|
+
if (!resourceFile || !fs.existsSync(resourceFile)) return null;
|
|
50
|
+
const names = new Set();
|
|
51
|
+
const content = fs.readFileSync(resourceFile, 'utf-8');
|
|
52
|
+
const linePattern = /^id:\d+,\s*'[^']*'\s+'([^']+)'/;
|
|
53
|
+
for (const line of content.split('\n')) {
|
|
54
|
+
const match = line.match(linePattern);
|
|
55
|
+
if (match) names.add(match[1]);
|
|
56
|
+
}
|
|
57
|
+
return names;
|
|
58
|
+
}
|
|
59
|
+
function validateSystemResources(files, resourceFile, project) {
|
|
60
|
+
const validNames = loadSystemResourceNames(resourceFile);
|
|
61
|
+
if (!validNames) return [];
|
|
62
|
+
const diagnostics = [];
|
|
63
|
+
const refPattern = /\$r\(\s*['"]sys\.(media|symbol)\.([^'"]+)['"]\s*\)/g;
|
|
64
|
+
for (const filePath of files) {
|
|
65
|
+
if (!fs.existsSync(filePath)) continue;
|
|
66
|
+
const lines = fs.readFileSync(filePath, 'utf-8').split('\n');
|
|
67
|
+
for (let i = 0; i < lines.length; i++) {
|
|
68
|
+
refPattern.lastIndex = 0;
|
|
69
|
+
let match;
|
|
70
|
+
while ((match = refPattern.exec(lines[i])) !== null) {
|
|
71
|
+
const name = match[2];
|
|
72
|
+
if (!validNames.has(name)) diagnostics.push({ file: path.relative(project, filePath), line: i + 1, column: match.index + 1, severity: 'error', message: "Unknown system resource '" + name + "' for sys." + match[1], rule: 'resource-name-check' });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return diagnostics;
|
|
77
|
+
}
|
|
78
|
+
function main() {
|
|
79
|
+
const args = parseArgs(process.argv);
|
|
80
|
+
const captured = [];
|
|
81
|
+
const capture = (...items) => { captured.push(items.map(String).join(' ')); };
|
|
82
|
+
const origLog = console.log;
|
|
83
|
+
const origError = console.error;
|
|
84
|
+
const origWarn = console.warn;
|
|
85
|
+
try {
|
|
86
|
+
if (args.hmsSdkEts && fs.existsSync(args.hmsSdkEts)) {
|
|
87
|
+
const existing = process.env.externalApiPaths || '';
|
|
88
|
+
process.env.externalApiPaths = existing ? existing + path.delimiter + args.hmsSdkEts : args.hmsSdkEts;
|
|
89
|
+
}
|
|
90
|
+
const etsChecker = require(path.join(args.etsLoader, 'lib', 'ets_checker.js'));
|
|
91
|
+
const mainModule = require(path.join(args.etsLoader, 'main.js'));
|
|
92
|
+
Object.assign(mainModule.partialUpdateConfig, { executeArkTSLinter: true, standardArkTSLinter: true });
|
|
93
|
+
const fileMap = {};
|
|
94
|
+
args.files.forEach((file, index) => { fileMap["file_" + index] = path.isAbsolute(file) ? file : path.resolve(args.project, file); });
|
|
95
|
+
const projectConfig = {
|
|
96
|
+
projectPath: args.project,
|
|
97
|
+
projectRootPath: args.project,
|
|
98
|
+
modulePath: args.moduleRoot,
|
|
99
|
+
moduleRootPath: args.moduleRoot,
|
|
100
|
+
cachePath: args.cacheDir || path.join(args.project, '.cache', 'arkts-check'),
|
|
101
|
+
aceModuleJsonPath: args.moduleJson,
|
|
102
|
+
compileMode: 'esmodule',
|
|
103
|
+
etsLoaderPath: args.etsLoader,
|
|
104
|
+
packageManagerType: 'ohpm',
|
|
105
|
+
packageDir: 'oh_modules',
|
|
106
|
+
runtimeOS: 'OpenHarmony',
|
|
107
|
+
sdkInfo: '5.0.0',
|
|
108
|
+
compatibleSdkVersion: Number.isFinite(args.compatibleSdkVersion) ? args.compatibleSdkVersion : 12,
|
|
109
|
+
compatibleSdkVersionStage: Number.isFinite(args.compatibleSdkVersion) ? args.compatibleSdkVersion : 12,
|
|
110
|
+
apiType: args.apiType,
|
|
111
|
+
permissions: args.permissions,
|
|
112
|
+
bundleType: '',
|
|
113
|
+
compilerTypes: [],
|
|
114
|
+
resolveModulePaths: [],
|
|
115
|
+
};
|
|
116
|
+
fs.mkdirSync(projectConfig.cachePath, { recursive: true });
|
|
117
|
+
if (args.apiType === 'stageMode') {
|
|
118
|
+
process.env.compileMode = 'moduleJson';
|
|
119
|
+
process.env.aceModuleJsonPath = projectConfig.aceModuleJsonPath;
|
|
120
|
+
}
|
|
121
|
+
console.log = capture; console.error = capture; console.warn = capture;
|
|
122
|
+
const logger = { debug: capture, info: capture, warn: capture, error: capture };
|
|
123
|
+
etsChecker.etsStandaloneChecker(fileMap, logger, projectConfig);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
captured.push("Internal error: " + (error && error.message ? error.message : String(error)));
|
|
126
|
+
} finally {
|
|
127
|
+
console.log = origLog; console.error = origError; console.warn = origWarn;
|
|
128
|
+
}
|
|
129
|
+
const diagnostics = [];
|
|
130
|
+
let current = null;
|
|
131
|
+
const lines = captured.flatMap((entry) => entry.split('\n'));
|
|
132
|
+
for (const raw of lines) {
|
|
133
|
+
const line = raw.replace(/\x1b\[[0-9;]*m/g, '');
|
|
134
|
+
const loc = parseDiagnosticLine(line);
|
|
135
|
+
if (loc) { current = loc; continue; }
|
|
136
|
+
if (current && line.trim() && !line.includes('ArkTS:') && !line.includes('For details about')) {
|
|
137
|
+
const message = parseMessageLine(line);
|
|
138
|
+
diagnostics.push({ file: path.relative(args.project, current.file), line: current.line, column: current.column, severity: current.severity, message: message.message, rule: message.rule });
|
|
139
|
+
current = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const selectedFiles = args.files.map((file) => path.isAbsolute(file) ? file : path.resolve(args.project, file));
|
|
143
|
+
diagnostics.push(...validateSystemResources(selectedFiles, args.sysResourceFile, args.project));
|
|
144
|
+
const errorCount = diagnostics.filter((item) => item.severity === 'error').length;
|
|
145
|
+
const warnCount = diagnostics.filter((item) => item.severity === 'warning').length;
|
|
146
|
+
const payload = { tool_status: captured.some((line) => line.startsWith('Internal error:')) ? 'internal_error' : 'ok', success: errorCount === 0, errors: diagnostics, summary: { errorCount, warnCount }, raw_tail: captured.slice(-20) };
|
|
147
|
+
const rendered = JSON.stringify(payload, null, 2);
|
|
148
|
+
if (args.output) fs.writeFileSync(args.output, rendered + '\n');
|
|
149
|
+
process.stdout.write('\n__ARKTS_PRECHECK_JSON_START__\n');
|
|
150
|
+
process.stdout.write(rendered);
|
|
151
|
+
process.stdout.write('\n__ARKTS_PRECHECK_JSON_END__\n');
|
|
152
|
+
process.exitCode = errorCount > 0 ? 1 : 0;
|
|
153
|
+
}
|
|
154
|
+
main();
|
|
155
|
+
`;
|
|
156
|
+
async function findArktsTool(commandlineTools) {
|
|
157
|
+
if (!commandlineTools) return { etsLoader: null };
|
|
158
|
+
const key = path.resolve(commandlineTools);
|
|
159
|
+
if (toolCache.has(key)) return toolCache.get(key);
|
|
160
|
+
const candidates = [];
|
|
161
|
+
for (const root of candidateRoots(commandlineTools)) {
|
|
162
|
+
candidates.push(
|
|
163
|
+
path.join(root, "sdk", "default", "openharmony", "ets", "build-tools", "ets-loader"),
|
|
164
|
+
path.join(root, "sdk", "openharmony", "ets", "build-tools", "ets-loader"),
|
|
165
|
+
path.join(root, "default", "openharmony", "ets", "build-tools", "ets-loader"),
|
|
166
|
+
path.join(root, "openharmony", "ets", "build-tools", "ets-loader")
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
for (const candidate of candidates) {
|
|
170
|
+
if (await exists(path.join(candidate, "lib", "ets_checker.js")) && await exists(path.join(candidate, "main.js"))) {
|
|
171
|
+
const result = { etsLoader: candidate };
|
|
172
|
+
toolCache.set(key, result);
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const result = { etsLoader: null };
|
|
177
|
+
toolCache.set(key, result);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
async function findHmsSdkEts(commandlineTools) {
|
|
181
|
+
if (!commandlineTools) return null;
|
|
182
|
+
const key = path.resolve(commandlineTools);
|
|
183
|
+
if (hmsSdkCache.has(key)) return hmsSdkCache.get(key);
|
|
184
|
+
const candidates = [];
|
|
185
|
+
for (const root of candidateRoots(commandlineTools)) {
|
|
186
|
+
candidates.push(
|
|
187
|
+
path.join(root, "sdk", "default", "hms", "ets"),
|
|
188
|
+
path.join(root, "sdk", "hms", "ets"),
|
|
189
|
+
path.join(root, "default", "hms", "ets"),
|
|
190
|
+
path.join(root, "hms", "ets")
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
for (const candidate of candidates) {
|
|
194
|
+
if (await exists(candidate)) {
|
|
195
|
+
hmsSdkCache.set(key, candidate);
|
|
196
|
+
return candidate;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
hmsSdkCache.set(key, null);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
async function findSystemResourceFile(commandlineTools) {
|
|
203
|
+
if (!commandlineTools) return null;
|
|
204
|
+
const key = path.resolve(commandlineTools);
|
|
205
|
+
if (systemResourceCache.has(key)) return systemResourceCache.get(key);
|
|
206
|
+
const candidates = [];
|
|
207
|
+
for (const root of candidateRoots(commandlineTools)) {
|
|
208
|
+
candidates.push(
|
|
209
|
+
path.join(root, "sdk", "default", "openharmony", "previewer", "common", "resources", "entry", "resources.txt"),
|
|
210
|
+
path.join(root, "sdk", "openharmony", "previewer", "common", "resources", "entry", "resources.txt"),
|
|
211
|
+
path.join(root, "default", "openharmony", "previewer", "common", "resources", "entry", "resources.txt"),
|
|
212
|
+
path.join(root, "openharmony", "previewer", "common", "resources", "entry", "resources.txt")
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
for (const candidate of candidates) {
|
|
216
|
+
if (await exists(candidate)) {
|
|
217
|
+
systemResourceCache.set(key, candidate);
|
|
218
|
+
return candidate;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
systemResourceCache.set(key, null);
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
function findFirstKey(value, key) {
|
|
225
|
+
if (!value || typeof value !== "object") return null;
|
|
226
|
+
if (Object.hasOwn(value, key)) return value[key];
|
|
227
|
+
for (const child of Object.values(value)) {
|
|
228
|
+
const found = findFirstKey(child, key);
|
|
229
|
+
if (found !== null) return found;
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
function parseApiLevel(value) {
|
|
234
|
+
if (!value) return null;
|
|
235
|
+
const paren = /\((\d+)\)/.exec(value);
|
|
236
|
+
if (paren) return Number.parseInt(paren[1], 10);
|
|
237
|
+
const plain = /\b(\d+)\b/.exec(value);
|
|
238
|
+
return plain ? Number.parseInt(plain[1], 10) : null;
|
|
239
|
+
}
|
|
240
|
+
async function moduleCheckerConfig(projectRoot, moduleRoot, moduleJsonPath, commandlineTools) {
|
|
241
|
+
const parseJson5 = harmonyJson5Parser(commandlineTools);
|
|
242
|
+
const rootProfile = await readConfig(path.join(projectRoot, "build-profile.json5"), parseJson5);
|
|
243
|
+
const moduleProfile = await readConfig(path.join(moduleRoot, "build-profile.json5"), parseJson5);
|
|
244
|
+
const manifest = await readConfig(moduleJsonPath, parseJson5);
|
|
245
|
+
const compatible = parseApiLevel(String(findFirstKey(rootProfile, "compatibleSdkVersion") ?? "")) ?? 12;
|
|
246
|
+
const apiType = String(findFirstKey(moduleProfile, "apiType") ?? "stageMode");
|
|
247
|
+
const permissions = [...new Set((Array.isArray(manifest.module?.requestPermissions) ? manifest.module.requestPermissions : [])
|
|
248
|
+
.map((item) => item?.name)
|
|
249
|
+
.filter((name) => typeof name === "string" && name.startsWith("ohos.permission.")))].sort();
|
|
250
|
+
return { compatibleSdkVersion: compatible, apiType, permissions };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async function groupFilesByModule(projectRoot, files) {
|
|
254
|
+
const groups = new Map();
|
|
255
|
+
const unowned = [];
|
|
256
|
+
for (const file of files) {
|
|
257
|
+
let current = path.dirname(file);
|
|
258
|
+
let context = null;
|
|
259
|
+
while (current.startsWith(projectRoot + path.sep)) {
|
|
260
|
+
if (path.basename(current) === "ets" && path.basename(path.dirname(current)) === "main" && path.basename(path.dirname(path.dirname(current))) === "src") {
|
|
261
|
+
const moduleRoot = path.dirname(path.dirname(path.dirname(current)));
|
|
262
|
+
const moduleJsonPath = path.join(path.dirname(current), "module.json5");
|
|
263
|
+
if (await exists(moduleJsonPath)) context = { moduleRoot, moduleJsonPath };
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
current = path.dirname(current);
|
|
267
|
+
}
|
|
268
|
+
if (!context) {
|
|
269
|
+
unowned.push(path.relative(projectRoot, file).replace(/\\/g, "/"));
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const key = path.relative(projectRoot, context.moduleRoot).replace(/\\/g, "/") || ".";
|
|
273
|
+
const group = groups.get(key) ?? { key, ...context, files: [] };
|
|
274
|
+
group.files.push(file);
|
|
275
|
+
groups.set(key, group);
|
|
276
|
+
}
|
|
277
|
+
return { groups: [...groups.values()].sort((a, b) => a.key.localeCompare(b.key)), unowned };
|
|
278
|
+
}
|
|
279
|
+
function validateCheckerPayload(payload) {
|
|
280
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
281
|
+
return "checker emitted a non-object JSON payload";
|
|
282
|
+
}
|
|
283
|
+
if (!Array.isArray(payload.errors)) {
|
|
284
|
+
return "checker emitted a malformed errors payload";
|
|
285
|
+
}
|
|
286
|
+
for (const item of Array.isArray(payload.errors) ? payload.errors : []) {
|
|
287
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
288
|
+
return "checker emitted a malformed errors payload";
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
async function filterOfficialDiagnostics({ projectRoot, apiType, diagnostics }) {
|
|
294
|
+
const errors = [];
|
|
295
|
+
const suppressedDiagnostics = [];
|
|
296
|
+
const stateFields = new Map();
|
|
297
|
+
const decorators = "State|Link|Prop|ObjectLink|Local|Param|Provide|Consume|StorageLink|StorageProp|LocalStorageLink|LocalStorageProp";
|
|
298
|
+
const fieldPattern = new RegExp(`@(?:${decorators})(?:\\([^)]*\\))?\\s+([A-Za-z_$][\\w$]*)`, "g");
|
|
299
|
+
const fieldsFor = async (file) => {
|
|
300
|
+
if (stateFields.has(file)) return stateFields.get(file);
|
|
301
|
+
const fields = new Set();
|
|
302
|
+
try {
|
|
303
|
+
const content = await readFile(file, "utf8");
|
|
304
|
+
fieldPattern.lastIndex = 0;
|
|
305
|
+
let match;
|
|
306
|
+
while ((match = fieldPattern.exec(content)) !== null) fields.add(match[1]);
|
|
307
|
+
} catch {}
|
|
308
|
+
stateFields.set(file, fields);
|
|
309
|
+
return fields;
|
|
310
|
+
};
|
|
311
|
+
for (const diagnostic of Array.isArray(diagnostics) ? diagnostics : []) {
|
|
312
|
+
const rawFile = String(diagnostic.file ?? "");
|
|
313
|
+
const absolute = path.isAbsolute(rawFile) ? path.normalize(rawFile) : path.resolve(projectRoot, rawFile);
|
|
314
|
+
const relative = path.relative(projectRoot, absolute);
|
|
315
|
+
let suppressionRule = relative.startsWith(`..${path.sep}`) || relative === ".." ? "outside-project" : null;
|
|
316
|
+
if (!suppressionRule && (rawFile.endsWith(".d.ets") || rawFile.endsWith(".d.ts"))) suppressionRule = "declaration-file";
|
|
317
|
+
if (!suppressionRule && apiType === "stageMode" && String(diagnostic.message ?? "").includes("the current Mode is FA")) suppressionRule = "stage-fa-mode";
|
|
318
|
+
if (!suppressionRule) {
|
|
319
|
+
const binding = /^Cannot find name '(\$[^']+)'/.exec(String(diagnostic.message ?? ""))?.[1];
|
|
320
|
+
if (binding?.startsWith("$$")) suppressionRule = "arkui-binding";
|
|
321
|
+
else {
|
|
322
|
+
const field = /^\$([A-Za-z_][\w$]*)$/.exec(binding ?? "")?.[1];
|
|
323
|
+
if (field && (await fieldsFor(absolute)).has(field)) suppressionRule = "arkui-binding";
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (suppressionRule) suppressedDiagnostics.push({ ...diagnostic, suppression_rule: suppressionRule });
|
|
327
|
+
else errors.push(diagnostic);
|
|
328
|
+
}
|
|
329
|
+
return { errors, suppressed_diagnostics: suppressedDiagnostics };
|
|
330
|
+
}
|
|
331
|
+
function unavailable(reason, elapsedMs = 0) {
|
|
332
|
+
return {
|
|
333
|
+
tool: "arkts_standalone_precheck",
|
|
334
|
+
tool_status: "unavailable",
|
|
335
|
+
evidence_status: "partial",
|
|
336
|
+
success: false,
|
|
337
|
+
mode: "full",
|
|
338
|
+
reason,
|
|
339
|
+
checked_files: [],
|
|
340
|
+
errors: [],
|
|
341
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
342
|
+
elapsed_ms: elapsedMs
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
async function runModulePrecheck({ projectRoot, group, outputDir, runnerPath, tool, hmsSdkEts, systemResourceFile, timeoutSeconds }) {
|
|
346
|
+
const started = Date.now();
|
|
347
|
+
await mkdir(outputDir, { recursive: true });
|
|
348
|
+
const resultPath = path.join(outputDir, "arkts-raw-diagnostics.json");
|
|
349
|
+
const stdoutPath = path.join(outputDir, "arkts-checker-stdout.txt");
|
|
350
|
+
const stderrPath = path.join(outputDir, "arkts-checker-stderr.txt");
|
|
351
|
+
const cacheDir = path.join(outputDir, "arkts-check-cache");
|
|
352
|
+
const artifactPaths = { raw_json: resultPath, stdout: stdoutPath, stderr: stderrPath, runner: runnerPath };
|
|
353
|
+
let checkerConfig;
|
|
354
|
+
try {
|
|
355
|
+
checkerConfig = await moduleCheckerConfig(projectRoot, group.moduleRoot, group.moduleJsonPath, tool.commandlineTools);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
return {
|
|
358
|
+
tool: "arkts_standalone_precheck",
|
|
359
|
+
tool_status: "internal_error",
|
|
360
|
+
evidence_status: "partial",
|
|
361
|
+
success: false,
|
|
362
|
+
mode: "full",
|
|
363
|
+
module: group.key,
|
|
364
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
365
|
+
checked_files: group.files.map((file) => path.relative(projectRoot, file).replace(/\\/g, "/")),
|
|
366
|
+
errors: [],
|
|
367
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
368
|
+
elapsed_ms: Date.now() - started,
|
|
369
|
+
artifact_paths: artifactPaths
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
await clearArtifacts(resultPath, stdoutPath, stderrPath);
|
|
373
|
+
await mkdir(cacheDir, { recursive: true });
|
|
374
|
+
const checkedFiles = group.files.map((file) => path.relative(projectRoot, file).replace(/\\/g, "/"));
|
|
375
|
+
const args = [
|
|
376
|
+
runnerPath,
|
|
377
|
+
"--project",
|
|
378
|
+
projectRoot,
|
|
379
|
+
"--module-root",
|
|
380
|
+
group.moduleRoot,
|
|
381
|
+
"--module-json",
|
|
382
|
+
group.moduleJsonPath,
|
|
383
|
+
"--ets-loader",
|
|
384
|
+
tool.etsLoader,
|
|
385
|
+
"--output",
|
|
386
|
+
resultPath,
|
|
387
|
+
"--api-type",
|
|
388
|
+
String(checkerConfig.apiType),
|
|
389
|
+
"--compatible-sdk-version",
|
|
390
|
+
String(checkerConfig.compatibleSdkVersion)
|
|
391
|
+
];
|
|
392
|
+
for (const permission of Array.isArray(checkerConfig.permissions) ? checkerConfig.permissions.map(String) : []) {
|
|
393
|
+
args.push("--permission", permission);
|
|
394
|
+
}
|
|
395
|
+
if (hmsSdkEts) args.push("--hms-sdk-ets", hmsSdkEts);
|
|
396
|
+
if (systemResourceFile) args.push("--sys-resource-file", systemResourceFile);
|
|
397
|
+
args.push("--cache-dir", cacheDir, "--files", ...group.files);
|
|
398
|
+
const result = await runProcess(process.execPath, args, { cwd: projectRoot, timeoutSeconds });
|
|
399
|
+
await writeFile(stdoutPath, result.stdout || "", "utf8");
|
|
400
|
+
await writeFile(stderrPath, result.stderr || "", "utf8");
|
|
401
|
+
if (result.timedOut) {
|
|
402
|
+
return { ...unavailable(`arkts standalone checker timed out after ${timeoutSeconds}s`, Date.now() - started), module: group.key, checked_files: checkedFiles, artifact_paths: artifactPaths };
|
|
403
|
+
}
|
|
404
|
+
let payload = null;
|
|
405
|
+
let evidenceStatus = "partial";
|
|
406
|
+
if (await exists(resultPath)) {
|
|
407
|
+
try {
|
|
408
|
+
const parsed = JSON.parse(await readFile(resultPath, "utf8"));
|
|
409
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
410
|
+
payload = parsed;
|
|
411
|
+
evidenceStatus = "raw_structured";
|
|
412
|
+
}
|
|
413
|
+
} catch {
|
|
414
|
+
payload = null;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (!payload) {
|
|
418
|
+
return {
|
|
419
|
+
tool: "arkts_standalone_precheck",
|
|
420
|
+
tool_status: "internal_error",
|
|
421
|
+
evidence_status: "partial",
|
|
422
|
+
success: false,
|
|
423
|
+
mode: "full",
|
|
424
|
+
reason: "checker did not emit JSON",
|
|
425
|
+
stdout_tail: (result.stdout || "").slice(-4e3),
|
|
426
|
+
stderr_tail: (result.stderr || "").slice(-4e3),
|
|
427
|
+
checked_files: checkedFiles,
|
|
428
|
+
errors: [],
|
|
429
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
430
|
+
elapsed_ms: Date.now() - started,
|
|
431
|
+
artifact_paths: artifactPaths
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
const payloadError = validateCheckerPayload(payload);
|
|
435
|
+
if (payloadError) {
|
|
436
|
+
return {
|
|
437
|
+
tool: "arkts_standalone_precheck",
|
|
438
|
+
tool_status: "internal_error",
|
|
439
|
+
evidence_status: "partial",
|
|
440
|
+
success: false,
|
|
441
|
+
mode: "full",
|
|
442
|
+
reason: payloadError,
|
|
443
|
+
checked_files: checkedFiles,
|
|
444
|
+
errors: [],
|
|
445
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
446
|
+
elapsed_ms: Date.now() - started,
|
|
447
|
+
artifact_paths: artifactPaths
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const filtered = await filterOfficialDiagnostics({
|
|
451
|
+
projectRoot,
|
|
452
|
+
apiType: checkerConfig.apiType,
|
|
453
|
+
diagnostics: payload.errors
|
|
454
|
+
});
|
|
455
|
+
payload.errors = filtered.errors;
|
|
456
|
+
payload.suppressed_diagnostics = [...(payload.suppressed_diagnostics ?? []), ...filtered.suppressed_diagnostics];
|
|
457
|
+
payload.summary = {
|
|
458
|
+
errorCount: payload.errors.filter((item) => item.severity === "error").length,
|
|
459
|
+
warnCount: payload.errors.filter((item) => item.severity === "warning").length
|
|
460
|
+
};
|
|
461
|
+
payload.tool = "arkts_standalone_precheck";
|
|
462
|
+
payload.module = group.key;
|
|
463
|
+
payload.tool_status = payload.tool_status ?? "ok";
|
|
464
|
+
payload.success = payload.tool_status === "ok" && payload.summary.errorCount === 0;
|
|
465
|
+
payload.evidence_status = evidenceStatus;
|
|
466
|
+
payload.mode = "full";
|
|
467
|
+
payload.ets_loader = tool.etsLoader;
|
|
468
|
+
payload.project_config = checkerConfig;
|
|
469
|
+
payload.checked_files = checkedFiles;
|
|
470
|
+
payload.elapsed_ms = Date.now() - started;
|
|
471
|
+
payload.artifact_paths = artifactPaths;
|
|
472
|
+
if (result.stderr) payload.stderr_tail = result.stderr.slice(-4e3);
|
|
473
|
+
return payload;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
async function runArktsStandalonePrecheck(options) {
|
|
477
|
+
const started = Date.now();
|
|
478
|
+
if (!process.execPath) return unavailable("node executable not found");
|
|
479
|
+
const projectRoot = path.resolve(options.projectRoot);
|
|
480
|
+
const commandlineTools = path.resolve(options.commandlineTools);
|
|
481
|
+
const tool = { ...await findArktsTool(commandlineTools), commandlineTools };
|
|
482
|
+
if (!tool.etsLoader) {
|
|
483
|
+
return unavailable(`ets-loader not found under commandline tools: ${commandlineTools}`, Date.now() - started);
|
|
484
|
+
}
|
|
485
|
+
const selectedFiles = (options.files?.length ? options.files : await collectEtsFiles(projectRoot))
|
|
486
|
+
.map((file) => path.resolve(file))
|
|
487
|
+
.filter((file) => file.startsWith(projectRoot + path.sep) && file.endsWith(".ets"));
|
|
488
|
+
if (!selectedFiles.length) {
|
|
489
|
+
return {
|
|
490
|
+
tool: "arkts_standalone_precheck",
|
|
491
|
+
tool_status: "ok",
|
|
492
|
+
success: true,
|
|
493
|
+
mode: "full",
|
|
494
|
+
ets_loader: tool.etsLoader,
|
|
495
|
+
module_results: [],
|
|
496
|
+
checked_files: [],
|
|
497
|
+
errors: [],
|
|
498
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
499
|
+
elapsed_ms: Date.now() - started
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
const { groups, unowned } = await groupFilesByModule(projectRoot, selectedFiles);
|
|
503
|
+
if (unowned.length) {
|
|
504
|
+
return {
|
|
505
|
+
...unavailable(`ETS files are outside a declared src/main/module.json5 module: ${unowned.join(", ")}`, Date.now() - started),
|
|
506
|
+
tool_status: "internal_error",
|
|
507
|
+
checked_files: unowned
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
await mkdir(options.outputDir, { recursive: true });
|
|
511
|
+
const runnerPath = path.join(options.outputDir, "arkts-standalone-check-runner.js");
|
|
512
|
+
await writeFile(runnerPath, CHECKER_SCRIPT, "utf8");
|
|
513
|
+
const hmsSdkEts = await findHmsSdkEts(commandlineTools);
|
|
514
|
+
const systemResourceFile = await findSystemResourceFile(commandlineTools);
|
|
515
|
+
const moduleResults = await Promise.all(groups.map((group) => runModulePrecheck({
|
|
516
|
+
projectRoot,
|
|
517
|
+
group,
|
|
518
|
+
outputDir: path.join(options.outputDir, "modules", group.key === "." ? "_root" : group.key),
|
|
519
|
+
runnerPath,
|
|
520
|
+
tool,
|
|
521
|
+
hmsSdkEts,
|
|
522
|
+
systemResourceFile,
|
|
523
|
+
timeoutSeconds: options.timeoutSeconds ?? 120
|
|
524
|
+
})));
|
|
525
|
+
const errors = moduleResults.flatMap((result) => result.errors ?? []);
|
|
526
|
+
const suppressed = moduleResults.flatMap((result) => result.suppressed_diagnostics ?? []);
|
|
527
|
+
const errorCount = errors.filter((item) => item.severity === "error").length;
|
|
528
|
+
const warnCount = errors.filter((item) => item.severity === "warning").length;
|
|
529
|
+
const aggregatePath = path.join(options.outputDir, "arkts-raw-diagnostics.json");
|
|
530
|
+
const toolStatus = moduleResults.some((result) => result.tool_status === "internal_error")
|
|
531
|
+
? "internal_error"
|
|
532
|
+
: moduleResults.some((result) => result.tool_status === "unavailable") ? "unavailable" : "ok";
|
|
533
|
+
const payload = {
|
|
534
|
+
tool: "arkts_standalone_precheck",
|
|
535
|
+
tool_status: toolStatus,
|
|
536
|
+
evidence_status: moduleResults.every((result) => result.evidence_status === "raw_structured") ? "raw_structured" : "partial",
|
|
537
|
+
success: toolStatus === "ok" && errorCount === 0,
|
|
538
|
+
mode: "full",
|
|
539
|
+
ets_loader: tool.etsLoader,
|
|
540
|
+
checked_files: moduleResults.flatMap((result) => result.checked_files ?? []).sort(),
|
|
541
|
+
errors,
|
|
542
|
+
suppressed_diagnostics: suppressed,
|
|
543
|
+
summary: { errorCount, warnCount },
|
|
544
|
+
module_results: moduleResults,
|
|
545
|
+
elapsed_ms: Date.now() - started,
|
|
546
|
+
artifact_paths: {
|
|
547
|
+
raw_json: aggregatePath,
|
|
548
|
+
runner: runnerPath,
|
|
549
|
+
stdout: moduleResults.length === 1 ? moduleResults[0].artifact_paths?.stdout : undefined,
|
|
550
|
+
stderr: moduleResults.length === 1 ? moduleResults[0].artifact_paths?.stderr : undefined,
|
|
551
|
+
modules: Object.fromEntries(moduleResults.map((result) => [result.module, result.artifact_paths ?? null]))
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
const reasons = moduleResults.filter((result) => result.reason).map((result) => `${result.module}: ${result.reason}`);
|
|
555
|
+
if (reasons.length) payload.reason = reasons.join("; ");
|
|
556
|
+
await writeFile(aggregatePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
557
|
+
return payload;
|
|
558
|
+
}
|
|
559
|
+
export {
|
|
560
|
+
collectEtsFiles,
|
|
561
|
+
findArktsTool,
|
|
562
|
+
findHmsSdkEts,
|
|
563
|
+
findSystemResourceFile,
|
|
564
|
+
filterOfficialDiagnostics,
|
|
565
|
+
runArktsStandalonePrecheck,
|
|
566
|
+
validateCheckerPayload
|
|
567
|
+
};
|