@buaa_smat/hometrans 0.1.17 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/README.md +138 -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 +35 -376
  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 +19 -146
  35. package/dist/cli/config.js +6 -8
  36. package/dist/cli/env-vars.js +1 -3
  37. package/dist/cli/index.js +0 -11
  38. package/dist/cli/init.js +147 -235
  39. package/dist/cli/uninstall.js +5 -129
  40. package/dist/utils/regex.js +8 -0
  41. package/env-requirements.json +57 -55
  42. package/package.json +6 -8
  43. package/resource/convert_pipeline_process.svg +103 -0
  44. package/resource/project_architecture.svg +122 -0
  45. package/resource/title_dark.png +0 -0
  46. package/skills/hmos-batch-ui-align/SKILL.md +345 -43
  47. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
  48. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  49. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  50. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. 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
  61. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  62. 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
  63. 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
  64. 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
  65. 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
  66. 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
  67. 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
  68. 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
  69. 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
  70. 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
  71. 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
  72. 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
  73. 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
  74. 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
  75. 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
  76. 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
  77. 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
  78. 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
  79. 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
  80. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
  81. package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
  82. package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
  83. package/skills/hmos-convert-pipeline/SKILL.md +188 -131
  84. package/skills/hmos-fix-build-errors/SKILL.md +87 -67
  85. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
  86. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
  87. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
  88. package/skills/hmos-incremental-ui-align/README.md +57 -40
  89. package/skills/hmos-incremental-ui-align/SKILL.md +180 -24
  90. package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
  91. package/skills/hmos-incremental-ui-align/page_align.md +62 -62
  92. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
  93. 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
  94. 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
  95. 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
  96. 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
  97. 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
  98. 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
  99. 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
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. 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
  106. 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
  107. 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
  108. 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
  109. 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
  110. 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
  111. 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
  112. 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
  113. 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
  114. 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
  115. 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
  116. 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
  117. 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
  118. 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
  119. 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
  120. 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
  121. package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
  122. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
  123. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
  124. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
  125. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  126. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
  127. package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
  128. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
  129. package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
  130. package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
  131. package/skills/hmos-integration-test/README.md +111 -79
  132. package/skills/hmos-integration-test/SKILL.md +216 -132
  133. package/skills/hmos-integration-test/scripts/report-tool.ts +791 -0
  134. package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +125 -0
  135. package/skills/hmos-integration-test/scripts/self-test-runner.ts +756 -0
  136. package/skills/hmos-integration-test/scripts/testcases-tool.ts +239 -0
  137. package/skills/hmos-resources-convert/SKILL.md +334 -66
  138. package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
  139. package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
  140. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
  141. package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
  142. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
  143. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
  144. package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
  145. package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
  146. package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
  147. package/skills/hmos-spec-generate/SKILL.md +293 -214
  148. package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
  149. package/skills/hmos-spec-generate/template/REQ.txt +22 -0
  150. package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
  151. package/skills/hmos-test-case-generation/README.md +241 -0
  152. package/skills/hmos-test-case-generation/SKILL.md +324 -0
  153. package/skills/hmos-test-case-generation/references/contract.md +315 -0
  154. package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
  155. package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
  156. package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
  157. package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
  158. package/tools/bfs-crawl/README.md +73 -0
  159. package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
  160. package/agents/build-fixer.md +0 -385
  161. package/agents/logic-coder/scripts/platform_context_query.py +0 -568
  162. package/agents/review-fixer.md +0 -405
  163. package/agents/spec-generator.md +0 -541
  164. package/dist/cli/mcp-setup.js +0 -258
  165. package/dist/cli/mcp.js +0 -94
  166. package/dist/context/index.js +0 -694
  167. package/resource/migration_process.svg +0 -94
  168. package/resource/migration_process_transparent.svg +0 -93
  169. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
  170. package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
  171. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
  172. package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
  173. package/skills/hmos-resources-convert/evals/evals.json +0 -171
  174. package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
  175. package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
  176. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
  177. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
  178. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
  179. package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
  180. package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
  181. package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
  182. package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
  183. package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
  184. package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
  185. package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
  186. package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
  187. package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
  188. package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
  189. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
  190. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
  191. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
  192. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
  193. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
  194. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
  195. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
  196. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
  197. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
  198. package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
  199. package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
  200. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
  201. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
  202. package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
  203. package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
  204. package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
  205. package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
  206. package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
  207. package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
  208. package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
  209. package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
  210. package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
  211. package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
  212. package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
  213. package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
  214. package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
  215. package/tools/test-tools/autotest/README.md +0 -238
  216. package/tools/test-tools/autotest/pyproject.toml +0 -26
  217. package/tools/test-tools/autotest/report_tool.py +0 -759
  218. package/tools/test-tools/autotest/self_test_runner.py +0 -895
  219. package/tools/test-tools/autotest/testcases_schema.md +0 -143
  220. package/tools/test-tools/autotest/testcases_tool.py +0 -215
  221. package/tools/test-tools/autotest/uv.lock +0 -3156
  222. package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
  223. package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
  224. package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
  225. package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
  226. package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
  227. package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
@@ -1,157 +1,157 @@
1
- # Known Compile Error Patterns
2
-
3
- > **This file is auto-maintained by `a2h-retrospect`.**
4
- > Manual edits are allowed but may be overwritten when retrospect detects updated patterns.
5
- > Last updated: 2026-03-27
6
-
7
- ---
8
-
9
- ## Pattern Index
10
-
11
- | # | Error Code / Type | Frequency | Short Description |
12
- |---|-------------------|-----------|-------------------|
13
- | 1 | arkts-identifiers-as-prop-names | 85 | ValuesBucket computed property name |
14
- | 2 | type mismatch (EventData) | 16 | EventData double type cast |
15
- | 3 | arkts-no-untyped-obj-literals | 9 | Untyped object literal |
16
- | 4 | type mismatch (promptAction) | 8 | promptAction button color type |
17
- | 5 | type error (@Prop) | 3 | @Prop naming conflict |
18
-
19
- ---
20
-
21
- ## 1. ValuesBucket Computed Property Name
22
-
23
- - **Date**: 2026-03-27
24
- - **Error code**: `arkts-identifiers-as-prop-names`
25
- - **Frequency**: 85 occurrences
26
- - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
27
-
28
- **Error code**:
29
- ```typescript
30
- const bucket: ValuesBucket = {
31
- [ColumnName.TITLE]: title, // ERROR: computed property name not allowed
32
- [ColumnName.URL]: url,
33
- };
34
- ```
35
-
36
- **Correct code**:
37
- ```typescript
38
- const bucket: ValuesBucket = {};
39
- bucket[ColumnName.TITLE] = title;
40
- bucket[ColumnName.URL] = url;
41
- ```
42
-
43
- **Rule**: ArkTS forbids computed property names (`[expr]: value`) in object literals. Build the object first, then assign properties via bracket notation.
44
-
45
- ---
46
-
47
- ## 2. EventData Double Type Cast
48
-
49
- - **Date**: 2026-03-27
50
- - **Error code**: type mismatch
51
- - **Frequency**: 16 occurrences
52
- - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
53
-
54
- **Error code**:
55
- ```typescript
56
- emitter.on({ eventId: 1 }, (data: emitter.EventData) => {
57
- const value = data.data?.['key'] as string; // ERROR: data.data is optional Record, direct cast fails
58
- });
59
- ```
60
-
61
- **Correct code**:
62
- ```typescript
63
- emitter.on({ eventId: 1 }, (data: emitter.EventData) => {
64
- const raw = data.data as Record<string, Object>;
65
- const value = raw['key'] as string;
66
- });
67
- ```
68
-
69
- **Rule**: `EventData.data` is typed `Record<string, Object> | undefined`. Access requires two steps: (1) cast to `Record<string, Object>`, (2) cast the extracted value to the target type.
70
-
71
- ---
72
-
73
- ## 3. Untyped Object Literal
74
-
75
- - **Date**: 2026-03-27
76
- - **Error code**: `arkts-no-untyped-obj-literals`
77
- - **Frequency**: 9 occurrences
78
- - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
79
-
80
- **Error code**:
81
- ```typescript
82
- const options = {
83
- title: 'Hello',
84
- message: 'World',
85
- }; // ERROR: object literal without explicit type annotation
86
- ```
87
-
88
- **Correct code**:
89
- ```typescript
90
- interface DialogOptions {
91
- title: string;
92
- message: string;
93
- }
94
- const options: DialogOptions = {
95
- title: 'Hello',
96
- message: 'World',
97
- };
98
- ```
99
-
100
- **Rule**: ArkTS requires all object literals to have an explicit type. Define an `interface` or `class` and annotate the variable.
101
-
102
- ---
103
-
104
- ## 4. promptAction Button Color Type
105
-
106
- - **Date**: 2026-03-27
107
- - **Error code**: type mismatch
108
- - **Frequency**: 8 occurrences
109
- - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
110
-
111
- **Error code**:
112
- ```typescript
113
- promptAction.showDialog({
114
- buttons: [
115
- { text: 'OK', color: '#ff0000' } // ERROR: color expects ResourceColor, not string
116
- ]
117
- });
118
- ```
119
-
120
- **Correct code**:
121
- ```typescript
122
- promptAction.showDialog({
123
- buttons: [
124
- { text: 'OK', color: Color.Red }
125
- ]
126
- });
127
- // Or use $r('app.color.xxx') for resource reference
128
- ```
129
-
130
- **Rule**: `promptAction.showDialog` button `color` property expects `ResourceColor` type (Color enum or `$r()` resource reference), not a raw hex string.
131
-
132
- ---
133
-
134
- ## 5. @Prop Naming Conflict
135
-
136
- - **Date**: 2026-03-27
137
- - **Error code**: type error
138
- - **Frequency**: 3 occurrences
139
- - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
140
-
141
- **Error code**:
142
- ```typescript
143
- @Component
144
- struct MyComponent {
145
- @Prop title: string = ''; // ERROR: 'title' conflicts with built-in component property
146
- }
147
- ```
148
-
149
- **Correct code**:
150
- ```typescript
151
- @Component
152
- struct MyComponent {
153
- @Prop itemTitle: string = ''; // Renamed to avoid conflict
154
- }
155
- ```
156
-
157
- **Rule**: Certain property names (`title`, `content`, `action`, etc.) conflict with built-in component attributes. Prefix with a domain-specific qualifier (e.g., `itemTitle`, `feedTitle`).
1
+ # Known Compile Error Patterns
2
+
3
+ > **This file is auto-maintained by `a2h-retrospect`.**
4
+ > Manual edits are allowed but may be overwritten when retrospect detects updated patterns.
5
+ > Last updated: 2026-03-27
6
+
7
+ ---
8
+
9
+ ## Pattern Index
10
+
11
+ | # | Error Code / Type | Frequency | Short Description |
12
+ |---|-------------------|-----------|-------------------|
13
+ | 1 | arkts-identifiers-as-prop-names | 85 | ValuesBucket computed property name |
14
+ | 2 | type mismatch (EventData) | 16 | EventData double type cast |
15
+ | 3 | arkts-no-untyped-obj-literals | 9 | Untyped object literal |
16
+ | 4 | type mismatch (promptAction) | 8 | promptAction button color type |
17
+ | 5 | type error (@Prop) | 3 | @Prop naming conflict |
18
+
19
+ ---
20
+
21
+ ## 1. ValuesBucket Computed Property Name
22
+
23
+ - **Date**: 2026-03-27
24
+ - **Error code**: `arkts-identifiers-as-prop-names`
25
+ - **Frequency**: 85 occurrences
26
+ - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
27
+
28
+ **Error code**:
29
+ ```typescript
30
+ const bucket: ValuesBucket = {
31
+ [ColumnName.TITLE]: title, // ERROR: computed property name not allowed
32
+ [ColumnName.URL]: url,
33
+ };
34
+ ```
35
+
36
+ **Correct code**:
37
+ ```typescript
38
+ const bucket: ValuesBucket = {};
39
+ bucket[ColumnName.TITLE] = title;
40
+ bucket[ColumnName.URL] = url;
41
+ ```
42
+
43
+ **Rule**: ArkTS forbids computed property names (`[expr]: value`) in object literals. Build the object first, then assign properties via bracket notation.
44
+
45
+ ---
46
+
47
+ ## 2. EventData Double Type Cast
48
+
49
+ - **Date**: 2026-03-27
50
+ - **Error code**: type mismatch
51
+ - **Frequency**: 16 occurrences
52
+ - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
53
+
54
+ **Error code**:
55
+ ```typescript
56
+ emitter.on({ eventId: 1 }, (data: emitter.EventData) => {
57
+ const value = data.data?.['key'] as string; // ERROR: data.data is optional Record, direct cast fails
58
+ });
59
+ ```
60
+
61
+ **Correct code**:
62
+ ```typescript
63
+ emitter.on({ eventId: 1 }, (data: emitter.EventData) => {
64
+ const raw = data.data as Record<string, Object>;
65
+ const value = raw['key'] as string;
66
+ });
67
+ ```
68
+
69
+ **Rule**: `EventData.data` is typed `Record<string, Object> | undefined`. Access requires two steps: (1) cast to `Record<string, Object>`, (2) cast the extracted value to the target type.
70
+
71
+ ---
72
+
73
+ ## 3. Untyped Object Literal
74
+
75
+ - **Date**: 2026-03-27
76
+ - **Error code**: `arkts-no-untyped-obj-literals`
77
+ - **Frequency**: 9 occurrences
78
+ - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
79
+
80
+ **Error code**:
81
+ ```typescript
82
+ const options = {
83
+ title: 'Hello',
84
+ message: 'World',
85
+ }; // ERROR: object literal without explicit type annotation
86
+ ```
87
+
88
+ **Correct code**:
89
+ ```typescript
90
+ interface DialogOptions {
91
+ title: string;
92
+ message: string;
93
+ }
94
+ const options: DialogOptions = {
95
+ title: 'Hello',
96
+ message: 'World',
97
+ };
98
+ ```
99
+
100
+ **Rule**: ArkTS requires all object literals to have an explicit type. Define an `interface` or `class` and annotate the variable.
101
+
102
+ ---
103
+
104
+ ## 4. promptAction Button Color Type
105
+
106
+ - **Date**: 2026-03-27
107
+ - **Error code**: type mismatch
108
+ - **Frequency**: 8 occurrences
109
+ - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
110
+
111
+ **Error code**:
112
+ ```typescript
113
+ promptAction.showDialog({
114
+ buttons: [
115
+ { text: 'OK', color: '#ff0000' } // ERROR: color expects ResourceColor, not string
116
+ ]
117
+ });
118
+ ```
119
+
120
+ **Correct code**:
121
+ ```typescript
122
+ promptAction.showDialog({
123
+ buttons: [
124
+ { text: 'OK', color: Color.Red }
125
+ ]
126
+ });
127
+ // Or use $r('app.color.xxx') for resource reference
128
+ ```
129
+
130
+ **Rule**: `promptAction.showDialog` button `color` property expects `ResourceColor` type (Color enum or `$r()` resource reference), not a raw hex string.
131
+
132
+ ---
133
+
134
+ ## 5. @Prop Naming Conflict
135
+
136
+ - **Date**: 2026-03-27
137
+ - **Error code**: type error
138
+ - **Frequency**: 3 occurrences
139
+ - **Source**: AntennaPod V1 migration (a2h-retrospect-report-2026-03-27)
140
+
141
+ **Error code**:
142
+ ```typescript
143
+ @Component
144
+ struct MyComponent {
145
+ @Prop title: string = ''; // ERROR: 'title' conflicts with built-in component property
146
+ }
147
+ ```
148
+
149
+ **Correct code**:
150
+ ```typescript
151
+ @Component
152
+ struct MyComponent {
153
+ @Prop itemTitle: string = ''; // Renamed to avoid conflict
154
+ }
155
+ ```
156
+
157
+ **Rule**: Certain property names (`title`, `content`, `action`, etc.) conflict with built-in component attributes. Prefix with a domain-specific qualifier (e.g., `itemTitle`, `feedTitle`).
@@ -1,131 +1,131 @@
1
- # RDB Entity 确定性修复 Pattern
2
- # 适用于: ArkTS 严格模式 + @kit.ArkData relationalStore
3
- # 触发场景: 迁移 Android RDB 实体类到 ArkTS 时
4
- # 经验来源: EinkBro 迁移 (2026-03-26)
5
-
6
- ---
7
-
8
- ## Pattern 1: ValuesBucket 正确用法
9
-
10
- ### 错误写法 (编译报错)
11
- ```typescript
12
- import { relationalStore, ValuesBucket } from '@kit.ArkData';
13
-
14
- toValuesBucket(): ValuesBucket {
15
- const bucket = new ValuesBucket(); // ERROR: 'ValuesBucket' only refers to a type
16
- bucket.put('key', value); // ERROR: ValuesBucket has no .put() method
17
- return bucket;
18
- }
19
- ```
20
-
21
- ### 正确写法
22
- ```typescript
23
- type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
24
-
25
- toValuesBucket(): EntityValuesBucket {
26
- const bucket: EntityValuesBucket = {};
27
- bucket['key'] = value;
28
- return bucket;
29
- }
30
- ```
31
-
32
- **原因**: `ValuesBucket` 在 SDK 中是 type alias (`Record<string, ValueType>`),不是可实例化的类。
33
-
34
- ---
35
-
36
- ## Pattern 2: fromResultSet 参数类型 (禁止 any)
37
-
38
- ### 错误写法 (编译报错)
39
- ```typescript
40
- // ArkTS 严格模式禁止 any
41
- static fromResultSet(resultSet: any): EntityName { // ERROR: arkts-no-any-unknown
42
- ```
43
-
44
- ### 正确写法
45
- ```typescript
46
- static fromResultSet(resultSet: Object): EntityName {
47
- const rs = resultSet as Record<string, Object>;
48
- const colIndex = (name: string): number =>
49
- (rs['getColumnIndex'] as Function)(name) as number;
50
-
51
- entity.field = (rs['getLong'] as Function)(colIndex('field_name')) as number;
52
- entity.name = (rs['getString'] as Function)(colIndex('name')) as string;
53
- return entity;
54
- }
55
- ```
56
-
57
- **替代方案** (更简洁但运行时开销略高):
58
- ```typescript
59
- // 使用类型断言避免 any,运行时通过 Record<string, Function> 调用
60
- static fromResultSet(resultSet: Object): EntityName {
61
- const getCol = (name: string): number =>
62
- (resultSet as Record<string, Function>)['getColumnIndex'](name) as number;
63
- const getLong = (name: string): number =>
64
- (resultSet as Record<string, Function>)['getLong'](getCol(name)) as number;
65
- const getStr = (name: string): string =>
66
- (resultSet as Record<string, Function>)['getString'](getCol(name)) as string;
67
-
68
- const entity = new EntityName();
69
- entity.id = getLong('id');
70
- entity.name = getStr('name');
71
- return entity;
72
- }
73
- ```
74
-
75
- ---
76
-
77
- ## Pattern 3: // @ts-ignore 不可用
78
-
79
- ### 错误尝试
80
- ```typescript
81
- // @ts-ignore // ERROR: Switching off type checks with in-place comments is not allowed
82
- static fromResultSet(resultSet: any): EntityName {
83
- ```
84
-
85
- ### 必须用 Pattern 2 替代
86
-
87
- ---
88
-
89
- ## Pattern 4: toValuesBucket() 返回类型注解
90
-
91
- ```typescript
92
- type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
93
-
94
- toValuesBucket(): EntityValuesBucket {
95
- const bucket: EntityValuesBucket = {} as EntityValuesBucket;
96
- // ...
97
- return bucket;
98
- }
99
- ```
100
-
101
- ---
102
-
103
- ## 完整 Entity 模板
104
-
105
- ```typescript
106
- type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
107
-
108
- export class MyEntity {
109
- id: number = 0;
110
- name: string = '';
111
- value: number = 0;
112
-
113
- static fromResultSet(resultSet: Object): MyEntity {
114
- const rs = resultSet as Record<string, Object>;
115
- const col = (n: string): number => (rs['getColumnIndex'] as Function)(n) as number;
116
- const entity = new MyEntity();
117
- entity.id = (rs['getLong'] as Function)(col('id')) as number;
118
- entity.name = (rs['getString'] as Function)(col('name')) as string;
119
- entity.value = (rs['getLong'] as Function)(col('value')) as number;
120
- return entity;
121
- }
122
-
123
- toValuesBucket(): EntityValuesBucket {
124
- const bucket: EntityValuesBucket = {} as EntityValuesBucket;
125
- if (this.id > 0) { bucket['id'] = this.id; }
126
- bucket['name'] = this.name;
127
- bucket['value'] = this.value;
128
- return bucket;
129
- }
130
- }
131
- ```
1
+ # RDB Entity 确定性修复 Pattern
2
+ # 适用于: ArkTS 严格模式 + @kit.ArkData relationalStore
3
+ # 触发场景: 迁移 Android RDB 实体类到 ArkTS 时
4
+ # 经验来源: EinkBro 迁移 (2026-03-26)
5
+
6
+ ---
7
+
8
+ ## Pattern 1: ValuesBucket 正确用法
9
+
10
+ ### 错误写法 (编译报错)
11
+ ```typescript
12
+ import { relationalStore, ValuesBucket } from '@kit.ArkData';
13
+
14
+ toValuesBucket(): ValuesBucket {
15
+ const bucket = new ValuesBucket(); // ERROR: 'ValuesBucket' only refers to a type
16
+ bucket.put('key', value); // ERROR: ValuesBucket has no .put() method
17
+ return bucket;
18
+ }
19
+ ```
20
+
21
+ ### 正确写法
22
+ ```typescript
23
+ type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
24
+
25
+ toValuesBucket(): EntityValuesBucket {
26
+ const bucket: EntityValuesBucket = {};
27
+ bucket['key'] = value;
28
+ return bucket;
29
+ }
30
+ ```
31
+
32
+ **原因**: `ValuesBucket` 在 SDK 中是 type alias (`Record<string, ValueType>`),不是可实例化的类。
33
+
34
+ ---
35
+
36
+ ## Pattern 2: fromResultSet 参数类型 (禁止 any)
37
+
38
+ ### 错误写法 (编译报错)
39
+ ```typescript
40
+ // ArkTS 严格模式禁止 any
41
+ static fromResultSet(resultSet: any): EntityName { // ERROR: arkts-no-any-unknown
42
+ ```
43
+
44
+ ### 正确写法
45
+ ```typescript
46
+ static fromResultSet(resultSet: Object): EntityName {
47
+ const rs = resultSet as Record<string, Object>;
48
+ const colIndex = (name: string): number =>
49
+ (rs['getColumnIndex'] as Function)(name) as number;
50
+
51
+ entity.field = (rs['getLong'] as Function)(colIndex('field_name')) as number;
52
+ entity.name = (rs['getString'] as Function)(colIndex('name')) as string;
53
+ return entity;
54
+ }
55
+ ```
56
+
57
+ **替代方案** (更简洁但运行时开销略高):
58
+ ```typescript
59
+ // 使用类型断言避免 any,运行时通过 Record<string, Function> 调用
60
+ static fromResultSet(resultSet: Object): EntityName {
61
+ const getCol = (name: string): number =>
62
+ (resultSet as Record<string, Function>)['getColumnIndex'](name) as number;
63
+ const getLong = (name: string): number =>
64
+ (resultSet as Record<string, Function>)['getLong'](getCol(name)) as number;
65
+ const getStr = (name: string): string =>
66
+ (resultSet as Record<string, Function>)['getString'](getCol(name)) as string;
67
+
68
+ const entity = new EntityName();
69
+ entity.id = getLong('id');
70
+ entity.name = getStr('name');
71
+ return entity;
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Pattern 3: // @ts-ignore 不可用
78
+
79
+ ### 错误尝试
80
+ ```typescript
81
+ // @ts-ignore // ERROR: Switching off type checks with in-place comments is not allowed
82
+ static fromResultSet(resultSet: any): EntityName {
83
+ ```
84
+
85
+ ### 必须用 Pattern 2 替代
86
+
87
+ ---
88
+
89
+ ## Pattern 4: toValuesBucket() 返回类型注解
90
+
91
+ ```typescript
92
+ type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
93
+
94
+ toValuesBucket(): EntityValuesBucket {
95
+ const bucket: EntityValuesBucket = {} as EntityValuesBucket;
96
+ // ...
97
+ return bucket;
98
+ }
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 完整 Entity 模板
104
+
105
+ ```typescript
106
+ type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
107
+
108
+ export class MyEntity {
109
+ id: number = 0;
110
+ name: string = '';
111
+ value: number = 0;
112
+
113
+ static fromResultSet(resultSet: Object): MyEntity {
114
+ const rs = resultSet as Record<string, Object>;
115
+ const col = (n: string): number => (rs['getColumnIndex'] as Function)(n) as number;
116
+ const entity = new MyEntity();
117
+ entity.id = (rs['getLong'] as Function)(col('id')) as number;
118
+ entity.name = (rs['getString'] as Function)(col('name')) as string;
119
+ entity.value = (rs['getLong'] as Function)(col('value')) as number;
120
+ return entity;
121
+ }
122
+
123
+ toValuesBucket(): EntityValuesBucket {
124
+ const bucket: EntityValuesBucket = {} as EntityValuesBucket;
125
+ if (this.id > 0) { bucket['id'] = this.id; }
126
+ bucket['name'] = this.name;
127
+ bucket['value'] = this.value;
128
+ return bucket;
129
+ }
130
+ }
131
+ ```