@buaa_smat/hometrans 0.1.17 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -56
- package/agents/code-reviewer.md +321 -65
- package/agents/logic-coder.md +113 -88
- package/agents/logic-context-builder.md +47 -29
- package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
- package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
- package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
- package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
- package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
- package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
- package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
- package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
- package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
- package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
- package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
- package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
- package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
- package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
- package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
- package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
- package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
- package/agents/scripts/hmos-precheck/index.mjs +17 -0
- package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
- package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
- package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
- package/agents/scripts/platform_query.mjs +626 -0
- package/agents/scripts/platform_query.test.mjs +422 -0
- package/agents/self-test-fixer.md +36 -34
- package/agents/self-tester.md +35 -376
- package/agents/test-case-generation-generator.md +317 -0
- package/agents/test-case-generation-validator.md +231 -0
- package/dist/cli/config-store.js +19 -146
- package/dist/cli/config.js +6 -8
- package/dist/cli/env-vars.js +1 -3
- package/dist/cli/index.js +0 -11
- package/dist/cli/init.js +147 -235
- package/dist/cli/uninstall.js +5 -129
- package/dist/utils/regex.js +8 -0
- package/env-requirements.json +57 -55
- package/package.json +6 -8
- package/resource/convert_pipeline_process.svg +103 -0
- package/resource/project_architecture.svg +122 -0
- package/resource/title_dark.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +345 -43
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
- package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
- package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
- package/skills/hmos-convert-pipeline/SKILL.md +188 -131
- package/skills/hmos-fix-build-errors/SKILL.md +87 -67
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/README.md +57 -40
- package/skills/hmos-incremental-ui-align/SKILL.md +180 -24
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
- package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
- package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
- package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
- package/skills/hmos-integration-test/README.md +111 -79
- package/skills/hmos-integration-test/SKILL.md +216 -132
- package/skills/hmos-integration-test/scripts/report-tool.ts +791 -0
- package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +125 -0
- package/skills/hmos-integration-test/scripts/self-test-runner.ts +756 -0
- package/skills/hmos-integration-test/scripts/testcases-tool.ts +239 -0
- package/skills/hmos-resources-convert/SKILL.md +334 -66
- package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
- package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
- package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
- package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
- package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
- package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
- package/skills/hmos-spec-generate/SKILL.md +293 -214
- package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
- package/skills/hmos-spec-generate/template/REQ.txt +22 -0
- package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
- package/skills/hmos-test-case-generation/README.md +241 -0
- package/skills/hmos-test-case-generation/SKILL.md +324 -0
- package/skills/hmos-test-case-generation/references/contract.md +315 -0
- package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
- package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
- package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
- package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
- package/tools/bfs-crawl/README.md +73 -0
- package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
- package/agents/build-fixer.md +0 -385
- package/agents/logic-coder/scripts/platform_context_query.py +0 -568
- package/agents/review-fixer.md +0 -405
- package/agents/spec-generator.md +0 -541
- package/dist/cli/mcp-setup.js +0 -258
- package/dist/cli/mcp.js +0 -94
- package/dist/context/index.js +0 -694
- package/resource/migration_process.svg +0 -94
- package/resource/migration_process_transparent.svg +0 -93
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
- package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
- package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
- package/skills/hmos-resources-convert/evals/evals.json +0 -171
- package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
- package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
- package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
- package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
- package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
- package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
- package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
- package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
- package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
- package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
- package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
- package/tools/test-tools/autotest/README.md +0 -238
- package/tools/test-tools/autotest/pyproject.toml +0 -26
- package/tools/test-tools/autotest/report_tool.py +0 -759
- package/tools/test-tools/autotest/self_test_runner.py +0 -895
- package/tools/test-tools/autotest/testcases_schema.md +0 -143
- package/tools/test-tools/autotest/testcases_tool.py +0 -215
- package/tools/test-tools/autotest/uv.lock +0 -3156
- package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { runArktsDiff } from "./arkts_diff.mjs";
|
|
5
|
+
import { runCodelinterDiffScan } from "./codelinter.mjs";
|
|
6
|
+
import { createScopePlan } from "../core/scope_plan.mjs";
|
|
7
|
+
import { loadRuleInventory } from "../rules/rule_inventory.mjs";
|
|
8
|
+
import { classifyRuleDiagnostic, normalizeRuleDiagnostic } from "../rules/rule_policy.mjs";
|
|
9
|
+
import { overallStatus, projectAgentResult, rawArtifactCandidates, writeSummary } from "../core/result_projection.mjs";
|
|
10
|
+
|
|
11
|
+
const SUPPORTED_PROFILES = new Set(["arkts-diff", "codelinter-diff"]);
|
|
12
|
+
|
|
13
|
+
async function writeJson(pathname, payload) {
|
|
14
|
+
await mkdir(path.dirname(pathname), { recursive: true });
|
|
15
|
+
await writeFile(pathname, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function prepareRunOutputDir(outputDir, runId) {
|
|
19
|
+
return path.join(outputDir, `run-${runId}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function backendCrashPayload(profile, error) {
|
|
23
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
24
|
+
if (profile === "arkts-diff") {
|
|
25
|
+
return {
|
|
26
|
+
tool: "arkts_standalone_precheck",
|
|
27
|
+
tool_status: "unavailable",
|
|
28
|
+
evidence_status: "partial",
|
|
29
|
+
success: false,
|
|
30
|
+
mode: "diff",
|
|
31
|
+
checked_files: [],
|
|
32
|
+
errors: [],
|
|
33
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
34
|
+
reason,
|
|
35
|
+
scope: "diff",
|
|
36
|
+
changed_files_only: true,
|
|
37
|
+
changed_line_ranges: {},
|
|
38
|
+
failure_rule: "backend-crashed"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
tool: "codelinter",
|
|
43
|
+
tool_status: "unavailable",
|
|
44
|
+
evidence_status: "partial",
|
|
45
|
+
success: false,
|
|
46
|
+
checked_files: [],
|
|
47
|
+
diagnostics: [],
|
|
48
|
+
summary: { errorCount: 0, warnCount: 0, suggestionCount: 0 },
|
|
49
|
+
reason,
|
|
50
|
+
scope: "diff",
|
|
51
|
+
changed_files_only: true,
|
|
52
|
+
changed_line_ranges: {},
|
|
53
|
+
failure_rule: "backend-crashed"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function sourceClassForArktsDiagnostic(diagnostic) {
|
|
58
|
+
return diagnostic?.source_class ?? "official_checker";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function runStaticPrecheck(options) {
|
|
62
|
+
const runId = randomUUID().replace(/-/g, "");
|
|
63
|
+
await mkdir(path.resolve(options.outputDir), { recursive: true });
|
|
64
|
+
const runDir = prepareRunOutputDir(path.resolve(options.outputDir), runId);
|
|
65
|
+
await mkdir(runDir, { recursive: true });
|
|
66
|
+
const selectedProfiles = [...new Set(options.profiles)];
|
|
67
|
+
const unknownProfiles = selectedProfiles.filter((profile) => !SUPPORTED_PROFILES.has(profile));
|
|
68
|
+
if (unknownProfiles.length) throw new Error(`unsupported profile(s): ${unknownProfiles.join(", ")}`);
|
|
69
|
+
const backendResults = {};
|
|
70
|
+
const jobs = [];
|
|
71
|
+
const scopePlan = createScopePlan({
|
|
72
|
+
projectRoot: path.resolve(options.projectRoot),
|
|
73
|
+
incremental: Boolean(options.incremental),
|
|
74
|
+
baseRef: options.baseRef,
|
|
75
|
+
headRef: options.headRef
|
|
76
|
+
});
|
|
77
|
+
if (selectedProfiles.includes("arkts-diff")) {
|
|
78
|
+
jobs.push((async () => {
|
|
79
|
+
try {
|
|
80
|
+
const result = await runArktsDiff({
|
|
81
|
+
projectRoot: path.resolve(options.projectRoot),
|
|
82
|
+
outputDir: runDir,
|
|
83
|
+
commandlineTools: options.commandlineTools.sdkRoot,
|
|
84
|
+
baseRef: options.baseRef,
|
|
85
|
+
headRef: options.headRef,
|
|
86
|
+
incremental: options.incremental,
|
|
87
|
+
scopePlan
|
|
88
|
+
});
|
|
89
|
+
backendResults["arkts-diff"] = { ...result, selected_backend: "builtin" };
|
|
90
|
+
} catch (error) {
|
|
91
|
+
backendResults["arkts-diff"] = backendCrashPayload("arkts-diff", error);
|
|
92
|
+
}
|
|
93
|
+
})());
|
|
94
|
+
}
|
|
95
|
+
if (selectedProfiles.includes("codelinter-diff")) {
|
|
96
|
+
jobs.push((async () => {
|
|
97
|
+
try {
|
|
98
|
+
backendResults["codelinter-diff"] = await runCodelinterDiffScan({
|
|
99
|
+
projectRoot: path.resolve(options.projectRoot),
|
|
100
|
+
validationOutputDir: runDir,
|
|
101
|
+
commandlineTools: options.commandlineTools.sdkRoot,
|
|
102
|
+
baseRef: options.baseRef,
|
|
103
|
+
headRef: options.headRef,
|
|
104
|
+
incremental_scope: options.incremental,
|
|
105
|
+
scopePlan
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
backendResults["codelinter-diff"] = backendCrashPayload("codelinter-diff", error);
|
|
109
|
+
}
|
|
110
|
+
})());
|
|
111
|
+
}
|
|
112
|
+
await Promise.all(jobs);
|
|
113
|
+
const ruleInventory = await loadRuleInventory();
|
|
114
|
+
const findings = [];
|
|
115
|
+
const summaryCounts = { hard_fixable: 0, strong_warn: 0, risk_only: 0, not_checked: 0 };
|
|
116
|
+
const arkts = backendResults["arkts-diff"];
|
|
117
|
+
if (arkts) {
|
|
118
|
+
if (String(arkts.tool_status ?? "") !== "ok") {
|
|
119
|
+
findings.push({
|
|
120
|
+
profile: "arkts-diff",
|
|
121
|
+
category: "tooling",
|
|
122
|
+
classification: "not_checked",
|
|
123
|
+
file: null,
|
|
124
|
+
line: null,
|
|
125
|
+
column: null,
|
|
126
|
+
rule: String(arkts.failure_rule ?? "backend-unavailable"),
|
|
127
|
+
message: String(arkts.reason ?? "ArkTS backend unavailable")
|
|
128
|
+
});
|
|
129
|
+
summaryCounts.not_checked += 1;
|
|
130
|
+
} else {
|
|
131
|
+
const repairSource = Array.isArray(arkts.repair_errors) ? arkts.repair_errors : arkts.errors;
|
|
132
|
+
for (const item of Array.isArray(repairSource) ? repairSource : []) {
|
|
133
|
+
const normalized = normalizeRuleDiagnostic(item, ruleInventory, { sourceClass: sourceClassForArktsDiagnostic(item) });
|
|
134
|
+
const classification = classifyRuleDiagnostic(normalized);
|
|
135
|
+
if (!classification) continue;
|
|
136
|
+
findings.push({
|
|
137
|
+
profile: "arkts-diff",
|
|
138
|
+
category: normalized.group,
|
|
139
|
+
classification,
|
|
140
|
+
file: item.file ?? null,
|
|
141
|
+
line: item.line ?? null,
|
|
142
|
+
column: item.column ?? null,
|
|
143
|
+
rule: normalized.rule_id,
|
|
144
|
+
raw_rule: normalized.raw_rule,
|
|
145
|
+
source_class: normalized.source_class,
|
|
146
|
+
confidence: normalized.confidence,
|
|
147
|
+
default_mode: normalized.default_mode,
|
|
148
|
+
fix_policy: normalized.fix_policy,
|
|
149
|
+
message: item.message ?? "",
|
|
150
|
+
evidence: { status: arkts.evidence_status ?? "partial", raw_files: rawArtifactCandidates(arkts.artifact_paths) }
|
|
151
|
+
});
|
|
152
|
+
summaryCounts[classification] += 1;
|
|
153
|
+
}
|
|
154
|
+
for (const item of arkts.diagnostic_scope?.outside_changed_lines ?? []) {
|
|
155
|
+
const normalized = normalizeRuleDiagnostic(item, ruleInventory, { sourceClass: sourceClassForArktsDiagnostic(item) });
|
|
156
|
+
if (!classifyRuleDiagnostic(normalized)) continue;
|
|
157
|
+
findings.push({
|
|
158
|
+
profile: "arkts-diff",
|
|
159
|
+
category: normalized.group,
|
|
160
|
+
classification: "strong_warn",
|
|
161
|
+
file: item.file ?? null,
|
|
162
|
+
line: item.line ?? null,
|
|
163
|
+
column: item.column ?? null,
|
|
164
|
+
rule: normalized.rule_id,
|
|
165
|
+
raw_rule: normalized.raw_rule,
|
|
166
|
+
source_class: normalized.source_class,
|
|
167
|
+
confidence: normalized.confidence,
|
|
168
|
+
default_mode: normalized.default_mode,
|
|
169
|
+
fix_policy: normalized.fix_policy,
|
|
170
|
+
message: item.message ?? "new diagnostic outside changed lines",
|
|
171
|
+
evidence: { status: arkts.evidence_status ?? "partial", raw_files: rawArtifactCandidates(arkts.artifact_paths) }
|
|
172
|
+
});
|
|
173
|
+
summaryCounts.strong_warn += 1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const codelinter = backendResults["codelinter-diff"];
|
|
178
|
+
if (codelinter) {
|
|
179
|
+
if (String(codelinter.tool_status ?? "") !== "ok") {
|
|
180
|
+
findings.push({
|
|
181
|
+
profile: "codelinter-diff",
|
|
182
|
+
category: "tooling",
|
|
183
|
+
classification: "not_checked",
|
|
184
|
+
file: null,
|
|
185
|
+
line: null,
|
|
186
|
+
column: null,
|
|
187
|
+
rule: String(codelinter.failure_rule ?? "backend-unavailable"),
|
|
188
|
+
message: String(codelinter.reason ?? "CodeLinter backend unavailable")
|
|
189
|
+
});
|
|
190
|
+
summaryCounts.not_checked += 1;
|
|
191
|
+
} else {
|
|
192
|
+
for (const item of Array.isArray(codelinter.diagnostics) ? codelinter.diagnostics : []) {
|
|
193
|
+
const severity = String(item.severity ?? "");
|
|
194
|
+
const classification = item.outside_changed_lines
|
|
195
|
+
? "strong_warn"
|
|
196
|
+
: severity === "error" ? "hard_fixable" : severity === "warning" ? "strong_warn" : "risk_only";
|
|
197
|
+
findings.push({
|
|
198
|
+
profile: "codelinter-diff",
|
|
199
|
+
category: "lint",
|
|
200
|
+
classification,
|
|
201
|
+
file: item.file ?? null,
|
|
202
|
+
line: item.line ?? null,
|
|
203
|
+
column: item.column ?? null,
|
|
204
|
+
rule: item.rule || "no-rule",
|
|
205
|
+
message: item.message ?? "",
|
|
206
|
+
evidence: { status: codelinter.evidence_status ?? "partial", raw_files: rawArtifactCandidates(codelinter.artifact_paths) }
|
|
207
|
+
});
|
|
208
|
+
if (classification === "hard_fixable") summaryCounts.hard_fixable += 1;
|
|
209
|
+
else if (classification === "strong_warn") summaryCounts.strong_warn += 1;
|
|
210
|
+
else summaryCounts.risk_only += 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const status = overallStatus(summaryCounts, backendResults, findings);
|
|
215
|
+
const compactSummary = summaryCounts.hard_fixable
|
|
216
|
+
? `${summaryCounts.hard_fixable} blocking finding(s) across ${selectedProfiles.length} profile(s)`
|
|
217
|
+
: summaryCounts.not_checked
|
|
218
|
+
? `no blocking findings; ${summaryCounts.not_checked} profile(s) not fully checked`
|
|
219
|
+
: "no blocking findings";
|
|
220
|
+
const payload = {
|
|
221
|
+
tool: "hmos-precheck",
|
|
222
|
+
run_id: runId,
|
|
223
|
+
schema_version: "hmos_precheck.v1",
|
|
224
|
+
status,
|
|
225
|
+
ok: status !== "fail",
|
|
226
|
+
profiles: selectedProfiles,
|
|
227
|
+
scope: options.incremental ? "incremental" : "full",
|
|
228
|
+
project_root: path.resolve(options.projectRoot),
|
|
229
|
+
summary: summaryCounts,
|
|
230
|
+
summary_counts: summaryCounts,
|
|
231
|
+
findings,
|
|
232
|
+
fixable: Boolean(summaryCounts.hard_fixable),
|
|
233
|
+
compact_summary: compactSummary,
|
|
234
|
+
backend_results: backendResults
|
|
235
|
+
};
|
|
236
|
+
const artifactPaths = {
|
|
237
|
+
json: path.join(runDir, "hmos-precheck-result.json"),
|
|
238
|
+
summary: path.join(runDir, "hmos-precheck-summary.md")
|
|
239
|
+
};
|
|
240
|
+
if (options.debugArtifact) artifactPaths.debug = path.join(runDir, "hmos-precheck-debug.json");
|
|
241
|
+
if (artifactPaths.debug) await writeJson(artifactPaths.debug, payload);
|
|
242
|
+
await writeSummary(payload, artifactPaths.summary);
|
|
243
|
+
await writeJson(artifactPaths.json, await projectAgentResult({ run_id: runId, status, artifact_paths: artifactPaths, backend_results: backendResults, findings }));
|
|
244
|
+
return { run_id: runId, status, backend_results: backendResults, findings, artifact_paths: artifactPaths };
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export { runStaticPrecheck };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { exists } from "./process_adapter.mjs";
|
|
5
|
+
|
|
6
|
+
const PROJECT_CONFIG_NAME = ".hmos-precheck.json";
|
|
7
|
+
const USER_CONFIG_BASENAME = "config.json";
|
|
8
|
+
|
|
9
|
+
function isObject(value) {
|
|
10
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function loadJson(pathname) {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(await readFile(pathname, "utf8"));
|
|
16
|
+
return isObject(parsed) ? parsed : null;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function expandHome(input) {
|
|
23
|
+
if (!input) return input;
|
|
24
|
+
if (input === "~") return os.homedir();
|
|
25
|
+
if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(os.homedir(), input.slice(2));
|
|
26
|
+
return input;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function expandConfiguredPath(input, env = process.env) {
|
|
30
|
+
if (input === "$DEVECO_SDK_HOME" || input === "%DEVECO_SDK_HOME%") return env.DEVECO_SDK_HOME || null;
|
|
31
|
+
return input;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function defaultUserConfigPath() {
|
|
35
|
+
if (process.platform === "darwin") {
|
|
36
|
+
return path.join(os.homedir(), "Library", "Application Support", "hmos-precheck", USER_CONFIG_BASENAME);
|
|
37
|
+
}
|
|
38
|
+
if (process.platform.startsWith("win")) {
|
|
39
|
+
const appdata = process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming");
|
|
40
|
+
return path.join(appdata, "hmos-precheck", USER_CONFIG_BASENAME);
|
|
41
|
+
}
|
|
42
|
+
const xdg = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
43
|
+
return path.join(xdg, "hmos-precheck", USER_CONFIG_BASENAME);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function defaultHomeTransConfigPath() {
|
|
47
|
+
return path.join(os.homedir(), ".hometrans", "config.json");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function commandlineToolsHelp() {
|
|
51
|
+
return "Run `hmos-precheck init --scope user --commandline-tools /abs/path/to/command-line-tools`, or pass `--commandline-tools`.";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function hasSdkShape(candidate) {
|
|
55
|
+
const probes = [
|
|
56
|
+
path.join(candidate, "openharmony", "toolchains"),
|
|
57
|
+
path.join(candidate, "openharmony", "ets"),
|
|
58
|
+
path.join(candidate, "hms", "ets"),
|
|
59
|
+
path.join(candidate, "hms", "toolchains"),
|
|
60
|
+
path.join(candidate, "default", "openharmony", "toolchains"),
|
|
61
|
+
path.join(candidate, "default", "openharmony", "ets"),
|
|
62
|
+
path.join(candidate, "default", "hms", "ets"),
|
|
63
|
+
path.join(candidate, "default", "hms", "toolchains")
|
|
64
|
+
];
|
|
65
|
+
for (const probe of probes) if (await exists(probe)) return true;
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function normalizeCommandlineToolsCandidate(candidate, env = process.env, baseDir = process.cwd()) {
|
|
70
|
+
const expanded = expandConfiguredPath(candidate, env);
|
|
71
|
+
if (!expanded) return null;
|
|
72
|
+
const resolved = path.resolve(baseDir, expandHome(expanded));
|
|
73
|
+
if (await hasSdkShape(resolved)) {
|
|
74
|
+
if (path.basename(resolved) === "default" && path.basename(path.dirname(resolved)) === "sdk") {
|
|
75
|
+
return { sdkRoot: path.dirname(resolved), toolRoot: path.dirname(path.dirname(resolved)) };
|
|
76
|
+
}
|
|
77
|
+
return { sdkRoot: resolved, toolRoot: path.dirname(resolved) };
|
|
78
|
+
}
|
|
79
|
+
const nested = path.join(resolved, "sdk");
|
|
80
|
+
if (await hasSdkShape(nested)) return { sdkRoot: nested, toolRoot: resolved };
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function resolveCommonCommandlineTools(env = process.env) {
|
|
85
|
+
const candidates = [];
|
|
86
|
+
if (process.platform.startsWith("win")) {
|
|
87
|
+
for (const root of [env.LOCALAPPDATA, env.PROGRAMFILES, env["PROGRAMFILES(X86)"], env.USERPROFILE].filter(Boolean)) {
|
|
88
|
+
candidates.push(
|
|
89
|
+
path.join(root, "HarmonyOS", "command-line-tools"),
|
|
90
|
+
path.join(root, "Huawei", "HarmonyOS", "command-line-tools"),
|
|
91
|
+
path.join(root, "OpenHarmony", "command-line-tools")
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
candidates.push(path.join(os.homedir(), "HarmonyOS", "command-line-tools"));
|
|
95
|
+
} else if (process.platform === "darwin") {
|
|
96
|
+
candidates.push("/Applications/HarmonyOS/command-line-tools", path.join(os.homedir(), "HarmonyOS", "command-line-tools"));
|
|
97
|
+
} else {
|
|
98
|
+
candidates.push("/opt/harmonyos/command-line-tools", path.join(os.homedir(), "HarmonyOS", "command-line-tools"), path.join(os.homedir(), "harmonyos", "command-line-tools"));
|
|
99
|
+
}
|
|
100
|
+
for (const candidate of candidates) {
|
|
101
|
+
const info = await normalizeCommandlineToolsCandidate(candidate, env);
|
|
102
|
+
if (info) return info.sdkRoot;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function resolveCommandlineToolsInfo(options) {
|
|
108
|
+
const env = options.env ?? process.env;
|
|
109
|
+
const hint = commandlineToolsHelp();
|
|
110
|
+
const wrap = async (candidate, source, baseDir = process.cwd()) => {
|
|
111
|
+
if (!candidate) return null;
|
|
112
|
+
const expanded = expandConfiguredPath(candidate, env);
|
|
113
|
+
if (!expanded) return null;
|
|
114
|
+
const info = await normalizeCommandlineToolsCandidate(expanded, env, baseDir);
|
|
115
|
+
if (!info) {
|
|
116
|
+
const resolved = path.resolve(baseDir, expandHome(expanded));
|
|
117
|
+
return { path: resolved, toolRoot: null, sdkRoot: null, source, configured: true, available: false, message: `Configured HarmonyOS command-line tools path is unavailable: ${resolved}`, hint };
|
|
118
|
+
}
|
|
119
|
+
return { path: info.sdkRoot, toolRoot: info.toolRoot, sdkRoot: info.sdkRoot, source, configured: true, available: true, message: null, hint };
|
|
120
|
+
};
|
|
121
|
+
const explicit = await wrap(options.explicitPath ?? null, "cli");
|
|
122
|
+
if (explicit) return explicit;
|
|
123
|
+
const sdkResult = await wrap(env.DEVECO_SDK_HOME ?? null, "env");
|
|
124
|
+
if (sdkResult) return sdkResult;
|
|
125
|
+
if (options.projectRoot) {
|
|
126
|
+
const projectConfigPath = path.join(path.resolve(options.projectRoot), PROJECT_CONFIG_NAME);
|
|
127
|
+
const projectConfig = await loadJson(projectConfigPath);
|
|
128
|
+
if (await exists(projectConfigPath) && !projectConfig) return { path: projectConfigPath, toolRoot: null, sdkRoot: null, source: "project_config", configured: true, available: false, message: `Invalid project configuration: ${projectConfigPath}`, hint };
|
|
129
|
+
const value = isObject(projectConfig?.toolchain) ? projectConfig.toolchain.commandline_tools : void 0;
|
|
130
|
+
const projectResult = await wrap(typeof value === "string" ? value : null, "project_config", path.dirname(projectConfigPath));
|
|
131
|
+
if (projectResult) return projectResult;
|
|
132
|
+
}
|
|
133
|
+
const homeTransConfigPath = defaultHomeTransConfigPath();
|
|
134
|
+
const homeTransConfig = await loadJson(homeTransConfigPath);
|
|
135
|
+
const homeTransValue = isObject(homeTransConfig?.env) ? homeTransConfig.env.DEVECO_SDK_HOME : void 0;
|
|
136
|
+
const homeTransResult = await wrap(typeof homeTransValue === "string" ? homeTransValue : null, "hometrans_config", path.dirname(homeTransConfigPath));
|
|
137
|
+
if (homeTransResult) return homeTransResult;
|
|
138
|
+
const userConfigPath = options.userConfigPath ?? defaultUserConfigPath();
|
|
139
|
+
const userConfig = await loadJson(userConfigPath);
|
|
140
|
+
const userValue = isObject(userConfig?.toolchain) ? userConfig.toolchain.commandline_tools : void 0;
|
|
141
|
+
const userResult = await wrap(typeof userValue === "string" ? userValue : null, "user_config", path.dirname(userConfigPath));
|
|
142
|
+
if (userResult) return userResult;
|
|
143
|
+
const auto = await resolveCommonCommandlineTools(env);
|
|
144
|
+
if (auto) return { path: auto, toolRoot: path.dirname(auto), sdkRoot: auto, source: "auto", configured: true, available: true, message: null, hint };
|
|
145
|
+
return { path: null, toolRoot: null, sdkRoot: null, source: "missing", configured: false, available: false, message: "HarmonyOS command-line tools are not configured. ArkTS-dependent checks will be skipped.", hint };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function resolveProfiles(options) {
|
|
149
|
+
const normalize = (values) => {
|
|
150
|
+
if (!values) return null;
|
|
151
|
+
const raw = Array.isArray(values) ? values : values.split(",");
|
|
152
|
+
const deduped = [...new Set(raw.map((item) => item.trim()).filter(Boolean))];
|
|
153
|
+
return deduped.length ? deduped : null;
|
|
154
|
+
};
|
|
155
|
+
const explicit = normalize(options.explicitProfiles ?? null);
|
|
156
|
+
if (explicit) return explicit;
|
|
157
|
+
if (options.projectRoot) {
|
|
158
|
+
const projectConfig = await loadJson(path.join(options.projectRoot, PROJECT_CONFIG_NAME));
|
|
159
|
+
const value = isObject(projectConfig?.run) ? projectConfig.run.profiles : void 0;
|
|
160
|
+
const fromProject = normalize(Array.isArray(value) ? value.map(String) : typeof value === "string" ? value : null);
|
|
161
|
+
if (fromProject) return fromProject;
|
|
162
|
+
}
|
|
163
|
+
const userConfig = await loadJson(options.userConfigPath ?? defaultUserConfigPath());
|
|
164
|
+
const value = isObject(userConfig?.run) ? userConfig.run.profiles : void 0;
|
|
165
|
+
return normalize(Array.isArray(value) ? value.map(String) : typeof value === "string" ? value : null);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function initConfig(targetPath, commandlineTools, options = {}) {
|
|
169
|
+
await mkdir(path.dirname(targetPath), { recursive: true });
|
|
170
|
+
const value = options.portable ? "$DEVECO_SDK_HOME" : path.resolve(commandlineTools);
|
|
171
|
+
await writeFile(targetPath, `${JSON.stringify({ toolchain: { commandline_tools: value } }, null, 2)}\n`, "utf8");
|
|
172
|
+
return targetPath;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
PROJECT_CONFIG_NAME,
|
|
177
|
+
commandlineToolsHelp,
|
|
178
|
+
defaultHomeTransConfigPath,
|
|
179
|
+
defaultUserConfigPath,
|
|
180
|
+
initConfig,
|
|
181
|
+
isObject,
|
|
182
|
+
resolveCommandlineToolsInfo,
|
|
183
|
+
resolveProfiles
|
|
184
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function lineInRanges(line, ranges) {
|
|
2
|
+
return Number.isInteger(line) && Array.isArray(ranges) && ranges.some(([start, end]) => start <= line && line <= end);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function classifyDiagnosticScope(diagnostics, changedLineRanges) {
|
|
6
|
+
const repairDiagnostics = [];
|
|
7
|
+
const outsideChangedLines = [];
|
|
8
|
+
for (const item of Array.isArray(diagnostics) ? diagnostics : []) {
|
|
9
|
+
if (lineInRanges(item.line, changedLineRanges[String(item.file ?? "")])) repairDiagnostics.push(item);
|
|
10
|
+
else outsideChangedLines.push(item);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
status: "available",
|
|
14
|
+
current_count: repairDiagnostics.length + outsideChangedLines.length,
|
|
15
|
+
repair_diagnostics: repairDiagnostics,
|
|
16
|
+
outside_changed_lines: outsideChangedLines
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { classifyDiagnosticScope };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { constants as fsConstants } from "node:fs";
|
|
2
|
+
import { access, rm } from "node:fs/promises";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
|
|
5
|
+
async function exists(pathname) {
|
|
6
|
+
try {
|
|
7
|
+
await access(pathname, fsConstants.R_OK);
|
|
8
|
+
return true;
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function runProcess(command, args, options = {}) {
|
|
15
|
+
const timeoutSeconds = options.timeoutSeconds ?? 120;
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const proc = spawn(command, args, {
|
|
18
|
+
cwd: options.cwd,
|
|
19
|
+
env: options.env,
|
|
20
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
21
|
+
});
|
|
22
|
+
let stdout = "";
|
|
23
|
+
let stderr = "";
|
|
24
|
+
let timedOut = false;
|
|
25
|
+
let settled = false;
|
|
26
|
+
const finish = (result) => {
|
|
27
|
+
if (settled) return;
|
|
28
|
+
settled = true;
|
|
29
|
+
if (timer) clearTimeout(timer);
|
|
30
|
+
resolve(result);
|
|
31
|
+
};
|
|
32
|
+
const timer = timeoutSeconds > 0 ? setTimeout(() => {
|
|
33
|
+
timedOut = true;
|
|
34
|
+
proc.kill("SIGKILL");
|
|
35
|
+
}, timeoutSeconds * 1000) : null;
|
|
36
|
+
proc.stdout.on("data", (chunk) => { stdout += String(chunk); });
|
|
37
|
+
proc.stderr.on("data", (chunk) => { stderr += String(chunk); });
|
|
38
|
+
proc.on("error", (error) => finish({ code: 1, stdout, stderr: `${stderr}${error instanceof Error ? error.message : String(error)}`, timedOut }));
|
|
39
|
+
proc.on("close", (code) => finish({ code: timedOut ? 1 : code ?? 1, stdout, stderr, timedOut }));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function clearArtifacts(...paths) {
|
|
44
|
+
await Promise.all(paths.map((pathname) => rm(pathname, { force: true })));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { clearArtifacts, exists, runProcess };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { exists } from "./process_adapter.mjs";
|
|
4
|
+
|
|
5
|
+
const ignored = new Set(["node_modules", "oh_modules", "build", ".cache", ".git"]);
|
|
6
|
+
|
|
7
|
+
async function etsFiles(root) {
|
|
8
|
+
const files = [];
|
|
9
|
+
async function walk(current) {
|
|
10
|
+
for (const entry of await readdir(current, { withFileTypes: true })) {
|
|
11
|
+
if (ignored.has(entry.name)) continue;
|
|
12
|
+
const absolute = path.join(current, entry.name);
|
|
13
|
+
if (entry.isDirectory()) await walk(absolute);
|
|
14
|
+
else if (entry.isFile() && absolute.endsWith(".ets") && !absolute.endsWith(".d.ets")) files.push(path.resolve(absolute));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (await exists(root)) await walk(root);
|
|
18
|
+
return files.sort();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function discoverProjectModules(projectRoot) {
|
|
22
|
+
const root = path.resolve(projectRoot);
|
|
23
|
+
const modules = [];
|
|
24
|
+
async function discover(current) {
|
|
25
|
+
for (const entry of await readdir(current, { withFileTypes: true })) {
|
|
26
|
+
if (ignored.has(entry.name)) continue;
|
|
27
|
+
const absolute = path.join(current, entry.name);
|
|
28
|
+
if (entry.isDirectory()) await discover(absolute);
|
|
29
|
+
else if (entry.isFile() && entry.name === "module.json5" && path.basename(current) === "main" && path.basename(path.dirname(current)) === "src") {
|
|
30
|
+
const moduleRoot = path.dirname(path.dirname(current));
|
|
31
|
+
const etsRoot = path.join(current, "ets");
|
|
32
|
+
modules.push({ module_root: moduleRoot, manifest_path: absolute, ets_root: etsRoot, ets_files: await etsFiles(etsRoot) });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await discover(root);
|
|
37
|
+
modules.sort((left, right) => left.module_root.localeCompare(right.module_root));
|
|
38
|
+
let allEts = modules.flatMap((item) => item.ets_files).sort();
|
|
39
|
+
if (!modules.length) {
|
|
40
|
+
for (const fallback of [path.join(root, "entry", "src", "main", "ets"), path.join(root, "src", "main", "ets")]) allEts.push(...await etsFiles(fallback));
|
|
41
|
+
allEts = [...new Set(allEts)].sort();
|
|
42
|
+
}
|
|
43
|
+
return { project_root: root, modules, ets_files: allEts };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function collectEtsFiles(projectRoot) {
|
|
47
|
+
return (await discoverProjectModules(projectRoot)).ets_files;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { collectEtsFiles, discoverProjectModules };
|