@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,159 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { runArktsStandalonePrecheck } from "./arkts.mjs";
|
|
4
|
+
import { checkArktsProjectRules } from "./arkts_project_rules.mjs";
|
|
5
|
+
import { classifyDiagnosticScope } from "../core/diagnostic_scope.mjs";
|
|
6
|
+
import { checkProjectIntegrity } from "./project_integrity.mjs";
|
|
7
|
+
import { createScopePlan } from "../core/scope_plan.mjs";
|
|
8
|
+
import { writeArktsSummary } from "../core/result_projection.mjs";
|
|
9
|
+
|
|
10
|
+
async function writeJson(pathname, payload) {
|
|
11
|
+
await mkdir(path.dirname(pathname), { recursive: true });
|
|
12
|
+
await writeFile(pathname, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function attachProjectIntegrity(projectRoot, backendResult, commandlineTools) {
|
|
16
|
+
const integrity = await checkProjectIntegrity(projectRoot, { commandlineTools });
|
|
17
|
+
const projectRules = checkArktsProjectRules(projectRoot, (backendResult.checked_files ?? []).map((file) => path.join(projectRoot, file)), { commandlineTools });
|
|
18
|
+
const merged = new Map();
|
|
19
|
+
for (const item of [...(backendResult.errors ?? []), ...integrity.diagnostics, ...projectRules]) merged.set(arktsDiagnosticKey(item), item);
|
|
20
|
+
return {
|
|
21
|
+
...backendResult,
|
|
22
|
+
tool_status: backendResult.tool_status === "ok" && integrity.tool_status !== "ok" ? integrity.tool_status : backendResult.tool_status,
|
|
23
|
+
success: backendResult.success !== false && integrity.success !== false,
|
|
24
|
+
reason: backendResult.tool_status === "ok" && integrity.tool_status !== "ok" ? integrity.reason : backendResult.reason ?? null,
|
|
25
|
+
errors: [...merged.values()],
|
|
26
|
+
project_integrity: integrity,
|
|
27
|
+
evidence_status: backendResult.evidence_status === "raw_structured" && integrity.evidence_status === "raw_structured" ? "raw_structured" : "partial"
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function runArktsDiff(options) {
|
|
32
|
+
const precheckOutputDir = path.join(options.outputDir, "arkts-precheck");
|
|
33
|
+
await mkdir(precheckOutputDir, { recursive: true });
|
|
34
|
+
const resultPath = path.join(options.outputDir, "arkts-precheck-result.json");
|
|
35
|
+
const summaryPath = path.join(options.outputDir, "arkts-precheck-fix-summary.md");
|
|
36
|
+
const rawOutput = {
|
|
37
|
+
raw_json: path.join(precheckOutputDir, "arkts-raw-diagnostics.json"),
|
|
38
|
+
runner: path.join(precheckOutputDir, "arkts-standalone-check-runner.js"),
|
|
39
|
+
stdout: path.join(precheckOutputDir, "arkts-checker-stdout.txt"),
|
|
40
|
+
stderr: path.join(precheckOutputDir, "arkts-checker-stderr.txt")
|
|
41
|
+
};
|
|
42
|
+
const incremental = Boolean(options.incremental);
|
|
43
|
+
const runStandalone = options.runStandalone ?? runArktsStandalonePrecheck;
|
|
44
|
+
let payload;
|
|
45
|
+
let scopeReceipt = null;
|
|
46
|
+
try {
|
|
47
|
+
const scopePlan = await (options.scopePlan ?? createScopePlan({
|
|
48
|
+
projectRoot: options.projectRoot,
|
|
49
|
+
incremental,
|
|
50
|
+
baseRef: options.baseRef,
|
|
51
|
+
headRef: options.headRef
|
|
52
|
+
}));
|
|
53
|
+
const checkedFiles = scopePlan.checked_files;
|
|
54
|
+
const changedProjectFiles = scopePlan.changed_project_files;
|
|
55
|
+
const changedLineRanges = scopePlan.changed_line_ranges;
|
|
56
|
+
if (incremental) scopeReceipt = {
|
|
57
|
+
changed_project_files: scopePlan.changed_project_files,
|
|
58
|
+
changed_ets_files: scopePlan.changed_ets_files,
|
|
59
|
+
impacted_ets_files: scopePlan.impacted_ets_files,
|
|
60
|
+
impact_basis: scopePlan.impact_basis
|
|
61
|
+
};
|
|
62
|
+
const needsIntegrity = !incremental || changedProjectFiles.length > 0;
|
|
63
|
+
if (!checkedFiles.length && !needsIntegrity) {
|
|
64
|
+
payload = {
|
|
65
|
+
tool: "arkts_standalone_precheck",
|
|
66
|
+
tool_status: "ok",
|
|
67
|
+
success: true,
|
|
68
|
+
mode: incremental ? "diff-working-tree" : "full",
|
|
69
|
+
checked_files: [],
|
|
70
|
+
errors: [],
|
|
71
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
72
|
+
reason: incremental ? "no changed ETS files" : "no ETS files",
|
|
73
|
+
scope: incremental ? "incremental" : "full",
|
|
74
|
+
changed_files_only: incremental,
|
|
75
|
+
changed_line_ranges: {}
|
|
76
|
+
};
|
|
77
|
+
} else if (checkedFiles.length && !options.commandlineTools && options.runStandalone === undefined) {
|
|
78
|
+
payload = {
|
|
79
|
+
tool: "arkts_standalone_precheck",
|
|
80
|
+
tool_status: "unavailable",
|
|
81
|
+
success: false,
|
|
82
|
+
mode: incremental ? "diff-working-tree" : "full",
|
|
83
|
+
checked_files: checkedFiles,
|
|
84
|
+
errors: [],
|
|
85
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
86
|
+
reason: "commandline_tools not configured",
|
|
87
|
+
scope: incremental ? "incremental" : "full",
|
|
88
|
+
changed_files_only: incremental,
|
|
89
|
+
changed_line_ranges: changedLineRanges
|
|
90
|
+
};
|
|
91
|
+
} else {
|
|
92
|
+
const files = checkedFiles.map((file) => path.join(options.projectRoot, file));
|
|
93
|
+
const currentBackend = files.length
|
|
94
|
+
? runStandalone({ projectRoot: options.projectRoot, commandlineTools: options.commandlineTools, outputDir: precheckOutputDir, files })
|
|
95
|
+
: Promise.resolve({ tool: "arkts_standalone_precheck", tool_status: "ok", evidence_status: "raw_structured", checked_files: [], errors: [] });
|
|
96
|
+
const raw = await currentBackend.then((result) => attachProjectIntegrity(options.projectRoot, result, options.commandlineTools));
|
|
97
|
+
const normalizedCheckedFiles = new Set(
|
|
98
|
+
(Array.isArray(raw.checked_files) ? raw.checked_files : []).map((item) => String(item).replace(/\\/g, "/"))
|
|
99
|
+
);
|
|
100
|
+
const rawErrors = (Array.isArray(raw.errors) ? raw.errors : []).filter((item) => {
|
|
101
|
+
const file = String(item.file ?? "").replace(/\\/g, "/");
|
|
102
|
+
return !(file.endsWith(".ets") && normalizedCheckedFiles.size && !normalizedCheckedFiles.has(file));
|
|
103
|
+
});
|
|
104
|
+
const currentErrors = rawErrors;
|
|
105
|
+
const diagnosticScope = incremental ? classifyDiagnosticScope(currentErrors, changedLineRanges) : null;
|
|
106
|
+
const repairErrors = diagnosticScope?.repair_diagnostics ?? currentErrors;
|
|
107
|
+
payload = {
|
|
108
|
+
...raw,
|
|
109
|
+
errors: currentErrors,
|
|
110
|
+
repair_errors: repairErrors,
|
|
111
|
+
summary: {
|
|
112
|
+
errorCount: currentErrors.filter((item) => item.severity === "error").length,
|
|
113
|
+
warnCount: currentErrors.filter((item) => item.severity === "warning").length
|
|
114
|
+
},
|
|
115
|
+
success: raw.tool_status === "ok" && repairErrors.filter((item) => item.default_mode !== "shadow").every((item) => item.severity !== "error"),
|
|
116
|
+
diagnostic_scope: diagnosticScope,
|
|
117
|
+
scope: incremental ? "incremental" : "full",
|
|
118
|
+
changed_files_only: incremental,
|
|
119
|
+
mode: incremental ? "diff-working-tree" : "full",
|
|
120
|
+
changed_line_ranges: changedLineRanges
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
payload = {
|
|
125
|
+
tool: "arkts_standalone_precheck",
|
|
126
|
+
tool_status: "unavailable",
|
|
127
|
+
success: false,
|
|
128
|
+
mode: incremental ? "diff-working-tree" : "full",
|
|
129
|
+
checked_files: [],
|
|
130
|
+
errors: [],
|
|
131
|
+
summary: { errorCount: 0, warnCount: 0 },
|
|
132
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
133
|
+
scope: incremental ? "incremental" : "full",
|
|
134
|
+
changed_files_only: incremental,
|
|
135
|
+
changed_line_ranges: {},
|
|
136
|
+
failure_rule: "git-diff-failed"
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (scopeReceipt) payload.scope_receipt = scopeReceipt;
|
|
140
|
+
payload.artifact_paths = {
|
|
141
|
+
json: resultPath,
|
|
142
|
+
summary: summaryPath,
|
|
143
|
+
raw_json: typeof payload.artifact_paths?.raw_json === "string" ? payload.artifact_paths.raw_json : rawOutput.raw_json,
|
|
144
|
+
runner: typeof payload.artifact_paths?.runner === "string" ? payload.artifact_paths.runner : rawOutput.runner,
|
|
145
|
+
stdout: typeof payload.artifact_paths?.stdout === "string" ? payload.artifact_paths.stdout : rawOutput.stdout,
|
|
146
|
+
stderr: typeof payload.artifact_paths?.stderr === "string" ? payload.artifact_paths.stderr : rawOutput.stderr
|
|
147
|
+
};
|
|
148
|
+
await writeJson(resultPath, payload);
|
|
149
|
+
await writeArktsSummary(payload, summaryPath);
|
|
150
|
+
return payload;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function arktsDiagnosticKey(item) {
|
|
154
|
+
return [item.file, item.line, item.column, item.severity, item.rule, String(item.message ?? "").replace(/\s+/g, " ").trim()]
|
|
155
|
+
.map((value) => String(value ?? ""))
|
|
156
|
+
.join("|");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { runArktsDiff };
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { findJson5Parser, parseStructuredConfig, toolRoots } from "../core/sdk_context.mjs";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const parserCache = new Map();
|
|
8
|
+
|
|
9
|
+
const V1 = new Set(["State", "Prop", "Link", "Provide", "Consume", "ObjectLink", "StorageLink", "StorageProp", "LocalStorageLink", "LocalStorageProp", "BuilderParam"]);
|
|
10
|
+
const V2 = new Set(["Local", "Param", "Once", "Event", "Provider", "Consumer"]);
|
|
11
|
+
const CONTAINERS = new Set("Column Row Stack Flex RelativeContainer GridRow GridCol List Grid Scroll Swiper Tabs Navigation Navigator NavDestination WaterFlow SideBarContainer Refresh FolderStack XComponent Panel Badge ColumnSplit RowSplit FlowItem ListItem ListItemGroup TabContent GridItem Counter AlphabetIndexer Stepper StepperItem EffectComponent RemoteWindow NodeContainer ContentSlot Hyperlink".split(" "));
|
|
12
|
+
const STRUCT = /^(\s*)((?:@\w+(?:\([^)]*\))?\s*)*)(?:export\s+(?:default\s+)?)?struct\s+(\w+)\b/;
|
|
13
|
+
const CLASS = /^(\s*)((?:@\w+(?:\([^)]*\))?\s*)*)(?:export\s+(?:default\s+)?)?class\s+(\w+)\b/;
|
|
14
|
+
|
|
15
|
+
function read(file) { try { return fs.readFileSync(file, "utf8"); } catch { return null; } }
|
|
16
|
+
function inside(root, file) { const relative = path.relative(root, file); return relative && !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative); }
|
|
17
|
+
function diagnostic(root, file, rule, message, line = 1, column = 1) {
|
|
18
|
+
return { file: path.relative(root, file), line, column, severity: "error", rule, message, source_class: "project_rule", default_mode: "shadow" };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function walk(root, predicate) {
|
|
22
|
+
const found = [];
|
|
23
|
+
const visit = (dir) => {
|
|
24
|
+
let entries;
|
|
25
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
if (["node_modules", "oh_modules", "build", ".git"].includes(entry.name)) continue;
|
|
28
|
+
const file = path.join(dir, entry.name);
|
|
29
|
+
if (entry.isDirectory()) visit(file);
|
|
30
|
+
else if (entry.isFile() && predicate(file)) found.push(file);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
visit(root);
|
|
34
|
+
return found;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function findArkTsParser(commandlineTools) {
|
|
38
|
+
const key = commandlineTools ? path.resolve(commandlineTools) : "";
|
|
39
|
+
if (parserCache.has(key)) return parserCache.get(key);
|
|
40
|
+
for (const root of toolRoots(commandlineTools)) {
|
|
41
|
+
try {
|
|
42
|
+
const parser = require(path.join(root, "codelinter/linter/arkPerfCheck/node_modules/arkanalyzer/node_modules/ohos-typescript"));
|
|
43
|
+
if (typeof parser.createSourceFile === "function" && parser.ScriptKind?.ETS !== undefined) {
|
|
44
|
+
parserCache.set(key, parser);
|
|
45
|
+
return parser;
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
// Continue toward the command-line tools root.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
parserCache.set(key, null);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function parseArkTs(parser, file) {
|
|
56
|
+
const source = read(file);
|
|
57
|
+
if (!parser || source === null) return null;
|
|
58
|
+
const parsed = parser.createSourceFile(file, source, parser.ScriptTarget.Latest, true, parser.ScriptKind.ETS);
|
|
59
|
+
return parsed.parseDiagnostics?.length ? null : parsed;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function astDecorators(parser, sourceFile, node) {
|
|
63
|
+
const modifiers = node.modifiers ?? (parser.canHaveModifiers?.(node) ? parser.getModifiers(node) ?? [] : []);
|
|
64
|
+
return modifiers.filter((item) => item.kind === parser.SyntaxKind.Decorator).map((item) => {
|
|
65
|
+
let expression = item.expression;
|
|
66
|
+
if (parser.isCallExpression?.(expression)) expression = expression.expression;
|
|
67
|
+
return parser.isIdentifier?.(expression) ? expression.text : expression.getText(sourceFile);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function selectedFiles(root, files) {
|
|
72
|
+
const candidates = files ?? walk(root, (file) => file.endsWith(".ets") && !file.endsWith(".d.ets") && file.includes(`${path.sep}src${path.sep}main${path.sep}ets${path.sep}`));
|
|
73
|
+
const unique = new Set();
|
|
74
|
+
for (const file of candidates) {
|
|
75
|
+
const absolute = path.resolve(path.isAbsolute(file) ? file : path.join(root, file));
|
|
76
|
+
if (inside(root, absolute) && absolute.endsWith(".ets") && !absolute.endsWith(".d.ets") && absolute.includes(`${path.sep}src${path.sep}main${path.sep}ets${path.sep}`)) unique.add(absolute);
|
|
77
|
+
}
|
|
78
|
+
return [...unique];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function declarations(lines, pattern = STRUCT) {
|
|
82
|
+
const result = [];
|
|
83
|
+
for (let index = 0; index < lines.length; index++) {
|
|
84
|
+
const match = pattern.exec(lines[index]);
|
|
85
|
+
if (match) result.push({ line: index, inline: match[2], name: match[3] });
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function decorators(lines, line, inline = "") {
|
|
91
|
+
const names = new Set();
|
|
92
|
+
for (const match of inline.matchAll(/@(\w+)/g)) names.add(match[1]);
|
|
93
|
+
for (let index = line - 1; index >= 0 && /^\s*@\w+(?:\([^)]*\))?\s*$/.test(lines[index]); index--) {
|
|
94
|
+
names.add(/^\s*@(\w+)/.exec(lines[index])[1]);
|
|
95
|
+
}
|
|
96
|
+
return names;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function modules(root) {
|
|
100
|
+
return walk(root, (file) => file.split(path.sep).slice(-3).join("/") === "src/main/module.json5")
|
|
101
|
+
.map((manifest) => ({ root: path.dirname(path.dirname(path.dirname(manifest))), manifest }));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function registeredPages(root, parseJson5) {
|
|
105
|
+
const pages = new Set();
|
|
106
|
+
for (const module of modules(root)) {
|
|
107
|
+
const manifest = read(module.manifest);
|
|
108
|
+
let profile;
|
|
109
|
+
try {
|
|
110
|
+
const payload = parseStructuredConfig(manifest ?? "", module.manifest, parseJson5);
|
|
111
|
+
const reference = payload.module?.pages;
|
|
112
|
+
profile = typeof reference === "string" && reference.startsWith("$profile:") ? reference.slice(9) : null;
|
|
113
|
+
} catch {
|
|
114
|
+
profile = /pages\s*:\s*["']\$profile:([A-Za-z0-9_]+)["']/.exec(manifest ?? "")?.[1];
|
|
115
|
+
}
|
|
116
|
+
if (!profile) continue;
|
|
117
|
+
const config = read(path.join(module.root, "src/main/resources/base/profile", `${profile}.json`));
|
|
118
|
+
let payload;
|
|
119
|
+
try { payload = JSON.parse(config); } catch { continue; }
|
|
120
|
+
for (const page of Array.isArray(payload.src) ? payload.src : []) {
|
|
121
|
+
if (typeof page !== "string") continue;
|
|
122
|
+
const file = path.resolve(module.root, "src/main/ets", `${page}.ets`);
|
|
123
|
+
if (inside(module.root, file)) pages.add(file);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return pages;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function appResources(root) {
|
|
130
|
+
const names = new Set();
|
|
131
|
+
const kinds = new Set();
|
|
132
|
+
for (const module of modules(root)) {
|
|
133
|
+
const resources = path.join(module.root, "src/main/resources");
|
|
134
|
+
let qualifiers;
|
|
135
|
+
try { qualifiers = fs.readdirSync(resources, { withFileTypes: true }); } catch { continue; }
|
|
136
|
+
for (const qualifier of qualifiers.filter((entry) => entry.isDirectory())) {
|
|
137
|
+
const qualifierRoot = path.join(resources, qualifier.name);
|
|
138
|
+
for (const kind of ["media", "profile"]) {
|
|
139
|
+
let files;
|
|
140
|
+
try { files = fs.readdirSync(path.join(qualifierRoot, kind), { withFileTypes: true }); } catch { continue; }
|
|
141
|
+
kinds.add(kind);
|
|
142
|
+
for (const file of files) if (file.isFile()) names.add(`${kind}.${path.basename(file.name, path.extname(file.name))}`);
|
|
143
|
+
}
|
|
144
|
+
let elements;
|
|
145
|
+
try { elements = fs.readdirSync(path.join(qualifierRoot, "element"), { withFileTypes: true }); } catch { continue; }
|
|
146
|
+
for (const element of elements) {
|
|
147
|
+
if (!element.isFile() || !element.name.endsWith(".json")) continue;
|
|
148
|
+
let payload;
|
|
149
|
+
try { payload = JSON.parse(read(path.join(qualifierRoot, "element", element.name))); } catch { continue; }
|
|
150
|
+
for (const [kind, entries] of Object.entries(payload)) {
|
|
151
|
+
if (!Array.isArray(entries)) continue;
|
|
152
|
+
kinds.add(kind);
|
|
153
|
+
for (const entry of entries) if (entry && typeof entry.name === "string") names.add(`${kind}.${entry.name}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return { names, kinds };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function checkAppResources(root, files) {
|
|
162
|
+
const { names, kinds } = appResources(root);
|
|
163
|
+
if (!names.size) return [];
|
|
164
|
+
const output = [];
|
|
165
|
+
for (const file of files) {
|
|
166
|
+
const source = read(file);
|
|
167
|
+
if (!source) continue;
|
|
168
|
+
for (const [index, line] of source.split("\n").entries()) {
|
|
169
|
+
for (const match of line.matchAll(/\$r\(\s*["']app\.([a-z]+)\.([A-Za-z0-9_]+)["']\s*\)/g)) {
|
|
170
|
+
if (kinds.has(match[1]) && !names.has(`${match[1]}.${match[2]}`)) {
|
|
171
|
+
output.push(diagnostic(root, file, "app-resource-name-check", `Unknown app.${match[1]} resource '${match[2]}'.`, index + 1, match.index + 1));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return output;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function checkPageEntries(root, files, parser, parseJson5) {
|
|
180
|
+
const registered = registeredPages(root, parseJson5);
|
|
181
|
+
const output = [];
|
|
182
|
+
for (const file of files.filter((candidate) => registered.has(candidate))) {
|
|
183
|
+
const sourceFile = parseArkTs(parser, file);
|
|
184
|
+
if (sourceFile) {
|
|
185
|
+
const entries = [];
|
|
186
|
+
for (const node of sourceFile.statements) {
|
|
187
|
+
if (!(parser.isStructDeclaration?.(node) || parser.isClassDeclaration?.(node))) continue;
|
|
188
|
+
if (!astDecorators(parser, sourceFile, node).includes("Entry")) continue;
|
|
189
|
+
entries.push(sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);
|
|
190
|
+
}
|
|
191
|
+
if (entries.length !== 1) output.push(diagnostic(root, file, "page-entry-count", "A registered page must have exactly one '@Entry' decorator.", entries[1] ?? 1));
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const lines = (read(file) ?? "").split("\n");
|
|
195
|
+
const entries = lines.flatMap((line, index) => /^\s*@Entry\b/.test(line) ? [index + 1] : []);
|
|
196
|
+
if (entries.length !== 1) output.push(diagnostic(root, file, "page-entry-count", "A registered page must have exactly one '@Entry' decorator.", entries[1] ?? 1));
|
|
197
|
+
}
|
|
198
|
+
return output;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function checkComponentDecorators(root, files, parser) {
|
|
202
|
+
const output = [];
|
|
203
|
+
for (const file of files) {
|
|
204
|
+
const sourceFile = parseArkTs(parser, file);
|
|
205
|
+
if (sourceFile) {
|
|
206
|
+
for (const node of sourceFile.statements) {
|
|
207
|
+
if (!(parser.isStructDeclaration?.(node) || parser.isClassDeclaration?.(node))) continue;
|
|
208
|
+
const own = new Set(astDecorators(parser, sourceFile, node));
|
|
209
|
+
const invalid = own.has("ComponentV2") ? V1 : own.has("Component") ? V2 : null;
|
|
210
|
+
if (!invalid) continue;
|
|
211
|
+
for (const member of node.members ?? []) {
|
|
212
|
+
for (const decorator of astDecorators(parser, sourceFile, member)) {
|
|
213
|
+
if (!invalid.has(decorator)) continue;
|
|
214
|
+
const line = sourceFile.getLineAndCharacterOfPosition(member.getStart(sourceFile)).line + 1;
|
|
215
|
+
output.push(diagnostic(root, file, "component-decorator-version-mismatch", `Decorator '@${decorator}' is incompatible with '${node.name?.text ?? "component"}'.`, line));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const lines = (read(file) ?? "").split("\n");
|
|
222
|
+
const structs = declarations(lines);
|
|
223
|
+
for (let index = 0; index < structs.length; index++) {
|
|
224
|
+
const struct = structs[index];
|
|
225
|
+
const own = decorators(lines, struct.line, struct.inline);
|
|
226
|
+
const invalid = own.has("ComponentV2") ? V1 : own.has("Component") ? V2 : null;
|
|
227
|
+
if (!invalid) continue;
|
|
228
|
+
for (let line = struct.line + 1; line < (structs[index + 1]?.line ?? lines.length); line++) {
|
|
229
|
+
const member = /^\s*@(\w+)\b/.exec(lines[line]);
|
|
230
|
+
if (member && invalid.has(member[1])) output.push(diagnostic(root, file, "component-decorator-version-mismatch", `Decorator '@${member[1]}' is incompatible with '${struct.name}'.`, line + 1));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return output;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function checkObservedV2(root, files, projectFiles) {
|
|
238
|
+
const observed = new Set(["NavPathStack"]);
|
|
239
|
+
for (const file of projectFiles) {
|
|
240
|
+
const lines = (read(file) ?? "").split("\n");
|
|
241
|
+
for (const item of declarations(lines, CLASS)) if (decorators(lines, item.line, item.inline).has("ObservedV2")) observed.add(item.name);
|
|
242
|
+
}
|
|
243
|
+
const output = [];
|
|
244
|
+
for (const file of files) for (const [index, line] of (read(file) ?? "").split("\n").entries()) {
|
|
245
|
+
const member = /^\s*@(State|Prop|Provide|Consume)\b(?:\([^)]*\))?\s+\w+\s*:\s*([A-Za-z_$][\w$]*)\b/.exec(line);
|
|
246
|
+
if (member && observed.has(member[2])) output.push(diagnostic(root, file, "observed-v2-state-property-type", `ObservedV2 type '${member[2]}' cannot use '@${member[1]}'.`, index + 1));
|
|
247
|
+
}
|
|
248
|
+
return output;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function componentProperties(projectFiles) {
|
|
252
|
+
const components = new Map();
|
|
253
|
+
for (const file of projectFiles) {
|
|
254
|
+
const lines = (read(file) ?? "").split("\n");
|
|
255
|
+
const structs = declarations(lines);
|
|
256
|
+
for (let index = 0; index < structs.length; index++) {
|
|
257
|
+
const struct = structs[index];
|
|
258
|
+
if (!decorators(lines, struct.line, struct.inline).has("ComponentV2")) continue;
|
|
259
|
+
const properties = new Map();
|
|
260
|
+
for (let line = struct.line + 1; line < (structs[index + 1]?.line ?? lines.length); line++) {
|
|
261
|
+
const local = /^\s*@Local\b(?:\([^)]*\))?\s+(?:\w+\s+)*([\w$]+)\s*(?:\?|!)?\s*[:=]/.exec(lines[line]);
|
|
262
|
+
if (local) properties.set(local[1], "local");
|
|
263
|
+
else if (/^\s*@Local(?:\([^)]*\))?\s*$/.test(lines[line]) && line + 1 < (structs[index + 1]?.line ?? lines.length)) {
|
|
264
|
+
const separate = /^\s*(?:private\s+|protected\s+|public\s+|readonly\s+)*([\w$]+)\s*(?:\?|!)?\s*[:=]/.exec(lines[line + 1]);
|
|
265
|
+
if (separate) properties.set(separate[1], "local");
|
|
266
|
+
line += 1;
|
|
267
|
+
}
|
|
268
|
+
else if (!/^\s*@\w+/.test(lines[line]) && !/\b(build|aboutTo\w+)\s*\(/.test(lines[line])) {
|
|
269
|
+
const regular = /^\s*(?:\w+\s+)*([\w$]+)\s*(?:\?|!)?\s*:\s*[^=;]+(?:=|;|$)/.exec(lines[line]);
|
|
270
|
+
if (regular) properties.set(regular[1], "regular");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (properties.size) components.set(struct.name, properties);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return components;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function checkPropertyInitializers(root, files, projectFiles) {
|
|
280
|
+
const components = componentProperties(projectFiles);
|
|
281
|
+
const output = [];
|
|
282
|
+
for (const file of files) {
|
|
283
|
+
const lines = (read(file) ?? "").split("\n");
|
|
284
|
+
for (let index = 0; index < lines.length; index++) {
|
|
285
|
+
const call = /(?:^|[^\w.$])([A-Z][\w$]*)\s*\(\s*\{/.exec(lines[index]);
|
|
286
|
+
const properties = call && components.get(call[1]);
|
|
287
|
+
if (!properties) continue;
|
|
288
|
+
let depth = 1;
|
|
289
|
+
for (let line = index; line < lines.length && depth > 0; line++) {
|
|
290
|
+
const body = lines[line].slice(line === index ? call.index + call[0].length : 0);
|
|
291
|
+
for (const key of body.matchAll(/(?:^|[{,])\s*([\w$]+)\s*:/g)) {
|
|
292
|
+
let keyDepth = depth + (key[0].includes("{") ? 1 : 0);
|
|
293
|
+
for (const character of body.slice(0, key.index)) keyDepth += character === "{" ? 1 : character === "}" ? -1 : 0;
|
|
294
|
+
if (keyDepth === 1 && properties.has(key[1])) output.push(diagnostic(root, file, properties.get(key[1]) === "local" ? "local-property-init" : "regular-property-init", `Property '${key[1]}' cannot be initialized for '${call[1]}'.`, line + 1));
|
|
295
|
+
}
|
|
296
|
+
for (const character of body) depth += character === "{" ? 1 : character === "}" ? -1 : 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return output;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function checkEntryRoots(root, files) {
|
|
304
|
+
const output = [];
|
|
305
|
+
for (const file of files) {
|
|
306
|
+
const lines = (read(file) ?? "").split("\n");
|
|
307
|
+
const structs = declarations(lines);
|
|
308
|
+
for (let index = 0; index < structs.length; index++) {
|
|
309
|
+
const struct = structs[index];
|
|
310
|
+
if (!decorators(lines, struct.line, struct.inline).has("Entry")) continue;
|
|
311
|
+
const end = structs[index + 1]?.line ?? lines.length;
|
|
312
|
+
const relativeBuild = lines.slice(struct.line + 1, end).findIndex((line) => /^\s*build\s*\(\s*\)\s*\{/.test(line));
|
|
313
|
+
const build = relativeBuild < 0 ? -1 : struct.line + 1 + relativeBuild;
|
|
314
|
+
if (build < 0) continue;
|
|
315
|
+
let depth = 1;
|
|
316
|
+
const roots = [];
|
|
317
|
+
for (let line = build + 1; line < end && depth > 0; line++) {
|
|
318
|
+
const root = depth === 1 && /^([A-Z][\w$]*)\s*[({]/.exec(lines[line].trim());
|
|
319
|
+
if (root) roots.push({ name: root[1], line: line + 1 });
|
|
320
|
+
for (const character of lines[line]) depth += character === "{" ? 1 : character === "}" ? -1 : 0;
|
|
321
|
+
}
|
|
322
|
+
if (roots.length !== 1 || !CONTAINERS.has(roots[0].name)) output.push(diagnostic(root, file, "entry-build-root-node", "Entry build must have one container root.", roots[1]?.line ?? roots[0]?.line ?? 1));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return output;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function checkBuilderBodies(root, files) {
|
|
329
|
+
const output = [];
|
|
330
|
+
for (const file of files) {
|
|
331
|
+
const lines = (read(file) ?? "").split("\n");
|
|
332
|
+
for (let start = 0; start < lines.length; start++) {
|
|
333
|
+
const header = /^\s*build\s*\(\s*\)\s*\{/.test(lines[start]) || (/^\s*@Builder\b/.test(lines[start]) && /\)\s*\{/.test(lines[start])) || (/^\s*@Builder\s*$/.test(lines[start - 1] ?? "") && /\)\s*\{/.test(lines[start]));
|
|
334
|
+
if (!header) continue;
|
|
335
|
+
const scopes = ["ui"];
|
|
336
|
+
for (let line = start + 1; line < lines.length && scopes.length; line++) {
|
|
337
|
+
if (scopes.at(-1) === "ui" && (/^\s*(const|let|var)\s+/.test(lines[line]) || /^\s*(for|while|do|switch)\s*[({]/.test(lines[line]))) output.push(diagnostic(root, file, "builder-body-ui-only", "Only UI syntax is allowed directly in a build or Builder body.", line + 1));
|
|
338
|
+
const jsScope = /=>|\bfunction\b/.test(lines[line]);
|
|
339
|
+
for (const character of lines[line]) { if (character === "{") scopes.push(jsScope ? "js" : scopes.at(-1)); else if (character === "}") scopes.pop(); }
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return output;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function checkMemberRules(root, files, parser) {
|
|
347
|
+
const output = [];
|
|
348
|
+
for (const file of files) {
|
|
349
|
+
const lines = (read(file) ?? "").split("\n");
|
|
350
|
+
const sourceFile = parseArkTs(parser, file);
|
|
351
|
+
if (sourceFile) {
|
|
352
|
+
for (const node of sourceFile.statements) {
|
|
353
|
+
if (!(parser.isStructDeclaration?.(node) || parser.isClassDeclaration?.(node))) continue;
|
|
354
|
+
if (!astDecorators(parser, sourceFile, node).includes("ComponentV2")) continue;
|
|
355
|
+
for (const member of node.members ?? []) {
|
|
356
|
+
if (!parser.isPropertyDeclaration?.(member)) continue;
|
|
357
|
+
const own = astDecorators(parser, sourceFile, member);
|
|
358
|
+
if (!own.includes("Param") || own.includes("Require") || member.initializer || member.questionToken) continue;
|
|
359
|
+
const line = sourceFile.getLineAndCharacterOfPosition(member.getStart(sourceFile)).line + 1;
|
|
360
|
+
const name = member.name?.getText(sourceFile) ?? "property";
|
|
361
|
+
output.push(diagnostic(root, file, "param-requires-require", `@Param '${name}' without a default requires @Require.`, line));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
for (const [index, line] of lines.entries()) {
|
|
365
|
+
const functionType = /^\s*@(Prop|Link|State)\b(?:\([^)]*\))?\s+([\w$]+)\s*(?:\?|!)?\s*:\s*(\([^)]*\)\s*=>|Function\b)/.exec(line);
|
|
366
|
+
if (functionType) output.push(diagnostic(root, file, "v1-decorator-function-type", `V1 decorator '@${functionType[1]}' cannot decorate function '${functionType[2]}'.`, index + 1));
|
|
367
|
+
}
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
for (const [index, line] of lines.entries()) {
|
|
371
|
+
const functionType = /^\s*@(Prop|Link|State)\b(?:\([^)]*\))?\s+([\w$]+)\s*(?:\?|!)?\s*:\s*(\([^)]*\)\s*=>|Function\b)/.exec(line);
|
|
372
|
+
if (functionType) output.push(diagnostic(root, file, "v1-decorator-function-type", `V1 decorator '@${functionType[1]}' cannot decorate function '${functionType[2]}'.`, index + 1));
|
|
373
|
+
const param = /^\s*@Param\b(?:\([^)]*\))?\s+([\w$]+)\s*\??\s*:\s*([^=]+)$/.exec(line.replace(/\/\/.*$/, "").trimEnd());
|
|
374
|
+
if (param && !/\?\s*:|@Require\b/.test(line) && !/^\s*@Require\s*$/.test(lines[index - 1] ?? "")) output.push(diagnostic(root, file, "param-requires-require", `@Param '${param[1]}' without a default requires @Require.`, index + 1));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return output;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function checkArktsProjectRules(projectRoot, files, options = {}) {
|
|
381
|
+
const root = path.resolve(projectRoot);
|
|
382
|
+
const selected = selectedFiles(root, files);
|
|
383
|
+
const projectFiles = selectedFiles(root);
|
|
384
|
+
const parser = findArkTsParser(options.commandlineTools);
|
|
385
|
+
const parseJson5 = findJson5Parser(options.commandlineTools);
|
|
386
|
+
return [
|
|
387
|
+
...checkAppResources(root, selected),
|
|
388
|
+
...checkPageEntries(root, selected, parser, parseJson5),
|
|
389
|
+
...checkComponentDecorators(root, selected, parser),
|
|
390
|
+
...checkObservedV2(root, selected, projectFiles),
|
|
391
|
+
...checkPropertyInitializers(root, selected, projectFiles),
|
|
392
|
+
...checkEntryRoots(root, selected),
|
|
393
|
+
...checkBuilderBodies(root, selected),
|
|
394
|
+
...checkMemberRules(root, selected, parser)
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export { checkArktsProjectRules };
|