@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
@@ -0,0 +1,241 @@
1
+ # TCG 测试用例生成系统 — 说明文档
2
+
3
+ > TCG = Test Case Generation。一套把**需求 SPEC** 自动转换为**自带证据的测试用例 md** 的流水线,打包为 `hmos-test-case-generation` skill(编排器 `SKILL.md`)+ 两个核心子 agent(`generator` 生成 / `validator` 复核)+ 非 LLM 校验脚本(`tools/validate.ts`)+ 三方共享契约(`references/contract.md`)。
4
+ > 本文档说明系统的整体架构、各文件职责、数据流、调用方式与失败处理。单个 skill / agent 的完整规则请直接看对应文件,本文档只做导航与总览。
5
+
6
+ ---
7
+
8
+ ## 1. 这套系统解决什么问题
9
+
10
+ TCG 的主流程是测试用例生成:输入一份 SPEC(`## 场景N` 原子场景块,由上游 `spec-generate` 拆好),可选读取 UI 元素描述(`ui_elements.json`)和参考资料,为每个场景生成自带四诚实证据的测试用例:
11
+
12
+ - `test_case.md` — 主测试用例(S3 逐批写,内嵌证据)
13
+ - `pre_test_case.md` — 前置用例(S3 按批累计,S6 收口;存在「见前置用例」时必须产出,无命中时可省略)
14
+ - `review_notes.md` — 单一人工伴随件(S6 合并:阻塞区 + 非阻塞区合一)
15
+
16
+ 下游由 `hmos-integration-test` skill 接力,把 `test_case.md` 转成可执行的 `testcases.json`。
17
+
18
+ `ui_elements.json` 是 TCG 的软参照输入,不是测试用例交付件本身。缺少 `ui-elements-path` 但给了 `package` 或 `android-project-dir` 时,TCG 可先运行 viewtree-based UI elements mapping 生成:用 `tools/bfs-crawl/android_viewtree_bfs_crawler.ts` 采集 Android 运行时 viewtree dump,再转换为 `ui_elements.json`。
19
+
20
+ 核心问题不是「把场景写成操作步骤」——这不难;难在**让写出来的用例值不值得信**。TCG 的解法是「生成与复核分离」+ 四诚实证据 + 两道复核门。
21
+
22
+ ---
23
+
24
+ ## 2. 架构总览
25
+
26
+ 三层 + 一份契约:
27
+
28
+ ```
29
+ ┌─────────────────────────────────────────────┐
30
+ │ TCG (Orchestrator skill) │
31
+ │ 瘦壳:S0 建表 / S1 分批 / S6 收口 + 驱动循环 │
32
+ │ 自己不读 SPEC 正文 / 不派生 / 不判语义 │
33
+ └─────────────────────────────────────────────┘
34
+ │ 逐批:dispatch generator → validate.ts → validator
35
+ ▼
36
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
37
+ │ generator │ → │ validate.ts │ → │ validator │
38
+ │ 生成(不自核)│ │ 机械核(S4) │ │ 语义复核(S5)│
39
+ └──────────────┘ └──────────────┘ └──────────────┘
40
+ ←──── FAIL 重试 ≤3 次(各门独立)────→
41
+ │
42
+ ┌─────────────────────────────────────────────┐
43
+ │ 共享底座:contract.md(三方共读) │
44
+ │ 四诚实 + 7 硬约束 + 用例格式 │
45
+ └─────────────────────────────────────────────┘
46
+ ```
47
+
48
+ **形态**:1 skill + 2 agent + 3 reference + 2 tool,没有更多。思路是**能用程序就不开 agent、单读者的纪律不单独抽 reference**。
49
+
50
+ **两条铁判据(不可违背):**
51
+ 1. **可判定边界**——S4(程序 `validate.ts`)与 S5(`validator` agent)分属两侧,机械核不做语义判断、语义校验不被判真,二者不可合并。
52
+ 2. **生产者 ≠ 复核者**——generator 只生成不自核;S4/S5 不重做生成。
53
+
54
+ ---
55
+
56
+ ## 3. 各文件职责
57
+
58
+ > `SKILL.md` / `references/` / `tools/` 同属 `skills/hmos-test-case-generation/` 目录;agents 装在仓库根 `agents/` 目录(独立于 skill,由 SKILL.md 调度)。
59
+
60
+ | 文件 | 角色 | 干什么 | 不干什么 |
61
+ |------|------|--------|----------|
62
+ | `SKILL.md` | 编排器 skill | S0 建场景表 / S1 枚举+分批 / S6 收口 + 驱动逐批循环(S2+S3 generator → S4 validate.ts → S5 validator)+ 重试兜底 | 不读 SPEC 正文、不派生、不渲染用例、不做语义校验 |
63
+ | `agents/test-case-generation-generator.md` | 生成子 agent · S2+S3 | S2 沿引用有界 BFS 裁工作集(≤窗口)+ 场景内 branch 派生 + S3 按 contract §3 写四诚实证据;repair 模式只修被点名项 | 只生成不自核(不跑 validate、不做语义判断) |
64
+ | `agents/test-case-generation-validator.md` | 复核子 agent · S5 | 四类语义裁决(来源相关+预期忠实 / 语义完整 / oracle 充分 / 跨态稳定)+ 跨场景数据等价去重;每条裁决带引用 | 只裁决不生成(不重写用例) |
65
+ | `references/contract.md` | 三方共享契约 | 四诚实 + 7 硬约束(左:generator 必满足 / 右:prog 机械核 + validator 语义)+ 用例格式骨架。generator 写 / validator 读 / validate.ts 扫,三方指这一份 | 不描述编排流程(指向 SKILL.md) |
66
+ | `references/review-notes-template.md` | 人工伴随件模板 | 单一 `review_notes.md` 的结构(阻塞区在上 + 非阻塞区在下,合一为一个文件);S6 渲染套用 | — |
67
+ | `references/ui-elements-schema.md` | UI 元素表 schema | 定义 `ui_elements.json` 的结构与消费规则;S0 step 3 的 dump → convert pipeline 按此产出,generator 的信任分层按此消费 | — |
68
+ | `tools/validate.ts` | 非 LLM 程序校验 | `cases`:S4 可判定核(非空/结构/枚举/外键/计数);`md`:S6 成品复核(文件名/禁字段/单一伴随件/pre_test_case 形态);`verify`:S5 核 validator 报告引文接地(req_span 场景存在 + quote 逐字命中 SPEC/test_case);`slice-spec`:确定性切累计 SPEC 视图 | 不做语义判断(含糊/恒真/相关性归 S5),verify 只核引文真伪不核裁决对错 |
69
+ | `tools/convert_to_ui_elements.ts` | 非 LLM 转换器 | viewtree dump → `ui_elements.json`(S0 step 3 调用,zero-LLM,详见 §8) | 不参与校验、不做语义判断 |
70
+
71
+ > **single source of truth**:派生与证据规则都在 `contract.md`;编排流程只在 `SKILL.md`;agent 只指向、不另抄;改 contract §3(格式/字段/枚举)须同步 validate.ts 顶部代码镜像正则。
72
+
73
+ ---
74
+
75
+ ## 4. 数据流与中间产物
76
+
77
+ ### 输入项
78
+
79
+ | 输入 | 必需 | 说明 |
80
+ |---|---|---|
81
+ | `spec-path` | 是 | `<feature>-SPEC.md`(spec-generate 产出,`## 场景N` 原子场景块)。意图 ≈ 场景:领取已拆好的场景,不再自行发现意图。 |
82
+ | `ui-elements-path` | 否 | `ui_elements.json`。**软参照**:不保真、可缺。缺但给了 `package` 或 `android-project-dir` 时,TCG 在 S0 step 3 自动产(BFS dump → convert);三者都缺则相关软核跳过。 |
83
+ | `package` | 否 | Android 应用包名(如 `com.example.app`)。`ui-elements-path` 缺时用它直接跑 dump,优先于 `android-project-dir`(跳过推导)。需 Node.js ≥22.18 / 23.6、ADB + 设备。 |
84
+ | `android-project-dir` | 否 | Android 源码工程根目录。`ui-elements-path` 和 `package` 都缺时才用:从 `build.gradle` 的 `applicationId` 推导包名 → 跑 dump。 |
85
+ | `references-dir` | 否 | 外部参照包:操作定义/页面描述/模板/可复用前置用例库/特殊测试数据。软参照,缺则相关复用机会消失、流程照走。 |
86
+ | `output-path` | 否 | 默认 `<sibling of spec-path>/testcase-output/`。 |
87
+
88
+ ### 主要交付产物
89
+
90
+ | 输出 | 必需 | 产生步 | 说明 |
91
+ |---|---|---|---|
92
+ | `test_case.md` | 是 | S3 逐批写 | 主用例,自带四诚实证据,SKIP 记录也写在此 |
93
+ | `pre_test_case.md` | 条件必须 | S3 累计 / S6 收口 | generator 外置「见前置用例」前提,S6 去重、排序、重编号;有命中则必须产出,无命中则不出 |
94
+ | `review_notes.md` | 是 | S6 合并 | **单一**人工伴随件(阻塞区 + 非阻塞区合一;**不得另产 manual-intervention.md**,拆文件会被 `md` 复核判 `companion_not_merged` / `manual_intervention_forbidden` FAIL) |
95
+
96
+ > **目录纪律**:交付目录只放上述三件;所有过程件(`cases-report.json` / `md-report.json` / 裁决文件及 `_bfs_dump/`)写入同级 `{output-path}.work/`,不进交付目录;交付件单独可读,人工处理所需信息不依赖过程产物或本机路径。
97
+ > **文件名是强约束**:固定名 `test_case.md` 等,下游 `hmos-integration-test` 以固定名 `test_case.md` 作为 `test-case-path` 接入。
98
+
99
+ ---
100
+
101
+ ## 5. 怎么调用
102
+
103
+ 调用 orchestrator,它会自动处理所有场景:
104
+
105
+ ```
106
+ Skill(hmos-test-case-generation, args: `
107
+ spec-path: path/to/<feature>-SPEC.md # 必需
108
+ ui-elements-path: path/to/ui_elements.json # 可选,软参照;缺则见下行
109
+ package: com.example.app # 可选,直接传包名(优先于下行)
110
+ android-project-dir: path/to/android/proj # 可选,package 缺时从工程推导包名
111
+ references-dir: path/to/references/ # 可选
112
+ output-path: path/to/testcase-output/ # 可选,默认 spec 同级
113
+ `)
114
+ ```
115
+
116
+ 完成时 stdout 最后一行:
117
+
118
+ ```
119
+ TCG_COMPLETE specs={N} ok={K} failed={A} output={output-path}
120
+ ```
121
+ (N=场景数,K=两门均放行的场景数,A=留记号/FATAL 的场景数)
122
+
123
+ ABORT(S4/S5 退出码 3 全局致命):
124
+ ```
125
+ TCG_ABORT reason=<全局配置致命> output={output-path}
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 6. 编排流程 S0–S6(概要)
131
+
132
+ 完整规则见 `SKILL.md`。要点:
133
+
134
+ - **S0 建场景表**:读 SPEC,grep `## 场景N` 建索引(只切 span,不深读);探测软参照可读性;建输出目录。
135
+ - **S1 领场景 + 分批**:每个 `## 场景N` 领为一份意图(漏领 FAIL);按上下文窗口贪心装箱(锚点 `CTX × 0.5`)。
136
+ - **逐批循环**(换页边界 = 一批):
137
+ - **S2+S3** dispatch generator(取信息 + 生成四诚实证据,只生成不自核)
138
+ - **S4** 覆盖刷新“截至当前批”的单个累计 SPEC 视图,再由 `validate.ts cases` 对累计 test_case 做程序可判定核(退出码 0/1/2/3)
139
+ - **S5** dispatch validator(四类语义裁决 + 去重);报告按批次/尝试留档,并用 `reviewed_scenarios` 做本批覆盖回执
140
+ - 两门各独立 ≤3 次重试(有效 FAIL 同页重开、只修被点名项;S5 坏报告只重写报告);耗尽留记号交人、本批不停。
141
+ - **S6 全局收口**:totality 终扫(防静默蒸发)+ 全量去重终扫(每场景去重后 ≥1)+ 合成三件交付件 + 可选 `md` 成品复核 + 红线声明 + 收口信号。
142
+
143
+ > 每批最坏:1×generate + ≤3×S4-repair + ≤3×S5-repair = ≤7 次 generator 派发 + ≤12 次 validate.ts 调用(7 × `cases` + 4 × `verify` + 1 × `slice-spec`,含 S5 修复后的 S4 回归检查)+ ≤4 次 validator。
144
+
145
+ ---
146
+
147
+ ## 7. 四诚实 + 控制不变量(概要)
148
+
149
+ 完整定义见 `contract.md`。
150
+
151
+ **四诚实**(契约的为什么):有源(对得上 SPEC)/ 周延(每支有去向)/ 可循(动作落到具体对象)/ 可证(TP 是机器能判真假的二值状态)。做不到的写带原因的 `[SKIP]`,不假装做到。
152
+
153
+ **7 条硬约束**(左:generator 必满足 / 右:prog 机械核 + validator 语义):
154
+ 1. 有源·场景映射;2. 周延·场景覆盖;3. 可循·动作具体;4. 可证·TP 非平凡;5. 兜底·SKIP 规范;6. 去重·base 撞车不丢;7. 前置·标注合法。
155
+
156
+ **推导类型**:`[推导]` 表示非 base、从同一 SPEC 场景内部派生。generator 在 `## 场景来源映射` 的 delta 中标注推导类型,validator 独立核对分类与分支覆盖;类型闭集及处理规则以 `contract.md` §3.3 为准。
157
+
158
+ **控制不变量**:每意图必有去向(出用例 / 出 SKIP / 留记号);场景 totality(每场景 ≥1 用例);ui_elements 非阻塞软核(硬门只留文本自洽 + SPEC 外键);按上下文窗口粗估换页;重试耗尽不扔、留记号交人。
159
+
160
+ > **签名构成**以 `contract.md` §2 #6 为唯一定义;validate.ts 据此判逐字精确重复。数据等价(100 vs 101、歌单A vs B)归 validator 语义侧,程序不抹平。
161
+
162
+ ---
163
+
164
+ ## 8. viewtree pipeline(产出 ui_elements.json)
165
+
166
+ `ui_elements.json` 是 TCG 的可选软参照输入(§4)。当 `ui-elements-path` 缺省但 `package` 或 `android-project-dir` 给了时,TCG 在 **S0 step 3** 自动跑这个两步 pipeline(runtime BFS view-tree dump → TCG schema)产 `ui_elements.json`;给了 `ui-elements-path` 则跳过。产物结构与消费规则见 `references/ui-elements-schema.md`。
167
+
168
+ ```
169
+ Step 0 BFS dump tools/bfs-crawl/android_viewtree_bfs_crawler.ts (Node + ADB)
170
+ → page_NNNN_<Activity>/{meta.json, view.xml, screenshot.png, view_scroll_*.xml}
171
+ Step 1 convert convert_to_ui_elements.ts (Node ≥22.18 / 23.6, zero-LLM)
172
+ → ui_elements.json + page.parsed.json (display_texts 副作用)
173
+ ```
174
+
175
+ ### Step 0: BFS dump
176
+
177
+ BFS crawler:
178
+
179
+ ```powershell
180
+ node .\tools\bfs-crawl\android_viewtree_bfs_crawler.ts `
181
+ --package com.example.app `
182
+ --output .\bfs_output `
183
+ [--device emulator-5554] [--max-depth 6] [--max-pages 500] [--max-scrolls 10] [--skip-same-activity]
184
+ ```
185
+
186
+ BFS 机制:uiautomator dump → tap 触发导航 → 签名去重判新页 → 滚动采 display_texts。crawler 包含 root 恢复、深度上限、危险操作拦截、近似重复合并和 `gaps.json`/`crawl_stats.json`/`crawl_decisions.jsonl` 诊断信息。`--allow-pm-clear` 是显式 opt-in:只有确认允许清空 app 数据时才传。诊断信息是人工 supplement,不写入最终 `ui_elements.json`;转换器仍只消费通用 dump contract。
187
+
188
+ ### Step 1: convert
189
+
190
+ ```powershell
191
+ node .\skills\hmos-test-case-generation\tools\convert_to_ui_elements.ts `
192
+ --dump <bfs_dump_dir> --out <out_dir>/ui_elements.json `
193
+ [--app-name <name>] [--package <pkg>] [--description <desc>]
194
+ ```
195
+
196
+ ### 测试(mock 数据,无需设备)
197
+
198
+ ```powershell
199
+ cd skills/hmos-test-case-generation/tools
200
+ node convert_to_ui_elements.ts --dump test_fixtures --out test_out/ui_elements.json
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 9. validate.ts(程序校验)
206
+
207
+ 非 LLM 的 TypeScript 脚本,四子命令(`cases` / `md` / `verify` / `slice-spec`)。靠 Node 原生类型擦除运行(Node ≥22.18 / 23.6 直接 `node validate.ts`),无需编译、无依赖。
208
+
209
+ ```bash
210
+ # S4:校验 test_case.md 用例结构(可判定核)
211
+ node tools/validate.ts cases <test_case.md> --spec <spec.md> [--ui <ui.json>] --report <report.json>
212
+
213
+ # S6:校验交付件成品
214
+ node tools/validate.ts md <output_dir> --report <report.json>
215
+
216
+ # S5:核 validator 报告引文接地(req_span 场景存在 + quote 逐字命中 SPEC/test_case)
217
+ node tools/validate.ts verify <validator-report.json> --spec <spec.md> [--test-case <test_case.md>] --report <report.json>
218
+
219
+ # S4:确定性切累计 SPEC 视图(SPEC 前言 + 指定场景块,滚动校验视图)
220
+ node tools/validate.ts slice-spec <spec.md> --scenes 1,2,3 --out <out_dir>/spec-through-current-batch.md
221
+ ```
222
+
223
+ 退出码:`0` 过 / `1` 规则失败(可重试,吐 report)/ `2` 不可解析(本批/目录级 FATAL)/ `3` 配置缺失(全局 FATAL)。
224
+
225
+ 校验失败写 report.json,含 `failed_items[]`(每项有 `rule` + `scenario_id` + `detail` + `fix_hint`),由编排器喂回 generator 做定向修复。**程序只查存在/计数/枚举/外键,不做语义判断**(含糊/恒真/相关性/数据等价归 S5)。
226
+
227
+ ---
228
+
229
+ ## 10. 常见问题
230
+
231
+ **Q: 为什么校验用程序而不是让 LLM 自检?**
232
+ A: 字面包含、文件命名、禁用字段、外键这类硬约束,程序判定 100% 可靠,LLM 自检会漏。LLM 只负责需要语义理解的部分(含糊/恒真/相关性/数据等价)。
233
+
234
+ **Q: 一个场景失败会影响其他场景吗?**
235
+ A: 不会。退出码 2(本批 FATAL)和重试耗尽都只跳过当前批,留记号交人。只有退出码 3(全局配置缺失)才中止整条流水。
236
+
237
+ **Q: 重试会不会死循环?**
238
+ A: 不会。S4、S5 各独立 MAX_RETRY=3,达到上限即标记失败放行(留记号交人),不再重试。
239
+
240
+ **Q: 为什么把人工伴随件合成一个 review_notes.md?**
241
+ A: 阻塞区(须先处理才能跑)和非阻塞区(不挡执行)分区但合一为一个文件,避免拆文件后人只看一份漏了另一份。validate.ts `md` 会拦「另起 manual-intervention.md」和「多个伴随件并存」。
@@ -0,0 +1,324 @@
1
+ ---
2
+ name: hmos-test-case-generation
3
+ description: "Generate test_case.md with built-in evidence from a SPEC file whose filename ends in -SPEC.md (produced by hmos-spec-generate; ## 场景N atomic scenario blocks) plus optional ui_elements.json. If ui_elements.json is absent, TCG can first produce a viewtree-based UI elements mapping from Android runtime dumps. Orchestrates generation-review separation: generate four-honesty evidence cases per scenario via page rotation, then finalize through two review gates — validate.ts (decidable) and validator (undecidable) — producing test_case.md / pre_test_case.md / a single manual companion document. Triggers: generate test cases, test case generation, TCG, scenarios to cases, test case generation. Downstream: hmos-integration-test."
4
+ license: MIT
5
+ allowed-tools: [Read, Write, Edit, Bash, Agent, Glob, Grep, AskUserQuestion]
6
+ ---
7
+
8
+ # TCG Orchestrator · Generation-Review Separation
9
+
10
+ > In one sentence: **every test case must stand trial for its own authenticity.**
11
+ > Sole goal = test case quality (four honesty dimensions: sourced/complete/traceable/provable); bounded context is the cost side; evidence lives in `test_case.md`, **`scenarios.json` is forbidden**.
12
+
13
+ You are an **orchestrator skill**. Your job is the **§10 "mechanical preparation/scheduling" type**: perform judgment-free routines like **S0 build index / S1 enumerate-claim + batch by context window / S6 global finalization**, and **drive the per-batch page-rotation loop + two review gates**. You **do not write evidence cases (delegated to generator), do not perform decidable checks (delegated to validate.ts), do not make semantic judgments (delegated to validator)**.
14
+
15
+ **Two iron rules (the basis for role separation, non-negotiable):**
16
+ 1. **Decidability boundary** — S4 (the program `validate.ts`) and S5 (the `validator` agent) sit on opposite sides of the boundary; mechanical checks make no semantic judgments, semantic validation cannot be mechanically asserted true; the two cannot be merged.
17
+ 2. **Producer ≠ Reviewer** — S3 generation (generator) and S4/S5 review must be separated; self-evidencing without self-review is the entire point of "generation-review separation".
18
+
19
+ > **Path convention**: `<skill_dir>` = this skill's install directory (i.e. the directory containing this `SKILL.md`). The validation script you run via Bash is at `<skill_dir>/tools/validate.ts`; reference materials are in `<skill_dir>/references/`. The two sub-agents (`test-case-generation-generator` / `test-case-generation-validator`) live in **a separate agents directory** and cannot relatively locate this skill's resources, so **when dispatching an agent you must pass the absolute path `<skill_dir>/references/contract.md` explicitly as `contract-path`**.
20
+
21
+ ---
22
+
23
+ ## Input / Output
24
+
25
+ | Input | Required | Notes |
26
+ |---|---|---|
27
+ | `spec-path` | **yes** | `<feature>-SPEC.md` (produced by spec-generate; `## 场景N` atomic scenario blocks = `### 场景概述` + `### 场景逻辑步骤`). **Intent ≈ scenario**: claim pre-split scenarios, do not discover intent yourself. |
28
+ | `ui-elements-path` | no | `ui_elements.json`. **Soft reference**: not guaranteed faithful, may be absent. If absent but `package` or `android-project-dir` is given, TCG produces it internally (S0 step 3). If all absent, the relevant soft checks are skipped. |
29
+ | `package` | no | Android app package name (e.g. `com.example.app`). Used when `ui-elements-path` is absent: run the repo-level BFS dump (`tools/bfs-crawl/android_viewtree_bfs_crawler.ts`) → convert (`convert_to_ui_elements.ts`) to produce `ui_elements.json`. Takes priority over `android-project-dir` (skip derivation). Requires Node.js ≥22.18 / 23.6, ADB, and an Android device/emulator with the app installed. |
30
+ | `android-project-dir` | no | Android source project root. Used only when both `ui-elements-path` and `package` are absent: derive package from `applicationId` in `build.gradle` → run dump + convert. |
31
+ | `references-dir` | no | External reference pack: operation definitions / page descriptions / templates / reusable precondition-case library / special test data / "allowed default precondition list". Soft reference; if absent, the relevant reuse opportunities disappear but the flow proceeds. |
32
+ | `output-path` | no | Default `<sibling of spec-path>/testcase-output/`. |
33
+
34
+ > **Removed** `spec-filter`, producer priority, extraction-only mode, and the old `_internal/` machinery — this flow enters directly from SPEC.
35
+
36
+ | Output | Required | Produced at step |
37
+ |---|---|---|
38
+ | `test_case.md` | **yes** | Produced per intent at S3, merged at S6. Carries built-in four-honesty evidence; SKIP records are also written here |
39
+ | `pre_test_case.md` | conditional | Accumulated per batch by the generator at S3 from "see precondition case" preconditions, then globally deduplicated/renumbered and finalized at S6; required when at least one such precondition exists, omitted only when there are no hits |
40
+ | Single manual companion document `review_notes.md` (blocking region + non-blocking region **merged into one file**; **must not also produce manual-intervention.md**) | **yes** | Accumulated throughout S0–S6, rendered at S6. Splitting into two files → validate.ts `md` judges `manual_intervention_forbidden` / `companion_not_merged` FAIL |
41
+
42
+ ---
43
+
44
+ ## Configuration Constants
45
+
46
+ | Constant | Default | Meaning |
47
+ |---|---|---|
48
+ | `CTX` | 200000 | Target model context window (rough char-count anchor, not exact token count) |
49
+ | `SAFE_FRACTION` | 0.5 | Safety fraction: per-batch merged working-set rough-size upper bound = `CTX × SAFE_FRACTION` (leaving half for output + reasoning + slack) |
50
+ | `MAX_RETRY` | 3 | Independent retry cap for S4 and S5 respectively; see each gate's loop for semantics |
51
+
52
+ ---
53
+
54
+ ## Process Overview (S0–S6)
55
+
56
+ You own **S0 build index / S1 enumerate + batch / S6 finalize + whole-flow scheduling**; in the per-batch loop: dispatch `test-case-generation-generator` for **S2+S3**, run `validate.ts cases` via Bash for **S4 (gate 1)**, dispatch `test-case-generation-validator` for **S5 (gate 2)**. Each gate carries ≤3 retries.
57
+
58
+ ```
59
+ S0 build index ── S1 enumerate + batch by window ──┐
60
+ │ for batch in batches:
61
+ ├──→ S2+S3 generator (generate, no self-review)
62
+ ├──→ S4 gate 1 validate.ts cases (program, decidable) ≤3 retry → repair
63
+ └──→ S5 gate 2 validator (semantic, undecidable) ≤3 retry → repair
64
+ S6 global finalization ←───────────────────────────┘
65
+ ```
66
+
67
+ ---
68
+
69
+ ## S0 — Build Index Base (you do this, mechanical)
70
+
71
+ 1. **Parse SPEC**: read `spec-path`, grep all `## 场景N` blocks, build `SceneIndex := {scene_id → {overview span, steps span}}`. This is the sole authoritative base.
72
+ - Here just slice out each scenario's "overview span" and "steps span" (line numbers / char ranges suffice); **do not deep-read, do not judge semantics** — deep reading is done by the generator at S2 when it looks up the original text.
73
+ 2. **Create output and work directories**: if `output-path` is omitted → `<sibling of spec-path>/testcase-output/`; set `work := {output-path}.work` (first strip any trailing `/` from `output-path`); create both directories. `{output-path}/` is the clean delivery directory, while `{work}/` holds BFS dumps, validation reports, and standalone debugging verdicts.
74
+ 3. **Produce ui_elements.json if absent** (mechanical, device-dependent): if `ui-elements-path` is already given → skip (use it as-is). Otherwise, resolve the package:
75
+ - If `package` is given → use it directly.
76
+ - Else if `android-project-dir` is given → **derive package**: locate the application module (the one whose Gradle file applies `com.android.application`, usually `app/`); read `applicationId` from `build.gradle` (Groovy: `applicationId "com.x"`) or `build.gradle.kts` (Kotlin DSL: `applicationId = "com.x"`); fallback to `package="..."` in `AndroidManifest.xml`.
77
+ - If neither `package` nor `android-project-dir` is given → skip (soft checks skipped, same as absent).
78
+ - **Run dump**: run the repo-level crawler directly with Node.js: `node {skill_dir}/../../tools/bfs-crawl/android_viewtree_bfs_crawler.ts --package <pkg> --output {work}/_bfs_dump [--device <serial>] [--adb-path <adb>] [--max-depth 6] [--max-pages <N>] [--max-scrolls <N>] [--skip-same-activity]`. This crawler records diagnostics (`gaps.json`, `crawl_stats.json`, `crawl_decisions.jsonl`) as manual-review supplements. Do not pass `--allow-pm-clear` unless the user explicitly opts into clearing app data before crawl.
79
+ - **Run convert**: `node {skill_dir}/tools/convert_to_ui_elements.ts --dump {work}/_bfs_dump --out {work}/_bfs_dump/ui_elements.json`.
80
+ - **Do not inline diagnostics**: keep `gaps.json` / `crawl_stats.json` / `crawl_decisions.jsonl` next to the dump for manual follow-up only; `convert_to_ui_elements.ts` preserves the existing `ui_elements.json` shape.
81
+ - Set `ui-elements-path := {work}/_bfs_dump/ui_elements.json`.
82
+ - **If dump fails** (no device / ADB unavailable / app not installed) → **do not abort**: record "no ui_elements (dump failed: <reason>)" to the companion-document buffer; the relevant soft checks are skipped (same as absent).
83
+ 4. **Light-probe soft references**: do one "can-read" probe (exists and is readable) for each of `ui-elements-path` (now possibly produced in step 3) and `references-dir`.
84
+ - **Do not parse contents**. If absent, record one entry "no mapping table" / "no references" to the companion-document buffer; **do not error, do not abort**.
85
+ 5. **Assert non-empty**: `assert SceneIndex has ≥1 ## 场景N`.
86
+ - If there is not a single scenario → **do not silently exit**: write a SKIP record (`skip_reason: 输入缺失`) into the companion document, then jump to S6 finalization (emit `TCG_COMPLETE specs=0 ...`).
87
+
88
+ ---
89
+
90
+ ## S1 — Claim Worklist + Batch by Budget (you do this, mechanical)
91
+
92
+ 1. **Enumerate intents**: `worklist := [ scenario-intent{scene_id, dim_type=base} for scene in SceneIndex ]`.
93
+ - Each `## 场景N` is claimed as one intent (faithfully render the scenario itself).
94
+ 2. **Assert totality**: `assert every ## 场景N is claimed as ≥1 intent` (scenario totality; missed claims are reported), eliminating "upstream split it, downstream missed testing it".
95
+ 3. **Do not make derivation judgments** (role boundary): branch derivation (A/B classification, pairwise, semantic implication) residual within a scenario is judgment work → **belongs to generator** (done inside S3 + bookkeeping). The generator classifies every derived or pruned branch with the authoritative type table in contract §3.3; S4 checks only structure, and S5 independently verifies each recorded classification. **You only enumerate scenarios, you do not make derivation judgments.**
96
+ 4. **Batch by context window** `batches := pack_by_ctx(worklist)`; assign each result its 1-based `batch_no`:
97
+ - Anchor = `CTX` (configuration constant). **Do not count tokens exactly, just roughly estimate text volume**.
98
+ - **Greedy bin-packing**: sequentially stuff scenarios into a batch, accumulating each scenario's rough size as you go; keep stuffing as long as `current batch rough-sum < CTX × SAFE_FRACTION`; **the moment it exceeds, seal the batch and open a new one**.
99
+ - **A single scenario itself is too large** (its rough size already ≥ `CTX × SAFE_FRACTION`) → **occupy a batch alone** (the generator then processes it per-intent / or converts to SKIP[上下文超窗] if needed).
100
+ - **Rough-estimate formula** (crude but enough for batching): `scenario span char count + roughly matched element count`. The real fallback is in the generator's S2 (it compares the actually assembled material against the window; if exceeded, it splits / leaves a debit).
101
+ - Result: each batch = one or several **small scenarios** batched together (merged ≤ window safety fraction), or one **large scenario** occupying alone.
102
+ > You **never stuff the full SPEC / the entire element table into any single generation** — only pass "this batch's scene ids + span references" to the generator, which decides its own working set.
103
+
104
+ ---
105
+
106
+ ## Per-Batch Page-Rotation Loop (page boundary = one batch)
107
+
108
+ For each `batch` in `batches`, reuse the run-level `work := {output-path}.work` for process reports. All batches write the accumulated deliverables to `{output-path}/`; run the following three segments in order: **S2+S3 generate → S4 gate 1 → S5 gate 2**. Only when a batch completes (both gates pass) do you rotate the page and take the next batch.
109
+
110
+ ### S2+S3 — Dispatch Generator to Generate (generate only, no self-review)
111
+
112
+ Dispatch the generator once to process this batch. It decides its own working set + does intra-scenario derivation + writes four-honesty evidence.
113
+
114
+ ```
115
+ Agent({
116
+ subagent_type: "test-case-generation-generator",
117
+ description: "Generate cases for batch (scenes={list of scene_ids in batch})",
118
+ prompt: `
119
+ Input parameters:
120
+ - scenes: {batch} # scenarios in this batch: each contains scene_id + overview/steps span (merged already ≤ window safety fraction)
121
+ - spec-path: {spec-path} # look up span original text
122
+ - ui-elements-path: {ui-elements-path or (empty)} # soft reference; if absent, the relevant soft-check slots are empty
123
+ - references-dir: {references-dir or (empty)}
124
+ - contract-path: {skill_dir}/references/contract.md
125
+ - output-path: {output-path}
126
+ Task: S2 via reference-bounded BFS cut out the minimal working set for this batch (≤ window; if exceeded, split / leave debit) → intra-scenario branch derivation (bookkeeping)
127
+ → S3 write test_case.md in the real format per contract §3 (with four-honesty evidence embedded); for every `[推导]`, record derivation type + trigger + change in `## 场景来源映射` or review_notes; for what cannot be done, write [SKIP: <reason>] records.
128
+ Generate only, no self-review.
129
+ `
130
+ })
131
+ ```
132
+
133
+ **Wait for return.** Then proceed to S4.
134
+
135
+ ### S4 — Gate 1: Decidable Review (`validate.ts cases`, program, not LLM)
136
+
137
+ Immediately before this batch's S4, **generate** `{work}/spec-through-current-batch.md` **deterministically with the tool — do not hand-assemble it** (a mis-stitched view, one dropped scene or garbled line, silently corrupts the totality check):
138
+
139
+ ```
140
+ node {skill_dir}/tools/validate.ts slice-spec {spec-path} \
141
+ --scenes <comma-joined scene numbers claimed by batches 1..batch_no, taken from SceneIndex> \
142
+ --out {work}/spec-through-current-batch.md
143
+ ```
144
+
145
+ This emits the SPEC preamble plus the complete `## 场景N` blocks for exactly those scenes, **verbatim and in source order** (a nonzero exit means the slice failed — common causes: requested scene id not in the SPEC, spec file missing, or usage error; check stderr for the reason). This rolling validation view reaches the full scenario set in the final batch; the generator and validator continue to use the original `spec-path`.
146
+
147
+ Run the program against the accumulated `{output-path}/test_case.md` and this cumulative SPEC view, so earlier batches are regression-checked without treating future batches as missing. **Initialize this gate's retry counter `r4 := 0` (MAX_RETRY=3) once for this batch**, enter the loop:
148
+
149
+ > **Fold-pointer check (part of `cases`)**: `cases` also mechanically verifies `去向=fold:N-M#TP-k` fold rows in `## 场景来源映射` (contract §3.3 「折叠记账」) — a pointer to a missing Scenario → `fold_target_scenario_missing`, to a missing TP-k → `fold_target_tp_missing` (both exit 1, repairable). This is the **decidable half of "禁空白折叠"**: the empty fold (a fold claimed with no TP behind it) is caught here, before it reaches S5. Whether the cited TP is *semantically adequate* to cover the folded field stays with the validator (S5). The prose-fold-literal ban (`折叠进/折叠入/folded into`) is a separate `md`-subcommand gate at S6 (rule `prose_fold_claim`). Only triggers when `去向=fold:` pointers are present → no effect on legacy baselines.
150
+
151
+ ```
152
+ loop:
153
+ code := run: node {skill_dir}/tools/validate.ts cases \
154
+ {output-path}/test_case.md \
155
+ --spec {work}/spec-through-current-batch.md \
156
+ --ui {ui-elements-path} # if ui-elements-path is absent, omit this arg (--ui is accepted but only used for an existence warning; the soft/grounding checks are performed by the validator agent in S5, not validate.ts)
157
+ --report {work}/cases-report.json
158
+ branch on code (see table below)
159
+ ```
160
+
161
+ | Exit code | Meaning | Action |
162
+ |---|---|---|
163
+ | **0** | PASS | Break out of this gate's loop → proceed to **S5 gate 2**. |
164
+ | **1** | Rule failure (retryable, has emitted `cases-report.json`) | `r4++`. **If `r4 ≤ 3`** → dispatch generator in **repair mode** (pass `cases-report.json`, **reopen on the same page, no page rotation**) to rewrite the named fields, then **return to the top of the loop and re-run S4**. **If `r4 > 3`** (i.e. after the 3rd repair the re-check still fails, retries exhausted) → **do not discard**: record a self-contained `FAIL_VALIDATE` summary into the companion review_notes per `review-notes-template.md`, **break out of this gate's loop, still proceed to S5** (leave a marker for humans, do not block remaining batches). |
165
+ | **2** | Batch/scenario-level fatal (unparseable) | Record a `FATAL` (this batch) into the companion document, **break out of this gate, skip S5 for this batch**, rotate the page directly to the next batch (**do not block remaining batches**). |
166
+ | **3** | Global config fatal (config/script missing) | `ABORT_PIPELINE`: stop the entire pipeline, emit failure finalization (see end of S6), do not process subsequent batches. |
167
+
168
+ **S4 repair dispatch (reopen on the same page, fix only named fields, do not re-dispatch the full set):**
169
+
170
+ ```
171
+ Agent({
172
+ subagent_type: "test-case-generation-generator",
173
+ description: "Repair cases for batch (S4 retry {r4})",
174
+ prompt: `
175
+ mode: repair
176
+ Input parameters:
177
+ - scenes: {batch}
178
+ - spec-path: {spec-path}
179
+ - ui-elements-path: {ui-elements-path or (empty)}
180
+ - references-dir: {references-dir or (empty)}
181
+ - contract-path: {skill_dir}/references/contract.md
182
+ - output-path: {output-path}
183
+ - report: {work}/cases-report.json # failure items named by validate.ts
184
+ Task: rewrite on the same page (no page rotation), fix only the named fields, do not re-dispatch the full set.
185
+ `
186
+ })
187
+ ```
188
+
189
+ > **Unambiguous retry boundary (S4)**: `r4` starts from 0; on exit code 1, `r4++`. The 1st/2nd/3rd failures (`r4=1,2,3`) each dispatch one repair then re-run; **if after the 3rd repair it still exits 1**, `r4` has now incremented to 4 (`>3`), i.e. "exhausted" — no more repairs, record `FAIL_VALIDATE` for humans and proceed to S5 as usual. At most **3 repair dispatches**.
190
+
191
+ ### S5 — Gate 2: Undecidable Judgment (dispatch validator, independent reviewer)
192
+
193
+ Dispatch the validator to read this batch's cases + cross-check against SPEC scenarios, performing four categories of semantic verdicts + dedup data-equivalence judgment. **Initialize this gate's retry counter `r5 := 0` (MAX_RETRY=3)**, enter the loop:
194
+
195
+ ```
196
+ loop:
197
+ current_report := {work}/validator-report-batch-{batch_no}-attempt-{r5}.json
198
+ Agent({
199
+ subagent_type: "test-case-generation-validator",
200
+ description: "Validator review for batch (S5 retry {r5})",
201
+ prompt: `
202
+ Input parameters:
203
+ - scenes: {batch} # authoritative scope for this call; test_case.md is accumulated, so review only cases mapped to these scene ids
204
+ - test-case-path: {output-path}/test_case.md
205
+ - spec-path: {spec-path}
206
+ - contract-path: {skill_dir}/references/contract.md
207
+ - ui-elements-path: {ui-elements-path or (empty)}
208
+ - pre-test-case-path: {output-path}/pre_test_case.md if it exists, otherwise (empty)
209
+ - output-path: {output-path}
210
+ - report-path: {current_report} # versioned per batch/attempt; never overwrite prior reports
211
+ Task: four categories of semantic verdicts (source-relevance + expected-faithfulness / semantic completeness [incl. derivation type review] / oracle sufficiency [incl. TP tautology judgment] / cross-state stability [incl. action-ambiguity and restart-overreach judgments])
212
+ + dedup data-equivalence judgment + lightweight consistency check between this batch's "see precondition case" references and the currently accumulated pre_test_case.md. Each FAIL verdict carries a citation ({req_span, quoted snippet}).
213
+ FAIL loop-closing: repairable defects → disposition=repair; structurally infeasible → disposition=convert_to_skip. The generator performs every test_case.md rewrite.
214
+ Merge verdicts into the single review_notes.md (blocking region + non-blocking region merged; follow review-notes-template.md; do not start a separate manual-intervention.md).
215
+ })
216
+ Require the validator to write {current_report} using the schema in its agent contract. First perform the small process-integrity check below; only then read failed_items and branch.
217
+ ```
218
+
219
+ After the validator returns, read `current_report` without making any semantic judgment. It is **structurally usable** only when: the file exists and is valid JSON; `batch_scenes` exactly matches this batch; `reviewed_scenarios` lists every Scenario belonging to this batch exactly once and no earlier Scenario; `failed_items` is an array; and every failed item names a current-batch `scenario`, a non-empty `field/reason/req_span/quote/fix_hint`, a `semantic_class` from `sourced|complete|provable|traceable`, and a `disposition` from `repair|convert_to_skip`.
220
+
221
+ Then run the **mechanical citation-grounding check** — the citation is the one decidable core of an undecidable verdict, so the orchestrator does **not** take it on faith:
222
+
223
+ ```
224
+ node {skill_dir}/tools/validate.ts verify {current_report} \
225
+ --spec {work}/spec-through-current-batch.md \
226
+ --test-case {output-path}/test_case.md \
227
+ --report {work}/verify-report-batch-{batch_no}-attempt-{r5}.json
228
+ ```
229
+
230
+ Per failed item it checks that `req_span` names a scene that **exists** in the SPEC and that `quote` appears **verbatim (whitespace-folded)** in the SPEC source or the test_case ledger — i.e. the validator did not hallucinate a citation to FAIL an innocent case. Exit `0` = all citations grounded; `1` = at least one ungrounded citation (**treat the whole report as untrustworthy, same as malformed** — a fabricated citation voids the routing); `≥2` = report unreadable. Together with the structural check this verifies **routing data + citation authenticity** only — never whether the verdict is *correct*, only that its cited span/quote is real (not a third semantic gate).
231
+
232
+ Then check whether it has any **outstanding FAIL** that "needs the orchestrator to return to the generator for repair":
233
+
234
+ | Report state | Action |
235
+ |---|---|
236
+ | Missing, malformed, failing the process-integrity check, **or failing `verify` (ungrounded citation, exit ≠ 0)** | `r5++`. **If `r5 ≤ 3`** → redispatch the validator for the same page and a new versioned `current_report`; do not dispatch the generator because no trustworthy semantic repair request was obtained. **If `r5 > 3`** → record a self-contained `FAIL_VALIDATOR_REPORT` summary in review_notes per `review-notes-template.md` and release this batch with a human marker. |
237
+ | `failed_items` is empty | Break out of this gate's loop → release this batch (proceed to "page-rotation criteria"). |
238
+ | `failed_items` is non-empty (each item has `disposition=repair` or `convert_to_skip`) | `r5++`. **If `r5 ≤ 3`** → dispatch generator in **repair mode** with `current_report`, then follow the repair path below. **If `r5 > 3`** → record a self-contained `FAIL_VALIDATOR` summary in review_notes per `review-notes-template.md`, release this batch with a human marker. |
239
+
240
+ > The validator **never edits `test_case.md`**. For a structurally infeasible case it reports `disposition=convert_to_skip`; the generator applies the SKIP conversion in repair mode, and the result goes through S4 then S5 again.
241
+
242
+ > **Explicit repair path**: `S5 → generator (mode: repair, same page) → S4 → S5`. This reopens the current S3 output, but does **not** rerun normal S2/S3 generation, BFS, or full-set derivation.
243
+
244
+ **S5 repair dispatch** (same shape as S4, except `report` is replaced with the validator's FAIL verdict):
245
+
246
+ ```
247
+ Agent({
248
+ subagent_type: "test-case-generation-generator",
249
+ description: "Repair cases for batch (S5 validator retry {r5})",
250
+ prompt: `
251
+ mode: repair
252
+ Input parameters:
253
+ - scenes: {batch}
254
+ - spec-path: {spec-path}
255
+ - ui-elements-path: {ui-elements-path or (empty)}
256
+ - references-dir: {references-dir or (empty)}
257
+ - contract-path: {skill_dir}/references/contract.md
258
+ - output-path: {output-path}
259
+ - report: {current_report} # structured semantic defects named by the validator
260
+ Task: rewrite on the same page (no page rotation), apply only failed_items named by the validator (including disposition=convert_to_skip), and synchronize only directly dependent ledger/precondition artifacts; do not re-dispatch the full set.
261
+ `
262
+ })
263
+ ```
264
+
265
+ > **Unambiguous retry boundary (S5)**: `r5` starts from 0 and is independent of `r4`; re-entering S4 preserves the current `r4`. Every non-releasing result — malformed/citation-ungrounded report, or non-empty `failed_items` — consumes one S5 retry (routed per the table above). If the result after the 3rd retry still cannot release (`r5>3`) → record `FAIL_VALIDATOR` or `FAIL_VALIDATOR_REPORT` for humans and release. At most **3 S5 retry dispatches** and **4 validator reports**, all preserved under versioned paths.
266
+
267
+ ### Page-Rotation Criteria
268
+
269
+ This batch **S4 PASS (or S4 exhausted with marker) + S5 no outstanding FAIL (or S5 exhausted with `FAIL_VALIDATOR` / `FAIL_VALIDATOR_REPORT` marker) + every intent in this batch has a destination (case emitted / SKIP emitted / marker left)** → rotate the page, take the next batch. S4 exit code 2 (batch FATAL) rotates the page directly; exit code 3 ABORTs directly.
270
+
271
+ > **Worst-case dispatch count per batch**: `1×generate + ≤3×S4-repair + ≤3×S5-repair` = ≤ **7 generator dispatches** + ≤7 `validate.ts cases` runs (including S4 re-checks after S5 repairs) + ≤4 validator dispatches + ≤4 `validate.ts verify` runs (program, no LLM) + 1 `slice-spec` per batch.
272
+
273
+ ---
274
+
275
+ ## S6 — Global Finalization (you do this, mechanical: set-difference + assemble deliverables)
276
+
277
+ After all batches have run (or ABORT):
278
+
279
+ 1. **Totality final scan (prevent silent evaporation)**:
280
+ `totality := setdiff({full set of intents enumerated at S1}, {cases emitted in test_case.md ∪ SKIP records ∪ marker-left set})`.
281
+ - Non-empty = some intent silently evaporated → for each evaporated intent, **FAIL fallback**: add a SKIP record with a reason (or re-run the corresponding batch, depending on cost), ensuring the "every intent must have a destination" invariant holds.
282
+ 2. **Full-exact dedup final scan**:
283
+ `dedup_final := case_signature_ledger full-exact char-by-char dedup final scan`, and verify **"each scenario still has ≥1 case after dedup"** (lower half of scenario totality); if some scenario reduces to zero after dedup → FAIL fallback for that scenario.
284
+ 3. **Assemble deliverables** (**the delivery directory holds only deliverables, no process files**):
285
+ > **Directory discipline (iron rule)**: `{output-path}/` **lands only these three** —— `test_case.md` + (if any) `pre_test_case.md` + **single manual companion document** (i.e. **one** `review_notes.md`, blocking region + non-blocking region merged; **must not also produce manual-intervention.md**, splitting files will be judged `manual_intervention_forbidden` / `companion_not_merged` FAIL by the `md` review). **All process files** (`cases-report.json` / `md-report.json` / any standalone semantic-validation verdict file / `_bfs_dump/`) are written to `{work}/`, **never to `{output-path}/`**. The deliverables remain self-contained per `review-notes-template.md`; process locations stay in run logs. Semantic-validation verdicts are **merged into the single manual companion document** by design, not started as separate files; if a verdict file is left standalone for debugging, it is a process file and belongs in `{work}/`.
286
+ - `test_case.md`: all accumulated cases (already including SKIP records from each batch).
287
+ - `pre_test_case.md`: take the S3-accumulated segments as the baseline and finalize them **in this order**:
288
+ 1. **Exact-dedup**: collapse byte-identical segments (genuine cross-batch reuse), preserving the generator's dependency order.
289
+ 2. **Global fixture-name reconciliation (cross-batch collision guard)**: batches accumulate blind (batch 2+ does not reread batch 1's bodies), so two batches can each emit a segment that builds a fixture with the **same data name but different content** (e.g. both build `测试歌单1` with different members). Segments are separate AutoTest tasks whose persisted data carries over, so two same-name-but-non-identical fixtures corrupt each other at runtime. For every data name (playlist / song / etc.) bound by **≥2 non-identical** surviving segments: keep the first occurrence, **rename each later occurrence to a fresh global neutral name** (continue the global `测试歌单K` / `歌曲X` counter), and **synchronize every verbatim `(见前置用例)` reference in `test_case.md`** that depended on the renamed name/state, so each consuming precondition still names the concrete fixture it actually uses. Byte-identical read-only baselines are not collisions — step 1 already merged them.
290
+ 3. **Renumber** segment ids (`## 段N`) into final contiguous order.
291
+ - Decide whether the file is required by scanning `test_case.md` for `(见前置用例)`; if a referenced segment is still missing after S5, record a finalization marker instead of synthesizing an operation chain. Only when there are no hits is the file omitted.
292
+ - **Single manual companion document**: apply `{skill_dir}/references/review-notes-template.md`, render the two regions accumulated throughout the flow into **one file `review_notes.md`** — blocking region on top (cross-app / white-box etc. SKIPs + special data that must be constructed first + empty-state execution-order exceptions aggregated) + non-blocking region at the bottom (pruning/sampling bookkeeping + stub-implementation background awareness items + validator semantic-validation verdicts + S4/S5 exhausted markers). **The companion file is always emitted (required deliverable); within it, emit each section only when it has content — fold empty categories as entire sections**. **Never split into `manual-intervention.md` + `review_notes.md` as two files** — blocking is just a region at the top of this file; landing multiple companion documents at once will be judged `manual_intervention_forbidden` / `companion_not_merged` FAIL by the `md` review in step 4.
293
+ 4. **Deliverable review (optional `md` subcommand)**: run `validate.ts md {output-path} --report {work}/md-report.json` to check the deliverable artifacts (filenames / forbidden fields / MI filtering / pre_test_case form / prose-fold-literal ban `prose_fold_claim`). **Report is written to `{work}/`, not landed in the delivery directory** (same directory discipline as step 3). Exit-code semantics are the same as the S4 table (0 pass / 1 record in review_notes / 2 this-directory FATAL / 3 ABORT).
294
+ 5. **Red-line declaration on disk**: write explicitly in the companion document that **"S6 PASS does not imply the scenario set is exhaustive"** (missing-from-universe is undecidable, belongs to S5, outside the red line).
295
+ 6. **Finalization signal** (the last line of stdout, no other decoration):
296
+ - Normal: `TCG_COMPLETE specs={N} ok={K} failed={A} output={output-path}`
297
+ (`N` = number of scenarios, `K` = number of scenarios released by both gates, `A` = number of scenarios with markers / FATAL)
298
+ - ABORT (S4/S5 exit code 3): `TCG_ABORT reason=<global-config-fatal> output={output-path}`
299
+
300
+ ---
301
+
302
+ ## Control Invariants (hard constraints, one violation = error)
303
+
304
+ 1. **Decidability boundary**: S4 = program, S5 = validator, separated on two sides, not mixed (criterion ①).
305
+ 2. **Producer ≠ Reviewer**: generator only generates, no self-review; S4/S5 do not redo generation (criterion ②).
306
+ 3. **Every intent must have a destination**: either emit a case, or write a SKIP with a reason (non-empty "should-have" expectation); silent evaporation is forbidden.
307
+ 4. **Scenario totality**: every `## 场景N` must be claimed as ≥1 intent, and still have ≥1 case after dedup.
308
+ 5. **ui_elements trust grading**: locator/observable verification against the json is a **non-blocking soft check** (misses record suspicion, absences are skipped), **never a hard gate**; hard gates are reserved for "text self-consistency + SPEC foreign keys".
309
+ 6. **Page rotation by context-window rough estimate**: the anchor is the target model's context window CTX (not exact token budget, not a rigid "one scenario per pass"); a batch's rough text volume < CTX safety fraction is enough, small scenarios are batched together, large scenarios occupy alone, the orchestrator never stuffs the full SPEC / the entire table into any single generation.
310
+ 7. **Retry**: S4 and S5 each independently ≤3 times; when exhausted **do not discard, leave a marker for humans** (record in review_notes), a single intent's failure does not block the rest.
311
+
312
+ ---
313
+
314
+ ## Reference Files
315
+
316
+ | File | Role |
317
+ |---|---|
318
+ | `references/contract.md` | ★ Four honesty dimensions + 7 hard constraints + evidence encoding format (written by generator / read by validator / scanned by validate.ts, shared by all three). Pass as `contract-path` (absolute path) when dispatching agents. |
319
+ | `references/review-notes-template.md` | Template + filled example for the single manual companion document `review_notes.md` (blocking region on top + non-blocking region at bottom, merged into one file); apply when rendering the companion document at S6. |
320
+ | `references/ui-elements-schema.md` | Schema for the `ui_elements.json` artifact + generator consumer rules (§Consumer rules: locator verbatim against on-screen text / flow tolerance / gaps→review_notes logging / display_texts external link). |
321
+ | `tools/validate.ts` | S4 decidable review · **pure-format check (Plan A)**: only checks non-empty / structure / enum / foreign-key / count; ambiguity · tautology judgments belong to semantic validation (`cases` scans test_case.md cases / `md` checks deliverable artifacts) |
322
+ | `agents/test-case-generation-generator.md` | S2+S3 generator (dispatch it for generation + repair) |
323
+ | `agents/test-case-generation-validator.md` | S5 semantic validation (dispatch it for semantic verdicts) |
324
+ | repo `tools/bfs-crawl/android_viewtree_bfs_crawler.ts` + `{skill_dir}/tools/convert_to_ui_elements.ts` | S0 step 3 · viewtree pipeline: full BFS dump (ADB + device, `uiautomator dump` → tap navigation → root recovery / depth cap / signature-dedup / variant merge / scroll-harvest) → `ui_elements.json` + `page.parsed.json`. Run when `ui-elements-path` is absent but `package` or `android-project-dir` is given. CLI details see `README.md §8` |