@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.
Files changed (235) hide show
  1. package/README.md +162 -54
  2. package/agents/code-reviewer.md +321 -65
  3. package/agents/logic-coder.md +113 -88
  4. package/agents/logic-context-builder.md +47 -29
  5. package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
  6. package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
  7. package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
  8. package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
  9. package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
  10. package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
  11. package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
  12. package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
  13. package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
  14. package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
  15. package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
  16. package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
  17. package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
  18. package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
  19. package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
  20. package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
  21. package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
  22. package/agents/scripts/hmos-precheck/index.mjs +17 -0
  23. package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
  24. package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
  25. package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
  26. package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
  27. package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
  28. package/agents/scripts/platform_query.mjs +626 -0
  29. package/agents/scripts/platform_query.test.mjs +422 -0
  30. package/agents/self-test-fixer.md +36 -34
  31. package/agents/self-tester.md +123 -143
  32. package/agents/test-case-generation-generator.md +317 -0
  33. package/agents/test-case-generation-validator.md +231 -0
  34. package/dist/cli/config-store.js +16 -63
  35. package/dist/cli/env-vars.js +1 -3
  36. package/dist/cli/index.js +0 -11
  37. package/dist/cli/init.js +127 -144
  38. package/dist/cli/uninstall.js +76 -110
  39. package/dist/utils/regex.js +8 -0
  40. package/env-requirements.json +55 -54
  41. package/package.json +6 -6
  42. package/resource/convert_pipeline_process.svg +103 -0
  43. package/resource/project_architecture.svg +122 -0
  44. package/resource/title_dark.png +0 -0
  45. package/skills/hmos-batch-ui-align/SKILL.md +345 -41
  46. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
  47. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  48. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  49. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  61. 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
  62. 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
  63. 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
  64. 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
  65. 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
  66. 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
  67. 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
  68. 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
  69. 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
  70. 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
  71. 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
  72. 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
  73. 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
  74. 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
  75. 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
  76. 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
  77. 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
  78. 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
  79. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
  80. package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
  81. package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
  82. package/skills/hmos-convert-pipeline/SKILL.md +168 -121
  83. package/skills/hmos-fix-build-errors/SKILL.md +87 -67
  84. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
  85. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
  86. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
  87. package/skills/hmos-incremental-ui-align/README.md +53 -36
  88. package/skills/hmos-incremental-ui-align/SKILL.md +179 -23
  89. package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
  90. package/skills/hmos-incremental-ui-align/page_align.md +62 -62
  91. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
  92. 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
  93. 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
  94. 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
  95. 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
  96. 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
  97. 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
  98. 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
  99. 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
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. 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
  106. 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
  107. 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
  108. 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
  109. 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
  110. 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
  111. 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
  112. 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
  113. 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
  114. 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
  115. 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
  116. 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
  117. 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
  118. 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
  119. 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
  120. package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
  121. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
  122. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  123. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  124. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  125. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
  126. package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
  127. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
  128. package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
  129. package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
  130. package/skills/hmos-integration-test/README.md +61 -70
  131. package/skills/hmos-integration-test/SKILL.md +128 -111
  132. package/skills/hmos-resources-convert/SKILL.md +334 -66
  133. package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
  134. package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
  135. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
  136. package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
  137. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
  138. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
  139. package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
  140. package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
  141. package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
  142. package/skills/hmos-spec-generate/SKILL.md +293 -214
  143. package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
  144. package/skills/hmos-spec-generate/template/REQ.txt +22 -0
  145. package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
  146. package/skills/hmos-test-case-generation/README.md +241 -0
  147. package/skills/hmos-test-case-generation/SKILL.md +324 -0
  148. package/skills/hmos-test-case-generation/references/contract.md +315 -0
  149. package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
  150. package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
  151. package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
  152. package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
  153. package/tools/bfs-crawl/README.md +73 -0
  154. package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
  155. package/tools/test-tools/autotest/config.ts +175 -0
  156. package/tools/test-tools/autotest/deps/autotest-agent-0.1.1.tgz +0 -0
  157. package/tools/test-tools/autotest/docs/README.md +266 -0
  158. package/tools/test-tools/autotest/{testcases_schema.md → docs/testcases_schema.md} +1 -1
  159. package/tools/test-tools/autotest/engine/batch-launcher.ts +327 -0
  160. package/tools/test-tools/autotest/engine/report-tool.ts +773 -0
  161. package/tools/test-tools/autotest/engine/self-test-runner.ts +961 -0
  162. package/tools/test-tools/autotest/engine/testcases-tool.ts +246 -0
  163. package/tools/test-tools/autotest/paths.ts +41 -0
  164. package/tools/test-tools/autotest/resolve-metadata-tool.ts +143 -0
  165. package/tools/test-tools/autotest/runner/logger.ts +45 -0
  166. package/tools/test-tools/autotest/runner/process-utils.ts +41 -0
  167. package/tools/test-tools/autotest/validate.ts +167 -0
  168. package/agents/build-fixer.md +0 -385
  169. package/agents/logic-coder/scripts/platform_context_query.py +0 -568
  170. package/agents/review-fixer.md +0 -405
  171. package/agents/spec-generator.md +0 -541
  172. package/dist/cli/mcp-setup.js +0 -258
  173. package/dist/cli/mcp.js +0 -94
  174. package/dist/context/index.js +0 -694
  175. package/resource/migration_process.svg +0 -94
  176. package/resource/migration_process_transparent.svg +0 -93
  177. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
  178. package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
  179. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
  180. package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
  181. package/skills/hmos-resources-convert/evals/evals.json +0 -171
  182. package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
  183. package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
  184. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
  185. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
  186. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
  187. package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
  188. package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
  189. package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
  190. package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
  191. package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
  192. package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
  193. package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
  194. package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
  195. package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
  196. package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
  197. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
  198. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
  199. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
  200. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
  201. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
  202. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
  203. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
  204. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
  205. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
  206. package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
  207. package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
  208. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
  209. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
  210. package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
  211. package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
  212. package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
  213. package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
  214. package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
  215. package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
  216. package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
  217. package/skills/hmos-resources-convert/tools/apktool.bat +0 -85
  218. package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
  219. package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
  220. package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
  221. package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
  222. package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
  223. package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
  224. package/tools/test-tools/autotest/README.md +0 -238
  225. package/tools/test-tools/autotest/pyproject.toml +0 -26
  226. package/tools/test-tools/autotest/report_tool.py +0 -759
  227. package/tools/test-tools/autotest/self_test_runner.py +0 -895
  228. package/tools/test-tools/autotest/testcases_tool.py +0 -215
  229. package/tools/test-tools/autotest/uv.lock +0 -3156
  230. package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
  231. package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
  232. package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
  233. package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
  234. package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
  235. package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
@@ -1,694 +0,0 @@
1
- import { createRequire as _htCreateRequire } from 'module'; const require = _htCreateRequire(import.meta.url);
2
-
3
- // src/context/index.ts
4
- import path4 from "node:path";
5
- import {
6
- CallGraph as CallGraph2,
7
- CallGraphBuilder,
8
- Scene as Scene2,
9
- SceneConfig
10
- } from "arkanalyzer";
11
-
12
- // src/cli/config-store.ts
13
- import { readFileSync } from "node:fs";
14
- import path from "node:path";
15
- import os from "node:os";
16
- function getConfigDir() {
17
- return path.join(os.homedir(), ".hometrans");
18
- }
19
- function getConfigPath() {
20
- return path.join(getConfigDir(), "config.json");
21
- }
22
- function readConfigEnvFieldSync(key) {
23
- try {
24
- const raw = readFileSync(getConfigPath(), "utf-8");
25
- const parsed = JSON.parse(raw);
26
- const v = parsed?.env?.[key];
27
- return typeof v === "string" ? v : "";
28
- } catch {
29
- return "";
30
- }
31
- }
32
- function expandHome(p) {
33
- if (!p) return p;
34
- if (p === "~") return os.homedir();
35
- if (p.startsWith("~/") || p.startsWith("~\\")) {
36
- return path.join(os.homedir(), p.slice(2));
37
- }
38
- return p;
39
- }
40
-
41
- // src/context/analysis/ArkTsGitInfoAnalysis.ts
42
- import {
43
- AbstractInvokeExpr,
44
- ArkAssignStmt,
45
- CallGraphNode,
46
- ArkInvokeStmt,
47
- fetchDependenciesFromFile,
48
- FunctionType,
49
- parseJsonText
50
- } from "arkanalyzer";
51
- import path3 from "path";
52
- import fs2 from "fs";
53
-
54
- // src/context/utils/util.ts
55
- import LoggerMod, { LOG_MODULE_TYPE } from "arkanalyzer/lib/utils/logger.js";
56
- import path2 from "path";
57
- import fs from "fs";
58
- var Logger = LoggerMod.default ?? LoggerMod;
59
- var logger = Logger.getLogger(LOG_MODULE_TYPE.DEFAULT, "util");
60
- function safePush(target, source, maxBatchSize = 1e4) {
61
- for (let i = 0; i < source.length; i += maxBatchSize) {
62
- const batch = source.slice(i, i + maxBatchSize);
63
- target.push(...batch);
64
- }
65
- }
66
- function getAllFiles(dirPath, exts, filenameArr = [], visited = /* @__PURE__ */ new Set()) {
67
- if (!fs.existsSync(dirPath)) {
68
- logger.error(`'${dirPath}' is not exist, please check!`);
69
- return filenameArr;
70
- }
71
- const realSrc = fs.realpathSync(dirPath);
72
- if (visited.has(realSrc)) {
73
- return filenameArr;
74
- }
75
- visited.add(realSrc);
76
- fs.readdirSync(realSrc).forEach((fileName) => {
77
- if (shouldSkipFile(fileName)) {
78
- return;
79
- }
80
- const realFile = path2.resolve(realSrc, fileName);
81
- if (fs.statSync(realFile).isDirectory()) {
82
- getAllFiles(realFile, exts, filenameArr, visited);
83
- } else {
84
- if (exts.length === 0) {
85
- filenameArr.push(realFile);
86
- } else if (shouldAddFile(realFile, exts)) {
87
- filenameArr.push(realFile);
88
- }
89
- }
90
- });
91
- return filenameArr;
92
- }
93
- function shouldSkipFile(fileName) {
94
- return ["oh_modules", "node_modules", "hvigorfile.ts", "ohosTest"].includes(fileName);
95
- }
96
- function shouldAddFile(filePath, exts) {
97
- if (exts.length === 0) {
98
- return true;
99
- }
100
- const ext = path2.extname(filePath).toLowerCase();
101
- return exts.includes(ext);
102
- }
103
- function getFilePath(parts) {
104
- return path2.join(...parts);
105
- }
106
- function toUnixPath(p) {
107
- return p.replace(/\\/g, "/");
108
- }
109
-
110
- // src/context/analysis/ArkTsGitInfoAnalysis.ts
111
- var ModuleDependency = class {
112
- moduleName;
113
- modulePath;
114
- pluralJsons;
115
- stringJsons;
116
- strArrayJsons;
117
- };
118
- var Resource = class {
119
- resource = /* @__PURE__ */ new Map();
120
- };
121
- var GitItem = class {
122
- mode;
123
- path;
124
- lineInterval;
125
- contentAfter;
126
- contentBefore;
127
- };
128
- var ArkTsGitInfoAnalysis = class {
129
- scene;
130
- mode;
131
- callGraph;
132
- originLines;
133
- copiedLines;
134
- dependencyFileDict = /* @__PURE__ */ new Map();
135
- dependencyResourceMap = /* @__PURE__ */ new Map();
136
- gitItem;
137
- moduleDependencies;
138
- modulePathDependenciesMap = /* @__PURE__ */ new Map();
139
- maxCallDepth = 2;
140
- analysis = (arkFile, gitItem, callGraph, mode) => {
141
- this.callGraph = callGraph;
142
- this.mode = mode;
143
- this.originLines = arkFile.getCode().split("\n");
144
- let copiedLinesInDict = this.dependencyFileDict.get(arkFile);
145
- if (!copiedLinesInDict) {
146
- this.copiedLines = new Array(this.originLines.length);
147
- this.dependencyFileDict.set(arkFile, this.copiedLines);
148
- } else {
149
- this.copiedLines = copiedLinesInDict;
150
- }
151
- this.gitItem = gitItem;
152
- this.scene = arkFile.getScene();
153
- const modulePath = arkFile.getModuleScene().getModulePath();
154
- if (this.modulePathDependenciesMap.has(modulePath)) {
155
- this.moduleDependencies = this.modulePathDependenciesMap.get(modulePath);
156
- } else {
157
- this.moduleDependencies = /* @__PURE__ */ new Map();
158
- this.getModuleDependency(arkFile.getModuleScene().getModulePath());
159
- this.modulePathDependenciesMap.set(modulePath, this.moduleDependencies);
160
- }
161
- this.analysisFileStructureTree(arkFile);
162
- for (let i = gitItem.lineInterval[0]; i <= gitItem.lineInterval[1]; i++) {
163
- if (this.copiedLines[i - 1] === void 0) {
164
- this.copiedLines[i - 1] = this.originLines[i - 1];
165
- }
166
- }
167
- return this.dependencyFileDict;
168
- };
169
- getModuleDependency(modulePath) {
170
- let OhPkgFilePath = path3.join(modulePath, "oh-package.json5");
171
- console.log(`modulePath ${modulePath} OhPkgFilePath ${OhPkgFilePath}`);
172
- let libOhPkgContent = fetchDependenciesFromFile(OhPkgFilePath);
173
- let dependencies = libOhPkgContent.dependencies;
174
- console.dir(dependencies, { depth: null });
175
- if (!dependencies) {
176
- return;
177
- }
178
- Object.entries(dependencies).forEach(([key, value]) => {
179
- if (key.startsWith("@ohos") && value.startsWith("file:")) {
180
- const targetModulePath = path3.resolve(modulePath, value.replace("file:", ""));
181
- if (!this.moduleDependencies.has(targetModulePath)) {
182
- const targetModuleResourcePath = path3.join(targetModulePath, "src", "main", "resources");
183
- const moduleDependency = new ModuleDependency();
184
- moduleDependency.moduleName = key.replace("@ohos/", "");
185
- moduleDependency.modulePath = targetModulePath;
186
- moduleDependency.pluralJsons = this.loadJsonResources(targetModuleResourcePath, "plural.json");
187
- moduleDependency.strArrayJsons = this.loadJsonResources(targetModuleResourcePath, "strarray.json");
188
- moduleDependency.stringJsons = this.loadJsonResources(targetModuleResourcePath, "string.json");
189
- this.moduleDependencies.set(moduleDependency.modulePath, moduleDependency);
190
- this.getModuleDependency(targetModulePath);
191
- }
192
- }
193
- });
194
- }
195
- resolveAnonymousMethod(arkMethod, arkClass) {
196
- let callStmtStartLine = arkMethod.getLine();
197
- let callStmtEndLine = this.getEndLine(callStmtStartLine, arkMethod.getCode());
198
- let outerArkMethod = arkMethod.getOuterMethod();
199
- while (outerArkMethod && outerArkMethod.getName().startsWith("%AM")) {
200
- arkMethod = outerArkMethod;
201
- outerArkMethod = arkMethod.getOuterMethod();
202
- }
203
- if (outerArkMethod) {
204
- if (outerArkMethod.getName() === "%instInit") {
205
- let targetArkField;
206
- for (let arkField of arkClass.getFields()) {
207
- const stmts = arkField.getInitializer() ?? [];
208
- for (let stmt of stmts) {
209
- if (stmt instanceof ArkAssignStmt) {
210
- const rightOp = stmt.getRightOp();
211
- let type = rightOp.getType();
212
- if (type instanceof FunctionType && type.getMethodSignature() === arkMethod.getSignature()) {
213
- arkMethod = this.scene.getMethod(type.getMethodSignature());
214
- targetArkField = arkField;
215
- callStmtStartLine = targetArkField.getOriginPosition().getLineNo();
216
- callStmtEndLine = this.getEndLine(callStmtStartLine, targetArkField.getCode());
217
- break;
218
- }
219
- }
220
- }
221
- if (targetArkField) {
222
- break;
223
- }
224
- }
225
- } else if (outerArkMethod.getName() === "%dflt") {
226
- let locals = outerArkMethod.getBody().getLocals();
227
- locals.forEach((local, str) => {
228
- let stmt = local.getDeclaringStmt();
229
- if (stmt instanceof ArkAssignStmt) {
230
- const rightOp = stmt.getRightOp();
231
- let type = rightOp.getType();
232
- if (type instanceof FunctionType && type.getMethodSignature() === arkMethod.getSignature()) {
233
- arkMethod = this.scene.getMethod(type.getMethodSignature());
234
- callStmtStartLine = stmt.getOriginPositionInfo().getLineNo();
235
- callStmtEndLine = this.getEndLine(callStmtStartLine, stmt.getOriginalText());
236
- }
237
- }
238
- });
239
- } else {
240
- callStmtStartLine = outerArkMethod.getLine();
241
- callStmtEndLine = this.getEndLine(callStmtStartLine, outerArkMethod.getCode());
242
- }
243
- }
244
- return { arkMethod, startLine: callStmtStartLine, endLine: callStmtEndLine };
245
- }
246
- copyClassHeader(arkClass, copiedLines, originLines, includeMinLine) {
247
- let classStartLine = arkClass.getLine();
248
- let classEndLine = this.getEndLine(classStartLine, arkClass.getCode());
249
- let minLineNumber = classEndLine;
250
- if (arkClass.getFields().length !== 0) {
251
- let fields = arkClass.getFields();
252
- fields.sort((a, b) => a.getOriginPosition().getLineNo() - b.getOriginPosition().getLineNo());
253
- let firstFieldLine = fields[0].getOriginPosition().getLineNo();
254
- minLineNumber = Math.min(firstFieldLine, minLineNumber);
255
- }
256
- if (arkClass.getMethods().length !== 0) {
257
- let methods = arkClass.getMethods();
258
- methods = methods.filter((method) => this.isMethodValid(method)).sort((a, b) => a.getLine() - b.getLine());
259
- if (methods.length !== 0) {
260
- let firstMethodLine = methods[0].getLine();
261
- if (firstMethodLine !== void 0 && firstMethodLine !== null) {
262
- minLineNumber = Math.min(firstMethodLine, minLineNumber);
263
- }
264
- }
265
- }
266
- const end = includeMinLine ? minLineNumber : minLineNumber - 1;
267
- for (let i = classStartLine; i <= end; i++) {
268
- copiedLines[i - 1] = originLines[i - 1];
269
- }
270
- copiedLines[classEndLine - 1] = originLines[classEndLine - 1];
271
- }
272
- loadJsonResources(resourcePath, fileName) {
273
- const jsonItems = [];
274
- const results = getAllFiles(resourcePath, [fileName]);
275
- for (const result of results) {
276
- const configText = fs2.readFileSync(result, "utf8");
277
- const json = parseJsonText(configText);
278
- jsonItems.push({ path: result, content: json });
279
- }
280
- return jsonItems;
281
- }
282
- getEndLine(startLine, code) {
283
- return startLine + (code ? code.split("\n").length - 1 : 0);
284
- }
285
- isMethodValid(method) {
286
- return !(method.getName() === "constructor" && method.getCode() === "") && method.getLine() !== -1 && method.getCode() !== void 0;
287
- }
288
- analysisFileStructureTree(arkFile) {
289
- let arkClasses = arkFile.getClasses().filter((cls) => cls.getName() === "%dflt" || !cls.getName().startsWith("%"));
290
- for (const arkClass of arkClasses) {
291
- if (arkClass.getName() === "%dflt") {
292
- this.analysisClassStructureTree(arkClass);
293
- } else {
294
- let classStartLine = arkClass.getLine();
295
- if (classStartLine === -1) {
296
- this.analysisClassStructureTree(arkClass);
297
- } else {
298
- let classEndLine = this.getEndLine(classStartLine, arkClass.getCode());
299
- let classLineInterval = [classStartLine, classEndLine];
300
- if (!(classLineInterval[0] > this.gitItem.lineInterval[1] || classLineInterval[1] < this.gitItem.lineInterval[0])) {
301
- this.copyClassHeader(arkClass, this.copiedLines, this.originLines, false);
302
- this.analysisClassStructureTree(arkClass);
303
- }
304
- }
305
- }
306
- }
307
- }
308
- getInvokeExprFromStmt(stmt) {
309
- if (stmt instanceof ArkInvokeStmt) {
310
- return stmt.getInvokeExpr();
311
- } else if (stmt instanceof ArkAssignStmt) {
312
- const rightOp = stmt.getRightOp();
313
- if (rightOp instanceof AbstractInvokeExpr) {
314
- return rightOp;
315
- }
316
- }
317
- }
318
- analysisMethodResource(method) {
319
- const stmts = method.getBody()?.getCfg().getStmts();
320
- if (!stmts) {
321
- return;
322
- }
323
- for (let stmt of stmts) {
324
- const invokeExpr = this.getInvokeExprFromStmt(stmt);
325
- if (!invokeExpr) {
326
- continue;
327
- }
328
- const invokeSignature = invokeExpr.getMethodSignature();
329
- let clazz = method.getDeclaringArkClass();
330
- let methodName = invokeSignature.getMethodSubSignature().getMethodName();
331
- let moduleName = clazz.getDeclaringArkFile().getModuleName();
332
- if (moduleName === void 0) {
333
- continue;
334
- }
335
- if (methodName === "$r") {
336
- const resourceLabel = invokeExpr.getArgs()[0].toString().slice(1, -1);
337
- const array = resourceLabel.split(".");
338
- if (array.length === 3) {
339
- const scope = array[0];
340
- if (scope !== "app") {
341
- continue;
342
- }
343
- const category = array[1];
344
- const name = array[2];
345
- for (const moduleDependency of this.moduleDependencies.values()) {
346
- if (category === "string" && moduleDependency.stringJsons.length !== 0) {
347
- for (const jsonItem of moduleDependency.stringJsons) {
348
- this.extracted(jsonItem, name);
349
- }
350
- } else if (category === "strarray" && moduleDependency.strArrayJsons.length !== 0) {
351
- for (const jsonItem of moduleDependency.strArrayJsons) {
352
- this.extracted(jsonItem, name);
353
- }
354
- } else if (category === "plural" && moduleDependency.pluralJsons.length !== 0) {
355
- for (const jsonItem of moduleDependency.pluralJsons) {
356
- this.extracted(jsonItem, name);
357
- }
358
- }
359
- }
360
- }
361
- }
362
- }
363
- }
364
- extracted(jsonItem, name) {
365
- for (const descriptor of jsonItem.content["string"]) {
366
- if (descriptor["name"] === name) {
367
- let stringResourceItem = this.dependencyResourceMap.get(jsonItem.path);
368
- if (!stringResourceItem) {
369
- stringResourceItem = new Resource();
370
- }
371
- if (!stringResourceItem.resource.has(name)) {
372
- stringResourceItem.resource.set(name, descriptor);
373
- this.dependencyResourceMap.set(jsonItem.path, stringResourceItem);
374
- }
375
- return true;
376
- }
377
- }
378
- return false;
379
- }
380
- analysisClassStructureTree(arkClass) {
381
- let callgraph = this.callGraph;
382
- let arkMethods = arkClass.getMethods();
383
- for (let arkMethod of arkMethods) {
384
- let methodStartLine = arkMethod.getLine();
385
- let methodEndLine = this.getEndLine(methodStartLine, arkMethod.getCode());
386
- let methodLineInterval = [];
387
- methodLineInterval = [methodStartLine, methodEndLine];
388
- if (!(methodLineInterval[0] > this.gitItem.lineInterval[1] || methodLineInterval[1] < this.gitItem.lineInterval[0])) {
389
- let callStmtStartLine = arkMethod.getLine();
390
- let callStmtEndLine = this.getEndLine(callStmtStartLine, arkMethod.getCode());
391
- if (arkMethod.getName().startsWith("%AM")) {
392
- const resolved = this.resolveAnonymousMethod(arkMethod, arkClass);
393
- arkMethod = resolved.arkMethod;
394
- callStmtStartLine = resolved.startLine;
395
- callStmtEndLine = resolved.endLine;
396
- }
397
- if (this.isMethodValid(arkMethod)) {
398
- for (let i = callStmtStartLine; i <= callStmtEndLine; i++) {
399
- this.copiedLines[i - 1] = this.originLines[i - 1];
400
- }
401
- }
402
- this.analysisMethodResource(arkMethod);
403
- if (this.mode === "default") {
404
- let invokeStmts = callgraph.getInvokeStmtByMethod(arkMethod.getSignature());
405
- if (invokeStmts) {
406
- for (let invokeStmt of invokeStmts) {
407
- let dstMethod = invokeStmt.getCfg().getDeclaringMethod();
408
- console.log(`[caller] ${arkMethod.getSignature()} is called by ${dstMethod.getSignature()} in ${dstMethod.getDeclaringArkClass().getDeclaringArkFile().getName()}`);
409
- this.analysisCallArkFile(dstMethod, 1);
410
- }
411
- }
412
- let setEdges = callgraph.getCallGraphNodeByMethod(arkMethod.getSignature()).getOutgoingEdges();
413
- if (setEdges) {
414
- setEdges.forEach((edge) => {
415
- let dst = edge.getDstNode();
416
- if (dst instanceof CallGraphNode && !dst.isSdkMethod()) {
417
- let dstMethodSignature = dst.getMethod();
418
- let dstMethod = this.scene.getMethod(dstMethodSignature);
419
- console.log(`[callee] ${arkMethod.getSignature()} calls ${dstMethodSignature} in ${dstMethod.getDeclaringArkClass().getDeclaringArkFile().getName()}`);
420
- this.analysisCallArkFile(dstMethod, 1);
421
- }
422
- });
423
- }
424
- }
425
- }
426
- }
427
- }
428
- analysisCallArkFile = (arkMethod, currentDepth = 1) => {
429
- let arkClass = arkMethod.getDeclaringArkClass();
430
- let callArkFile = arkClass.getDeclaringArkFile();
431
- let originLines = callArkFile.getCode().split("\n");
432
- let copiedLines = this.dependencyFileDict.get(callArkFile);
433
- if (!copiedLines) {
434
- copiedLines = new Array(originLines.length);
435
- this.dependencyFileDict.set(callArkFile, copiedLines);
436
- }
437
- if (arkClass.getName() != "%dlft") {
438
- this.copyClassHeader(arkClass, copiedLines, originLines, true);
439
- }
440
- let callStmtStartLine = arkMethod.getLine();
441
- let callStmtEndLine = this.getEndLine(callStmtStartLine, arkMethod.getCode());
442
- if (arkMethod.getName().startsWith("%AM")) {
443
- const resolved = this.resolveAnonymousMethod(arkMethod, arkClass);
444
- arkMethod = resolved.arkMethod;
445
- callStmtStartLine = resolved.startLine;
446
- callStmtEndLine = resolved.endLine;
447
- }
448
- if (this.isMethodValid(arkMethod)) {
449
- for (let i = callStmtStartLine; i <= callStmtEndLine; ++i) {
450
- copiedLines[i - 1] = originLines[i - 1];
451
- }
452
- }
453
- if (this.mode === "default" && currentDepth < this.maxCallDepth) {
454
- let invokeStmts = this.callGraph.getInvokeStmtByMethod(arkMethod.getSignature());
455
- if (invokeStmts) {
456
- for (let invokeStmt of invokeStmts) {
457
- let dstMethod = invokeStmt.getCfg().getDeclaringMethod();
458
- console.log(`[caller][depth=${currentDepth}] ${arkMethod.getSignature()} is called by ${dstMethod.getSignature()} in ${dstMethod.getDeclaringArkClass().getDeclaringArkFile().getName()}`);
459
- this.analysisCallArkFile(dstMethod, currentDepth + 1);
460
- }
461
- }
462
- let setEdges = this.callGraph.getCallGraphNodeByMethod(arkMethod.getSignature()).getOutgoingEdges();
463
- if (setEdges) {
464
- setEdges.forEach((edge) => {
465
- let dst = edge.getDstNode();
466
- if (dst instanceof CallGraphNode && !dst.isSdkMethod()) {
467
- let dstMethodSignature = dst.getMethod();
468
- let dstMethod = this.scene.getMethod(dstMethodSignature);
469
- console.log(`[callee][depth=${currentDepth}] ${arkMethod.getSignature()} calls ${dstMethodSignature} in ${dstMethod.getDeclaringArkClass().getDeclaringArkFile().getName()}`);
470
- this.analysisCallArkFile(dstMethod, currentDepth + 1);
471
- }
472
- });
473
- }
474
- }
475
- return copiedLines;
476
- };
477
- };
478
-
479
- // src/context/git/GitDiffExtractor.ts
480
- import simpleGit from "simple-git";
481
- var ALLOWED_EXTS = [".ets", ".ts", ".c", ".cpp", ".h", ".hpp"];
482
- function hasAllowedExt(filePath) {
483
- if (!filePath) return false;
484
- const lower = filePath.toLowerCase();
485
- return ALLOWED_EXTS.some((ext) => lower.endsWith(ext));
486
- }
487
- function normalize(content) {
488
- return content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/-\n textPara/g, "-\n textPara");
489
- }
490
- function parseNameStatus(raw) {
491
- const out = [];
492
- if (!raw) return out;
493
- for (const rawLine of raw.split("\n")) {
494
- const line = rawLine.trim();
495
- if (!line) continue;
496
- const parts = line.split(" ");
497
- const status = parts[0];
498
- if (!status) continue;
499
- if (status.startsWith("R") || status.startsWith("C")) {
500
- out.push({ status, oldPath: parts[1] ?? "", newPath: parts[2] ?? "" });
501
- } else if (status === "A") {
502
- out.push({ status, oldPath: "", newPath: parts[1] ?? "" });
503
- } else if (status === "D") {
504
- out.push({ status, oldPath: parts[1] ?? "", newPath: "" });
505
- } else {
506
- out.push({ status, oldPath: parts[1] ?? "", newPath: parts[1] ?? "" });
507
- }
508
- }
509
- return out;
510
- }
511
- function resolveFileMode(change) {
512
- if (change.status.startsWith("R")) return "rename";
513
- if (change.status === "A") return "add";
514
- if (change.status === "D") return "delete";
515
- return "modify";
516
- }
517
- function parseHunks(patch, newFilePath) {
518
- const items = [];
519
- if (!patch) return items;
520
- const lines = patch.split("\n");
521
- let current = new GitItem();
522
- let oldLines = [];
523
- let newLines = [];
524
- for (const line of lines) {
525
- if (line.startsWith("---") || line.startsWith("+++")) {
526
- continue;
527
- }
528
- if (line.startsWith("@@")) {
529
- current.contentBefore = normalize(oldLines.join("\n"));
530
- current.contentAfter = normalize(newLines.join("\n"));
531
- items.push(current);
532
- current = new GitItem();
533
- oldLines = [];
534
- newLines = [];
535
- const parts = line.split(" ");
536
- const oldInfo = parts[1].substring(1).split(",");
537
- const oldRow = parseInt(oldInfo[0], 10);
538
- const oldAffected = oldInfo.length === 2 ? parseInt(oldInfo[1], 10) : 1;
539
- const newInfo = parts[2].substring(1).split(",");
540
- const newRow = parseInt(newInfo[0], 10);
541
- const newAffected = newInfo.length === 2 ? parseInt(newInfo[1], 10) : 1;
542
- current.path = newFilePath;
543
- current.lineInterval = [newRow, newRow + newAffected - 1];
544
- if (oldAffected === 0) current.mode = "add";
545
- if (newAffected === 0) {
546
- current.mode = "delete";
547
- } else {
548
- current.mode = "modify";
549
- }
550
- } else if (line.startsWith("-")) {
551
- oldLines.push(line.substring(1));
552
- } else if (line.startsWith("+")) {
553
- newLines.push(line.substring(1));
554
- }
555
- }
556
- current.contentBefore = normalize(oldLines.join("\n"));
557
- current.contentAfter = normalize(newLines.join("\n"));
558
- items.push(current);
559
- items.shift();
560
- return items;
561
- }
562
- async function extractCommitDiff(repoPath, commitId) {
563
- const git = simpleGit(repoPath);
564
- const parentId = (await git.raw(["rev-parse", `${commitId}^`])).trim();
565
- console.log(`commit: ${commitId} parent: ${parentId}`);
566
- const nameStatus = await git.raw(["diff", "--name-status", "-M", parentId, commitId]);
567
- const changes = parseNameStatus(nameStatus);
568
- const results = [];
569
- for (const change of changes) {
570
- if (change.oldPath && !hasAllowedExt(change.oldPath)) continue;
571
- if (change.newPath && !hasAllowedExt(change.newPath)) continue;
572
- const reportPath = change.newPath || change.oldPath;
573
- const filePaths = [change.oldPath, change.newPath].filter((p) => p);
574
- const patchArgs = ["diff", "-U0", "-M", parentId, commitId, "--", ...new Set(filePaths)];
575
- const patch = await git.raw(patchArgs);
576
- const hunkItems = parseHunks(patch, reportPath);
577
- const fileMode = resolveFileMode(change);
578
- for (const item of hunkItems) {
579
- item.file_mode = fileMode;
580
- }
581
- results.push(...hunkItems);
582
- }
583
- return results;
584
- }
585
-
586
- // src/context/index.ts
587
- function linesToRanges(lines) {
588
- const ranges = [];
589
- let start = -1;
590
- for (let i = 0; i < lines.length; i++) {
591
- const defined = lines[i] !== void 0;
592
- if (defined && start === -1) {
593
- start = i + 1;
594
- } else if (!defined && start !== -1) {
595
- ranges.push([start, i]);
596
- start = -1;
597
- }
598
- }
599
- if (start !== -1) {
600
- ranges.push([start, lines.length]);
601
- }
602
- return ranges;
603
- }
604
- function loadSdks(ohosSdkPath, hmsSdkPath) {
605
- return [
606
- { name: "ohosSdk", path: ohosSdkPath, moduleName: "" },
607
- { name: "hmsSdk", path: hmsSdkPath, moduleName: "" }
608
- ];
609
- }
610
- async function extractCommitContext(input) {
611
- const { projectPath, commitId } = input;
612
- const mode = input.mode ?? "default";
613
- const ohosSdkPath = expandHome(
614
- input.ohosSdkPath || process.env.OHOS_SDK_PATH || readConfigEnvFieldSync("OHOS_SDK_PATH")
615
- );
616
- const hmsSdkPath = expandHome(
617
- input.hmsSdkPath || process.env.HMS_SDK_PATH || readConfigEnvFieldSync("HMS_SDK_PATH")
618
- );
619
- if (!projectPath) {
620
- throw new Error("extractCommitContext: projectPath is required");
621
- }
622
- if (!commitId) {
623
- throw new Error("extractCommitContext: commitId is required");
624
- }
625
- if (!ohosSdkPath && !hmsSdkPath) {
626
- throw new Error(
627
- "extractCommitContext: OHOS_SDK_PATH / HMS_SDK_PATH not found in the OS environment. Run `ht init` to set them as machine environment variables (and open a new terminal), or pass ohosSdkPath / hmsSdkPath as tool input (e.g. D:\\DevEco Studio\\sdk\\default\\openharmony\\ets)."
628
- );
629
- }
630
- console.error(
631
- `[hometrans/context] analyzing commit=${commitId} project=${projectPath} mode=${mode}`
632
- );
633
- const gitItems = await extractCommitDiff(projectPath, commitId);
634
- console.error(`[hometrans/context] extracted ${gitItems.length} diff items`);
635
- const scene = new Scene2();
636
- const analysisResult = [];
637
- const sceneConfig = new SceneConfig({ enableAST: false });
638
- const sdkList = loadSdks(ohosSdkPath, hmsSdkPath);
639
- const fileList = getAllFiles(projectPath, [".ts", ".ets", ".js", ".json5"]);
640
- sceneConfig.buildFromProjectFiles("hometrans_target", projectPath, fileList, sdkList);
641
- scene.buildSceneFromFiles(sceneConfig);
642
- scene.inferTypes();
643
- const callGraph = new CallGraph2(scene);
644
- if (mode === "default") {
645
- const callGraphBuilder = new CallGraphBuilder(callGraph, scene);
646
- const entryPoints = [];
647
- const totalMethodSignatures = scene.getFiles().filter(
648
- (arkFile) => arkFile.getFilePath().endsWith(".ets") || arkFile.getFilePath().endsWith(".ts")
649
- ).flatMap((arkFile) => arkFile.getClasses()).flatMap((arkClass) => arkClass.getMethods()).map((arkMethod) => arkMethod.getSignature());
650
- safePush(entryPoints, totalMethodSignatures);
651
- callGraphBuilder.buildClassHierarchyCallGraph(entryPoints, false);
652
- }
653
- const arkFiles = scene.getFiles();
654
- const gitAnalysis = new ArkTsGitInfoAnalysis();
655
- for (const gitItem of gitItems) {
656
- for (const arkFile of arkFiles) {
657
- const segments = gitItem.path.split(/[\\/]+/).filter(Boolean);
658
- const gitFilePath = getFilePath([arkFile.getProjectDir(), ...segments]);
659
- if (toUnixPath(arkFile.getFilePath()) === toUnixPath(gitFilePath)) {
660
- gitAnalysis.analysis(arkFile, gitItem, callGraph, mode);
661
- }
662
- }
663
- }
664
- const dependencyResourceMap = gitAnalysis.dependencyResourceMap;
665
- dependencyResourceMap.forEach((resource, filePath) => {
666
- const base = path4.basename(filePath);
667
- if (base === "string.json" || base === "plural.json" || base === "strarray.json") {
668
- analysisResult.push({
669
- path: filePath,
670
- kind: "resource",
671
- resourceNames: Array.from(resource.resource.keys())
672
- });
673
- }
674
- });
675
- const dependencyFileDict = gitAnalysis.dependencyFileDict;
676
- dependencyFileDict.forEach((lines, arkFile) => {
677
- const ranges = linesToRanges(lines);
678
- if (ranges.length === 0) {
679
- return;
680
- }
681
- analysisResult.push({
682
- path: arkFile.getFilePath(),
683
- kind: "source",
684
- ranges
685
- });
686
- });
687
- console.error(
688
- `[hometrans/context] produced ${analysisResult.length} context entries`
689
- );
690
- return analysisResult;
691
- }
692
- export {
693
- extractCommitContext
694
- };