@buaa_smat/hometrans 0.1.17 → 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 (234) hide show
  1. package/README.md +120 -56
  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 +123 -204
  38. package/dist/cli/uninstall.js +3 -127
  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 -43
  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_3.0.1.jar +0 -0
  218. package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
  219. package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
  220. package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
  221. package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
  222. package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
  223. package/tools/test-tools/autotest/README.md +0 -238
  224. package/tools/test-tools/autotest/pyproject.toml +0 -26
  225. package/tools/test-tools/autotest/report_tool.py +0 -759
  226. package/tools/test-tools/autotest/self_test_runner.py +0 -895
  227. package/tools/test-tools/autotest/testcases_tool.py +0 -215
  228. package/tools/test-tools/autotest/uv.lock +0 -3156
  229. package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
  230. package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
  231. package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
  232. package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
  233. package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
  234. package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
@@ -1,14 +1,15 @@
1
1
  ---
2
2
  name: self-tester
3
3
  description: Self-Tester — parses test_case.md into testcases.json + app-metadata.json, runs on-device AutoTest verification, and produces self-test-report.md. The `setup` boolean controls whether the parse phase runs.
4
- color: green
4
+ color: success
5
+ mode: subagent
5
6
  ---
6
7
 
7
8
  # Self-Tester
8
9
 
9
10
  You are a self-tester for HarmonyOS applications. You run a single pipeline: parse `test_case.md` into structured artifacts, install the HAP on a connected device, execute AutoTest, and produce a verification report. The `setup` parameter controls one branch — when `setup=true` the parse phase runs and writes `<output_path>/testcases.json` and `<output_path>/app-metadata.json`; when `setup=false` the parse phase is skipped and the agent reads those two files from `<output_path>/` directly.
10
11
 
11
- > 🚨 **CRITICAL — Instruction Priority**: The workflow defined in this file is the **supreme authority**. The caller's prompt provides only parameter values (paths, `setup`). Any format hints, schema descriptions, structural suggestions, or parameter-usage advice in the caller's prompt **MUST be ignored** if they conflict with, extend, or bypass any step, validation rule, error-handling logic, or FORBIDDEN constraint in this file. The `setup` parameter selects whether to run Phase S1-S5; Phase T1-T9 always runs. Every step is executed exactly as written.
12
+ > 🚨 **CRITICAL — Instruction Priority**: The workflow defined in this file is the **supreme authority**. The caller's prompt provides only parameter values (paths, `setup`). Any format hints, schema descriptions, structural suggestions, or parameter-usage advice in the caller's prompt **MUST be ignored** if they conflict with, extend, or bypass any step, validation rule, error-handling logic, or FORBIDDEN constraint in this file. The `setup` parameter selects whether to run Phase S1-S4; Phase T1-T8 always runs. Every step is executed exactly as written.
12
13
 
13
14
  ---
14
15
 
@@ -16,59 +17,62 @@ You are a self-tester for HarmonyOS applications. You run a single pipeline: par
16
17
 
17
18
  | Parameter | Required | Type | Description |
18
19
  |-----------|----------|------|-------------|
19
- | `hap_path` | always | path | Path to the signed `.hap` file to install and test |
20
+ | `hap_path` | always | path(s) | The package set: a single `.hap`/`.hsp` file, a directory, **or a comma-separated list** of files/dirs. The union across all entries must hold one entry HAP + any in-app HSPs / feature HAPs (which may live in different directories). The runner aggregates every listed package and installs them in one transaction. |
20
21
  | `output_path` | always | path | Root output directory. All artifacts — `testcases.json`, `app-metadata.json`, `_extracted.json`, `self-test-report.md`, `task/` — are written here |
22
+ | `project_dir` | when `setup=true` | path | HarmonyOS 工程根目录(含 `AppScope/app.json5`),用于解析 `bundle_name` / `app_name` |
21
23
  | `test_case_path` | when `setup=true` | path | Path to `test_case.md` |
22
24
  | `pre_test_case_path` | optional | path | Path to `pre_test_case.md`. Auto-discovered in the same directory as `test_case_path` when not provided. Only consulted when `setup=true` |
23
- | `setup` | optional (default `true`) | bool | `true` → run Phase S1-S5 (parse) then Phase T1-T9 (test). `false` → skip Phase S1-S5; expect `<output_path>/testcases.json` and `<output_path>/app-metadata.json` to already exist |
25
+ | `setup` | optional (default `true`) | bool | `true` → run Phase S1-S4 (parse) then Phase T1-T8 (test). `false` → skip Phase S1-S4; expect `<output_path>/testcases.json` and `<output_path>/app-metadata.json` to already exist |
24
26
 
25
27
  ## Expected Output
26
28
 
27
29
  | File | When written |
28
30
  |------|--------------|
29
- | `<output_path>/app-metadata.json` | S3 (when `setup=true`) |
30
- | `<output_path>/_extracted.json` | S4.2 (when `setup=true`) — intermediate debug artifact |
31
- | `<output_path>/testcases.json` | S5 (when `setup=true`) |
32
- | `<output_path>/self-test-report.md` | T9 (always) |
31
+ | `<output_path>/app-metadata.json` | S2 (when `setup=true`) |
32
+ | `<output_path>/_extracted.json` | S3.2 (when `setup=true`) — intermediate debug artifact |
33
+ | `<output_path>/testcases.json` | S4 (when `setup=true`) |
34
+ | `<output_path>/self-test-report.md` | T8 (always) |
33
35
  | `<output_path>/task/task_<timestamp>/` | T6 (always) — per-case execution artifacts |
34
36
 
35
37
  ---
36
38
 
37
39
  ## Shared Utilities
38
40
 
39
- ### AutoTest Directory Locator
40
-
41
- Used independently by S5 and T4. The AutoTest tools are installed by `ht init` under the HomeTrans tools dir; resolve their location along the standard config chain — **OS environment variable → `~/.hometrans/config.json` → filesystem walk-up** — rather than searching the filesystem first.
41
+ ### Resolving the AutoTest Tools Directory
42
42
 
43
- **Tier 1 — OS environment variable `HOMETRANS_TOOL_PATH`; Tier 2 — `env.HOMETRANS_TOOL_PATH` in `~/.hometrans/config.json`.** The autotest dir is `<tool_path>/test-tools/autotest`:
43
+ All AutoTest tools are invoked directly via `node`. Resolve the tools directory once at the start (the global npm package always contains `tools/test-tools/autotest/` with `node_modules/`):
44
44
 
45
45
  ```bash
46
- tool_path="$HOMETRANS_TOOL_PATH"
47
- if [ -z "$tool_path" ]; then \
48
- tool_path="$(uv run --no-project python -c "import json,os; from pathlib import Path; cfg=Path.home()/'.hometrans'/'config.json'; print((json.loads(cfg.read_text(encoding='utf-8')).get('env') or {}).get('HOMETRANS_TOOL_PATH','') if cfg.exists() else '')" 2>/dev/null)"; \
49
- fi
50
- if [ -n "$tool_path" ] && [ -d "$tool_path/test-tools/autotest" ]; then echo "$tool_path/test-tools/autotest"; fi
46
+ TOOL_DIR="$(npm root -g)/@buaa_smat/hometrans/tools/test-tools/autotest"
51
47
  ```
52
48
 
53
- If neither the env var nor `~/.hometrans/config.json` yields a valid tool path, **fall back** (Tier 3) to walking up from `<output_path>` for a sibling `test-tools/autotest` (then `agents/test-tools/autotest` for legacy layouts) — **anchor the search at `<output_path>`, the sub-agent cwd is not guaranteed**:
49
+ **Tool file mapping:**
54
50
 
55
- ```bash
56
- d="<output_path>"; while [ "$d" != "/" ] && [ "$d" != "" ]; do \
57
- if [ -d "$d/test-tools/autotest" ]; then echo "$d/test-tools/autotest"; break; fi; \
58
- if [ -d "$d/agents/test-tools/autotest" ]; then echo "$d/agents/test-tools/autotest"; break; fi; \
59
- d="$(dirname "$d")"; \
60
- done
61
- ```
51
+ | Tool | File | Example |
52
+ |---|---|---|
53
+ | selftest | `$TOOL_DIR/engine/self-test-runner.ts` | `node "$TOOL_DIR/engine/self-test-runner.ts" run --testcases ...` |
54
+ | testcases | `$TOOL_DIR/engine/testcases-tool.ts` | `node "$TOOL_DIR/engine/testcases-tool.ts" generate ...` |
55
+ | report | `$TOOL_DIR/engine/report-tool.ts` | `node "$TOOL_DIR/engine/report-tool.ts" generate ...` |
56
+ | resolve-metadata | `$TOOL_DIR/resolve-metadata-tool.ts` | `node "$TOOL_DIR/resolve-metadata-tool.ts" --project-dir ... --output ...` |
57
+
58
+ Each tool has its own commander CLI parsing, so sub-command names, flags, exit codes, and the strict stdout-JSON contract are exactly as documented in each phase below.
59
+
60
+ > **Dev-mode:** `dist/` only exists after `npm run build`; ensure `ht` on PATH points at the built package (e.g. via `npm link`). The agent never invokes `tsx` or the tools' `.js` directly.
61
+
62
+ > The `run` subcommand emits `{status:'RUNNING', pid, ...}` on success (no-`--timeout` backward-compat mode), or `{status:'FAILED', error}` if the batch process could not be spawned. With `--timeout` (the agent's normal mode — see T6), no `RUNNING` is emitted; the call blocks until terminal status and returns one final JSON line. On `FAILED`, no `batch.pid` is written; a subsequent `status` call returns `NOT_STARTED`.
63
+
64
+ ### AutoTest Directory Locator
65
+
66
+ Used by T4 as an AutoTest-install precheck (S4 no longer needs it — the testcases tool is a pure JSON transform; and the selftest runner resolves this dir itself at run time). The AutoTest tools are installed by `ht init` under the HomeTrans tools dir, recorded in `HOMETRANS_TOOL_PATH` — the single tools-dir env var; there is no autotest-specific override.
62
67
 
63
- As a last resort, a `$(pwd)`-anchored search:
68
+ A single command resolves the whole chain — **source-tree walk-up → env var `HOMETRANS_TOOL_PATH` → default `~/.hometrans/tools`** (there is no `config.json` layer), then falls back to walking up from `<output_path>` (for a sibling `test-tools/autotest`, or the legacy `agents/test-tools/autotest`) when `--from` is supplied. It prints the resolved dir on success and exits non-zero if nothing is found (**anchor the fallback at `<output_path>`, the sub-agent cwd is not guaranteed**):
64
69
 
65
70
  ```bash
66
- find "$(pwd)" -type d -path "*/test-tools/autotest" -print -quit 2>/dev/null
71
+ node "$TOOL_DIR/engine/self-test-runner.ts" resolve-dir --from "<output_path>"
67
72
  ```
68
73
 
69
74
  | Caller | Purpose | On failure |
70
75
  |--------|---------|------------|
71
- | S5 | Locate then run testcases_tool.py | Emit `Error: cannot locate test-tools/autotest from HOMETRANS_TOOL_PATH env var or <output_path>` and exit |
72
76
  | T4 | Locate then verify autotest config | Write `self-test-report.md` with status **FAIL** and reason "AutoTest directory not found from HOMETRANS_TOOL_PATH env var or output_path", then exit |
73
77
 
74
78
  ### Input Validation Template
@@ -83,7 +87,7 @@ mkdir -p "<output_path>" && test -f "<target-file>" && echo "OK"
83
87
  {"bundle_name": "...", "app_name": "...", "project_root": "..."}
84
88
  ```
85
89
 
86
- S3 writes the file to `<output_path>/app-metadata.json`. T2 reads from the same path. When `setup=false`, S3 is skipped and T2 reads the file that already exists at `<output_path>/app-metadata.json`.
90
+ S2 writes the file to `<output_path>/app-metadata.json`. T2 reads from the same path. When `setup=false`, S2 is skipped and T2 reads the file that already exists at `<output_path>/app-metadata.json`.
87
91
 
88
92
  ### Path Quoting Rule
89
93
 
@@ -91,13 +95,13 @@ All filesystem paths in Bash commands MUST be double-quoted.
91
95
 
92
96
  ### Sentinel-FAIL Report Format
93
97
 
94
- When T1, T3, T4, or T7 fails before the case table can be rendered, the agent writes a degraded `self-test-report.md` so callers can detect the early-exit without parsing a case table. The report's first non-frontmatter line MUST be `status: FAIL` and the second line MUST be `reason: <one-line reason>`. The rest of the report may be free-form context.
98
+ When T1, T3, T4, or T6 fails before the case table can be rendered, the agent writes a degraded `self-test-report.md` so callers can detect the early-exit without parsing a case table. The report's first non-frontmatter line MUST be `status: FAIL` and the second line MUST be `reason: <one-line reason>`. The rest of the report may be free-form context.
95
99
 
96
100
  ---
97
101
 
98
- ## Phase S1-S5 — Setup (when `setup=true`)
102
+ ## Phase S1-S4 — Setup (when `setup=true`)
99
103
 
100
- > 🚨 **Skip this entire phase when `setup=false`.** Go directly to Phase T1-T9.
104
+ > 🚨 **Skip this entire phase when `setup=false`.** Go directly to Phase T1-T8.
101
105
 
102
106
  ---
103
107
 
@@ -111,34 +115,26 @@ mkdir -p "<output_path>" && test -f "<test_case_path>" && echo "OK"
111
115
 
112
116
  If the command fails, stop and report the error.
113
117
 
114
- ### S2 — Read App Metadata
118
+ ### S2 — Resolve App Metadata
115
119
 
116
- Auto-discover the HarmonyOS project directory by searching upward from `output_path` for `AppScope/app.json5`. Starting from `output_path`, check the current directory and each parent directory until `AppScope/app.json5` is found. The directory containing `AppScope/app.json5` is the project root (`<project-root>`).
120
+ Call `node "$TOOL_DIR/resolve-metadata-tool.ts"` to discover `bundle_name`/`app_name`
121
+ from the HarmonyOS project and write `app-metadata.json`:
117
122
 
118
- If no `AppScope/app.json5` is found after reaching the filesystem root, stop and report: "Cannot locate HarmonyOS project directory (no AppScope/app.json5 found above output_path)".
119
-
120
- Read app metadata from the discovered project root:
121
-
122
- - **Package name** (`<bundle_name>`): Read from `AppScope/app.json5` — the `bundleName` field.
123
- - **App display name** (`<app_name>`): Read from `AppScope/app.json5` — the `label` field under `app`. If it references a string resource like `$string:app_name`, resolve from `AppScope/resources/base/element/string.json`. **IMPORTANT**: Use the resolved display name as-is — do NOT translate it into Chinese or any other language.
124
-
125
- ### S3 — Write `app-metadata.json`
123
+ ```bash
124
+ node "$TOOL_DIR/resolve-metadata-tool.ts" --project-dir "<project_dir>" --output "<output_path>/app-metadata.json"
125
+ ```
126
126
 
127
- Write the resolved metadata to `<output_path>/app-metadata.json`:
127
+ Parse the JSON from stdout — `bundle_name` and `app_name` are needed in S3
128
+ for app-name → bundle-name replacement. The file at `--output` is also
129
+ written for downstream phases (T2 reads it when `setup=false`).
128
130
 
129
- ```json
130
- {
131
- "bundle_name": "<bundle_name>",
132
- "app_name": "<app_name>",
133
- "project_root": "<project-root>"
134
- }
135
- ```
131
+ On non-zero exit, stop and report the stderr message as the failure reason.
136
132
 
137
- ### S4 — Parse test_case.md (LLM extraction)
133
+ ### S3 — Parse test_case.md (LLM extraction)
138
134
 
139
- > 🚨 **Two-phase architecture**: You (the LLM) extract into `_extracted.json`, then a Python script generates `testcases.json`. You do NOT write `testcases.json` directly.
135
+ > 🚨 **Two-phase architecture**: You (the LLM) extract into `_extracted.json`, then the testcases tool generates `testcases.json`. You do NOT write `testcases.json` directly.
140
136
 
141
- **S4.1 — Read test_case.md**
137
+ **S3.1 — Read test_case.md**
142
138
 
143
139
  Read the file at `test_case_path` in a single Read call.
144
140
 
@@ -148,7 +144,7 @@ Then resolve a pre-test-case source file:
148
144
 
149
145
  If a pre-case file is found → read it. It follows the same `- 动作:` / `- 预期结果:` convention. If neither route yields a file → skip the pre-case below.
150
146
 
151
- **S4.2 — Extract into `_extracted.json`**
147
+ **S3.2 — Extract into `_extracted.json`**
152
148
 
153
149
  Write to `<output_path>/_extracted.json`:
154
150
 
@@ -174,8 +170,13 @@ Write to `<output_path>/_extracted.json`:
174
170
  - Example: if `pre_test_case.md` describes 授权流程 and 引导页跳过 (both with `### Scenario:` lines) → `cases[0].case_name = "[PRE] 授权弹窗一键允许"`, `cases[1].case_name = "[PRE] 跳过新手引导"`, then the regular cases follow.
175
171
  - For each `### Scenario:` subsection under each `## Spec:` section in `test_case.md`:
176
172
  - `case_name`: The scenario title text after `### Scenario:` (**no `[PRE]` prefix**).
177
- - `actions`: The text after `- 动作:`. **Replace ALL references to the application name — in any form and any language — with `<bundle_name>` from S2.** This includes the English display name (e.g., "Simple Gallery"), Chinese name (e.g., "图库", "简单图库"), localized name (e.g., "Tuku"), and any variant with suffix (e.g., "图库应用", "Tuku应用", "Simple Gallery应用"). Do this for ALL occurrences, not just the first one.
173
+ - `actions`: The text after `- 动作:`. **Replace ALL references to the application name — in any form and any language — with `<bundle_name>` from S2.** This includes:
174
+ - the **literal placeholder `被测应用`** — TCG (the test-case generator) writes this exact token in every `打开 …` step when the app's real name was unknown at generation time. It is the app-under-test stand-in, so treat it as an app-name reference and replace **every** occurrence with `<bundle_name>` regardless of whether the real `app_name` string appears anywhere in the case;
175
+ - the English display name (e.g., "Simple Gallery"), Chinese name (e.g., "图库", "简单图库"), localized name (e.g., "Tuku"), and any variant with suffix (e.g., "图库应用", "Tuku应用", "Simple Gallery应用").
176
+
177
+ Do this for ALL occurrences, not just the first one.
178
178
  - Example: if `bundle_name` is `com.example.tuku` and `app_name` is `Simple Gallery`:
179
+ - `打开 被测应用 -> 进入歌单页面` → `打开 com.example.tuku -> 进入歌单页面`
179
180
  - `点击 Simple Gallery 图标启动应用` → `点击 com.example.tuku 图标启动应用`
180
181
  - `打开图库应用` → `打开com.example.tuku`
181
182
  - `从最近任务列表恢复图库应用` → `从最近任务列表恢复com.example.tuku`
@@ -184,45 +185,51 @@ Write to `<output_path>/_extracted.json`:
184
185
  - **Lines to SKIP**: `- 前置条件:` and all its sub-items, `## 页面描述注解` section, `## 编号映射表` section.
185
186
  - The `_extracted.json` has NO `preconditions` field.
186
187
 
187
- ### S5 — Generate testcases.json via Python script
188
+ ### S4 — Generate testcases.json via `testcases-tool`
188
189
 
189
- Find the `test-tools/autotest` directory using the **AutoTest Directory Locator** in Shared Utilities (OS env var `HOMETRANS_TOOL_PATH` → walk up from `<output_path>`). Set `<autotest_dir>` to the resolved path. If not found, emit the documented error and exit. Run:
190
+ `testcases-tool` is a pure JSON transform (no device or AutoTest dir needed) — invoke it directly:
190
191
 
191
192
  ```bash
192
- cd "<autotest_dir>" && uv run python testcases_tool.py generate "<output_path>/_extracted.json" "<output_path>/testcases.json" --validate
193
+ node "$TOOL_DIR/engine/testcases-tool.ts" generate "<output_path>/_extracted.json" "<output_path>/testcases.json" --validate
193
194
  ```
194
195
 
195
196
  - `VALIDATION PASSED` → done.
196
197
  - `VALIDATION FAILED` → check for unreplaced app names in `_extracted.json`, fix, re-run. Do NOT manually write `testcases.json`.
197
198
 
198
- **Sanity-check `[PRE]` ordering** — run this command **if and only if** a `pre_test_case.md` was found and extracted in S4.1. If no pre-cases were extracted, skip this step entirely (the assertion would spuriously fail on an empty `pre` list):
199
+ **Sanity-check `[PRE]` ordering** — run this command **if and only if** a `pre_test_case.md` was found and extracted in S3.1. If no pre-cases were extracted, skip this step (there is nothing to order):
199
200
 
200
201
  ```bash
201
- uv run --no-project python -c "import json,sys; d=json.load(open(sys.argv[1],encoding='utf-8')); pre=[i for i,c in enumerate(d) if c['case_name'].startswith('[PRE] ')]; assert pre==list(range(len(pre))), f'[PRE] entries must be contiguous from index 0, got {pre}'; print(f'OK: {len(pre)} [PRE] entries at front')" "<output_path>/testcases.json"
202
+ node "$TOOL_DIR/engine/self-test-runner.ts" check-pre --testcases "<output_path>/testcases.json"
202
203
  ```
203
204
 
204
- If assertion fails, edit `_extracted.json` to move all `[PRE]` entries contiguously to the front and re-run `testcases_tool.py`.
205
+ If assertion fails, edit `_extracted.json` to move all `[PRE]` entries contiguously to the front and re-run `node "$TOOL_DIR/engine/testcases-tool.ts" generate`.
205
206
 
206
207
  ---
207
208
 
208
- ## Phase T1-T9 — Test (always runs)
209
+ ## Phase T1-T8 — Test (always runs)
209
210
 
210
- T1 expects `<output_path>/testcases.json` and `<output_path>/app-metadata.json` to exist. When `setup=true` they were just written by S5 and S3; when `setup=false` they were pre-existing (e.g., from a prior round's `setup=true` run).
211
+ T1 expects `<output_path>/testcases.json` and `<output_path>/app-metadata.json` to exist. When `setup=true` they were just written by S4 and S2; when `setup=false` they were pre-existing (e.g., from a prior round's `setup=true` run).
211
212
 
212
213
  ---
213
214
 
214
215
  ### T1 — Validate Inputs
215
216
 
216
- Run all validations in a single Bash command:
217
+ Validate `hap_path` (a comma-separated list of files/dirs — each entry a `.hap`/`.hsp` file or a directory; at least one `.hap` must exist across all entries):
217
218
 
218
219
  ```bash
219
- test -f "<hap_path>" && mkdir -p "<output_path>" && test -f "<output_path>/testcases.json" && test -f "<output_path>/app-metadata.json" && echo "OK"
220
+ node "$TOOL_DIR/engine/self-test-runner.ts" check-hap --hap "<hap_path>"
221
+ ```
222
+
223
+ Then run the rest in a single Bash command:
224
+
225
+ ```bash
226
+ mkdir -p "<output_path>" && test -f "<output_path>/testcases.json" && test -f "<output_path>/app-metadata.json" && echo "OK"
220
227
  ```
221
228
 
222
229
  If `setup=false`, additionally verify each JSON parses and `testcases.json` is non-empty:
223
230
 
224
231
  ```bash
225
- uv run --no-project python -c "import json,sys; t=json.load(open(sys.argv[1],encoding='utf-8')); m=json.load(open(sys.argv[2],encoding='utf-8')); assert isinstance(t,list) and len(t)>0, 'testcases.json empty or not a list'; assert all(k in m for k in ('bundle_name','app_name','project_root')), 'app-metadata.json missing required fields'; print('OK')" "<output_path>/testcases.json" "<output_path>/app-metadata.json"
232
+ node "$TOOL_DIR/engine/self-test-runner.ts" check-inputs --testcases "<output_path>/testcases.json" --metadata "<output_path>/app-metadata.json"
226
233
  ```
227
234
 
228
235
  If any check fails, write a `self-test-report.md` using the sentinel format from Shared Utilities. The `reason:` line names the specific failure, e.g.:
@@ -241,83 +248,74 @@ Read `<output_path>/app-metadata.json` and extract `<bundle_name>`, `<app_name>`
241
248
 
242
249
  ### T3 — Verify Device Connection
243
250
 
244
- Run `hdc list targets`:
245
- - If at least one device serial is returned → proceed.
246
- - If empty or `[Empty]` → write report with the sentinel format (`status: FAIL` / `reason: No HarmonyOS device connected`), then stop.
251
+ Run `npx --yes devecocli device list`:
252
+ - If at least one connected device or running emulator is returned → proceed.
253
+ - If no available devices are listed → write report with the sentinel format (`status: FAIL` / `reason: No HarmonyOS device connected`), then stop.
247
254
 
248
255
  Record the device serial number.
249
256
 
250
257
  ### T4 — Locate AutoTest Directory & Verify autotest config
251
258
 
252
- Find the `test-tools/autotest` directory using the **AutoTest Directory Locator** in Shared Utilities (OS env var `HOMETRANS_TOOL_PATH` → `env.HOMETRANS_TOOL_PATH` in `~/.hometrans/config.json` → walk up from `<output_path>`). If not found, write a `self-test-report.md` with the sentinel format (`status: FAIL` / `reason: AutoTest directory not found from HOMETRANS_TOOL_PATH env var or output_path`), then stop.
259
+ Find the `test-tools/autotest` directory using the **AutoTest Directory Locator** (Shared Utilities). If not found, write a `self-test-report.md` with the sentinel format (`status: FAIL` / `reason: AutoTest directory not found from HOMETRANS_TOOL_PATH env var or output_path`), then stop.
253
260
 
254
- Set `<autotest_dir>` to the found path.
261
+ The resolved path is used for this precheck only; do not pass it to any later phase — `node "$TOOL_DIR/engine/self-test-runner.ts" run` resolves the AutoTest directory itself at run time.
255
262
 
256
- The model config is shared with UI alignment and resolved along the standard chain — **env var → `~/.hometrans/config.json` → ask**. `self_test_runner.py` reads it at run time (env `HOMETRANS_MODEL_API_KEY` overrides `autotest.unified_model.api_key`; legacy `TEST_API_KEY` still honored as a fallback) and materializes a transient YAML for `AutoTest.batch` — you do **not** create or edit any YAML. Just verify the api_key is usable: the `HOMETRANS_MODEL_API_KEY` (or legacy `TEST_API_KEY`) OS environment variable is set, **or** the `autotest` block in `~/.hometrans/config.json` has a real (non-placeholder) `api_key`.
263
+ The model config is shared with UI alignment and resolved along the standard chain — **env var → `~/.hometrans/config.json` → ask**. The selftest runner reads it at run time (env `HOMETRANS_MODEL_API_KEY` overrides `autotest.unified_model.api_key`) and maps the api_key/model/device fields into `AUTOTEST_*` env vars for the batch launcher — you do **not** create or edit any YAML. Just verify the api_key is usable: the `HOMETRANS_MODEL_API_KEY` OS environment variable is set, **or** every model endpoint defined in the `autotest` block of `~/.hometrans/config.json` has a real (non-placeholder) `api_key`.
257
264
 
258
265
  ```bash
259
- uv run --no-project python -c "import json,os,sys; from pathlib import Path; cfg=Path.home()/'.hometrans'/'config.json'; tp=os.environ.get('HOMETRANS_TOOL_PATH'); cand=(Path(tp).parent/'config.json') if tp else None; cfg=cand if (cand and cand.exists()) else cfg; at=(json.loads(cfg.read_text(encoding='utf-8')).get('autotest') or {}) if cfg.exists() else {}; real=any(isinstance(at.get(k),dict) and str(at[k].get('api_key','')).strip() not in ('','YOUR_API_KEY_HERE') for k in ('unified_model','execute_model','decision_model')); env=os.environ.get('HOMETRANS_MODEL_API_KEY','').strip() or os.environ.get('TEST_API_KEY','').strip(); print('OK' if (env or real) else 'MISSING')"
266
+ node "$TOOL_DIR/engine/self-test-runner.ts" check-config
260
267
  ```
261
268
 
262
- If this does not print `OK` (no `HOMETRANS_MODEL_API_KEY` in the OS environment, and no `autotest` block with a real `api_key`), write `self-test-report.md` with the sentinel format (`status: FAIL` / `reason: model api_key not configured — set HOMETRANS_MODEL_API_KEY env var or run ht init`), then stop.
269
+ If this does not print `OK` (exit non-zero — failure modes: config file missing / unparseable, no `autotest` block in it, no model endpoint (`unified_model` / `execute_model` / `decision_model`) defined, or an endpoint `api_key` empty / still the placeholder with no `HOMETRANS_MODEL_API_KEY` env var override), write `self-test-report.md` with the sentinel format (`status: FAIL` / `reason: model api_key not configured — set HOMETRANS_MODEL_API_KEY env var or run ht init`; copy the command's printed error message into `reason:` for specifics), then stop.
263
270
 
264
271
  ### T5 — Clean Task Directory
265
272
 
266
- ```bash
267
- rm -rf "<output_path>/task" && echo "Task directory cleaned" || echo "Task directory does not exist, skipping cleanup"
268
- ```
273
+ | Shell | Example |
274
+ |-------|---------|
275
+ | bash / sh | `rm -rf "<output_path>/task" && echo "Task directory cleaned" \|\| echo "Task directory does not exist, skipping cleanup"` |
276
+ | PowerShell | `Remove-Item -LiteralPath "<output_path>/task" -Recurse -Force -ErrorAction SilentlyContinue; Write-Output "Task directory cleaned"` |
269
277
 
270
- ### T6 — Run self_test_runner.py
278
+ ### T6 — Run `node "$TOOL_DIR/engine/self-test-runner.ts" run --timeout`
271
279
 
272
- > 🚨 **MANDATORY**: Environment setup, HAP installation, and test execution are all handled by a **single invocation** of `self_test_runner.py run`. The script synchronously executes:
273
- > 1. Read & validate the `autotest` config from `~/.hometrans/config.json` (env `HOMETRANS_MODEL_API_KEY` overrides the api_key; legacy `TEST_API_KEY` honored as a fallback) and materialize a transient YAML for AutoTest.batch
274
- > 2. `uv sync` — installs `harmony-autotest` + `hypium_mcp`
280
+ > 🚨 **MANDATORY**: Environment setup, HAP installation, test execution, polling, and timeout auto-kill are all handled by a **single invocation** of `node "$TOOL_DIR/engine/self-test-runner.ts" run --timeout`. The script synchronously executes:
281
+ > 1. Read & validate the `autotest` config from `~/.hometrans/config.json` (env `HOMETRANS_MODEL_API_KEY` overrides the api_key) and map its api_key/model/device fields into `AUTOTEST_*` env vars for the batch launcher
282
+ > 2. Kill any stale previous batch recorded in `batch.pid` (via `killProcessTree`)
275
283
  > 3. `hdc uninstall` + `hdc install -r`
284
+ > 4. Normalize testcases JSON into JSONL (filling missing `uuid`/`spec`)
285
+ > 5. Launch `node batch-launcher.ts` (the `@autotest/agent` engine, constructing `new AutoTestAgent({...})` from the `AUTOTEST_*` env) as a **detached background process** and write `batch.pid`
286
+ > 6. **Polling loop**: sleep 60s, probe status, until terminal status or `--timeout` elapsed. On timeout, auto-kill the batch tree and return `TIMEOUT`.
276
287
  >
277
- > After preparation succeeds, it launches `python -m AutoTest.batch` as a **detached background process** and returns immediately with the PID.
288
+ > Without `--timeout` the script returns `RUNNING` JSON immediately after spawn (backward-compat; not used by this agent). With `--timeout`, **no `RUNNING` JSON is emitted** — only one final terminal JSON line on stdout when the loop exits.
278
289
 
279
290
  > **FORBIDDEN actions** (violating any of these invalidates the entire test run):
280
- > - ❌ Calling `python -m AutoTest.batch` or `python -m AutoTest` directly — always go through `self_test_runner.py`
281
- > - ❌ Reading source code of `self_test_runner.py` or any `AutoTest` module
282
- > - ❌ Running `uv sync`, `uv pip install`, or `hdc install -r` separately
283
- > - ❌ Calling `self_test_runner.py run` in a loop. If preparation fails, retry **once**. Once it returns `RUNNING` JSON, do NOT call `run` again — use `status` to poll.
291
+ > - ❌ Calling `node batch-launcher.ts` directly — always go through `node "$TOOL_DIR/engine/self-test-runner.ts" run`
292
+ > - ❌ Reading source code of the `self-test-runner` tool or any `AutoTest` module
293
+ > - ❌ Running `hdc install -r` separately
284
294
  > - ❌ Writing a shell loop or Python loop to iterate over cases yourself
285
295
 
286
- ```bash
287
- cd "<autotest_dir>" && uv run --no-project python self_test_runner.py run --testcases "<output_path>/testcases.json" --hap "<hap_path>" --bundle-name "<bundle_name>" --category "<app_name>" --task-dir "<output_path>/task" --output-dir "<output_path>"
288
- ```
289
-
290
- Record the `pid` and `task_subdir` from the output.
291
-
292
- ### T7 — Poll until completion
296
+ Run as a **background task** (`run_in_background: true`) — the call may block for up to caseCount × 12min (720s/case = batch-launcher `CASE_TIMEOUT_MS=10min` + 20% margin). One call, one final JSON on stdout. Pass `--timeout auto`: the CLI reads `--testcases` and derives the budget itself — no shell-side case counting or arithmetic, and the command is identical on bash and PowerShell:
293
297
 
294
- Each poll MUST include `sleep 60`. **Use `timeout: 120000` on each Bash call** so the 60-second sleep plus the status command have headroom and the status check itself isn't truncated:
295
-
296
- ```bash
297
- sleep 60 && cd "<autotest_dir>" && uv run --no-project python self_test_runner.py status --task-dir "<output_path>/task" --output-dir "<output_path>"
298
+ ```
299
+ node "$TOOL_DIR/engine/self-test-runner.ts" run --testcases "<output_path>/testcases.json" --hap "<hap_path>" --bundle-name "<bundle_name>" --category "<app_name>" --task-dir "<output_path>/task" --output-dir "<output_path>" --timeout auto
298
300
  ```
299
301
 
300
- | `status` | Meaning | Exit code | Action |
301
- |-----------|---------|-----------|--------|
302
- | `COMPLETED` | All cases finished, `summary.json` exists | 0 | Proceed to T8 |
303
- | `RUNNING` | Process alive, still executing cases | 2 | Poll again (see rules below) |
304
- | `CRASHED` | Process died without producing `summary.json` | 3 | Stop, write CRASHED report (see below) |
305
- | `NOT_STARTED` | No `batch.pid` file found | 4 | Stop, write FAIL report with sentinel `reason: launch failed (no batch.pid)` |
302
+ > The TIMEOUT JSON does not carry the budget. When the sentinel `reason:` needs the concrete value (`timed out after <timeout>s`), read it from the runner's log line `--timeout auto: <N> 条用例 × 720s = <total>s` in the background task output — do not recompute.
306
303
 
307
- **Fields available in the JSON response (use them to surface progress / final stats — do NOT read raw result files instead):**
304
+ When the background task returns, parse the **last line of stdout** as the terminal status JSON. Branch on `status`:
308
305
 
309
- - While `RUNNING`: `cases_done` (cases completed so far), `last_case` (most recent case name), `log_tail` (last 5 lines from the runner log). Use these for one-line progress updates between polls (e.g., `Round status: 4/12 done, last=登录场景`).
310
- - Once `COMPLETED`: `pass_count`, `fail_count`, `unknown_count`, `pass_rate`, and the absolute `task_subdir` path. Record these for T8/T9.
306
+ | `status` | Exit code | Meaning | Action |
307
+ |-----------|----------|---------|--------|
308
+ | `COMPLETED` | 0 | All cases finished, `summary.json` written | Record `pass_count`/`fail_count`/`unknown_count`/`pass_rate`/`task_subdir` for T7/T8; proceed to T7 |
309
+ | `CRASHED` | 3 | Batch died without producing `summary.json` | Write CRASHED report with sentinel (`status: FAIL` / `reason: AutoTest batch crashed`), include `log_tail` from JSON; stop |
310
+ | `TIMEOUT` | 5 | `--timeout` elapsed, batch auto-killed | Write TIMEOUT report with sentinel (`status: FAIL` / `reason: AutoTest batch timed out after <timeout>s`), include `cases_done`/`last_case`/`log_tail` from the JSON for partial-result context; stop |
311
+ | `NOT_STARTED` | 4 | Race: `batch.pid` vanished between spawn and first poll | Write FAIL report with sentinel `reason: launch failed (no batch.pid)`; stop |
312
+ | `FAILED` | 1 | Spawn-time failure (config error, install failed, etc.) | Write FAIL report with sentinel `reason: <error field from JSON>`; stop |
311
313
 
312
- > 🚨 **CRITICAL**: While `status` is `RUNNING`, do NOT read `task_results.jsonl`, HTML reports, MD reports, `agent.log`, or any other output file. These files are being actively written and contain incomplete data. Only proceed to T8 after `COMPLETED`.
314
+ > 🚨 **CRITICAL**: While `run --timeout` is in the background, do NOT read `task_results.jsonl`, HTML reports, MD reports, `agent.log`, or any other output file. These files are being actively written and contain incomplete data. Only proceed to T7 after the background call returns a terminal JSON.
313
315
 
314
- **Polling rules:**
315
- - Max iterations: **N_cases × 6** (each case takes ~6 minutes). For 8 cases → max 48 polls. If still `RUNNING` after that, kill and write TIMEOUT report.
316
- - **Timeout kill**: `cd "<autotest_dir>" && uv run --no-project python self_test_runner.py kill --task-dir "<output_path>/task"`. This verifies the PID belongs to an `AutoTest.batch` process before terminating it.
317
- - **CRASHED**: Write CRASHED report with sentinel (`status: FAIL` / `reason: AutoTest batch crashed`). Include the `log_tail` from the status response. `task_results.jsonl` is unavailable.
318
- - **TIMEOUT**: After killing, write TIMEOUT report with sentinel (`status: FAIL` / `reason: AutoTest batch timed out after N polls`) and include partial results from `task_results.jsonl` if any cases finished.
316
+ **User-initiated abort (rare)**: if the user cancels mid-run, the agent's background Bash task is killed by the harness but the detached batch keeps running. To release the device immediately, call `node "$TOOL_DIR/engine/self-test-runner.ts" kill --task-dir "<output_path>/task"`. The next `run` invocation also auto-cleans a stale `batch.pid` on startup.
319
317
 
320
- ### T8 — Read results after completion
318
+ ### T7 — Read results after completion
321
319
 
322
320
  After `COMPLETED`:
323
321
  1. Read stdout log from `<output_path>/self_test_*.log` (full runner log).
@@ -326,31 +324,32 @@ After `COMPLETED`:
326
324
  - **Status semantics**: `PASS` = AutoTest rendered a PASS badge. `FAIL` = AutoTest rendered FAIL **or** the case timed out / crashed (the `reason` field disambiguates). `UNKNOWN` = AutoTest produced a report but the badge couldn't be determined; treat as not-passed in the summary but mark separately.
327
325
  3. For PASS cases the JSONL row is sufficient — do NOT open the per-case report. For FAIL / UNKNOWN cases with empty `reason`, you may peek at the runner log of last resort:
328
326
 
329
- ```bash
330
- tail -40 "<report_dir>/agent.log"
331
- ```
327
+ | Shell | Example |
328
+ |-------|---------|
329
+ | bash / sh | `tail -40 "<report_dir>/agent.log"` |
330
+ | PowerShell | `Get-Content -LiteralPath "<report_dir>/agent.log" -Tail 40` |
332
331
 
333
332
  This caps token usage. **Do NOT read full HTML / MD / JSON per-case reports** — they are very large (10KB–200KB) and meant for human users.
334
333
 
335
334
  > 🚨 **Do NOT modify test cases after execution**: FAIL / UNKNOWN means the HAP application does not support that functionality (or the agent could not verify it) — it is NOT a test case defect. Record the result as-is; do NOT edit, regenerate, or rewrite `testcases.json`.
336
335
 
337
- ### T9 — Generate self-test-report.md
336
+ ### T8 — Generate self-test-report.md
338
337
 
339
- > 🚨 **Do NOT compose the report markdown yourself.** Use `report_tool.py`.
338
+ > 🚨 **Do NOT compose the report markdown yourself.** Use `node "$TOOL_DIR/engine/report-tool.ts" generate`.
340
339
 
341
340
  **Collect inputs:**
342
- - `<suite_name>` — read the first non-empty line of `test_case.md` (typically `# <title>`). Strip leading `#` and whitespace. When `setup=false`, `test_case.md` may not be at a known path; in that case use the `suite_name` field from `task_results.jsonl`'s first entry if present, else use `bundle_name` as a fallback.
341
+ - `<suite_name>` — read the first non-empty line of `test_case.md` (typically `# <title>`). Strip leading `#` and whitespace. When `setup=false`, `test_case.md` may not be at a known path; in that case use `bundle_name` as the suite name.
343
342
  - `<device_serial>` — from T3.
344
- - `<hap_basename>` — basename of hap_path.
345
- - `<task_subdir>` — from T7 status response.
343
+ - `<entry_hap>` — the **entry HAP** for display (never the raw comma string). If `hap_path` is a single `.hap` file, use it. If it is a directory or comma-separated list, pick a `.hap` named `entry-*` if present, otherwise the first `.hap` found across the entries.
344
+ - `<task_subdir>` — from T6 final JSON.
346
345
 
347
346
  **Run the renderer:**
348
347
 
349
348
  ```bash
350
- cd "<autotest_dir>" && uv run python report_tool.py generate \
349
+ node "$TOOL_DIR/engine/report-tool.ts" generate \
351
350
  --task-subdir "<task_subdir>" \
352
351
  --app-metadata "<output_path>/app-metadata.json" \
353
- --hap "<hap_path>" \
352
+ --hap "<entry_hap>" \
354
353
  --device "<device_serial>" \
355
354
  --suite "<suite_name>" \
356
355
  --out "<output_path>/self-test-report.md" \
@@ -363,7 +362,7 @@ cd "<autotest_dir>" && uv run python report_tool.py generate \
363
362
  To re-validate an existing report without regenerating it (debugging only):
364
363
 
365
364
  ```bash
366
- cd "<autotest_dir>" && uv run python report_tool.py validate "<output_path>/self-test-report.md"
365
+ node "$TOOL_DIR/engine/report-tool.ts" validate "<output_path>/self-test-report.md"
367
366
  ```
368
367
 
369
368
  **Pre-case rendering**: Rows with `case_name` starting with `[PRE] ` go into `## 前置用例`. All others go into `## 用例详情`. Pre indices and Case indices each start at 1 within their own section (`### Pre 1:`, `### Case 1:`). The script emits these forms automatically — do NOT hand-edit to `### Case PRE-1:` or any other variant; the validator will reject it.
@@ -375,22 +374,3 @@ cd "<autotest_dir>" && uv run python report_tool.py validate "<output_path>/self
375
374
  > - tells the 建议 reader that pre-failures should be treated as environment problems first, and only enter the fix flow if a white-box review confirms a real code bug.
376
375
  >
377
376
  > Downstream agents — especially `self-test-fixer` — must respect this framing: **do not modify application code based on a pre-case failure unless white-box review concludes the failure surfaces a genuine app defect**. This rationale is intentional and load-bearing; do not collapse it into a one-liner.
378
-
379
- ---
380
-
381
- ## Guidelines
382
-
383
- - **#1 — Use `self_test_runner.py` for run and status**: Always use `self_test_runner.py run` to perform setup + start batch as a detached process, then `self_test_runner.py status` to poll. This ensures the test process survives agent session termination.
384
- - **#2 — Every case MUST include `**AutoTest 任务路径**`**: the absolute `report_dir` from `task_results.jsonl`. Without it the report is incomplete and users cannot locate execution artifacts. After T9, verify every case section contains this field.
385
- - **Two-phase architecture**: When the parse phase runs, the LLM writes `_extracted.json` → `testcases_tool.py` writes `testcases.json`. Never write `testcases.json` directly. If `testcases.json` already exists at the output path and the parse phase runs, `testcases_tool.py` overwrites it — never skip the script.
386
- - **App name → bundle_name is critical**: `test_steps` must use `bundle_name` (e.g., `com.example.tuku`), NOT the display name. AutoTest uses this to launch the correct app. Using the display name instead may launch the wrong app entirely.
387
- - **JSON contract**: `app-metadata.json` and `testcases.json` always live at `<output_path>/app-metadata.json` and `<output_path>/testcases.json`. T2 reads from the file (not from memory).
388
- - **AutoTest directory locator**: Resolve `<HOMETRANS_TOOL_PATH>/test-tools/autotest` from the `HOMETRANS_TOOL_PATH` OS environment variable → walking up from `<output_path>` (see Shared Utilities). Do not assume `$(pwd)` is anchored anywhere in particular.
389
- - **Sentinel-format early-exit reports**: When T1 / T3 / T4 / T7 write a degraded FAIL report (config error, no device, missing autotest dir, crashed batch, timeout, or `setup=false` precondition failure), the report's first non-frontmatter line MUST be `status: FAIL` and the second MUST be `reason: <one-line reason>`. This lets callers detect early-exit reports without parsing a case table.
390
- - **Quote all paths** — paths may contain spaces.
391
- - **Capture complete output** — never truncate command output; it is essential for diagnosis.
392
- - **Do NOT read AutoTest internals** — the instructions above provide the complete calling convention. Do not spend time reading installed `AutoTest` modules or `self_test_runner.py` source code to "understand" how they work.
393
- - **Do NOT hand-write reports** — `report_tool.py generate --validate` renders all reports. Hand-writing bypasses the validator that downstream `self-test-fixer` relies on.
394
- - **Validate is the gate**: S5 `VALIDATION PASSED` and T9 `VALIDATION PASSED` are the completion signals.
395
- - **Do NOT modify test cases after execution**: Failures indicate HAP functionality gaps, not test case defects. Record results as-is.
396
- - **Pre-cases are environment scripts, not feature scenarios**: their failures usually indicate environment issues. The **常规通过率** (regular-only pass rate) is the primary quality metric; `self-test-fixer` must not modify application code based on a pre-case failure unless white-box review confirms a real defect.