@buaa_smat/hometrans 0.1.16 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -54
- package/agents/code-reviewer.md +321 -65
- package/agents/logic-coder.md +113 -88
- package/agents/logic-context-builder.md +47 -29
- package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
- package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
- package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
- package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
- package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
- package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
- package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
- package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
- package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
- package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
- package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
- package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
- package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
- package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
- package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
- package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
- package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
- package/agents/scripts/hmos-precheck/index.mjs +17 -0
- package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
- package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
- package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
- package/agents/scripts/platform_query.mjs +626 -0
- package/agents/scripts/platform_query.test.mjs +422 -0
- package/agents/self-test-fixer.md +36 -34
- package/agents/self-tester.md +123 -143
- package/agents/test-case-generation-generator.md +317 -0
- package/agents/test-case-generation-validator.md +231 -0
- package/dist/cli/config-store.js +16 -63
- package/dist/cli/env-vars.js +1 -3
- package/dist/cli/index.js +0 -11
- package/dist/cli/init.js +127 -144
- package/dist/cli/uninstall.js +76 -110
- package/dist/utils/regex.js +8 -0
- package/env-requirements.json +55 -54
- package/package.json +6 -6
- package/resource/convert_pipeline_process.svg +103 -0
- package/resource/project_architecture.svg +122 -0
- package/resource/title_dark.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +345 -41
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
- package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
- package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
- package/skills/hmos-convert-pipeline/SKILL.md +168 -121
- package/skills/hmos-fix-build-errors/SKILL.md +87 -67
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/README.md +53 -36
- package/skills/hmos-incremental-ui-align/SKILL.md +179 -23
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
- package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
- package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
- package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
- package/skills/hmos-integration-test/README.md +61 -70
- package/skills/hmos-integration-test/SKILL.md +128 -111
- package/skills/hmos-resources-convert/SKILL.md +334 -66
- package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
- package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
- package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
- package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
- package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
- package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
- package/skills/hmos-spec-generate/SKILL.md +293 -214
- package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
- package/skills/hmos-spec-generate/template/REQ.txt +22 -0
- package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
- package/skills/hmos-test-case-generation/README.md +241 -0
- package/skills/hmos-test-case-generation/SKILL.md +324 -0
- package/skills/hmos-test-case-generation/references/contract.md +315 -0
- package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
- package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
- package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
- package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
- package/tools/bfs-crawl/README.md +73 -0
- package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
- package/tools/test-tools/autotest/config.ts +175 -0
- package/tools/test-tools/autotest/deps/autotest-agent-0.1.1.tgz +0 -0
- package/tools/test-tools/autotest/docs/README.md +266 -0
- package/tools/test-tools/autotest/{testcases_schema.md → docs/testcases_schema.md} +1 -1
- package/tools/test-tools/autotest/engine/batch-launcher.ts +327 -0
- package/tools/test-tools/autotest/engine/report-tool.ts +773 -0
- package/tools/test-tools/autotest/engine/self-test-runner.ts +961 -0
- package/tools/test-tools/autotest/engine/testcases-tool.ts +246 -0
- package/tools/test-tools/autotest/paths.ts +41 -0
- package/tools/test-tools/autotest/resolve-metadata-tool.ts +143 -0
- package/tools/test-tools/autotest/runner/logger.ts +45 -0
- package/tools/test-tools/autotest/runner/process-utils.ts +41 -0
- package/tools/test-tools/autotest/validate.ts +167 -0
- package/agents/build-fixer.md +0 -385
- package/agents/logic-coder/scripts/platform_context_query.py +0 -568
- package/agents/review-fixer.md +0 -405
- package/agents/spec-generator.md +0 -541
- package/dist/cli/mcp-setup.js +0 -258
- package/dist/cli/mcp.js +0 -94
- package/dist/context/index.js +0 -694
- package/resource/migration_process.svg +0 -94
- package/resource/migration_process_transparent.svg +0 -93
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
- package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
- package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
- package/skills/hmos-resources-convert/evals/evals.json +0 -171
- package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
- package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
- package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
- package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
- package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
- package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
- package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
- package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
- package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
- package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
- package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/tools/apktool.bat +0 -85
- package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
- package/tools/test-tools/autotest/README.md +0 -238
- package/tools/test-tools/autotest/pyproject.toml +0 -26
- package/tools/test-tools/autotest/report_tool.py +0 -759
- package/tools/test-tools/autotest/self_test_runner.py +0 -895
- package/tools/test-tools/autotest/testcases_tool.py +0 -215
- package/tools/test-tools/autotest/uv.lock +0 -3156
- package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { clearArtifacts, exists, runProcess } from "../core/process_adapter.mjs";
|
|
4
|
+
import { createScopePlan } from "../core/scope_plan.mjs";
|
|
5
|
+
import { candidateRoots } from "../core/sdk_context.mjs";
|
|
6
|
+
async function findCodelinterTool(commandlineTools) {
|
|
7
|
+
if (!commandlineTools) return null;
|
|
8
|
+
const suffixes = process.platform.startsWith("win") ? ["codelinter.bat", "codelinter.cmd"] : ["codelinter"];
|
|
9
|
+
const candidates = [];
|
|
10
|
+
for (const root of candidateRoots(commandlineTools)) {
|
|
11
|
+
for (const suffix of suffixes) {
|
|
12
|
+
candidates.push(
|
|
13
|
+
path.join(root, "bin", suffix),
|
|
14
|
+
path.join(root, "codelinter", "bin", suffix)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (const candidate of candidates) {
|
|
19
|
+
if (await exists(candidate)) return path.resolve(candidate);
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function lineInRanges(line, ranges) {
|
|
24
|
+
if (line === null) return false;
|
|
25
|
+
return ranges.some(([start, end]) => start <= line && line <= end);
|
|
26
|
+
}
|
|
27
|
+
function normalizeSeverity(value) {
|
|
28
|
+
const severity = String(value ?? "").toLowerCase();
|
|
29
|
+
return severity === "warn" ? "warning" : severity;
|
|
30
|
+
}
|
|
31
|
+
function relativeFile(projectRoot, rawPath) {
|
|
32
|
+
const absolute = path.isAbsolute(rawPath) ? rawPath : path.resolve(projectRoot, rawPath);
|
|
33
|
+
if (!absolute.startsWith(path.resolve(projectRoot) + path.sep)) {
|
|
34
|
+
return rawPath.replace(/\\/g, "/");
|
|
35
|
+
}
|
|
36
|
+
return path.relative(projectRoot, absolute).replace(/\\/g, "/");
|
|
37
|
+
}
|
|
38
|
+
async function parseReport(reportPath) {
|
|
39
|
+
if (!await exists(reportPath)) return [];
|
|
40
|
+
try {
|
|
41
|
+
const payload = JSON.parse(await readFile(reportPath, "utf8"));
|
|
42
|
+
if (Array.isArray(payload)) return payload.filter((item) => item && typeof item === "object");
|
|
43
|
+
if (payload && typeof payload === "object" && (typeof payload.filePath === "string" || typeof payload.file === "string") && Array.isArray(payload.messages)) return [payload];
|
|
44
|
+
return null;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function writeSummary(payload, pathname, maxFindings = 30) {
|
|
50
|
+
const diagnostics = Array.isArray(payload.diagnostics) ? payload.diagnostics : [];
|
|
51
|
+
const errors = diagnostics.filter((item) => item.severity === "error");
|
|
52
|
+
const warnings = diagnostics.filter((item) => item.severity === "warning");
|
|
53
|
+
const suggestions = diagnostics.filter((item) => item.severity === "suggestion");
|
|
54
|
+
const lines = [
|
|
55
|
+
"# CodeLinter Diff Summary",
|
|
56
|
+
"",
|
|
57
|
+
`- status: ${String(payload.tool_status ?? "")}`,
|
|
58
|
+
`- checked_files: ${Array.isArray(payload.checked_files) ? payload.checked_files.length : 0}`,
|
|
59
|
+
`- errors: ${errors.length}`,
|
|
60
|
+
`- warnings_hidden_from_fixer: ${warnings.length}`,
|
|
61
|
+
`- suggestions_hidden_from_fixer: ${suggestions.length}`,
|
|
62
|
+
"",
|
|
63
|
+
"## Blocking Errors"
|
|
64
|
+
];
|
|
65
|
+
if (!errors.length) lines.push("- none");
|
|
66
|
+
for (const item of errors.slice(0, maxFindings)) {
|
|
67
|
+
lines.push(`- ${String(item.file ?? "<unknown>")}:${String(item.line ?? "?")}:${String(item.column ?? "?")} [${String(item.rule || "no-rule")}] ${String(item.message ?? "")}`);
|
|
68
|
+
}
|
|
69
|
+
await writeFile(pathname, `${lines.join("\n")}
|
|
70
|
+
`, "utf8");
|
|
71
|
+
}
|
|
72
|
+
function unavailable(reason, checkedFiles, changedLineRanges, elapsedMs, failureRule) {
|
|
73
|
+
const payload = {
|
|
74
|
+
tool: "codelinter",
|
|
75
|
+
tool_status: "unavailable",
|
|
76
|
+
evidence_status: "partial",
|
|
77
|
+
success: false,
|
|
78
|
+
checked_files: checkedFiles,
|
|
79
|
+
diagnostics: [],
|
|
80
|
+
summary: { errorCount: 0, warnCount: 0, suggestionCount: 0 },
|
|
81
|
+
reason,
|
|
82
|
+
scope: "diff",
|
|
83
|
+
changed_files_only: true,
|
|
84
|
+
changed_line_ranges: Object.fromEntries(Object.entries(changedLineRanges).map(([file, ranges]) => [file, ranges.map(([start, end]) => [start, end])]))
|
|
85
|
+
};
|
|
86
|
+
if (failureRule) payload.failure_rule = failureRule;
|
|
87
|
+
if (elapsedMs !== void 0) payload.elapsed_ms = elapsedMs;
|
|
88
|
+
return payload;
|
|
89
|
+
}
|
|
90
|
+
function buildArtifactPaths(derivedPath, rawPath, summaryPath, stdoutPath, stderrPath) {
|
|
91
|
+
return {
|
|
92
|
+
json: derivedPath,
|
|
93
|
+
raw_json: rawPath,
|
|
94
|
+
summary: summaryPath,
|
|
95
|
+
stdout: stdoutPath,
|
|
96
|
+
stderr: stderrPath
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function diagnosticsFromReport(parsedReport, projectRoot, checkedFileList, changedLineRanges, incremental) {
|
|
100
|
+
const diagnostics = [];
|
|
101
|
+
const checkedFiles = new Set(checkedFileList);
|
|
102
|
+
let malformed = false;
|
|
103
|
+
for (const entry of parsedReport) {
|
|
104
|
+
const relative = relativeFile(projectRoot, String(entry.filePath ?? entry.file ?? ""));
|
|
105
|
+
if (!checkedFiles.has(relative)) continue;
|
|
106
|
+
const ranges = changedLineRanges[relative];
|
|
107
|
+
if (entry.messages !== void 0 && !Array.isArray(entry.messages)) {
|
|
108
|
+
malformed = true;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
for (const rawMessage of Array.isArray(entry.messages) ? entry.messages : []) {
|
|
112
|
+
if (!rawMessage || typeof rawMessage !== "object" || Array.isArray(rawMessage)) {
|
|
113
|
+
malformed = true;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const message = rawMessage;
|
|
117
|
+
const line = message.line == null ? null : Number(message.line);
|
|
118
|
+
diagnostics.push({
|
|
119
|
+
file: relative,
|
|
120
|
+
line,
|
|
121
|
+
column: message.column == null ? null : Number(message.column),
|
|
122
|
+
severity: normalizeSeverity(message.severity),
|
|
123
|
+
message: String(message.message ?? ""),
|
|
124
|
+
rule: String(message.rule ?? ""),
|
|
125
|
+
outside_changed_lines: Boolean(incremental && (!Array.isArray(ranges) || !lineInRanges(line, ranges)))
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { diagnostics, checkedFiles: [...checkedFiles].sort(), malformed };
|
|
130
|
+
}
|
|
131
|
+
async function runCodelinterDiffScan(options) {
|
|
132
|
+
const started = Date.now();
|
|
133
|
+
const incremental = Boolean(options.incremental_scope);
|
|
134
|
+
const rawReportPath = path.join(options.validationOutputDir, "codelinter-raw-report.json");
|
|
135
|
+
const derivedReportPath = path.join(options.validationOutputDir, "codelinter-derived.json");
|
|
136
|
+
const stdoutPath = path.join(options.validationOutputDir, "codelinter-stdout.txt");
|
|
137
|
+
const stderrPath = path.join(options.validationOutputDir, "codelinter-stderr.txt");
|
|
138
|
+
const summaryPath = path.join(options.validationOutputDir, "codelinter-fix-summary.md");
|
|
139
|
+
await mkdir(options.validationOutputDir, { recursive: true });
|
|
140
|
+
await clearArtifacts(rawReportPath, derivedReportPath, stdoutPath, stderrPath, summaryPath);
|
|
141
|
+
let payload;
|
|
142
|
+
try {
|
|
143
|
+
const scopePlan = await (options.scopePlan ?? createScopePlan({
|
|
144
|
+
projectRoot: options.projectRoot,
|
|
145
|
+
incremental,
|
|
146
|
+
baseRef: options.baseRef ?? "HEAD",
|
|
147
|
+
headRef: options.headRef ?? null
|
|
148
|
+
}));
|
|
149
|
+
const files = scopePlan.checked_files.map((file) => path.resolve(options.projectRoot, file));
|
|
150
|
+
const changedLineRanges = scopePlan.changed_line_ranges;
|
|
151
|
+
if (!files.length) {
|
|
152
|
+
payload = {
|
|
153
|
+
tool: "codelinter",
|
|
154
|
+
tool_status: "ok",
|
|
155
|
+
success: true,
|
|
156
|
+
checked_files: [],
|
|
157
|
+
diagnostics: [],
|
|
158
|
+
summary: { errorCount: 0, warnCount: 0, suggestionCount: 0 },
|
|
159
|
+
reason: incremental ? "no changed ETS files" : "no ETS files",
|
|
160
|
+
scope: incremental ? "incremental" : "full",
|
|
161
|
+
changed_files_only: incremental,
|
|
162
|
+
changed_line_ranges: {}
|
|
163
|
+
};
|
|
164
|
+
} else {
|
|
165
|
+
const codelinter = await findCodelinterTool(options.commandlineTools);
|
|
166
|
+
const checkedFileList = files.map((file) => path.relative(options.projectRoot, file).replace(/\\/g, "/"));
|
|
167
|
+
if (!codelinter) {
|
|
168
|
+
payload = unavailable("codelinter not found", checkedFileList, changedLineRanges, void 0, "codelinter-missing");
|
|
169
|
+
} else {
|
|
170
|
+
const command = [
|
|
171
|
+
"--format",
|
|
172
|
+
"json",
|
|
173
|
+
"--output",
|
|
174
|
+
rawReportPath,
|
|
175
|
+
"--exit-on",
|
|
176
|
+
"error"
|
|
177
|
+
];
|
|
178
|
+
if (incremental) command.push("--incremental");
|
|
179
|
+
command.push(...checkedFileList);
|
|
180
|
+
const result = await runProcess(codelinter, command, { cwd: options.projectRoot, timeoutSeconds: options.timeoutSeconds ?? 30 });
|
|
181
|
+
await writeFile(stdoutPath, result.stdout || "", "utf8");
|
|
182
|
+
await writeFile(stderrPath, result.stderr || "", "utf8");
|
|
183
|
+
if (result.timedOut) {
|
|
184
|
+
payload = unavailable(`codelinter timed out after ${options.timeoutSeconds ?? 30}s`, checkedFileList, changedLineRanges, Date.now() - started, "codelinter-timeout");
|
|
185
|
+
payload.incremental = incremental;
|
|
186
|
+
payload.timeout_seconds = options.timeoutSeconds ?? 30;
|
|
187
|
+
} else {
|
|
188
|
+
const parsedReport = await parseReport(rawReportPath);
|
|
189
|
+
if (parsedReport === null) {
|
|
190
|
+
payload = unavailable("codelinter produced an unreadable JSON report", checkedFileList, changedLineRanges, Date.now() - started, "codelinter-report-invalid");
|
|
191
|
+
payload.exit_code = result.code;
|
|
192
|
+
payload.incremental = incremental;
|
|
193
|
+
payload.timeout_seconds = options.timeoutSeconds ?? 30;
|
|
194
|
+
} else {
|
|
195
|
+
const { diagnostics, checkedFiles, malformed } = diagnosticsFromReport(parsedReport, options.projectRoot, checkedFileList, changedLineRanges, incremental);
|
|
196
|
+
if (malformed) {
|
|
197
|
+
payload = unavailable("codelinter produced a malformed JSON report", checkedFileList, changedLineRanges, Date.now() - started, "codelinter-report-invalid");
|
|
198
|
+
payload.exit_code = result.code;
|
|
199
|
+
payload.incremental = incremental;
|
|
200
|
+
payload.timeout_seconds = options.timeoutSeconds ?? 30;
|
|
201
|
+
} else {
|
|
202
|
+
const toolStatus = await exists(rawReportPath) ? "ok" : "internal_error";
|
|
203
|
+
payload = {
|
|
204
|
+
tool: "codelinter",
|
|
205
|
+
tool_status: toolStatus,
|
|
206
|
+
evidence_status: toolStatus === "ok" ? "raw_structured" : "partial",
|
|
207
|
+
success: toolStatus === "ok" && !diagnostics.some((item) => item.severity === "error"),
|
|
208
|
+
checked_files: checkedFiles,
|
|
209
|
+
diagnostics,
|
|
210
|
+
summary: {
|
|
211
|
+
errorCount: diagnostics.filter((item) => item.severity === "error").length,
|
|
212
|
+
warnCount: diagnostics.filter((item) => item.severity === "warning").length,
|
|
213
|
+
suggestionCount: diagnostics.filter((item) => item.severity === "suggestion").length
|
|
214
|
+
},
|
|
215
|
+
reason: toolStatus === "ok" ? null : `codelinter exited without report (exit_code=${result.code})`,
|
|
216
|
+
failure_rule: toolStatus === "ok" ? null : "codelinter-report-missing",
|
|
217
|
+
scope: incremental ? "incremental" : "full",
|
|
218
|
+
changed_files_only: incremental,
|
|
219
|
+
changed_line_ranges: Object.fromEntries(Object.entries(changedLineRanges).map(([file, ranges]) => [file, ranges.map(([start, end]) => [start, end])])),
|
|
220
|
+
exit_code: result.code,
|
|
221
|
+
elapsed_ms: Date.now() - started,
|
|
222
|
+
incremental,
|
|
223
|
+
timeout_seconds: options.timeoutSeconds ?? 30
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} catch (error) {
|
|
231
|
+
payload = unavailable(
|
|
232
|
+
error instanceof Error ? error.message : String(error),
|
|
233
|
+
[],
|
|
234
|
+
{},
|
|
235
|
+
Date.now() - started,
|
|
236
|
+
"git-diff-failed"
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
payload.scope = incremental ? "incremental" : "full";
|
|
240
|
+
payload.changed_files_only = incremental;
|
|
241
|
+
payload.artifact_paths = buildArtifactPaths(derivedReportPath, rawReportPath, summaryPath, stdoutPath, stderrPath);
|
|
242
|
+
await writeFile(derivedReportPath, `${JSON.stringify(payload, null, 2)}
|
|
243
|
+
`, "utf8");
|
|
244
|
+
await writeSummary(payload, summaryPath);
|
|
245
|
+
return payload;
|
|
246
|
+
}
|
|
247
|
+
export {
|
|
248
|
+
findCodelinterTool,
|
|
249
|
+
runCodelinterDiffScan
|
|
250
|
+
};
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { access, readFile, readdir } from "node:fs/promises";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
5
|
+
import { discoverProjectModules } from "../core/project_catalog.mjs";
|
|
6
|
+
import { findJson5Parser, toolRoots } from "../core/sdk_context.mjs";
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
const ignored = new Set(["node_modules", "oh_modules", "build", ".cache", ".git"]);
|
|
11
|
+
const routeKeys = new Set(["name", "pageSourceFile", "buildFunction", "data", "customData"]);
|
|
12
|
+
const requiredRouteKeys = ["name", "pageSourceFile", "buildFunction"];
|
|
13
|
+
|
|
14
|
+
async function exists(pathname) {
|
|
15
|
+
try {
|
|
16
|
+
await access(pathname);
|
|
17
|
+
return true;
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function readConfig(pathname, parseJson5 = null) {
|
|
24
|
+
const text = await readFile(pathname, "utf8");
|
|
25
|
+
if (parseJson5) {
|
|
26
|
+
try {
|
|
27
|
+
return parseJson5(text);
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const errors = [];
|
|
33
|
+
const value = parseJsonc(text, errors, { allowTrailingComma: true, disallowComments: false });
|
|
34
|
+
return errors.length ? null : value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function loadSdkContext(commandlineTools) {
|
|
38
|
+
const parseJson5 = findJson5Parser(commandlineTools);
|
|
39
|
+
let ts = null;
|
|
40
|
+
let permissionsPath = null;
|
|
41
|
+
let userGrantPath = null;
|
|
42
|
+
for (const root of toolRoots(commandlineTools)) {
|
|
43
|
+
const typescriptPath = path.join(root, "codelinter", "node_modules", "typescript", "lib", "typescript.js");
|
|
44
|
+
if (!ts && await exists(typescriptPath)) ts = require(typescriptPath);
|
|
45
|
+
for (const candidate of [
|
|
46
|
+
path.join(root, "openharmony", "ets", "api", "permissions.d.ts"),
|
|
47
|
+
path.join(root, "sdk", "default", "openharmony", "ets", "api", "permissions.d.ts")
|
|
48
|
+
]) if (!permissionsPath && await exists(candidate)) permissionsPath = candidate;
|
|
49
|
+
const grantCandidate = path.join(root, "hvigor", "hvigor-ohos-plugin", "res", "permissions", "userGrantPermissions.json");
|
|
50
|
+
if (!userGrantPath && await exists(grantCandidate)) userGrantPath = grantCandidate;
|
|
51
|
+
}
|
|
52
|
+
const allPermissions = new Set();
|
|
53
|
+
if (ts && permissionsPath) {
|
|
54
|
+
const source = ts.createSourceFile(permissionsPath, await readFile(permissionsPath, "utf8"), ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
|
|
55
|
+
const visit = (node) => {
|
|
56
|
+
if (ts.isTypeAliasDeclaration(node) && node.name.text === "Permissions") {
|
|
57
|
+
const collect = (child) => {
|
|
58
|
+
if (ts.isLiteralTypeNode(child) && ts.isStringLiteral(child.literal)) allPermissions.add(child.literal.text);
|
|
59
|
+
ts.forEachChild(child, collect);
|
|
60
|
+
};
|
|
61
|
+
collect(node.type);
|
|
62
|
+
}
|
|
63
|
+
ts.forEachChild(node, visit);
|
|
64
|
+
};
|
|
65
|
+
visit(source);
|
|
66
|
+
}
|
|
67
|
+
let userGrantPermissions = new Set();
|
|
68
|
+
if (userGrantPath) {
|
|
69
|
+
const payload = JSON.parse(await readFile(userGrantPath, "utf8"));
|
|
70
|
+
userGrantPermissions = new Set(Array.isArray(payload.userGrantPermissions) ? payload.userGrantPermissions : []);
|
|
71
|
+
}
|
|
72
|
+
return { parseJson5, allPermissions, userGrantPermissions };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function relative(projectRoot, pathname) {
|
|
76
|
+
return path.relative(projectRoot, pathname).replace(/\\/g, "/");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function diagnostic(projectRoot, file, rule, message, line = 1) {
|
|
80
|
+
return { file: relative(projectRoot, file), line, column: 1, severity: "error", rule, message };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function lineOf(text, value, fallback = 1) {
|
|
84
|
+
const index = text.indexOf(JSON.stringify(value));
|
|
85
|
+
return index < 0 ? fallback : text.slice(0, index).split(/\r?\n/).length;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function profileFiles(moduleRoot) {
|
|
89
|
+
const resources = path.join(moduleRoot, "src", "main", "resources");
|
|
90
|
+
if (!await exists(resources)) return [];
|
|
91
|
+
const files = [];
|
|
92
|
+
for (const qualifier of await readdir(resources, { withFileTypes: true })) {
|
|
93
|
+
if (!qualifier.isDirectory()) continue;
|
|
94
|
+
const profile = path.join(resources, qualifier.name, "profile");
|
|
95
|
+
if (!await exists(profile)) continue;
|
|
96
|
+
for (const entry of await readdir(profile, { withFileTypes: true })) {
|
|
97
|
+
if (entry.isFile() && ["main_pages.json", "route_map.json", "router_map.json"].includes(entry.name)) files.push(path.join(profile, entry.name));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return files.sort();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function resourceNames(moduleRoot, parseJson5) {
|
|
104
|
+
const resources = path.join(moduleRoot, "src", "main", "resources");
|
|
105
|
+
const names = new Set();
|
|
106
|
+
if (!await exists(resources)) return names;
|
|
107
|
+
for (const qualifier of await readdir(resources, { withFileTypes: true })) {
|
|
108
|
+
if (!qualifier.isDirectory()) continue;
|
|
109
|
+
const base = path.join(resources, qualifier.name);
|
|
110
|
+
for (const kind of ["media", "profile"] ) {
|
|
111
|
+
const directory = path.join(base, kind);
|
|
112
|
+
if (!await exists(directory)) continue;
|
|
113
|
+
for (const file of await readdir(directory, { withFileTypes: true })) {
|
|
114
|
+
if (file.isFile()) names.add(`${kind}:${file.name.replace(/\.[^.]+$/, "")}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const element = path.join(base, "element");
|
|
118
|
+
if (!await exists(element)) continue;
|
|
119
|
+
for (const file of await readdir(element, { withFileTypes: true })) {
|
|
120
|
+
if (!file.isFile() || !file.name.endsWith(".json")) continue;
|
|
121
|
+
const payload = await readConfig(path.join(element, file.name), parseJson5);
|
|
122
|
+
if (!payload || typeof payload !== "object") continue;
|
|
123
|
+
for (const [kind, entries] of Object.entries(payload)) {
|
|
124
|
+
if (!Array.isArray(entries)) continue;
|
|
125
|
+
entries.filter((entry) => entry && typeof entry.name === "string").forEach((entry) => names.add(`${kind}:${entry.name}`));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return names;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function collectResourceReferences(value, output = []) {
|
|
133
|
+
if (typeof value === "string") {
|
|
134
|
+
const match = /^\$(profile|string|media|color|float|integer|boolean|intarray|strarray|pattern|plural|symbol):(.+)$/.exec(value);
|
|
135
|
+
if (match) output.push({ kind: match[1], name: match[2] });
|
|
136
|
+
} else if (Array.isArray(value)) {
|
|
137
|
+
value.forEach((item) => collectResourceReferences(item, output));
|
|
138
|
+
} else if (value && typeof value === "object") {
|
|
139
|
+
Object.values(value).forEach((item) => collectResourceReferences(item, output));
|
|
140
|
+
}
|
|
141
|
+
return output;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function targetPath(moduleRoot, sourceFile) {
|
|
145
|
+
if (typeof sourceFile !== "string" || !sourceFile) return null;
|
|
146
|
+
const normalized = sourceFile.endsWith(".ets") ? sourceFile : `${sourceFile}.ets`;
|
|
147
|
+
const candidate = normalized.startsWith("src/")
|
|
148
|
+
? path.resolve(moduleRoot, normalized)
|
|
149
|
+
: path.resolve(moduleRoot, "src", "main", "ets", normalized);
|
|
150
|
+
return candidate.startsWith(moduleRoot + path.sep) ? candidate : null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function checkProjectIntegrity(projectRoot, options = {}) {
|
|
154
|
+
const root = path.resolve(projectRoot);
|
|
155
|
+
const sdk = await loadSdkContext(options.commandlineTools);
|
|
156
|
+
const diagnostics = [];
|
|
157
|
+
const checkedFiles = [];
|
|
158
|
+
const unverifiedBuildFunctions = [];
|
|
159
|
+
let permissionCatalogRequired = false;
|
|
160
|
+
const roots = (await discoverProjectModules(root)).modules.map((item) => item.module_root);
|
|
161
|
+
const manifests = new Map();
|
|
162
|
+
for (const moduleRoot of roots) {
|
|
163
|
+
const manifestPath = path.join(moduleRoot, "src", "main", "module.json5");
|
|
164
|
+
checkedFiles.push(relative(root, manifestPath));
|
|
165
|
+
let manifest = null;
|
|
166
|
+
try {
|
|
167
|
+
manifest = await readConfig(manifestPath, sdk.parseJson5);
|
|
168
|
+
} catch {
|
|
169
|
+
manifest = null;
|
|
170
|
+
}
|
|
171
|
+
if (!manifest) {
|
|
172
|
+
diagnostics.push(diagnostic(root, manifestPath, "project-config-json", "module.json5 is not valid structured JSON5"));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
manifests.set(moduleRoot, manifest);
|
|
176
|
+
const module = manifest.module && typeof manifest.module === "object" ? manifest.module : {};
|
|
177
|
+
const resources = await resourceNames(moduleRoot, sdk.parseJson5);
|
|
178
|
+
const { requestPermissions: _requestPermissions, ...manifestResourceFields } = module;
|
|
179
|
+
for (const reference of collectResourceReferences(manifestResourceFields)) {
|
|
180
|
+
if (!resources.has(`${reference.kind}:${reference.name}`)) {
|
|
181
|
+
diagnostics.push(diagnostic(root, manifestPath, reference.kind === "profile" ? "module-profile-exists" : "manifest-resource-reference-exists", `Referenced $${reference.kind}:${reference.name} does not exist in this module`));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const abilities = Array.isArray(module.abilities) ? module.abilities : [];
|
|
185
|
+
for (const ability of abilities) {
|
|
186
|
+
if (!ability || typeof ability !== "object" || typeof ability.srcEntry !== "string") continue;
|
|
187
|
+
const target = path.resolve(moduleRoot, "src", "main", ability.srcEntry);
|
|
188
|
+
if (!target.startsWith(path.join(moduleRoot, "src", "main") + path.sep) || !await exists(target)) {
|
|
189
|
+
diagnostics.push(diagnostic(root, manifestPath, "module-ability-src-entry-exists", `Ability '${String(ability.name ?? "")}' srcEntry '${ability.srcEntry}' does not exist in this module`));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (typeof module.mainElement === "string" && !abilities.some((ability) => ability?.name === module.mainElement)) {
|
|
193
|
+
diagnostics.push(diagnostic(root, manifestPath, "module-main-element-exists", `mainElement '${module.mainElement}' does not match a declared ability`));
|
|
194
|
+
}
|
|
195
|
+
const customPermissions = new Set((Array.isArray(module.definePermissions) ? module.definePermissions : [])
|
|
196
|
+
.map((item) => item?.name).filter((name) => typeof name === "string"));
|
|
197
|
+
const requestedPermissions = Array.isArray(module.requestPermissions) ? module.requestPermissions : [];
|
|
198
|
+
if (requestedPermissions.some((permission) => permission?.name && !customPermissions.has(permission.name) && !sdk.allPermissions.size)) {
|
|
199
|
+
permissionCatalogRequired = true;
|
|
200
|
+
}
|
|
201
|
+
if (sdk.allPermissions.size) {
|
|
202
|
+
for (const permission of requestedPermissions) {
|
|
203
|
+
if (!permission || typeof permission.name !== "string") continue;
|
|
204
|
+
const line = lineOf(await readFile(manifestPath, "utf8"), permission.name);
|
|
205
|
+
if (!sdk.allPermissions.has(permission.name) && !customPermissions.has(permission.name)) {
|
|
206
|
+
diagnostics.push(diagnostic(root, manifestPath, "permission-name-exists", `Unknown permission '${permission.name}'`, line));
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (!sdk.userGrantPermissions.has(permission.name)) continue;
|
|
210
|
+
if (typeof permission.reason !== "string" || !permission.reason.startsWith("$string:")) {
|
|
211
|
+
diagnostics.push(diagnostic(root, manifestPath, "permission-reason-required", `user_grant permission '${permission.name}' requires a $string: reason`, line));
|
|
212
|
+
} else if (!resources.has(`string:${permission.reason.slice("$string:".length)}`)) {
|
|
213
|
+
diagnostics.push(diagnostic(root, manifestPath, "permission-reason-resource", `Permission reason '${permission.reason}' does not exist in this module`, line));
|
|
214
|
+
}
|
|
215
|
+
const scene = permission.usedScene;
|
|
216
|
+
if (!scene || ((!Array.isArray(scene.abilities) || !scene.abilities.length) && scene.when === undefined)) {
|
|
217
|
+
diagnostics.push({ ...diagnostic(root, manifestPath, "permission-usedscene-recommended", `user_grant permission '${permission.name}' has no usedScene`, line), severity: "warning" });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
for (const file of await profileFiles(moduleRoot)) {
|
|
222
|
+
checkedFiles.push(relative(root, file));
|
|
223
|
+
let payload;
|
|
224
|
+
let text = "";
|
|
225
|
+
try {
|
|
226
|
+
text = await readFile(file, "utf8");
|
|
227
|
+
payload = JSON.parse(text);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
const rule = path.basename(file) === "main_pages.json" ? "project-config-json" : "route-map-json";
|
|
230
|
+
diagnostics.push(diagnostic(root, file, rule, `Invalid project JSON: ${error instanceof Error ? error.message : String(error)}`));
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (path.basename(file) === "main_pages.json") {
|
|
234
|
+
if (!payload || !Array.isArray(payload.src)) {
|
|
235
|
+
diagnostics.push(diagnostic(root, file, "project-config-json", "main_pages.json must contain a src array"));
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
for (const [index, page] of (Array.isArray(payload.src) ? payload.src : []).entries()) {
|
|
239
|
+
const target = targetPath(moduleRoot, page);
|
|
240
|
+
if (!target || !await exists(target)) diagnostics.push(diagnostic(root, file, "page-file-exists", `Registered page '${String(page)}' does not exist in this module`, lineOf(text, page, index + 1)));
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (!payload || !Array.isArray(payload.routerMap)) {
|
|
245
|
+
diagnostics.push(diagnostic(root, file, "route-map-schema", "route map must contain a routerMap array"));
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const entries = payload.routerMap;
|
|
249
|
+
for (const [index, entry] of entries.entries()) {
|
|
250
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
251
|
+
diagnostics.push(diagnostic(root, file, "route-map-schema", `routerMap[${index}] must be an object`, index + 1));
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
for (const key of Object.keys(entry)) {
|
|
255
|
+
if (!routeKeys.has(key)) diagnostics.push(diagnostic(root, file, "route-map-schema", `routerMap[${index}] has unknown property '${key}'`, lineOf(text, key, index + 1)));
|
|
256
|
+
}
|
|
257
|
+
for (const key of requiredRouteKeys) {
|
|
258
|
+
if (!(key in entry)) diagnostics.push(diagnostic(root, file, "route-map-schema", `routerMap[${index}] is missing '${key}'`, lineOf(text, entry.name, index + 1)));
|
|
259
|
+
}
|
|
260
|
+
if (typeof entry.pageSourceFile === "string") {
|
|
261
|
+
const target = targetPath(moduleRoot, entry.pageSourceFile);
|
|
262
|
+
if (!target || !await exists(target)) diagnostics.push(diagnostic(root, file, "route-target-exists", `Route '${String(entry.name)}' source '${entry.pageSourceFile}' does not exist in this module`, lineOf(text, entry.pageSourceFile, index + 1)));
|
|
263
|
+
}
|
|
264
|
+
if (typeof entry.buildFunction === "string" && typeof entry.pageSourceFile === "string") {
|
|
265
|
+
unverifiedBuildFunctions.push({ file: relative(root, file), route: String(entry.name ?? ""), build_function: entry.buildFunction });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const buildProfile = path.join(root, "build-profile.json5");
|
|
271
|
+
if (await exists(buildProfile)) {
|
|
272
|
+
checkedFiles.push(relative(root, buildProfile));
|
|
273
|
+
const profile = await readConfig(buildProfile, sdk.parseJson5);
|
|
274
|
+
if (!profile) {
|
|
275
|
+
diagnostics.push(diagnostic(root, buildProfile, "project-config-json", "build-profile.json5 is not valid structured JSON5"));
|
|
276
|
+
} else {
|
|
277
|
+
for (const entry of Array.isArray(profile.modules) ? profile.modules : []) {
|
|
278
|
+
if (!entry || typeof entry !== "object" || typeof entry.srcPath !== "string") continue;
|
|
279
|
+
const moduleRoot = path.resolve(root, entry.srcPath);
|
|
280
|
+
const manifestPath = path.join(moduleRoot, "src", "main", "module.json5");
|
|
281
|
+
if ((moduleRoot !== root && !moduleRoot.startsWith(root + path.sep)) || !await exists(manifestPath)) {
|
|
282
|
+
diagnostics.push(diagnostic(root, buildProfile, "build-profile-module-path-exists", `Module '${String(entry.name ?? "")}' srcPath '${entry.srcPath}' has no src/main/module.json5`));
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
const manifest = manifests.get(moduleRoot) ?? await readConfig(manifestPath, sdk.parseJson5);
|
|
286
|
+
if (typeof entry.name === "string" && manifest?.module?.name !== entry.name) {
|
|
287
|
+
diagnostics.push(diagnostic(root, buildProfile, "build-profile-module-name-match", `Module name '${entry.name}' does not match manifest name '${String(manifest?.module?.name ?? "")}'`));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const hvigorConfig = path.join(root, "hvigor", "hvigor-config.json5");
|
|
293
|
+
const ohPackage = path.join(root, "oh-package.json5");
|
|
294
|
+
if (await exists(hvigorConfig) && await exists(ohPackage)) {
|
|
295
|
+
checkedFiles.push(relative(root, hvigorConfig), relative(root, ohPackage));
|
|
296
|
+
const [hvigor, oh] = await Promise.all([readConfig(hvigorConfig, sdk.parseJson5), readConfig(ohPackage, sdk.parseJson5)]);
|
|
297
|
+
if (typeof hvigor?.modelVersion === "string" && typeof oh?.modelVersion === "string" && hvigor.modelVersion !== oh.modelVersion) {
|
|
298
|
+
diagnostics.push(diagnostic(root, hvigorConfig, "model-version-consistency", `modelVersion '${hvigor.modelVersion}' does not match oh-package.json5 '${oh.modelVersion}'`, lineOf(await readFile(hvigorConfig, "utf8"), hvigor.modelVersion)));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const errorCount = diagnostics.filter((item) => item.severity === "error").length;
|
|
302
|
+
const warnCount = diagnostics.filter((item) => item.severity === "warning").length;
|
|
303
|
+
const permissionCatalogUnavailable = permissionCatalogRequired && !sdk.allPermissions.size;
|
|
304
|
+
return {
|
|
305
|
+
tool: "project_integrity",
|
|
306
|
+
tool_status: permissionCatalogUnavailable ? "unavailable" : "ok",
|
|
307
|
+
evidence_status: permissionCatalogUnavailable ? "partial" : "raw_structured",
|
|
308
|
+
success: errorCount === 0 && !permissionCatalogUnavailable,
|
|
309
|
+
checked_files: [...new Set(checkedFiles)].sort(),
|
|
310
|
+
diagnostics,
|
|
311
|
+
coverage: {
|
|
312
|
+
unverified_build_functions: unverifiedBuildFunctions,
|
|
313
|
+
permission_catalog: sdk.allPermissions.size ? "checked" : "unavailable",
|
|
314
|
+
permission_catalog_required: permissionCatalogRequired
|
|
315
|
+
},
|
|
316
|
+
summary: { errorCount, warnCount },
|
|
317
|
+
reason: permissionCatalogUnavailable ? "permission catalog unavailable; permission rules not checked" : null
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export { checkProjectIntegrity };
|