@buaa_smat/hometrans 26.0.2 → 26.0.4

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 (1471) hide show
  1. package/README.md +8 -7
  2. package/agents/code-reviewer.md +111 -154
  3. package/dist/cli/index.js +4 -1
  4. package/dist/cli/init.js +131 -26
  5. package/dist/cli/uninstall.js +5 -5
  6. package/dist/platform/language.js +77 -0
  7. package/env-requirements.json +30 -5
  8. package/i18n/FILE-NAMES.md +9 -0
  9. package/i18n/agents/code-reviewer.md +436 -0
  10. package/i18n/agents/model-render-worker.md +38 -0
  11. package/i18n/agents/specgen-worker.md +18 -0
  12. package/i18n/commands/hometrans.md +17 -0
  13. package/i18n/skills/a2h-app-migrate/SKILL.md +206 -0
  14. package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
  15. package/i18n/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  16. package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
  17. package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
  18. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +2007 -0
  19. package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +187 -0
  20. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1656 -0
  21. package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +728 -0
  22. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
  23. package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  24. package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  25. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  26. package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  27. package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  28. package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  29. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  30. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  31. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  32. package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  33. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  34. package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  35. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  36. package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  37. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  38. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  39. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  40. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  41. package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  42. package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  43. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +207 -0
  44. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  45. package/i18n/skills/a2h-arch-generate/SKILL.md +378 -0
  46. package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  47. package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  48. package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
  49. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  50. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  51. package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  52. package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  53. package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  54. package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  55. package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  56. package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +131 -0
  57. package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  58. package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
  59. package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
  60. package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  61. package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
  62. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  63. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  64. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  65. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  66. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  67. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  68. package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
  69. package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  70. package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
  71. package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
  72. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +304 -0
  73. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +10 -0
  74. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +249 -0
  75. package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +344 -0
  76. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
  77. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
  78. package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +877 -0
  79. package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  80. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  81. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  82. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  83. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  84. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  85. package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  86. package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +597 -0
  87. package/i18n/skills/a2h-batch-ui-align/SKILL.md +372 -0
  88. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +35 -0
  89. package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  90. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  91. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  92. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +85 -0
  93. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +23 -0
  94. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +89 -0
  95. package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  96. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  97. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +62 -0
  98. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +30 -0
  99. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +930 -0
  100. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +420 -0
  101. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +158 -0
  102. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  103. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2552 -0
  104. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
  105. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +175 -0
  106. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +251 -0
  107. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
  108. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +232 -0
  109. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +206 -0
  110. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +232 -0
  111. package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
  112. package/i18n/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  113. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +2118 -0
  114. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  115. package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  116. package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  117. package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1805 -0
  118. package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  119. package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  120. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1959 -0
  121. package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  122. package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
  123. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1632 -0
  124. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1300 -0
  125. package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1234 -0
  126. package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +417 -0
  127. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  128. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
  129. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +216 -0
  130. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +615 -0
  131. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  132. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +49 -0
  133. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  134. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  135. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  136. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
  137. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  138. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
  139. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  140. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  141. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  142. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  143. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  144. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  145. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  146. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  147. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  148. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  149. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  150. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  151. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  152. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  153. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +780 -0
  154. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  155. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  156. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +408 -0
  157. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  158. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  159. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  160. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  161. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  162. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  163. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  164. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +81 -0
  165. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
  166. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  167. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  168. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  169. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  170. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +147 -0
  171. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  172. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  173. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +127 -0
  174. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  175. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  176. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  177. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  178. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  179. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  180. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  181. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  182. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  183. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  184. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  185. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  186. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  187. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  188. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  189. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
  190. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  191. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  192. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  193. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  194. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  195. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  196. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  197. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  198. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  199. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  200. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  201. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  202. package/i18n/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  203. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  204. package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
  205. package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  206. package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  207. package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  208. package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  209. package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  210. package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  211. package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  212. package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  213. package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  214. package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  215. package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  216. package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  217. package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +62 -0
  218. package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
  219. package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
  220. package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  221. package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  222. package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  223. package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
  224. package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2050 -0
  225. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  226. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  227. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  228. package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  229. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  230. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  231. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
  232. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  233. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  234. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  235. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  236. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  237. package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  238. package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  239. package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
  240. package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  241. package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  242. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +265 -0
  243. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  244. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  245. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  246. package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  247. package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  248. package/i18n/skills/a2h-page-specgen/SKILL.md +239 -0
  249. package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +1174 -0
  250. package/i18n/skills/a2h-page-specgen/references/body-language.md +179 -0
  251. package/i18n/skills/a2h-page-specgen/references/gates.md +329 -0
  252. package/i18n/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  253. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +274 -0
  254. package/i18n/skills/a2h-page-specgen/references/spec-example.md +312 -0
  255. package/i18n/skills/a2h-page-specgen/references/spec-template.md +210 -0
  256. package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  257. package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  258. package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  259. package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  260. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  261. package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  262. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  263. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +864 -0
  264. package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +346 -0
  265. package/i18n/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  266. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  267. package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  268. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +684 -0
  269. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  270. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  271. package/i18n/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  272. package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +252 -0
  273. package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  274. package/i18n/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  275. package/i18n/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  276. package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  277. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +864 -0
  278. package/i18n/skills/a2h-page-specgen/scripts/render.mjs +276 -0
  279. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +897 -0
  280. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +25 -0
  281. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +373 -0
  282. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +300 -0
  283. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +47 -0
  284. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +373 -0
  285. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +300 -0
  286. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  287. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  288. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  289. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +373 -0
  290. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  291. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +267 -0
  292. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +57 -0
  293. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +373 -0
  294. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +300 -0
  295. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  296. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  297. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  298. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  299. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  300. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +553 -0
  301. package/i18n/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  302. package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  303. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +546 -0
  304. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +655 -0
  305. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1234 -0
  306. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +520 -0
  307. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1516 -0
  308. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +759 -0
  309. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +630 -0
  310. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +118 -0
  311. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +798 -0
  312. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +886 -0
  313. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  314. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  315. package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1205 -0
  316. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +271 -0
  317. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
  318. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
  319. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
  320. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  321. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  322. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  323. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  324. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  325. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  326. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  327. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  328. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  329. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  330. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  331. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  332. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  333. package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  334. package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  335. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1121 -0
  336. package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  337. package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  338. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  339. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  340. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  341. package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  342. package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +348 -0
  343. package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  344. package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  345. package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  346. package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  347. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  348. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  349. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  350. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +240 -0
  351. package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +427 -0
  352. package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  353. package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  354. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  355. package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  356. package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +536 -0
  357. package/i18n/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  358. package/i18n/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  359. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1239 -0
  360. package/i18n/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  361. package/i18n/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  362. package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  363. package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  364. package/i18n/skills/a2h-resource-convert/SKILL.md +375 -0
  365. package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +336 -0
  366. package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +272 -0
  367. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +226 -0
  368. package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
  369. package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +251 -0
  370. package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  371. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2596 -0
  372. package/i18n/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  373. package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  374. package/i18n/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  375. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +238 -0
  376. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +358 -0
  377. package/i18n/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +307 -0
  378. package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +103 -0
  379. package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +266 -0
  380. package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  381. package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +71 -0
  382. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +55 -0
  383. package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  384. package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +246 -0
  385. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +752 -0
  386. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +661 -0
  387. package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
  388. package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
  389. package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  390. package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  391. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
  392. package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
  393. package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  394. package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  395. package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  396. package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
  397. package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  398. package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  399. package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  400. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
  401. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  402. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  403. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  404. package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
  405. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
  406. package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  407. package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  408. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
  409. package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
  410. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
  411. package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
  412. package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
  413. package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
  414. package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
  415. package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
  416. package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
  417. package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
  418. package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
  419. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  420. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  421. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  422. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  423. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
  424. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
  425. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
  426. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
  427. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  428. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
  429. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
  430. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
  431. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
  432. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
  433. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
  434. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  435. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
  436. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
  437. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
  438. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  439. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
  440. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  441. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  442. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  443. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  444. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  445. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  446. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
  447. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
  448. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
  449. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
  450. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  451. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  452. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  453. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  454. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  455. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  456. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  457. package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
  458. package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  459. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
  460. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
  461. package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
  462. package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  463. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  464. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  465. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  466. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  467. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  468. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  469. package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  470. package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  471. package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  472. package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  473. package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  474. package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  475. package/i18n/skills/a2h-utg-explorer/SKILL.md +126 -0
  476. package/i18n/skills/a2h-utg-explorer/references/architecture.md +282 -0
  477. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +908 -0
  478. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
  479. package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
  480. package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  481. package/i18n/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  482. package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
  483. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +647 -0
  484. package/i18n/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  485. package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  486. package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  487. package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  488. package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +252 -0
  489. package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  490. package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  491. package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  492. package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  493. package/i18n/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  494. package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  495. package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  496. package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  497. package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  498. package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  499. package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  500. package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  501. package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  502. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  503. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  504. package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  505. package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  506. package/i18n/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  507. package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  508. package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  509. package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  510. package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  511. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  512. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  513. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1562 -0
  514. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  515. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2714 -0
  516. package/i18n/skills/a2h-utg-static/SKILL.md +372 -0
  517. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  518. package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
  519. package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2190 -0
  520. package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  521. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +720 -0
  522. package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
  523. package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
  524. package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  525. package/i18n/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  526. package/i18n/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  527. package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
  528. package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +705 -0
  529. package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  530. package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +958 -0
  531. package/i18n/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  532. package/i18n/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  533. package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +545 -0
  534. package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  535. package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
  536. package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  537. package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  538. package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  539. package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  540. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +125 -0
  541. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  542. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  543. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +113 -0
  544. package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  545. package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  546. package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  547. package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  548. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  549. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  550. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  551. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +457 -0
  552. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  553. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  554. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  555. package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  556. package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
  557. package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  558. package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +78 -0
  559. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  560. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  561. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  562. package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  563. package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  564. package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  565. package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  566. package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  567. package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  568. package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  569. package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  570. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  571. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  572. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  573. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +330 -0
  574. package/i18n/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  575. package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  576. package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1394 -0
  577. package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  578. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  579. package/package.json +11 -161
  580. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  581. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  582. package/skills/a2h-app-migrate/SKILL.md +31 -12
  583. package/skills/a2h-app-migrate/references/config.example.json +1 -0
  584. package/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  585. package/skills/a2h-app-migrate/references/stage-map.md +4 -2
  586. package/skills/a2h-app-migrate/references/workflow.yaml +427 -103
  587. package/skills/a2h-app-migrate/scripts/android_index.mjs +35 -8
  588. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +39 -1
  589. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -6
  590. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +144 -9
  591. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +14 -1
  592. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +46 -5
  593. package/skills/a2h-app-migrate/scripts/diagnose.mjs +162 -0
  594. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +178 -44
  595. package/skills/a2h-app-migrate/scripts/feature_scope.mjs +347 -0
  596. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +81 -11
  597. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +17 -1
  598. package/skills/a2h-app-migrate/scripts/ledger.mjs +80 -10
  599. package/skills/a2h-app-migrate/scripts/migration_manifest.mjs +351 -0
  600. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +9 -23
  601. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +72 -12
  602. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +33 -1
  603. package/skills/a2h-app-migrate/scripts/run_dir.mjs +137 -41
  604. package/skills/a2h-app-migrate/scripts/scope_model.mjs +255 -0
  605. package/skills/a2h-app-migrate/scripts/scope_report.mjs +128 -0
  606. package/skills/a2h-app-migrate/scripts/source_fp.mjs +120 -0
  607. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
  608. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
  609. package/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  610. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  611. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  612. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  613. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  614. package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
  615. package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  616. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
  617. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  618. package/skills/a2h-app-migrate/test/test_feature_scope.mjs +217 -0
  619. package/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  620. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  621. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  622. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
  623. package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  624. package/skills/a2h-app-migrate/test/test_incremental_acceptance.mjs +145 -0
  625. package/skills/a2h-app-migrate/test/test_incremental_phase2.mjs +223 -0
  626. package/skills/a2h-app-migrate/test/test_incremental_phase2_acceptance.mjs +157 -0
  627. package/skills/a2h-app-migrate/test/test_incremental_profile.mjs +84 -0
  628. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +101 -0
  629. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  630. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  631. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +150 -0
  632. package/skills/a2h-app-migrate/test/test_migration_manifest.mjs +225 -0
  633. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +86 -0
  634. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  635. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  636. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  637. package/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  638. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  639. package/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  640. package/skills/a2h-app-migrate/test/test_scope_model.mjs +172 -0
  641. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  642. package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
  643. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +155 -0
  644. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  645. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  646. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +511 -0
  647. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  648. package/skills/a2h-app-migrate/test/test_ui_batch_capture_audit.mjs +106 -0
  649. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +65 -0
  650. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  651. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  652. package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  653. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
  654. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +214 -0
  655. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  656. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  657. package/skills/a2h-arch-generate/SKILL.md +20 -17
  658. package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
  659. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
  660. package/skills/a2h-arch-generate/references/homegraph-workflow.md +25 -14
  661. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
  662. package/skills/a2h-arch-generate/references/source-baseline.md +4 -4
  663. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +34 -3
  664. package/skills/a2h-arch-generate/scripts/create_project.mjs +24 -1
  665. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
  666. package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +29 -5
  667. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
  668. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
  669. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  670. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  671. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  672. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  673. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  674. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  675. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  676. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  677. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  678. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  679. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  680. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  681. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  682. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  683. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  684. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  685. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  686. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  687. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  688. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  689. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  690. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  691. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  692. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  693. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  694. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  695. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  696. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
  697. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +208 -0
  698. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  699. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  700. package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  701. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +164 -0
  702. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
  703. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +4 -2
  704. package/skills/a2h-arkts-logic-coder/SKILL.md +163 -15
  705. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +3 -1
  706. package/skills/a2h-arkts-logic-coder/references/code-generation.md +120 -1
  707. package/skills/a2h-arkts-logic-coder/references/spec-design.md +46 -11
  708. package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
  709. package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +873 -0
  710. package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
  711. package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  712. package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  713. package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  714. package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
  715. package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  716. package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  717. package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  718. package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +596 -0
  719. package/skills/a2h-batch-ui-align/SKILL.md +78 -26
  720. package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +16 -2
  721. package/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
  722. package/skills/a2h-batch-ui-align/references/cards/geometry.md +6 -1
  723. package/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
  724. package/skills/a2h-batch-ui-align/references/cards/resources.md +9 -3
  725. package/skills/a2h-batch-ui-align/references/cards/widgets.md +27 -3
  726. package/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
  727. package/skills/a2h-batch-ui-align/references/checker-rules.md +301 -13
  728. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +53 -13
  729. package/skills/a2h-batch-ui-align/references/host-dispatch.md +2 -0
  730. package/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
  731. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +14 -9
  732. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
  733. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
  734. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +30 -0
  735. package/skills/a2h-batch-ui-align/references/step3-capture.md +25 -6
  736. package/skills/a2h-batch-ui-align/references/step4-prepare.md +7 -2
  737. package/skills/a2h-batch-ui-align/references/step5-convert.md +33 -9
  738. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
  739. package/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  740. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +463 -22
  741. package/skills/a2h-batch-ui-align/scripts/capture_audit.mjs +474 -0
  742. package/skills/a2h-batch-ui-align/scripts/capture_fast.mjs +665 -0
  743. package/skills/a2h-batch-ui-align/scripts/capture_verify.mjs +552 -0
  744. package/skills/a2h-batch-ui-align/scripts/detach.mjs +5 -2
  745. package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  746. package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +263 -0
  747. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +20 -3
  748. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
  749. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +220 -35
  750. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +517 -41
  751. package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  752. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
  753. package/skills/a2h-batch-ui-align/scripts/list_existing.mjs +141 -0
  754. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +239 -14
  755. package/skills/a2h-batch-ui-align/scripts/page_gap.mjs +210 -0
  756. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +98 -11
  757. package/skills/a2h-batch-ui-align/scripts/progress_identity.mjs +208 -0
  758. package/skills/a2h-batch-ui-align/scripts/scroll_verdict.mjs +62 -0
  759. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +118 -4
  760. package/skills/a2h-batch-ui-align/scripts/shell_requests.mjs +273 -0
  761. package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
  762. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
  763. package/skills/a2h-batch-ui-align/scripts/static_check/core/baseline.ts +79 -0
  764. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
  765. package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +90 -2
  766. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +44 -0
  767. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +61 -12
  768. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +32 -0
  769. package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
  770. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
  771. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
  772. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
  773. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
  774. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
  775. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
  776. package/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  777. package/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  778. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  779. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
  780. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  781. package/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  782. package/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  783. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
  784. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  785. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
  786. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +110 -12
  787. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  788. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  789. package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  790. package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
  791. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
  792. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  793. package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
  794. package/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  795. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
  796. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  797. package/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  798. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  799. package/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  800. package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
  801. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
  802. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +30 -2
  803. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +231 -0
  804. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  805. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
  806. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_baseline.test.mjs +129 -0
  807. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  808. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  809. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  810. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_runtime2.test.mjs +697 -0
  811. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  812. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +298 -0
  813. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  814. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  815. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  816. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  817. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  818. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +269 -0
  819. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  820. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +346 -0
  821. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  822. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
  823. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  824. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
  825. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme_runtime.test.mjs +95 -0
  826. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  827. package/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  828. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  829. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +291 -0
  830. package/skills/a2h-batch-ui-align/scripts/tests/capture_audit.test.mjs +179 -0
  831. package/skills/a2h-batch-ui-align/scripts/tests/capture_fast.test.mjs +56 -0
  832. package/skills/a2h-batch-ui-align/scripts/tests/capture_gate.test.mjs +197 -0
  833. package/skills/a2h-batch-ui-align/scripts/tests/capture_review_fixes.test.mjs +322 -0
  834. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +93 -0
  835. package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
  836. package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
  837. package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +435 -0
  838. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  839. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  840. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/SearchMenuDialog.buggy.ets +95 -0
  841. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/meta.json +21 -0
  842. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/screenshot.png +0 -0
  843. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/view.xml +35 -0
  844. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  845. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  846. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  847. package/skills/a2h-batch-ui-align/scripts/tests/group_pack_evidence.test.mjs +95 -0
  848. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1782 -0
  849. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  850. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  851. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  852. package/skills/a2h-batch-ui-align/scripts/tests/icon_coverage.test.mjs +314 -0
  853. package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  854. package/skills/a2h-batch-ui-align/scripts/tests/list_existing.test.mjs +157 -0
  855. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  856. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  857. package/skills/a2h-batch-ui-align/scripts/tests/page_gap.test.mjs +115 -0
  858. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  859. package/skills/a2h-batch-ui-align/scripts/tests/progress_identity.test.mjs +174 -0
  860. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +302 -0
  861. package/skills/a2h-batch-ui-align/scripts/tests/shell_requests.test.mjs +158 -0
  862. package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  863. package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  864. package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  865. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  866. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  867. package/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
  868. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
  869. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
  870. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  871. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  872. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  873. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  874. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  875. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  876. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  877. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  878. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  879. package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
  880. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  881. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  882. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  883. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  884. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  885. package/skills/a2h-dashboard-render/test/test_device_locale_dialogs.mjs +17 -0
  886. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  887. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  888. package/skills/a2h-module-semantic-docs/SKILL.md +51 -13
  889. package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +66 -11
  890. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  891. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  892. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  893. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  894. package/skills/a2h-module-semantic-docs/test/test_incremental_fingerprint.mjs +94 -0
  895. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  896. package/skills/a2h-page-specgen/SKILL.md +240 -0
  897. package/skills/a2h-page-specgen/references/behavior-ledger.md +1170 -0
  898. package/skills/a2h-page-specgen/references/body-language.md +179 -0
  899. package/skills/a2h-page-specgen/references/evidence.md +105 -0
  900. package/skills/a2h-page-specgen/references/execution-model.md +364 -0
  901. package/skills/a2h-page-specgen/references/footprint-and-grouping.md +255 -0
  902. package/skills/a2h-page-specgen/references/gates.md +323 -0
  903. package/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  904. package/skills/a2h-page-specgen/references/scenario-authoring.md +272 -0
  905. package/skills/a2h-page-specgen/references/spec-example.md +312 -0
  906. package/skills/a2h-page-specgen/references/spec-template.md +210 -0
  907. package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  908. package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  909. package/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  910. package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  911. package/skills/a2h-page-specgen/scripts/dispatch.mjs +212 -0
  912. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  913. package/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  914. package/skills/a2h-page-specgen/scripts/finalize.mjs +825 -0
  915. package/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  916. package/skills/a2h-page-specgen/scripts/gate.mjs +848 -0
  917. package/skills/a2h-page-specgen/scripts/interactions.mjs +344 -0
  918. package/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  919. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  920. package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
  921. package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +229 -0
  922. package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
  923. package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
  924. package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  925. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +683 -0
  926. package/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  927. package/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  928. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +478 -0
  929. package/skills/a2h-page-specgen/scripts/lib/main-module.mjs +24 -0
  930. package/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  931. package/skills/a2h-page-specgen/scripts/lib/prose.mjs +238 -0
  932. package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  933. package/skills/a2h-page-specgen/scripts/lib/recovery-policy.mjs +28 -0
  934. package/skills/a2h-page-specgen/scripts/lib/scope.mjs +355 -0
  935. package/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  936. package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  937. package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
  938. package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
  939. package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
  940. package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  941. package/skills/a2h-page-specgen/scripts/prepare.mjs +840 -0
  942. package/skills/a2h-page-specgen/scripts/render.mjs +294 -0
  943. package/skills/a2h-page-specgen/scripts/report.mjs +340 -0
  944. package/skills/a2h-page-specgen/scripts/submission.mjs +697 -0
  945. package/skills/a2h-page-specgen/scripts/submit.mjs +85 -0
  946. package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
  947. package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +871 -0
  948. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.java +15 -0
  949. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +26 -0
  950. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +347 -0
  951. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +298 -0
  952. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.java +36 -0
  953. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +43 -0
  954. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +347 -0
  955. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +298 -0
  956. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  957. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  958. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  959. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +347 -0
  960. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  961. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +265 -0
  962. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.java +47 -0
  963. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +54 -0
  964. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +347 -0
  965. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +298 -0
  966. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  967. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  968. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  969. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  970. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  971. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +515 -0
  972. package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
  973. package/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  974. package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  975. package/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +543 -0
  976. package/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +652 -0
  977. package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1231 -0
  978. package/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +494 -0
  979. package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1513 -0
  980. package/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +758 -0
  981. package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +623 -0
  982. package/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +116 -0
  983. package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +795 -0
  984. package/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +883 -0
  985. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  986. package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
  987. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  988. package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1203 -0
  989. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +243 -0
  990. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
  991. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
  992. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
  993. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
  994. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
  995. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
  996. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
  997. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
  998. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
  999. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
  1000. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
  1001. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
  1002. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
  1003. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
  1004. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
  1005. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
  1006. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
  1007. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
  1008. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
  1009. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
  1010. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
  1011. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
  1012. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
  1013. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
  1014. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
  1015. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
  1016. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
  1017. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
  1018. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
  1019. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
  1020. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
  1021. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
  1022. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
  1023. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
  1024. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
  1025. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
  1026. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
  1027. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
  1028. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
  1029. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
  1030. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
  1031. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
  1032. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
  1033. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
  1034. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
  1035. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
  1036. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
  1037. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
  1038. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
  1039. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
  1040. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
  1041. package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
  1042. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +112 -0
  1043. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.java +14 -0
  1044. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.kt +14 -0
  1045. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanelsKotlinForms.kt +12 -0
  1046. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ChildContent.java +6 -0
  1047. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ComposeLifecycle.kt +26 -0
  1048. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleCallAndOverride.java +10 -0
  1049. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleHooks.kt +31 -0
  1050. package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
  1051. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyLifecycleHooks.kt +12 -0
  1052. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
  1053. package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
  1054. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshOnResume.java +7 -0
  1055. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshResultNoise.kt +36 -0
  1056. package/skills/a2h-page-specgen/scripts/test/fixtures/src/SelectionView.java +5 -0
  1057. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ShowPage.vue +12 -0
  1058. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ThirdPartyLifecycle.kt +25 -0
  1059. package/skills/a2h-page-specgen/scripts/test/fixtures/src/fragment_detail.xml +1 -0
  1060. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  1061. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  1062. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  1063. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  1064. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  1065. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  1066. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  1067. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  1068. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  1069. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  1070. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  1071. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  1072. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
  1073. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
  1074. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  1075. package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
  1076. package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  1077. package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  1078. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1078 -0
  1079. package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  1080. package/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  1081. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  1082. package/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  1083. package/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  1084. package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  1085. package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +310 -0
  1086. package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  1087. package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  1088. package/skills/a2h-page-specgen/scripts/test/ledger-lock.test.mjs +77 -0
  1089. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
  1090. package/skills/a2h-page-specgen/scripts/test/main-module.test.mjs +43 -0
  1091. package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  1092. package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  1093. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  1094. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  1095. package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +160 -0
  1096. package/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  1097. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +236 -0
  1098. package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +398 -0
  1099. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  1100. package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  1101. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  1102. package/skills/a2h-page-specgen/scripts/test/recovery-policy.test.mjs +14 -0
  1103. package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  1104. package/skills/a2h-page-specgen/scripts/test/render.test.mjs +546 -0
  1105. package/skills/a2h-page-specgen/scripts/test/report.test.mjs +296 -0
  1106. package/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  1107. package/skills/a2h-page-specgen/scripts/test/scope.test.mjs +292 -0
  1108. package/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  1109. package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
  1110. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1231 -0
  1111. package/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  1112. package/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  1113. package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  1114. package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
  1115. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  1116. package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1993 -0
  1117. package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +342 -0
  1118. package/skills/a2h-page-specgen/scripts/waker.mjs +1301 -0
  1119. package/skills/a2h-page-specgen/scripts/watchdog.mjs +299 -0
  1120. package/skills/a2h-resource-convert/SKILL.md +9 -1
  1121. package/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
  1122. package/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
  1123. package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
  1124. package/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
  1125. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +115 -53
  1126. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +68 -0
  1127. package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +45 -3
  1128. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +42 -5
  1129. package/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  1130. package/skills/a2h-resource-convert/scripts/lottie_refs.ts +398 -0
  1131. package/skills/a2h-resource-convert/scripts/merge_mapping.ts +316 -0
  1132. package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +2 -1
  1133. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  1134. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  1135. package/skills/a2h-resource-convert/scripts/tests/code_vector_guard.test.mjs +75 -0
  1136. package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  1137. package/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  1138. package/skills/a2h-resource-convert/scripts/tests/lottie_incremental.test.mjs +178 -0
  1139. package/skills/a2h-resource-convert/scripts/tests/merge_mapping.test.mjs +201 -0
  1140. package/skills/a2h-spec-design-pipeline/SKILL.md +98 -121
  1141. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +170 -45
  1142. package/skills/a2h-spec-design-pipeline/references/execution-model.md +62 -12
  1143. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -4
  1144. package/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +229 -0
  1145. package/skills/a2h-spec-design-pipeline/references/initialization.md +49 -6
  1146. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +198 -54
  1147. package/skills/a2h-spec-design-pipeline/references/permission-index.json +206 -0
  1148. package/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  1149. package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +67 -0
  1150. package/skills/a2h-spec-design-pipeline/references/review-loop.md +46 -0
  1151. package/skills/a2h-spec-design-pipeline/references/scripts.md +47 -14
  1152. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +390 -0
  1153. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +148 -29
  1154. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +104 -24
  1155. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +18 -0
  1156. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +16 -0
  1157. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +47 -0
  1158. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +31 -0
  1159. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +698 -0
  1160. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +96 -0
  1161. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +103 -0
  1162. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +124 -0
  1163. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +138 -0
  1164. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +106 -0
  1165. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +113 -0
  1166. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +705 -0
  1167. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +1063 -0
  1168. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +473 -0
  1169. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/platform/ExtraDataSubCheck.js +485 -0
  1170. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +13 -0
  1171. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +18 -0
  1172. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
  1173. package/skills/a2h-spec-design-pipeline/scripts/check_design_map.ts +108 -0
  1174. package/skills/a2h-spec-design-pipeline/scripts/check_permissions.ts +420 -0
  1175. package/skills/a2h-spec-design-pipeline/scripts/check_review_evidence.ts +45 -0
  1176. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +95 -7
  1177. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +156 -7
  1178. package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +71 -0
  1179. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +22 -3
  1180. package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +63 -4
  1181. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +33 -3
  1182. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
  1183. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +232 -13
  1184. package/skills/a2h-spec-design-pipeline/scripts/ensure_index.ts +866 -0
  1185. package/skills/a2h-spec-design-pipeline/scripts/fixtures/homecheck-stub.cjs +47 -0
  1186. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +220 -44
  1187. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
  1188. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
  1189. package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
  1190. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +178 -14
  1191. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
  1192. package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +368 -0
  1193. package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
  1194. package/skills/a2h-spec-design-pipeline/scripts/sync_permission_index.ts +340 -0
  1195. package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +281 -0
  1196. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +690 -0
  1197. package/skills/a2h-spec-design-pipeline/scripts/test_check_design_map.ts +46 -0
  1198. package/skills/a2h-spec-design-pipeline/scripts/test_check_permissions.ts +201 -0
  1199. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +42 -8
  1200. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +27 -9
  1201. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +242 -9
  1202. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +192 -7
  1203. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +531 -0
  1204. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +49 -1
  1205. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +92 -4
  1206. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +51 -0
  1207. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index.ts +572 -0
  1208. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index_real.ts +56 -0
  1209. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +17 -10
  1210. package/skills/a2h-spec-design-pipeline/scripts/test_homegraph_docs.ts +217 -0
  1211. package/skills/a2h-spec-design-pipeline/scripts/test_permission_index.ts +214 -0
  1212. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
  1213. package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +308 -0
  1214. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
  1215. package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +401 -0
  1216. package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
  1217. package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
  1218. package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
  1219. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +165 -0
  1220. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
  1221. package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
  1222. package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
  1223. package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
  1224. package/skills/a2h-spec-generate/SKILL.md +89 -23
  1225. package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
  1226. package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  1227. package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
  1228. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  1229. package/skills/a2h-spec-generate/references/specs.schema.json +24 -11
  1230. package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
  1231. package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
  1232. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
  1233. package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
  1234. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
  1235. package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
  1236. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +1 -2
  1237. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
  1238. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
  1239. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
  1240. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
  1241. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
  1242. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
  1243. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
  1244. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
  1245. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
  1246. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
  1247. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
  1248. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
  1249. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  1250. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
  1251. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
  1252. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
  1253. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
  1254. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
  1255. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
  1256. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
  1257. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
  1258. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
  1259. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
  1260. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
  1261. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  1262. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  1263. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  1264. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  1265. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
  1266. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
  1267. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  1268. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  1269. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  1270. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
  1271. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  1272. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
  1273. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
  1274. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
  1275. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
  1276. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
  1277. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  1278. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  1279. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  1280. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  1281. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  1282. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  1283. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  1284. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  1285. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  1286. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  1287. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  1288. package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
  1289. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
  1290. package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
  1291. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
  1292. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  1293. package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
  1294. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +229 -0
  1295. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  1296. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  1297. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  1298. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  1299. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  1300. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  1301. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  1302. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  1303. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  1304. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  1305. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  1306. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  1307. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  1308. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  1309. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  1310. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  1311. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  1312. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  1313. package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  1314. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
  1315. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  1316. package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  1317. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  1318. package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  1319. package/skills/a2h-utg-explorer/SKILL.md +9 -3
  1320. package/skills/a2h-utg-explorer/references/architecture.md +7 -0
  1321. package/skills/a2h-utg-explorer/scripts/audit.mjs +8 -2
  1322. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +120 -85
  1323. package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +47 -2
  1324. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
  1325. package/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  1326. package/skills/a2h-utg-explorer/scripts/plan.mjs +8 -0
  1327. package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
  1328. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
  1329. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
  1330. package/skills/a2h-utg-explorer/scripts/report.mjs +89 -0
  1331. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +67 -10
  1332. package/skills/a2h-utg-explorer/scripts/run_device.mjs +10 -2
  1333. package/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  1334. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  1335. package/skills/a2h-utg-explorer/scripts/tests/blank_wait.test.mjs +126 -0
  1336. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
  1337. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  1338. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  1339. package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  1340. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  1341. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
  1342. package/skills/a2h-utg-explorer/scripts/tests/default_override.test.mjs +109 -0
  1343. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
  1344. package/skills/a2h-utg-explorer/scripts/tests/device_locale_dialogs.test.mjs +29 -0
  1345. package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
  1346. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  1347. package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +254 -0
  1348. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  1349. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
  1350. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  1351. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  1352. package/skills/a2h-utg-explorer/scripts/tests/foreground_spelling.test.mjs +155 -0
  1353. package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
  1354. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  1355. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  1356. package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
  1357. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +120 -0
  1358. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  1359. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  1360. package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  1361. package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
  1362. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  1363. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  1364. package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  1365. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  1366. package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  1367. package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  1368. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  1369. package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +218 -0
  1370. package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +292 -0
  1371. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  1372. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  1373. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  1374. package/skills/a2h-utg-explorer/scripts/tests/recover_d_grounding.test.mjs +164 -0
  1375. package/skills/a2h-utg-explorer/scripts/tests/replay_reroute.test.mjs +143 -0
  1376. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  1377. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  1378. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +458 -0
  1379. package/skills/a2h-utg-explorer/scripts/tests/run_cycle_follow.test.mjs +35 -0
  1380. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  1381. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  1382. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  1383. package/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  1384. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  1385. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
  1386. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  1387. package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
  1388. package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
  1389. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  1390. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  1391. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  1392. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  1393. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  1394. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +135 -7
  1395. package/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  1396. package/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  1397. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +245 -69
  1398. package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  1399. package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +164 -0
  1400. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +718 -42
  1401. package/skills/a2h-utg-explorer/scripts/variant.mjs +57 -11
  1402. package/skills/a2h-utg-static/SKILL.md +6 -2
  1403. package/skills/a2h-utg-static/scripts/assemble.mjs +93 -3
  1404. package/skills/a2h-utg-static/scripts/click_paths.mjs +135 -25
  1405. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
  1406. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +110 -3
  1407. package/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
  1408. package/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
  1409. package/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  1410. package/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  1411. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
  1412. package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +46 -1
  1413. package/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
  1414. package/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  1415. package/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  1416. package/skills/a2h-utg-static/scripts/menu_nav.mjs +1 -1
  1417. package/skills/a2h-utg-static/scripts/nl_hints.mjs +34 -7
  1418. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
  1419. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
  1420. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +86 -4
  1421. package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
  1422. package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
  1423. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +30 -0
  1424. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +18 -0
  1425. package/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  1426. package/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +114 -0
  1427. package/skills/a2h-utg-static/scripts/tests/test_guard_kinds_locale.mjs +12 -0
  1428. package/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  1429. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +165 -1
  1430. package/skills/a2h-utg-static/scripts/tests/test_library_activity.mjs +45 -0
  1431. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
  1432. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
  1433. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_default_override.mjs +50 -0
  1434. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +21 -0
  1435. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +172 -0
  1436. package/skills/a2h-utg-static/scripts/tests/test_redirect_path_cost.mjs +136 -0
  1437. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
  1438. package/skills/a2h-utg-static/scripts/tests/test_uniapp_route_jump.mjs +175 -0
  1439. package/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  1440. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +99 -0
  1441. package/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  1442. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +21 -0
  1443. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +112 -69
  1444. package/skills/a2h-utg-static/scripts/vm_nav.mjs +9 -1
  1445. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
  1446. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
  1447. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
  1448. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
  1449. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
  1450. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
  1451. package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
  1452. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
  1453. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
  1454. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
  1455. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
  1456. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
  1457. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
  1458. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +0 -885
  1459. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
  1460. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
  1461. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +0 -856
  1462. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
  1463. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
  1464. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
  1465. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
  1466. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
  1467. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
  1468. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
  1469. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
  1470. package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
  1471. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
@@ -0,0 +1,3245 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * HomeTrans dashboard — Node.js native runtime.
5
+ *
6
+ * This is intentionally dependency-free (only Node.js built-ins).
7
+ * Requires Node.js >=22.18.0.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import http from 'node:http';
13
+ import os from 'node:os';
14
+ import { spawn } from 'node:child_process';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { Worker } from 'node:worker_threads';
17
+ import { DeviceCaptureManager } from './device_capture.mjs';
18
+ import { lookupArtifactRegistry, resolveArtifact } from './artifact_contract.mjs';
19
+ import { collectUsage, resolveUsageSources } from './usage_readers.mjs';
20
+
21
+ const usageWorkerUrl = new URL('./usage_worker.mjs', import.meta.url);
22
+
23
+ // Minimal projects payload the worker receives: only the project root —
24
+ // attribution (directory/content match) and the time window (.hometrans mtimes) are both derived from root.
25
+ function usageProjectsPayload(projects) {
26
+ return projects.map((project) => ({ root: project.root }));
27
+ }
28
+
29
+ const MIN_NODE_VERSION = [22, 18, 0];
30
+
31
+ function exists(file) {
32
+ try { return fs.existsSync(file); } catch { return false; }
33
+ }
34
+
35
+ function isDirectoryPath(file) {
36
+ try { return fs.statSync(file).isDirectory(); } catch { return false; }
37
+ }
38
+
39
+ function parseTimestamp(raw) {
40
+ if (typeof raw === 'number' && Number.isFinite(raw)) {
41
+ if (raw <= 0) return null;
42
+ return raw > 10_000_000_000 ? raw : raw * 1000;
43
+ }
44
+ const cleaned = String(raw ?? '').replaceAll('`', '').trim();
45
+ if (/^\d+(?:\.\d+)?$/.test(cleaned)) {
46
+ const value = Number(cleaned);
47
+ if (!Number.isFinite(value) || value <= 0) return null;
48
+ return value > 10_000_000_000 ? value : value * 1000;
49
+ }
50
+ const value = Date.parse(cleaned);
51
+ return Number.isFinite(value) ? value : null;
52
+ }
53
+
54
+ function walkFilesRecursive(root, suffix) {
55
+ const result = [];
56
+ const stack = [root];
57
+ while (stack.length) {
58
+ const dir = stack.pop();
59
+ let entries = [];
60
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { continue; }
61
+ for (const entry of entries) {
62
+ const full = path.join(dir, entry.name);
63
+ if (entry.isDirectory()) stack.push(full);
64
+ else if (entry.isFile() && entry.name.endsWith(suffix)) result.push(full);
65
+ }
66
+ }
67
+ return result;
68
+ }
69
+
70
+ function supportsNodeVersion(version = process.versions.node) {
71
+ const actual = String(version).split('.').map((part) => Number.parseInt(part, 10) || 0);
72
+ for (let index = 0; index < MIN_NODE_VERSION.length; index += 1) {
73
+ if ((actual[index] ?? 0) > MIN_NODE_VERSION[index]) return true;
74
+ if ((actual[index] ?? 0) < MIN_NODE_VERSION[index]) return false;
75
+ }
76
+ return true;
77
+ }
78
+
79
+ function escapeHtml(value) {
80
+ return String(value ?? '')
81
+ .replaceAll('&', '&amp;')
82
+ .replaceAll('<', '&lt;')
83
+ .replaceAll('>', '&gt;')
84
+ .replaceAll('"', '&quot;')
85
+ .replaceAll("'", '&#39;');
86
+ }
87
+
88
+ // --- Display-language layer (board chrome i18n) -----------------------------
89
+ // English build: board chrome is English only.
90
+ const RENDER_LANG = 'en';
91
+ const EN_STRINGS = Object.assign(Object.create(null), {
92
+ // shell / nav / header
93
+ 'HomeTrans Conversion Dashboard': 'HomeTrans Conversion Dashboard',
94
+ 'Conversion Dashboard': 'Conversion Dashboard',
95
+ 'Workspace': 'Workspace',
96
+ 'No project selected': 'No project selected',
97
+ 'Overview': 'Overview',
98
+ 'Architecture': 'Architecture',
99
+ 'UI Migration': 'UI Migration',
100
+ 'Spec Generation': 'Spec Generation',
101
+ 'Logic Conversion': 'Logic Conversion',
102
+ 'Collapse / expand nav': 'Collapse / expand nav',
103
+ 'Collapse nav': 'Collapse nav',
104
+ 'Expand nav': 'Expand nav',
105
+ 'Live · auto-refresh every 30s': 'Live · auto-refresh every 30s',
106
+ 'Generated: ': 'Generated: ',
107
+ ' (auto-refresh rescans artifacts on disk only; device screenshots are captured once at dashboard startup)': ' (auto-refresh rescans artifacts on disk only; device screenshots are captured once at dashboard startup)',
108
+ 'Switch language': 'Switch language',
109
+ 'Switch light / dark theme': 'Switch light / dark theme',
110
+ 'Switch between light and dark themes': 'Switch between light and dark themes',
111
+ // shutdown flow
112
+ 'Stop dashboard': 'Stop dashboard',
113
+ 'Stop the dashboard server (equivalent to Ctrl+C in the launching terminal)': 'Stop the dashboard server (equivalent to Ctrl+C in the launching terminal)',
114
+ 'Stop the dashboard server? This page becomes unavailable; rerun the command in the launching terminal to view it again.': 'Stop the dashboard server? This page becomes unavailable; rerun the command in the launching terminal to view it again.',
115
+ 'Stopping…': 'Stopping…',
116
+ '<strong>Dashboard server stopped</strong><br>This page is no longer available; you can close this tab.<br><small>To view it again, rerun the command in the terminal that launched the dashboard.</small>': '<strong>Dashboard server stopped</strong><br>This page is no longer available; you can close this tab.<br><small>To view it again, rerun the command in the terminal that launched the dashboard.</small>',
117
+ // canonical status vocabulary (buckets -> display words)
118
+ 'Done': 'Done',
119
+ 'Pending': 'Pending',
120
+ 'In progress': 'In progress',
121
+ 'Blocked': 'Blocked',
122
+ 'Skipped': 'Skipped',
123
+ 'Not recorded': 'Not recorded',
124
+ 'Not started': 'Not started',
125
+ 'Not generated': 'Not generated',
126
+ // overview
127
+ 'Overall progress': 'Overall progress',
128
+ ' steps done': ' steps done',
129
+ 'UI Migration': 'UI Migration',
130
+ 'Conversion steps': 'Conversion steps',
131
+ 'View architecture details': 'View architecture details',
132
+ 'View UI migration details': 'View UI migration details',
133
+ 'View spec generation details': 'View spec generation details',
134
+ 'View logic conversion details': 'View logic conversion details',
135
+ 'Agent usage': 'Agent usage',
136
+ 'Agent usage is being computed on a background thread and appears after an auto-refresh; the first scan of a large session store can take longer.': 'Agent usage is being computed on a background thread and appears after an auto-refresh; the first scan of a large session store can take longer.',
137
+ 'Accounting: sessions are attributed to projects by directory (startup path match or content reference); all tokens of an attributed session are counted.': 'Accounting: sessions are attributed to projects by directory (startup path match or content reference); all tokens of an attributed session are counted.',
138
+ 'Input tokens': 'Input tokens',
139
+ 'Cache write tokens': 'Cache write tokens',
140
+ 'Cache read tokens': 'Cache read tokens',
141
+ 'Output tokens': 'Output tokens',
142
+ 'Reasoning tokens': 'Reasoning tokens',
143
+ 'excluding cached prompt portions': 'excluding cached prompt portions',
144
+ '0 when the agent does not report it': '0 when the agent does not report it',
145
+ 'cache hits, priced at the model cache rate': 'cache hits, priced at the model cache rate',
146
+ 'content actually generated by the model': 'content actually generated by the model',
147
+ 'shown as 0 when the platform does not record it': 'shown as 0 when the platform does not record it',
148
+ 'not provided': 'not provided',
149
+ // stage label maps (values translated at the use site)
150
+ 'UI design': 'UI design',
151
+ 'Page migration': 'Page migration',
152
+ 'Compliance check': 'Compliance check',
153
+ 'Build verification': 'Build verification',
154
+ 'Commit': 'Commit',
155
+ 'Logic development': 'Logic development',
156
+ 'Build': 'Build',
157
+ 'Code review loop': 'Code review loop',
158
+ 'Design doc': 'Design doc',
159
+ 'Logic conversion': 'Logic conversion',
160
+ 'Semantic docs': 'Semantic docs',
161
+ 'Spec commit': 'Spec commit',
162
+ // architecture tab
163
+ 'No architecture design artifacts found (project_design.md / spec_pipeline_state.json). Run a2h-arch-generate or a2h-spec-design-pipeline first to generate the architecture design documents.': 'No architecture design artifacts found (project_design.md / spec_pipeline_state.json). Run a2h-arch-generate or a2h-spec-design-pipeline first to generate the architecture design documents.',
164
+ 'Generation flow': 'Generation flow',
165
+ 'HarmonyOS target architecture design': 'HarmonyOS target architecture design',
166
+ 'Database design': 'Database design',
167
+ 'Preferences design': 'Preferences design',
168
+ // ';' stays: the review-round "this round" row still uses it as a separator.
169
+ ';': '; ',
170
+ 'No artifact files generated for this stage yet': 'No artifact files generated for this stage yet',
171
+ // source lines / shared fragments
172
+ 'Capture cache directory': 'Capture cache directory',
173
+ 'Migration task source': 'Migration task source',
174
+ 'Spec file': 'Spec file',
175
+ // UI tab
176
+ 'Pages': 'Pages',
177
+ 'Migrated': 'Migrated',
178
+ 'Marker count mismatch': 'Marker count mismatch',
179
+ 'No usable HarmonyOS capture': 'No usable HarmonyOS capture',
180
+ 'Search page titles, e.g. Main Page (ignores case and spaces)': 'Search page titles, e.g. Main Page (ignores case and spaces)',
181
+ 'Jump to page title': 'Jump to page title',
182
+ 'Jump': 'Jump',
183
+ ' Pending only': ' Pending only',
184
+ '← Prev': '← Prev',
185
+ 'Previous page': 'Previous page',
186
+ 'Next →': 'Next →',
187
+ 'Next page': 'Next page',
188
+ 'Use ← → keys to page': 'Use ← → keys to page',
189
+ 'Cached device capture': 'Cached device capture',
190
+ 'Live capture cache': 'Live capture cache',
191
+ 'No UI migration tasks match the current filter; untick "Pending only".': 'No UI migration tasks match the current filter; untick "Pending only".',
192
+ 'batch_progress.json was not generated or contains no UI migration tasks, and no HarmonyOS capture cache was found.': 'batch_progress.json was not generated or contains no UI migration tasks, and no HarmonyOS capture cache was found.',
193
+ ' capture cached': ' capture cached',
194
+ 'Page task completed': 'Page task completed',
195
+ 'Marker counts match': 'Marker counts match',
196
+ 'Markers ': 'Markers ',
197
+ 'No screenshot file recorded': 'No screenshot file recorded',
198
+ 'No target code file recorded': 'No target code file recorded',
199
+ 'Captured from the connected device': 'Captured from the connected device',
200
+ 'Capturing from the connected device': 'Capturing from the connected device',
201
+ 'Local cache fallback': 'Local cache fallback',
202
+ 'HarmonyOS device': 'HarmonyOS device',
203
+ 'The HarmonyOS side is capturing; refresh the dashboard when it finishes to see the screenshots.': 'The HarmonyOS side is capturing; refresh the dashboard when it finishes to see the screenshots.',
204
+ 'No HarmonyOS capture cache was read': 'No HarmonyOS capture cache was read',
205
+ ': no HarmonyOS device capture has been run yet': ': no HarmonyOS device capture has been run yet',
206
+ '. Connect a device, finish a capture, and refresh the dashboard.': '. Connect a device, finish a capture, and refresh the dashboard.',
207
+ ':': ': ',
208
+ 'No ': 'No ',
209
+ ' screenshot was read for this task.': ' screenshot was read for this task.',
210
+ 'The HarmonyOS side has capture caches for other pages, but not for this one; the same-task pairing rule never borrows across tasks. Re-run the HarmonyOS capture to cover this page, or assign a capture seq for this task via ui_hmos_content_map in the dashboard config.': 'The HarmonyOS side has capture caches for other pages, but not for this one; the same-task pairing rule never borrows across tasks. Re-run the HarmonyOS capture to cover this page, or assign a capture seq for this task via ui_hmos_content_map in the dashboard config.',
211
+ 'Before migration · ': 'Before migration · ',
212
+ 'After migration · ': 'After migration · ',
213
+ ' (UI migration artifacts)': ' (UI migration artifacts)',
214
+ ' · stitched (dedup)': ' · stitched (dedup)',
215
+ 'No UI migration artifact screenshot found for this page (ui_info / capture cache)': 'No UI migration artifact screenshot found for this page (ui_info / capture cache)',
216
+ ' screenshot validation failed': ' screenshot validation failed',
217
+ 'does not fully match the source page': 'does not fully match the source page',
218
+ ' (internal retries in the first round: ': ' (internal retries in the first round: ',
219
+ ')': ')',
220
+ '. The screenshot was kept in the capture cache; recapture after fixing and pass validation to display it.': '. The screenshot was kept in the capture cache; recapture after fixing and pass validation to display it.',
221
+ 'Missing UI migration artifact screenshot': 'Missing UI migration artifact screenshot',
222
+ ' migration artifact screenshot': ' migration artifact screenshot',
223
+ ' screenshot': ' screenshot',
224
+ ' frames': ' frames',
225
+ 'Markers · ': 'Markers · ',
226
+ 'Numbers pair by per-side capture order and only indicate whether the same number exists on both sides.': 'Numbers pair by per-side capture order and only indicate whether the same number exists on both sides.',
227
+ 'No interactive elements detected': 'No interactive elements detected',
228
+ 'same number exists on the other side': 'same number exists on the other side',
229
+ 'same number not found on the other side': 'same number not found on the other side',
230
+ // spec tab
231
+ 'Search ': 'Search ',
232
+ ' specs': ' specs',
233
+ 'Search specs': 'Search specs',
234
+ 'Spec overview': 'Spec overview',
235
+ ' scenarios fully generated': ' scenarios fully generated',
236
+ 'No scenarios generated': 'No scenarios generated',
237
+ 'No matching specs': 'No matching specs',
238
+ 'Fully generated': 'Fully generated',
239
+ 'Not fully generated': 'Not fully generated',
240
+ ' scenarios': ' scenarios',
241
+ 'Scenario overview': 'Scenario overview',
242
+ 'Scenario logic steps': 'Scenario logic steps',
243
+ 'This spec has no scenarios generated yet.': 'This spec has no scenarios generated yet.',
244
+ 'No spec artifacts found.': 'No spec artifacts found.',
245
+ // logic tab
246
+ 'No grouped-pipeline artifacts found': 'No grouped-pipeline artifacts found',
247
+ ' specs done': ' specs done',
248
+ 'Click to show only pending specs of this stage': 'Click to show only pending specs of this stage',
249
+ '3.1-3.3 all processed': '3.1-3.3 all processed',
250
+ ' stages processed': ' stages processed',
251
+ 'Spec:': 'Spec: ',
252
+ 'Evidence: ': 'Evidence: ',
253
+ // scenario evidence 3.1-3.3 and review rounds
254
+ '3.1 Scenario coding record': '3.1 Scenario coding record',
255
+ 'Expected result: ': 'Expected result: ',
256
+ '3.1 coding check: ': '3.1 coding check: ',
257
+ 'No matching record for this scenario in coverage-ledger.md': 'No matching record for this scenario in coverage-ledger.md',
258
+ 'Scenario spec': 'Scenario spec',
259
+ 'Trigger entry': 'Trigger entry',
260
+ 'Target symbol / call chain': 'Target symbol / call chain',
261
+ '3.2 Spec build record': '3.2 Spec build record',
262
+ 'Not started: no step-3 build report found.': 'Not started: no step-3 build report found.',
263
+ 'Status updated, but no readable build report was found.': 'Status updated, but no readable build report was found.',
264
+ 'Build time': 'Build time',
265
+ 'Build end time': 'Build end time',
266
+ 'Build type': 'Build type',
267
+ 'Build command': 'Build command',
268
+ 'Total duration': 'Total duration',
269
+ 'Hvigor duration': 'Hvigor duration',
270
+ 'ArkTS compile': 'ArkTS compile',
271
+ 'HAP package': 'HAP package',
272
+ 'HAP signing': 'HAP signing',
273
+ 'Compile errors': 'Compile errors',
274
+ 'Errors fixed this round': 'Errors fixed this round',
275
+ 'Compile warnings': 'Compile warnings',
276
+ 'Build artifacts': 'Build artifacts',
277
+ 'Build report: ': 'Build report: ',
278
+ 'This build result is shared by all scenarios of this spec; it does not mean each scenario was built individually.': 'This build result is shared by all scenarios of this spec; it does not mean each scenario was built individually.',
279
+ '3.3 Spec code review record': '3.3 Spec code review record',
280
+ 'Not started: no step-3 code review report found.': 'Not started: no step-3 code review report found.',
281
+ 'Status updated, but no readable code review report was found.': 'Status updated, but no readable code review report was found.',
282
+ ' runtime-unverified (raw UNABLE TO VERIFY)': ' runtime-unverified (raw UNABLE TO VERIFY)',
283
+ ',': ', ',
284
+ 'Finished (': 'Finished (',
285
+ ' rounds recorded)': ' rounds recorded)',
286
+ 'Review notes': 'Review notes',
287
+ 'No verdict recorded': 'No verdict recorded',
288
+ 'Static review done · runtime unverified': 'Static review done · runtime unverified',
289
+ 'Runtime unverified': 'Runtime unverified',
290
+ 'Raw report verdict': 'Raw report verdict',
291
+ 'Review conclusion': 'Review conclusion',
292
+ 'Key gaps': 'Key gaps',
293
+ 'Fix status': 'Fix status',
294
+ 'The review summary covers this scenario, but the report provides no finer evidence sections.': 'The review summary covers this scenario, but the report provides no finer evidence sections.',
295
+ 'Scenarios reviewed': 'Scenarios reviewed',
296
+ 'Confirmed defects': 'Confirmed defects',
297
+ 'Round ': 'Round ',
298
+ ' — per-scenario review': ' — per-scenario review',
299
+ 'Raw report verdict: ': 'Raw report verdict: ',
300
+ 'Raw report verdict': 'Raw report verdict',
301
+ 'Static snapshot': 'Static snapshot',
302
+ 'Per-scenario review details': 'Per-scenario review details',
303
+ 'Expand a scenario to see its review evidence, unverified items, and fix status': 'Expand a scenario to see its review evidence, unverified items, and fix status',
304
+ 'This round: ': 'This round: ',
305
+ '3.3 loop status': '3.3 loop status',
306
+ 'Final recorded round': 'Final recorded round',
307
+ 'Scenario verdict summary': 'Scenario verdict summary',
308
+ 'Confirmed issues': 'Confirmed issues',
309
+ 'Successfully fixed': 'Successfully fixed',
310
+ 'Fix failed': 'Fix failed',
311
+ 'Stop reason': 'Stop reason',
312
+ 'Confirmed and handled issues': 'Confirmed and handled issues',
313
+ 'Review evidence files': 'Review evidence files',
314
+ 'Stage completion is judged by the review reports under spec_group_{G}/review-round_*/. UNABLE TO VERIFY means the static review finished but runtime results are unverified — it does not mean 3.3 is incomplete.': 'Stage completion is judged by the review reports under spec_group_{G}/review-round_*/. UNABLE TO VERIFY means the static review finished but runtime results are unverified — it does not mean 3.3 is incomplete.',
315
+ 'No step-3 artifacts found for this spec.': 'No step-3 artifacts found for this spec.',
316
+ '3.1 shows the current scenario\'s coding record only; 3.2-3.3 show the shared results of the current spec.': "3.1 shows the current scenario's coding record only; 3.2-3.3 show the shared results of the current spec.",
317
+ 'Current spec shared results': 'Current spec shared results',
318
+ 'The build and review records below belong to this spec — not to other specs, and not repeated per scenario.': 'The build and review records below belong to this spec — not to other specs, and not repeated per scenario.',
319
+ });
320
+ const tr = (s) => {
321
+ if (RENDER_LANG !== 'en') return s;
322
+ const exact = EN_STRINGS[s];
323
+ if (exact != null) return exact;
324
+ for (const [pattern, render] of EN_PATTERNS) {
325
+ const match = pattern.exec(s);
326
+ if (match) return render(match);
327
+ }
328
+ return s;
329
+ };
330
+ // Composed strings whose dynamic parts defeat exact dictionary keys.
331
+ const EN_PATTERNS = [
332
+ [/^Clickable element (\d+)$/, (m) => `Clickable element ${m[1]}`],
333
+ ];
334
+
335
+ // Marker labels are app UI text captured from device dumps (data-derived — they
336
+ // must stay as produced); only the synthetic "Clickable element N" fallback is board chrome.
337
+ const trMarkerLabel = (s) => {
338
+ if (RENDER_LANG !== 'en') return s;
339
+ for (const [pattern, render] of EN_PATTERNS) {
340
+ const match = pattern.exec(s);
341
+ if (match) return render(match);
342
+ }
343
+ return s;
344
+ };
345
+
346
+ // Scenario names synthesized by parseScenarios ("Scenario N" / "Scenario N: title", or
347
+ // "Scenario N" / "Scenario N: title" in an English install) — the
348
+ // numbered prefix is board chrome, the title after the colon is report data.
349
+ // A Chinese install only ever synthesizes the zh form, so the en -> zh direction
350
+ // runs only in an English install and the zh output stays byte-identical.
351
+ const translateScenarioName = (s) => {
352
+ if (RENDER_LANG !== 'en') {
353
+
354
+ const en = /^Scenario\s*(\d+)\s*(?:[::]\s*(.*))?$/.exec(String(s ?? '').trim());
355
+ if (!en) return s;
356
+ return en[2] ? `Scenario ${en[1]}: ${en[2]}` : `Scenario ${en[1]}`;
357
+ }
358
+ const m = /^(?:Scenario)\s*(\d+)\s*(?::\s*(.*))?$/.exec(String(s ?? '').trim());
359
+ if (!m) return s;
360
+ return m[2] ? `Scenario ${m[1]}: ${m[2]}` : `Scenario ${m[1]}`;
361
+ };
362
+
363
+ // Capture-state captions produced by device_capture.mjs carry dynamic page
364
+ // counts and nested error payloads, so exact-string dictionary keys cannot
365
+ // cover them. The display layer rewrites the known caption shapes; any payload
366
+ // after a colon stays verbatim (it is producer-side debug detail, same as
367
+ // other data-derived text). Unmatched captions fall back to the raw text.
368
+ // device_capture.mjs writes them in the installed language: the en
369
+ // renderings below are exactly the English templates it emits in an English
370
+ // install, so English source text passes through en display unchanged, and
371
+ // CAPTURE_DETAIL_PATTERNS_EN maps it back for zh display.
372
+ const CAPTURE_DETAIL_PATTERNS = [
373
+ // the composed capturing state ends with a fixed suffix — match it first so
374
+ // the payload patterns cannot swallow the suffix
375
+ [/^(.+?), capturing from the connected device$/, (m) => `${trCaptureDetail(m[1])}, capturing from the connected device`],
376
+ [/^Captured (\d+) page\(s\) from the connected HarmonyOS device$/, (m) => `Captured ${m[1]} page(s) from the connected HarmonyOS device`],
377
+ [/^Captured (\d+) page\(s\) from the connected HarmonyOS device, (\d+) of them do not fully match the source page \(kept\)$/, (m) => `Captured ${m[1]} page(s) from the connected HarmonyOS device, ${m[2]} of them do not fully match the source page (kept)`],
378
+ [/^HarmonyOS capture succeeded for (\d+)\/(\d+) page\(s\); the rest fell back to the local cache$/, (m) => `HarmonyOS capture succeeded for ${m[1]}/${m[2]} page(s); the rest fell back to the local cache`],
379
+ [/^HarmonyOS capture could not start: (.+)$/, (m) => `HarmonyOS capture could not start: ${m[1]}`],
380
+ [/^Device capture failed; using the local cache: (.+)$/, (m) => `Device capture failed; using the local cache: ${m[1]}`],
381
+ [/^hdc not found; using the local cache$/, () => 'hdc not found; using the local cache'],
382
+ [/^hdc check failed: (.+)$/, (m) => `hdc check failed: ${m[1]}`],
383
+ [/^Connected: ([^,]+)$/, (m) => `Connected: ${m[1]}`],
384
+ [/^No HarmonyOS device detected; using the local cache$/, () => 'No HarmonyOS device detected; using the local cache'],
385
+ [/^Checking UI migration artifact screenshots$/, () => 'Checking UI migration artifact screenshots'],
386
+ [/^Checking HDC devices$/, () => 'Checking HDC devices'],
387
+ [/^Using (\d+)\/(\d+) UI migration artifact screenshot\(s\); missing pages show a placeholder on the source side$/, (m) => `Using ${m[1]}/${m[2]} UI migration artifact screenshot(s); missing pages show a placeholder on the source side`],
388
+ [/^Reused (\d+) UI migration artifact screenshot\(s\)$/, (m) => `Reused ${m[1]} UI migration artifact screenshot(s)`],
389
+ // validation verdicts (device_capture screenshot validation)
390
+ [/^Target-state text mismatch \((\d+) text-bearing elements located, only (\d+) of them agree with the target\)$/, (m) => `Target-state text mismatch (${m[1]} text-bearing elements located, only ${m[2]} of them agree with the target)`],
391
+ [/^Page structure does not match the target state \((\d+)\/(\d+) element positions correspond\)$/, (m) => `Page structure does not match the target state (${m[1]}/${m[2]} element positions correspond)`],
392
+ [/^The screenshot shows (\d+) text element\(s\) that do not belong to the target state \((.*)\); likely a leftover overlay or dialog$/, (m) => `The screenshot shows ${m[1]} text element(s) that do not belong to the target state (${m[2]}); likely a leftover overlay or dialog`],
393
+ [/^Target state is missing visible content: (.+)$/, (m) => `Target state is missing visible content: ${m[1]}`],
394
+ [/^The actual page is (.+?), which does not match the target (.+)$/, (m) => `The actual page is ${m[1] === 'unknown page' ? 'unknown page' : m[1]}, which does not match the target ${m[2]}`],
395
+ [/^The foreground page does not belong to (.+?) \(actually (.+?)\)$/, (m) => `The foreground page does not belong to ${m[1]} (actually ${m[2]})`],
396
+ [/^The foreground page does not belong to (.+)$/, (m) => `The foreground page does not belong to ${m[1]}`],
397
+ [/^The screenshot shows content from another state: (.+)$/, (m) => `The screenshot shows content from another state: ${m[1]}`],
398
+ [/^The page structure did not change after the tap; the target page or dialog did not actually open$/, () => 'The page structure did not change after the tap; the target page or dialog did not actually open'],
399
+ [/^meta.json or the screenshot file is missing$/, () => 'meta.json or the screenshot file is missing'],
400
+ [/^meta.json, view.xml, or the screenshot file is missing$/, () => 'meta.json, view.xml, or the screenshot file is missing'],
401
+ [/^HDC returned no verifiable page_name$/, () => 'HDC returned no verifiable page_name'],
402
+ [/^The HDC page tree returned no foreground app bundle; the screenshot cannot be attributed$/, () => 'The HDC page tree returned no foreground app bundle; the screenshot cannot be attributed'],
403
+ ];
404
+
405
+ // English source captions (an English install) rendered for zh display: the
406
+ // inverse of CAPTURE_DETAIL_PATTERNS. Used only in an English install, so a
407
+ // Chinese install's zh display is unchanged.
408
+ const CAPTURE_DETAIL_PATTERNS_EN = [
409
+ [/^(.+?), capturing from the connected device$/, (m) => `${trCaptureDetail(m[1])}, capturing from the connected device`],
410
+ [/^Captured (\d+) page\(s\) from the connected HarmonyOS device$/, (m) => `Captured ${m[1]} page(s) from the connected HarmonyOS device`],
411
+ [/^Captured (\d+) page\(s\) from the connected HarmonyOS device, (\d+) of them do not fully match the source page \(kept\)$/, (m) => `Captured ${m[1]} page(s) from the connected HarmonyOS device, ${m[2]} of them do not fully match the source page (kept)`],
412
+ [/^HarmonyOS capture succeeded for (\d+)\/(\d+) page\(s\); the rest fell back to the local cache$/, (m) => `HarmonyOS capture succeeded for ${m[1]}/${m[2]} page(s); the rest fell back to the local cache`],
413
+ [/^HarmonyOS capture could not start: (.+)$/, (m) => `HarmonyOS capture could not start: ${m[1]}`],
414
+ [/^Device capture failed; using the local cache: (.+)$/, (m) => `Device capture failed; using the local cache: ${m[1]}`],
415
+ [/^hdc not found; using the local cache$/, () => 'hdc not found; using the local cache'],
416
+ [/^hdc check failed: (.+)$/, (m) => `hdc check failed: ${m[1]}`],
417
+ [/^Connected: (.+)$/, (m) => `Connected: ${m[1]}`],
418
+ [/^No HarmonyOS device detected; using the local cache$/, () => 'No HarmonyOS device detected; using the local cache'],
419
+ [/^Checking UI migration artifact screenshots$/, () => 'Checking UI migration artifact screenshots'],
420
+ [/^Checking HDC devices$/, () => 'Checking HDC devices'],
421
+ [/^Using (\d+)\/(\d+) UI migration artifact screenshot\(s\); missing pages show a placeholder on the source side$/, (m) => `Using ${m[1]}/${m[2]} UI migration artifact screenshot(s); missing pages show a placeholder on the source side`],
422
+ [/^Reused (\d+) UI migration artifact screenshot\(s\)$/, (m) => `Reused ${m[1]} UI migration artifact screenshot(s)`],
423
+ [/^Target-state text mismatch \((\d+) text-bearing elements located, only (\d+) of them agree with the target\)$/, (m) => `Target-state text mismatch (${m[1]} text-bearing elements located, only ${m[2]} of them agree with the target)`],
424
+ [/^Page structure does not match the target state \((\d+)\/(\d+) element positions correspond\)$/, (m) => `Page structure does not match the target state (${m[1]}/${m[2]} element positions correspond)`],
425
+ [/^The screenshot shows (\d+) text element\(s\) that do not belong to the target state \((.*)\); likely a leftover overlay or dialog$/, (m) => `The screenshot shows ${m[1]} text element(s) that do not belong to the target state (${m[2]}); likely a leftover overlay or dialog`],
426
+ [/^Target state is missing visible content: (.+)$/, (m) => `Target state is missing visible content: ${m[1]}`],
427
+ [/^The actual page is (.+?), which does not match the target (.+)$/, (m) => `The actual page is ${m[1] === 'unknown page' ? 'unknown page' : m[1]}, which does not match the target ${m[2]}`],
428
+ [/^The foreground page does not belong to (.+?) \(actually (.+?)\)$/, (m) => `The foreground page does not belong to ${m[1]} (actually ${m[2]})`],
429
+ [/^The foreground page does not belong to (.+)$/, (m) => `The foreground page does not belong to ${m[1]}`],
430
+ [/^The screenshot shows content from another state: (.+)$/, (m) => `The screenshot shows content from another state: ${m[1]}`],
431
+ [/^The page structure did not change after the tap; the target page or dialog did not actually open$/, () => 'The page structure did not change after the tap; the target page or dialog did not actually open'],
432
+ [/^meta\.json or the screenshot file is missing$/, () => 'meta.json or the screenshot file is missing'],
433
+ [/^meta\.json, view\.xml, or the screenshot file is missing$/, () => 'meta.json, view.xml, or the screenshot file is missing'],
434
+ [/^HDC returned no verifiable page_name$/, () => 'HDC returned no verifiable page_name'],
435
+ [/^The HDC page tree returned no foreground app bundle; the screenshot cannot be attributed$/, () => 'The HDC page tree returned no foreground app bundle; the screenshot cannot be attributed'],
436
+ ];
437
+
438
+ function trCaptureDetail(text) {
439
+ const s = String(text ?? '').trim();
440
+ if (!s) return s;
441
+ const patterns = RENDER_LANG === 'en' ? CAPTURE_DETAIL_PATTERNS : CAPTURE_DETAIL_PATTERNS_EN;
442
+ for (const [pattern, render] of patterns) {
443
+ const match = pattern.exec(s);
444
+ if (match) return render(match);
445
+ }
446
+ return s;
447
+ }
448
+
449
+ function readText(file) {
450
+ try { return fs.readFileSync(file, 'utf8'); } catch { return null; }
451
+ }
452
+
453
+ function readJson(file) {
454
+ const raw = readText(file);
455
+ if (raw == null) return null;
456
+ try { return JSON.parse(raw.replace(/^\uFEFF/, '')); } catch { return null; }
457
+ }
458
+
459
+
460
+
461
+ function firstExisting(candidates) {
462
+ return candidates.find(exists) ?? null;
463
+ }
464
+
465
+ function statusBucket(raw) {
466
+ const value = String(raw ?? '').trim().toLowerCase();
467
+ // Negative words first: "not passed/did not pass" mean failed rather than done, "not completed/not yet..." mean not started rather
468
+ // than done — the positive words (complete/passed) are substrings of them and must be intercepted first.
469
+ if (/fail|error|block|failed|blocked|not passed|did not pass/.test(value)) return 'blocked';
470
+ if (/^(not|not yet|no)\b/.test(value)) return 'not_started';
471
+ if (/^(done|complete|completed|success|passed|pass|ok|implemented|encoded)$/.test(value) || /\b(?:completed|complete|passed|implemented|encoded)\b/.test(value)) return 'done';
472
+ if (/running|progress|active|ongoing|executing/.test(value)) return 'in_progress';
473
+ if (/skip/.test(value)) return 'skipped';
474
+ return 'not_started';
475
+ }
476
+
477
+ function statusLabel(bucket) {
478
+ return ({ done: tr('Done'), blocked: tr('Blocked'), in_progress: tr('In progress'), skipped: tr('Skipped'), not_started: tr('Pending') })[bucket] ?? tr('Pending');
479
+ }
480
+
481
+ function parseArgs(argv) {
482
+ const args = { projects: [], requirements: [], usageSources: [], port: 8765, portExplicit: false, once: false, out: '', open: true, config: '', hmosHap: '' };
483
+ for (let i = 0; i < argv.length; i += 1) {
484
+ const token = argv[i];
485
+ if (token === '--config') args.config = argv[++i] ?? '';
486
+ else if (token === '--hmos-hap') args.hmosHap = argv[++i] ?? '';
487
+ else if (token === '--port') { args.port = Number(argv[++i] ?? 8765); args.portExplicit = true; }
488
+ else if (token === '--once') args.once = true;
489
+ else if (token === '--out') args.out = argv[++i] ?? '';
490
+ else if (token === '--no-open') args.open = false;
491
+ else if (token === '--codex') args.usageSources.push('codex');
492
+ else if (token === '--claude-code') args.usageSources.push('claude');
493
+ else if (token === '--opencode') args.usageSources.push('opencode');
494
+ else if (token === '--deveco-code') args.usageSources.push('deveco');
495
+ else if (token === '--usage-source') args.usageSources.push((argv[++i] ?? '').toLowerCase());
496
+ else if (token === '--requirements') {
497
+ while (argv[i + 1] && !argv[i + 1].startsWith('--')) args.requirements.push(argv[++i]);
498
+ } else if (token === '--help' || token === '-h') args.help = true;
499
+ else if (!token.startsWith('--')) args.projects.push(token);
500
+ else throw new Error(`Unsupported argument: ${token}`);
501
+ }
502
+ if (!Number.isInteger(args.port) || args.port < 1 || args.port > 65535) throw new Error(`Invalid port: ${args.port}`);
503
+ return args;
504
+ }
505
+
506
+ function helpText() {
507
+ return `HomeTrans Node dashboard (Node.js >=22.18.0, no Python required)
508
+
509
+ Usage:
510
+ node dashboard.mjs <HarmonyOS project...>
511
+ node dashboard.mjs --config dashboard.config.json
512
+ node dashboard.mjs --config dashboard.config.json --port 8765
513
+ node dashboard.mjs --config dashboard.config.json --once --out dashboard.html
514
+
515
+ Options:
516
+ --config <file> Read a projects config compatible with the Python version
517
+ --hmos-hap <file> Single-project mode: point at a signed HAP outside the project;
518
+ for multiple projects configure hmos_hap per project
519
+ --requirements <...> REQ.txt files, explicitly
520
+ --usage-source <id> Agent usage sources: auto/claude/codex/opencode/deveco/none (repeatable)
521
+ --claude-code Read Claude Code only; same as --usage-source claude
522
+ --codex Read Codex only; same as --usage-source codex
523
+ --opencode Read OpenCode only; same as --usage-source opencode
524
+ --deveco-code Read DevEco Code only; same as --usage-source deveco
525
+ --port <number> Dynamic server port, default 8765; when the default port is busy the
526
+ server shifts upward automatically (up to +20); an explicitly
527
+ requested busy port fails immediately
528
+ --once --out <file> Export a static dashboard
529
+ --no-open Do not open the browser automatically
530
+
531
+ Stopping:
532
+ The live server stops via the "Stop dashboard" button in the page's bottom-left
533
+ corner, or Ctrl+C in the launching terminal; --once static export has no server
534
+ process.`;
535
+ }
536
+
537
+ function pipelineRunContext(root) {
538
+ const candidates = [
539
+ resolveArtifact('pipeline_checkpoint', { root }).found,
540
+ path.join(root, '.hometrans', 'pipeline-checkpoint.md'),
541
+ path.join(root, 'pipeline-checkpoint.md'),
542
+ ].filter(Boolean);
543
+ for (const file of candidates) {
544
+ const text = readText(file);
545
+ const raw = text?.match(/^\s*-\s*arguments:\s*(.+)$/im)?.[1]?.trim();
546
+ if (!raw) continue;
547
+ const values = {};
548
+ for (const key of ['SRC', 'HMOS', 'SPEC', 'OUTPUT']) {
549
+ const match = new RegExp(`(?:^|\\s)${key}=([\\s\\S]*?)(?=\\s+[A-Z][A-Z0-9_]*=|$)`).exec(raw);
550
+ if (!match) continue;
551
+ values[key] = match[1].trim().replace(/^(["'])(.*)\1$/, '$2');
552
+ }
553
+ return { file, ...values };
554
+ }
555
+ return {};
556
+ }
557
+
558
+ function inferEntryPaths(entry) {
559
+ const root = path.resolve(entry.path);
560
+ const context = pipelineRunContext(root);
561
+ const inferredAndroid = context.SRC && exists(context.SRC) ? path.resolve(context.SRC) : '';
562
+ const inferredHmos = context.HMOS && exists(context.HMOS) ? path.resolve(context.HMOS) : '';
563
+ const androidProject = entry.android_project_dir || inferredAndroid;
564
+ const inferredUiInfo = androidProject ? path.join(androidProject, 'ui_info') : '';
565
+ return {
566
+ ...entry,
567
+ path: root,
568
+ android_project_dir: entry.android_project_dir || inferredAndroid,
569
+ ui_info_root: entry.ui_info_root || inferredUiInfo,
570
+ hmos_capture_project_dir: entry.hmos_capture_project_dir || inferredHmos,
571
+ pipeline_checkpoint_path: entry.pipeline_checkpoint_path || context.file || '',
572
+ };
573
+ }
574
+
575
+ function loadEntries(args) {
576
+ let entries = args.projects.map((projectPath) => ({ name: path.basename(path.resolve(projectPath)), path: projectPath }));
577
+ let requirements = [...args.requirements];
578
+ let androidPaths = [];
579
+ let specNames = {};
580
+ let usageSources = [...args.usageSources];
581
+ let architectureOutputDir = '';
582
+ let architectureArtifactsDir = '';
583
+ let pipelineConfig = {};
584
+ if (args.config) {
585
+ const configPath = path.resolve(args.config);
586
+ const config = readJson(configPath);
587
+ if (!config) throw new Error(`Config file is not valid UTF-8 JSON: ${configPath}`);
588
+ const base = path.dirname(configPath);
589
+ const resolveConfiguredPath = (value, key = 'Config value') => {
590
+ if (!value) return '';
591
+ if (typeof value !== 'string') throw new Error(`${key} must be a path string`);
592
+ return path.isAbsolute(value) ? value : path.resolve(base, value);
593
+ };
594
+ entries = (config.projects ?? []).map((item) => {
595
+ const raw = typeof item === 'string' ? item : item.path;
596
+ const resolved = path.isAbsolute(raw) ? raw : path.resolve(base, raw);
597
+ const objectItem = typeof item === 'object' ? item : {};
598
+ return {
599
+ ...objectItem,
600
+ name: objectItem.name || path.basename(resolved),
601
+ path: resolved,
602
+ ui_capture_dir: resolveConfiguredPath(objectItem.ui_capture_dir),
603
+ ui_info_root: resolveConfiguredPath(objectItem.ui_info_root),
604
+ android_project_dir: resolveConfiguredPath(objectItem.android_project_dir),
605
+ hmos_capture_project_dir: resolveConfiguredPath(objectItem.hmos_capture_project_dir),
606
+ hmos_hap: resolveConfiguredPath(objectItem.hmos_hap),
607
+ hmos_hdc: resolveConfiguredPath(objectItem.hmos_hdc),
608
+ };
609
+ });
610
+ requirements = [...requirements, ...(config.requirements ?? []).map(resolveConfiguredPath)];
611
+ androidPaths = (config.android_paths ?? []).map((item) => (
612
+ path.isAbsolute(item) ? item : path.resolve(base, item)
613
+ ));
614
+ specNames = config.spec_names ?? {};
615
+ usageSources = [...usageSources, ...(config.usage_sources ?? [])];
616
+ architectureOutputDir = resolveConfiguredPath(config.architecture_output_dir);
617
+ architectureArtifactsDir = resolveConfiguredPath(config.architecture_artifacts_dir);
618
+ pipelineConfig = Object.fromEntries([
619
+ 'specs_json', 'spec_pipeline_state', 'spec_design_dir',
620
+ ].map((key) => [key, resolveConfiguredPath(config[key], key)]).filter(([, value]) => value));
621
+ }
622
+ if (!entries.length) throw new Error('No target projects. Pass project paths or use --config.');
623
+ for (const entry of entries) {
624
+ if (!fs.existsSync(path.join(entry.path, '.hometrans'))) {
625
+ throw new Error(`HarmonyOS project path does not exist or lacks a .hometrans directory: ${entry.path}`);
626
+ }
627
+ }
628
+ if (args.hmosHap) {
629
+ if (entries.length !== 1) throw new Error('--hmos-hap applies to a single project only; for multiple projects configure hmos_hap per project.');
630
+ entries[0].hmos_hap = path.resolve(args.hmosHap);
631
+ }
632
+ const resolvedEntries = entries.map((entry, index) => inferEntryPaths({
633
+ ...entry,
634
+ ...pipelineConfig,
635
+ dashboard_config: { ...pipelineConfig, ...(entry.dashboard_config ?? {}) },
636
+ path: path.resolve(entry.path),
637
+ android_project_dir: entry.android_project_dir
638
+ ? (path.isAbsolute(entry.android_project_dir) ? entry.android_project_dir : path.resolve(entry.android_project_dir))
639
+ : (androidPaths[index] ?? androidPaths[0] ?? ''),
640
+ ui_info_root: entry.ui_info_root
641
+ ? (path.isAbsolute(entry.ui_info_root) ? entry.ui_info_root : path.resolve(entry.ui_info_root))
642
+ : '',
643
+ hmos_capture_project_dir: entry.hmos_capture_project_dir
644
+ ? (path.isAbsolute(entry.hmos_capture_project_dir) ? entry.hmos_capture_project_dir : path.resolve(entry.hmos_capture_project_dir))
645
+ : '',
646
+ hmos_hap: entry.hmos_hap
647
+ ? (path.isAbsolute(entry.hmos_hap) ? entry.hmos_hap : path.resolve(entry.hmos_hap))
648
+ : '',
649
+ }));
650
+ // utg_static is located through the artifact contract (the convention fallback lives inside device_capture).
651
+ for (const entry of resolvedEntries) {
652
+ if (!entry.utg_static_dir) {
653
+ const hit = resolveArtifact('utg_static', { root: entry.path });
654
+ if (hit.found) entry.utg_static_dir = hit.found;
655
+ }
656
+ }
657
+ return {
658
+ entries: resolvedEntries,
659
+ requirements: requirements.map((item) => path.resolve(item)),
660
+ androidPaths,
661
+ specNames,
662
+ usageSources: [...new Set(usageSources.filter(Boolean))],
663
+ architectureOutputDir,
664
+ architectureArtifactsDir,
665
+ architecture_output_dir: architectureOutputDir,
666
+ architecture_artifacts_dir: architectureArtifactsDir,
667
+ ...pipelineConfig,
668
+ };
669
+ }
670
+
671
+ function uiInfoRoot(root, entry = {}) {
672
+ const candidates = [
673
+ entry.ui_info_root,
674
+ entry.android_project_dir ? path.join(entry.android_project_dir, 'ui_info') : '',
675
+ path.join(root, 'ui_info'),
676
+ path.join(root, '.hometrans', 'ui_info'),
677
+ ].filter(Boolean).map((candidate) => path.resolve(candidate));
678
+ return candidates.find((candidate) => exists(path.join(candidate, 'index.json')))
679
+ || candidates.find((candidate) => exists(candidate))
680
+ || candidates[0]
681
+ || path.join(root, 'ui_info');
682
+ }
683
+
684
+ function sourceScreenshotInventory(root, entry = {}) {
685
+ const infoRoot = uiInfoRoot(root, entry);
686
+ const index = readJson(path.join(infoRoot, 'index.json'));
687
+ const rawRows = Array.isArray(index) ? index : (Array.isArray(index?.pages) ? index.pages : []);
688
+ const rows = [];
689
+ const seen = new Set();
690
+ const add = (id, row = {}) => {
691
+ const pageId = String(id || '').trim();
692
+ if (!pageId || seen.has(pageId)) return;
693
+ const pageDir = path.join(infoRoot, pageId);
694
+ const configured = row.screenshot ? path.resolve(infoRoot, String(row.screenshot)) : '';
695
+ const screenshot = firstExisting([
696
+ configured,
697
+ path.join(pageDir, 'screenshot.png'),
698
+ path.join(pageDir, 'screenshot.jpg'),
699
+ path.join(pageDir, 'screenshot.jpeg'),
700
+ ].filter(Boolean));
701
+ // Scroll supplements belong to the same page. Step 1 counts one base
702
+ // source screenshot/page directory, never every long-image frame.
703
+ if (!screenshot) return;
704
+ seen.add(pageId);
705
+ rows.push({ id: pageId, screenshot, label: String(row.label || row.name || pageId) });
706
+ };
707
+ rawRows.forEach((row, indexNumber) => add(row?.page_id || row?.id || row?.name || `page_${indexNumber + 1}`, row || {}));
708
+ if (!rows.length && exists(infoRoot)) {
709
+ let dirs = [];
710
+ try { dirs = fs.readdirSync(infoRoot, { withFileTypes: true }); } catch { dirs = []; }
711
+ dirs.filter((item) => item.isDirectory() && /^page_\d+_/i.test(item.name))
712
+ .sort((left, right) => left.name.localeCompare(right.name, undefined, { numeric: true }))
713
+ .forEach((item) => add(item.name));
714
+ }
715
+ return { root: infoRoot, rows };
716
+ }
717
+
718
+ function configuredRows(file, key) {
719
+ const payload = file ? readJson(file) : null;
720
+ if (Array.isArray(payload)) return payload;
721
+ return Array.isArray(payload?.[key]) ? payload[key] : [];
722
+ }
723
+
724
+ function pipelineStage(id, raw, inferred = false) {
725
+ const object = raw && typeof raw === 'object' ? raw : {};
726
+ return {
727
+ id,
728
+ status: statusBucket(object.status ?? raw),
729
+ evidence: Array.isArray(object.evidence) ? object.evidence : [],
730
+ note: String(object.note ?? ''),
731
+ inferred,
732
+ };
733
+ }
734
+
735
+ const UI_STAGE_LABELS = {
736
+ A: 'UI design', B: 'Page migration', B1: 'Compliance check', B2: 'Build verification', C: 'Commit',
737
+ complete: 'Done', done: 'Done',
738
+ };
739
+ function uiStageLabel(row) {
740
+ const current = String(row.current_stage || '').toLowerCase();
741
+ if (current && UI_STAGE_LABELS[current]) return tr(UI_STAGE_LABELS[current]);
742
+ if (current) return current;
743
+ const overall = statusBucket(row.status);
744
+ return overall === 'done' ? tr('Done') : tr('Not recorded');
745
+ }
746
+
747
+ function findUiProgress(root, entry = {}, config = {}) {
748
+ const inventory = sourceScreenshotInventory(root, entry);
749
+ const file = firstExisting([
750
+ // Explicit configuration (the ledger pointed to by entry.ui_info_root) wins over the contract default.
751
+ path.join(inventory.root, 'batch_progress.json'),
752
+ resolveArtifact('batch_progress', { root }).found,
753
+ path.join(root, 'ui_info', 'batch_progress.json'),
754
+ path.join(root, '.hometrans', 'ui_info', 'batch_progress.json'),
755
+ path.join(root, '.hometrans', 'batch_progress.json'),
756
+ path.join(root, 'batch_progress.json'),
757
+ ].filter(Boolean));
758
+ const payload = file ? readJson(file) : null;
759
+ const rawPages = payload?.pages ?? {};
760
+ const pairs = Array.isArray(rawPages)
761
+ ? rawPages.map((row, index) => [row.id || row.name || row.page_id || `page_${index + 1}`, row])
762
+ : Object.entries(rawPages);
763
+ const checkpointTasks = pairs.map(([id, row]) => ({
764
+ id,
765
+ status: statusBucket(row?.status),
766
+ output: row?.output ?? '',
767
+ summary: row?.summary ?? '',
768
+ }));
769
+ // batch_progress.json is the authoritative Step-1 task ledger. ui_info
770
+ // contains source screenshots and interaction states, not necessarily one
771
+ // independently converted task per screenshot. Never expand an existing
772
+ // checkpoint back to every source state. UTG currently has no persistent
773
+ // task ledger, though, so in that one case the base screenshot inventory is
774
+ // the only safe denominator; every row stays pending until real completion
775
+ // evidence appears instead of being guessed from target source-file counts.
776
+ const tasks = file ? checkpointTasks : inventory.rows.map((page) => ({
777
+ id: page.id,
778
+ status: 'not_started',
779
+ output: '',
780
+ summary: `Source page snapshot found: ${page.label || page.id}; waiting for UI conversion to write per-page completion evidence.`,
781
+ captureName: page.label || page.id,
782
+ }));
783
+ const taskDone = tasks.filter((row) => row.status === 'done').length;
784
+ const result = {
785
+ file,
786
+ updatedAt: payload?.updated_at ?? '',
787
+ tasks,
788
+ taskDone,
789
+ taskTotal: tasks.length,
790
+ uiInfoRoot: inventory.root,
791
+ sourceScreenshots: inventory.rows,
792
+ inferredFromInventory: !file && inventory.rows.length > 0,
793
+ done: taskDone,
794
+ total: tasks.length,
795
+ };
796
+ return result;
797
+ }
798
+
799
+ function markdownTitle(text, fallback) {
800
+ const match = text.match(/^#\s+(.+?)\s*$/m);
801
+ return match ? match[1].replace(/\s*SPEC\s*$/i, '').trim() : fallback;
802
+ }
803
+
804
+ function parseScenarios(text) {
805
+ const heading = /^##\s+(?:Scenario)\s*([^\r\n]*)/gim;
806
+ const matches = [...text.matchAll(heading)];
807
+ if (matches.length > 0) return matches.map((match, index) => {
808
+ const start = match.index + match[0].length;
809
+ const end = matches[index + 1]?.index ?? text.length;
810
+ // A scenario body never extends past the next H2. Without this the LAST
811
+ // scenario swallows whatever follows it — notably the publisher's trailing
812
+ // provenance section, whose path bullets would show up as scenario steps.
813
+ const nextH2 = /^##[ \t]/m.exec(text.slice(start));
814
+ const body = text.slice(start, nextH2 ? Math.min(end, start + nextH2.index) : end);
815
+ const description = body.match(/###\s*(?:Scenario\s+(?:Overview|Description))\s*\r?\n+([\s\S]*?)(?=\r?\n###|$)/i)?.[1]?.trim() ?? '';
816
+ const steps = body.match(/###\s*(?:Scenario\s+(?:Steps|Logic))\s*\r?\n+([\s\S]*?)(?=\r?\n###|$)/i)?.[1]?.trim() ?? '';
817
+ const expected = body.match(/###\s*(?:Expected\s+Result)\s*\r?\n+([\s\S]*?)(?=\r?\n###|$)/i)?.[1]?.trim() ?? description;
818
+ return { name: `Scenario ${match[1].trim() || index + 1}`, description, steps, expected, complete: Boolean(description && steps) };
819
+ });
820
+
821
+ // UTG generate-spec uses one `## Atomic Scenarios` section and puts each atomic
822
+ // scenario under an H3 heading. Keep this parser separate from the legacy
823
+ // H2 shape so headings such as `### Scenario Overview` cannot become scenarios.
824
+ // Both languages are read (i18n/terms.json): zh `## Atomic Scenarios` / `### Scenario N: <title>`
825
+ // / `Semantics: ` / `Trigger and Flow: ` / `Signature: `, en `## Atomic Scenarios` / `### Scenario N: <title>`
826
+ // / `Semantics:` / `Trigger and Flow:` / `Signature:` (English numbers are digits only).
827
+ const atomicStart = /^##\s+(?:Atomic Scenarios)\s*$/im.exec(text);
828
+ const atomicBodyStart = atomicStart ? atomicStart.index + atomicStart[0].length : -1;
829
+ const nextH2 = atomicBodyStart >= 0 ? /^##\s+/m.exec(text.slice(atomicBodyStart)) : null;
830
+ const atomicSection = atomicBodyStart < 0
831
+ ? ''
832
+ : text.slice(atomicBodyStart, nextH2 ? atomicBodyStart + nextH2.index : text.length);
833
+ const atomicHeading = /^###\s+Scenario\s+(\d+)(?:\s*:\s*([^\r\n]+))?\s*$/gim;
834
+ const atomicMatches = [...atomicSection.matchAll(atomicHeading)];
835
+ return atomicMatches.map((match, index) => {
836
+ const start = match.index + match[0].length;
837
+ const end = atomicMatches[index + 1]?.index ?? atomicSection.length;
838
+ const body = atomicSection.slice(start, end);
839
+ const description = body.match(/^(?:Semantics)\s*:\s*([^\r\n]+(?:\r?\n(?!\s*(?:Trigger and Flow|Signature)\s*:)[\s\S]*?)?)(?=^\s*(?:Trigger and Flow|Signature)\s*:|$)/im)?.[1]?.trim() ?? '';
840
+ const steps = body.match(/^(?:Trigger and Flow)\s*:\s*\r?\n+([\s\S]*?)$/im)?.[1]?.trim() ?? '';
841
+ const number = match[1].trim() || String(index + 1);
842
+ const title = match[2]?.trim();
843
+ return {
844
+ name: title ? `Scenario ${number}: ${title}` : `Scenario ${number}`,
845
+ description,
846
+ steps,
847
+ expected: description,
848
+ complete: Boolean(description && steps),
849
+ };
850
+ });
851
+ }
852
+
853
+
854
+ function specStageStatus(raw) {
855
+ const value = String(raw?.status ?? raw ?? '').trim().toLowerCase();
856
+ if (/^(done|complete|completed|success|passed|pass|ok)$/.test(value)) return 'done';
857
+ if (/^(block|fail|error)$/.test(value)) return 'blocked';
858
+ if (/^(running|progress|active|in_progress)$/.test(value)) return 'in_progress';
859
+ if (/^(skip|skipped)$/.test(value)) return 'skipped';
860
+ return 'not_started';
861
+ }
862
+
863
+ // Directory names skipped by default (case-insensitive): only the obviously noisy directories that can never hold reqgen artifacts.
864
+ const DEFAULT_SPEC_PRUNE = ['node_modules', 'oh_modules', '.git', '.idea', '.hvigor', 'build', '.cxx', '.preview', '.claude', '.codebuddy', 'entry', 'AppScope', 'hvigor', 'products'];
865
+
866
+ // Suffix scan: the base set = the registry-declared spec_root (**exclusive**) or the default full
867
+ // .hometrans scan, plus the configured app_reqgen_dirs extras, unioned. Why exclusive: the publish
868
+ // roots in the producer layout all live inside .hometrans, and the same batch of SPECs has sibling
869
+ // copy roots (the page-group root generation/pages and the idx root generation/specs each hold a
870
+ // byte-identical copy) — a full union would collect the same document twice via two paths, and
871
+ // file-level dedup cannot merge different paths. When the declaration exists and is a directory it is
872
+ // the producer's single authoritative SPEC root; when it goes stale (missing / not a directory) fall
873
+ // back to the full .hometrans scan — fallback resilience unchanged. The project source tree is never
874
+ // walked — the root-level layouts {root}/specs, {root}/spec, hometrans_output/**/spec were removed
875
+ // with the old mechanism; the skill's artifact locations all live in .hometrans or declared/registered
876
+ // directories.
877
+ function collectSpecMarkdown(root, config = {}, declaredRoot = null) {
878
+ const prune = new Set((Array.isArray(config.spec_prune_names) ? config.spec_prune_names : DEFAULT_SPEC_PRUNE).map((s) => String(s).toLowerCase()));
879
+ const result = [];
880
+ const bases = declaredRoot ? [declaredRoot] : [path.join(root, '.hometrans')];
881
+ for (const raw of (Array.isArray(config.app_reqgen_dirs) ? config.app_reqgen_dirs : [])) {
882
+ if (!raw) continue;
883
+ bases.push(path.isAbsolute(raw) ? raw : path.resolve(root, raw));
884
+ }
885
+ const seenBases = new Set();
886
+ const seenFiles = new Set();
887
+ for (const base of bases) {
888
+ const key = path.resolve(base).toLowerCase();
889
+ if (seenBases.has(key) || !exists(base)) continue;
890
+ seenBases.add(key);
891
+ const stack = [base];
892
+ while (stack.length) {
893
+ const dir = stack.pop();
894
+ let entries = [];
895
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { continue; }
896
+ for (const entry of entries) {
897
+ const full = path.join(dir, entry.name);
898
+ if (entry.isDirectory()) {
899
+ if (!prune.has(entry.name.toLowerCase())) stack.push(full);
900
+ } else if (entry.isFile() && /-SPEC\.md$/i.test(entry.name)) {
901
+ // The bases may nest or overlap (e.g. a configured app_reqgen_dirs dir inside .hometrans);
902
+ // file-level dedup guarantees each document appears exactly once.
903
+ const fileKey = path.resolve(full).toLowerCase();
904
+ if (seenFiles.has(fileKey)) continue;
905
+ seenFiles.add(fileKey);
906
+ result.push(full);
907
+ }
908
+ }
909
+ }
910
+ }
911
+ return result;
912
+ }
913
+
914
+ function findSpecs(root, specNames = {}, config = {}) {
915
+ // SPEC document discovery: the registry-declared spec_root (the producer's own root, relative to
916
+ // the project root) is **exclusive** — the same batch of SPECs has sibling copy roots (the
917
+ // page-group root + the idx root, both inside .hometrans), so unioning with the full .hometrans
918
+ // scan would collect each document twice via two paths. When the declaration goes stale (missing /
919
+ // not a directory) fall back to the full .hometrans scan — the fallback still covers everything.
920
+ // Manifests (specs.json / spec_pipeline_state.json) do not participate in discovery — they only
921
+ // provide progress denominators and pipeline state (see specPipelineModel).
922
+ const declared = lookupArtifactRegistry(root, 'spec_root');
923
+ const declaredRoot = declared && isDirectoryPath(declared.path) ? declared.path : null;
924
+ const specs = collectSpecMarkdown(root, config, declaredRoot).map((file, index) => {
925
+ const text = readText(file) ?? '';
926
+ const scenarios = parseScenarios(text);
927
+ return {
928
+ id: `S${index + 1}`,
929
+ file,
930
+ title: specNames[`S${index + 1}`] || markdownTitle(text, path.basename(file, '.md')),
931
+ scenarios,
932
+ complete: scenarios.length > 0 && scenarios.every((row) => row.complete),
933
+ };
934
+ });
935
+ return { specs, done: specs.filter((row) => row.complete).length, total: specs.length };
936
+ }
937
+
938
+ function specPipelineModel(root, specNames = {}, config = {}, legacy = null) {
939
+ const stageIds = ['A', 'B', 'B2', 'C'];
940
+ const fallback = legacy ?? findSpecs(root, specNames, config);
941
+ const stateFile = config.spec_pipeline_state
942
+ || resolveArtifact('spec_pipeline_state', { root }).found
943
+ || path.join(root, '.hometrans', 'spec_pipeline_state.json');
944
+ const state = exists(stateFile) ? readJson(stateFile) : null;
945
+
946
+ if (state && Array.isArray(state.specs)) {
947
+ // specs.json (when configured) is the authoritative full set of specs for
948
+ // this project — state.specs only records the subset that has run through
949
+ // the pipeline (e.g. config.scope = first_2_specs). Overlay state's
950
+ // completion status onto the full set so unconverted specs surface as
951
+ // not_started instead of being invisible (2/15 rather than a misleading
952
+ // 2/2). The denominator is dynamic: specs.json may hold 8, 15, or 20
953
+ // entries depending on the project; nothing here hard-codes a count.
954
+ const fullSet = configuredRows(config.specs_json, 'specs');
955
+ const configuredSpecRoot = config.specs_json ? path.dirname(config.specs_json) : root;
956
+ const designDir = config.spec_design_dir
957
+ || resolveArtifact('spec_design_dir', { root }).found
958
+ || path.join(root, '.hometrans', 'spec_design');
959
+ const groupDesignForSoId = (soId) => {
960
+ if (!Array.isArray(state.groups)) return '';
961
+ const specRow = state.specs.find((r) => Number(r['so-id']) === soId);
962
+ if (!specRow) return '';
963
+ const group = state.groups.find((r) => Number(r.G) === Number(specRow.group));
964
+ if (!group || !Array.isArray(group.chunks)) return '';
965
+ const chunk = group.chunks.find((c) => Array.isArray(c.spec_ids) && c.spec_ids.includes(soId));
966
+ if (!chunk || !chunk.design_file) return '';
967
+ return path.isAbsolute(chunk.design_file) ? chunk.design_file
968
+ : path.join(designDir, chunk.design_file);
969
+ };
970
+ const normSpecPath = (file) => path.resolve(file).replace(/\\/g, '/').toLowerCase();
971
+ const stateByPath = new Map();
972
+ for (const row of state.specs) {
973
+ if (row.spec_file) stateByPath.set(normSpecPath(row.spec_file), row);
974
+ }
975
+ const buildStateStages = (row) => {
976
+ const current = String(row.stage || '').toUpperCase();
977
+ const currentIndex = stageIds.indexOf(current);
978
+ const overall = statusBucket(row.status);
979
+ return stageIds.map((id, stageIndex) => {
980
+ if (row.stages?.[id] != null) return pipelineStage(id, row.stages[id]);
981
+ if (overall === 'done') return pipelineStage(id, 'done', true);
982
+ if (currentIndex < 0 || stageIndex > currentIndex) return pipelineStage(id, 'not_started', true);
983
+ return pipelineStage(id, stageIndex < currentIndex ? 'done' : overall, true);
984
+ });
985
+ };
986
+
987
+ // No full set available → fall back to state.specs as the whole set, so
988
+ // projects without specs.json do not regress (total = state.specs.length).
989
+ // state.spec_file is the absolute path from migration time — it breaks when the project is copied or moved
990
+ // to another machine. Re-locate the file inside the local .hometrans by the trailing relative structure
991
+ // (…/generation/specs/<batch>/<file>) or by file name, avoiding a fake 0/N board.
992
+ if (!fullSet.length) {
993
+ const localSpecRoots = [
994
+ path.join(root, '.hometrans', 'app-migrate', 'reqgen', 'generation', 'specs'),
995
+ path.join(root, '.hometrans', 'reqgen', 'generation', 'specs'),
996
+ ];
997
+ const localSpecsByBase = new Map();
998
+ for (const file of collectSpecMarkdown(root, {})) {
999
+ const base = path.basename(file).toLowerCase();
1000
+ if (!localSpecsByBase.has(base)) localSpecsByBase.set(base, file);
1001
+ }
1002
+ const resolveStateSpecFile = (row) => {
1003
+ // state.spec_file is the absolute path at migration time and may come from another machine / another OS:
1004
+ // path.basename on Linux does not split a Windows backslash path, so the whole string would be used as the file name
1005
+ // and the lookup always misses; normalize to forward slashes before taking the tail and basename.
1006
+ const raw = String(row.spec_file || '').replace(/\\/g, '/');
1007
+ if (!raw) return '';
1008
+ if (exists(raw)) return raw;
1009
+ // Tail structure markers: both the idx root and the Step 5b page-grouped root are recognized (take the one appearing
1010
+ // last in the path, to support multi-level layouts with generation nested inside a run directory).
1011
+ let tail = '';
1012
+ let tailAt = -1;
1013
+ for (const marker of ['/generation/pages/', '/generation/specs/']) {
1014
+ const at = raw.toLowerCase().lastIndexOf(marker);
1015
+ if (at > tailAt) {
1016
+ tailAt = at;
1017
+ tail = raw.slice(at + marker.length);
1018
+ }
1019
+ }
1020
+ if (tail) {
1021
+ for (const localRoot of localSpecRoots) {
1022
+ const candidate = path.join(localRoot, ...tail.split('/'));
1023
+ if (exists(candidate)) return candidate;
1024
+ }
1025
+ }
1026
+ return localSpecsByBase.get(raw.split('/').pop().toLowerCase()) || '';
1027
+ };
1028
+ const specs = state.specs.map((row, index) => {
1029
+ const file = resolveStateSpecFile(row);
1030
+ const text = file ? (readText(file) ?? '') : '';
1031
+ const id = `S${Number(row.index) || index + 1}`;
1032
+ const stages = buildStateStages(row);
1033
+ // `complete` reflects whether the SPEC.md scenarios are fully authored
1034
+ // (step 3 — spec generation), NOT whether the conversion pipeline ran.
1035
+ // The pipeline status lives in `status`/`pipelineStages` (step 4).
1036
+ const scenarios = parseScenarios(text);
1037
+ const complete = scenarios.length > 0 && scenarios.every((scene) => scene.complete);
1038
+ return {
1039
+ id, file,
1040
+ title: specNames[id] || markdownTitle(text, row.spec_stem || `Spec ${index + 1}`),
1041
+ scenarios,
1042
+ status: statusBucket(row.status),
1043
+ liveStatus: statusBucket(row.status),
1044
+ pipelineStages: stages, stages,
1045
+ designFile: String(row.design_file || ''),
1046
+ group: Number(row.group) || null,
1047
+ wave: Number((state.groups || []).find((g) => Number(g.G) === Number(row.group))?.wave) || null,
1048
+ complete,
1049
+ };
1050
+ });
1051
+ return { authoritative: true, file: stateFile, specs, done: specs.filter((row) => row.complete).length, total: specs.length };
1052
+ }
1053
+
1054
+ const specs = fullSet.map((row, index) => {
1055
+ const configuredFile = String(row.path || row.spec_file || '');
1056
+ const file = configuredFile
1057
+ ? (path.isAbsolute(configuredFile) ? configuredFile : path.resolve(configuredSpecRoot, configuredFile))
1058
+ : '';
1059
+ const soId = Number(row['so-id']) || index + 1;
1060
+ const id = `S${soId}`;
1061
+ const stateRow = file ? stateByPath.get(normSpecPath(file)) : null;
1062
+ const text = file ? (readText(file) ?? '') : '';
1063
+ if (stateRow) {
1064
+ // Converted spec — authoritative per-stage status from the pipeline state.
1065
+ const overall = statusBucket(stateRow.status);
1066
+ const stages = buildStateStages(stateRow);
1067
+ const scenarios = parseScenarios(text);
1068
+ return {
1069
+ id, file,
1070
+ title: specNames[id] || markdownTitle(text, stateRow.spec_stem || `Spec ${index + 1}`),
1071
+ scenarios,
1072
+ status: overall, liveStatus: overall,
1073
+ pipelineStages: stages, stages,
1074
+ designFile: String(stateRow.design_file || ''),
1075
+ group: Number(stateRow.group) || null,
1076
+ wave: Number((state.groups || []).find((g) => Number(g.G) === Number(stateRow.group))?.wave) || null,
1077
+ // `complete` = step 3 (spec generation) done = SPEC.md scenarios fully
1078
+ // authored. The pipeline run status is in `status`/`pipelineStages`.
1079
+ complete: scenarios.length > 0 && scenarios.every((scene) => scene.complete),
1080
+ };
1081
+ }
1082
+ // Member of the full set but not yet run through the pipeline.
1083
+ const designFile = groupDesignForSoId(soId)
1084
+ || (designDir ? path.join(designDir, `SPEC_DESIGN_${soId}.md`) : '');
1085
+ const stages = stageIds.map((sid) => pipelineStage(sid, 'not_started', false));
1086
+ const scenarios = parseScenarios(text);
1087
+ return {
1088
+ id, file,
1089
+ title: specNames[id] || row.title || markdownTitle(text, path.basename(file, path.extname(file)) || `Spec ${index + 1}`),
1090
+ scenarios,
1091
+ status: 'not_started', liveStatus: 'not_started',
1092
+ pipelineStages: stages, stages, designFile,
1093
+ complete: scenarios.length > 0 && scenarios.every((scene) => scene.complete),
1094
+ };
1095
+ });
1096
+ return { authoritative: true, file: stateFile, specs, done: specs.filter((row) => row.complete).length, total: specs.length };
1097
+ }
1098
+
1099
+ const configured = configuredRows(config.specs_json, 'specs');
1100
+ const source = configured.length ? configured : (fallback.specs ?? []).map((row) => ({ path: row.file, title: row.title }));
1101
+ const configuredSpecRoot = config.specs_json ? path.dirname(config.specs_json) : root;
1102
+ const designDir = config.spec_design_dir
1103
+ || resolveArtifact('spec_design_dir', { root }).found
1104
+ || path.join(root, '.hometrans', 'spec_design');
1105
+ const specs = source.map((row, index) => {
1106
+ const configuredFile = String(row.path || row.spec_file || '');
1107
+ const file = configuredFile
1108
+ ? (path.isAbsolute(configuredFile) ? configuredFile : path.resolve(configuredSpecRoot, configuredFile))
1109
+ : '';
1110
+ const text = file ? (readText(file) ?? '') : '';
1111
+ const id = `S${index + 1}`;
1112
+ const designFile = designDir ? path.join(designDir, `SPEC_DESIGN_${index + 1}.md`) : '';
1113
+ const aDone = Boolean(designFile && exists(designFile));
1114
+ const scenarios = parseScenarios(text);
1115
+ const complete = scenarios.length > 0 && scenarios.every((scenario) => scenario.complete);
1116
+ const stages = [
1117
+ pipelineStage('A', aDone ? 'done' : 'not_started', aDone),
1118
+ pipelineStage('B', 'not_started'), pipelineStage('B2', 'not_started'), pipelineStage('C', 'not_started'),
1119
+ ];
1120
+ const status = aDone ? 'in_progress' : 'not_started';
1121
+ return {
1122
+ id, file,
1123
+ title: specNames[id] || row.title || markdownTitle(text, path.basename(file, path.extname(file)) || `Spec ${index + 1}`),
1124
+ scenarios, status, liveStatus: status,
1125
+ pipelineStages: stages, stages, designFile, complete,
1126
+ };
1127
+ });
1128
+ return { authoritative: false, file: null, specs, done: specs.filter((row) => row.complete).length, total: specs.length };
1129
+ }
1130
+
1131
+ function hasExplicitUserSkip(value) {
1132
+ const text = String(value ?? '');
1133
+ const hasSkip = /skip/i.test(text);
1134
+ if (!hasSkip) return false;
1135
+ return /per user|user.{0,12}(?:explicitly\s+)?(?:request|instruction|command|configuration)|user.{0,16}(?:request|instruction|command|configuration)/i.test(text);
1136
+ }
1137
+
1138
+ function explicitUserSkipForStage(text, id, rawStatus) {
1139
+ if (hasExplicitUserSkip(rawStatus)) return true;
1140
+ const group = String(id ?? '').slice(0, 3);
1141
+ const number = group.split('.')[1] ?? '';
1142
+ return String(text ?? '').split(/\r?\n/).some((line) => {
1143
+ const mentionsStage = line.includes(group)
1144
+ || new RegExp(`(?:stage|step)\\s*${number}\\b`, 'i').test(line);
1145
+ return mentionsStage && hasExplicitUserSkip(line);
1146
+ });
1147
+ }
1148
+
1149
+ // Map a manifest stage-cell token to the canonical 3.x group id used throughout
1150
+ // the dashboard. Recognizes two numbering schemes:
1151
+ // - UTG-wave: 3.1 / 3.2 / 3.3 (optionally suffixed with a letter)
1152
+ // - legacy single-spec pipeline (removed a2h-arkts-convert-pipeline): 1 / 2 / 3 / 3a / 3b
1153
+ // The arkts `N` ids are projected onto the same 3.x groups so downstream
1154
+ // manifestTableStatuses / logicForSpec (which key by 3.x) work unchanged.
1155
+ const ARKTS_STAGE_MAP = {
1156
+ '1': '3.1', '2': '3.2', '3': '3.3', '3a': '3.3', '3b': '3.3',
1157
+ };
1158
+ function manifestStageCell(cell) {
1159
+ // UTG-wave standalone stage id: 3.1 / 3.2 / 3.3 (optionally suffixed).
1160
+ // arkts stage ids (1/2/3/3a/4/4a/...) are intentionally NOT matched here as
1161
+ // standalone cells: they appear as a bare column value only in the manifest's
1162
+ // Configuration table (bare digits = config values) and its "Files Touched by
1163
+ // Stage" table (3a/3b = a file's stage-ownership tag, not a stage status row).
1164
+ // Matching those would pollute the stage groups with not_started rows lifted
1165
+ // from file descriptions. arkts stage status is read solely from the fused
1166
+ // "N - Name" Duration Summary rows in manifestStageRows below.
1167
+ if (/^3\.[1-3](?:[a-z])?$/.test(cell)) return { id: cell, group: cell.slice(0, 3) };
1168
+ return null;
1169
+ }
1170
+ // The legacy single-spec pipeline (removed a2h-arkts-convert-pipeline) wrote its Duration Summary table with the stage
1171
+ // id and the name fused in one cell, e.g. "1 - Logic Coding", "3a - Review Fix".
1172
+ // Split that into { id, name }. Returns null for non-stage cells (TOTAL, headers).
1173
+ function manifestArktsFusedCell(cell) {
1174
+ const match = cell.match(/^(\d+[a-z]?)\s*-\s*(.+)$/);
1175
+ if (!match) return null;
1176
+ if (/^(?:TOTAL|Stage|Parameter|Defects|Not|Details)$/i.test(match[1])) return null;
1177
+ return { id: match[1], name: match[2] };
1178
+ }
1179
+ // Infer an arkts Duration Summary row's status. The pipeline writes a skipped
1180
+ // sub-stage as "| 3a - Review Fix | — | — | SKIPPED (all_passed) |" — the
1181
+ // SKIPPED token sits in the trailing Duration column while Start stays "—";
1182
+ // older sheets put it in the Start cell. Read both so a skipped 3a/3b/4 is not
1183
+ // misread as not_started (which would drag its whole 3.x group to in_progress).
1184
+ function manifestArktsRowStatus(cells) {
1185
+ const start = (cells[1] || '').trim();
1186
+ const trailing = (cells.at(-1) || '').trim();
1187
+ if (/^skipped/i.test(start) || /^skipped/i.test(trailing)) return 'skipped';
1188
+ if (/\d{4}-\d{2}-\d{2}T/.test(start)) return 'done';
1189
+ return 'not_started';
1190
+ }
1191
+ // Grouped-pipeline wave attribution: state.specs[].group → state.groups[].wave →
1192
+ // {hometrans}/wave_N/. Build evidence (HAP + build-fix-report) is wave-level — one
1193
+ // build covers every group in the wave; it can never be found in group or per-spec directories.
1194
+ function waveDirForSpec(root, spec) {
1195
+ const stateFile = resolveArtifact('spec_pipeline_state', { root }).found
1196
+ || path.join(root, '.hometrans', 'spec_pipeline_state.json');
1197
+ const state = exists(stateFile) ? readJson(stateFile) : null;
1198
+ if (!state || !Array.isArray(state.groups) || !Array.isArray(state.specs)) return '';
1199
+ const soId = Number(String(spec?.id || '').replace(/^s/i, ''));
1200
+ if (!Number.isInteger(soId) || soId <= 0) return '';
1201
+ const row = state.specs.find((item) => Number(item.index) === soId || Number(item['so-id']) === soId);
1202
+ if (!row || row.group == null) return '';
1203
+ const groupRow = state.groups.find((item) => Number(item.G) === Number(row.group));
1204
+ const wave = Number(groupRow?.wave);
1205
+ if (!Number.isInteger(wave) || wave <= 0) return '';
1206
+ const dir = path.join(root, '.hometrans', `wave_${wave}`);
1207
+ return exists(dir) ? dir : '';
1208
+ }
1209
+
1210
+ function logicForSpec(root, spec, index, config = {}) {
1211
+ // Logic evidence has exactly one caliber: the grouped pipeline (a2h-spec-design-pipeline).
1212
+ // The attribution chain comes entirely from spec_pipeline_state.json: specs[].group → groups[].wave.
1213
+ // 3.1 = group chunk commit (commit-info.md); 3.2 = wave build artifacts (HAP +
1214
+ // build-fix-report.md); 3.3 = group review-round reports (code-review-report.md).
1215
+ // Specs without a group/wave attribution: every stage honestly shows not done.
1216
+ const hometrans = path.join(root, '.hometrans');
1217
+ const group = Number(spec.group) || 0;
1218
+ const wave = Number(spec.wave) || 0;
1219
+ const groupDir = group ? path.join(hometrans, `spec_group_${group}`) : '';
1220
+ const waveBuildDir = wave ? path.join(hometrans, `wave_${wave}`, 'build') : '';
1221
+ const evidence = {
1222
+ '3.1': group ? walkFilesRecursive(groupDir, 'commit-info.md') : [],
1223
+ '3.2': wave ? [
1224
+ ...walkFilesRecursive(waveBuildDir, '.hap'),
1225
+ ...walkFilesRecursive(waveBuildDir, 'build-fix-report.md'),
1226
+ ] : [],
1227
+ '3.3': group ? walkFilesRecursive(groupDir, 'code-review-report.md') : [],
1228
+ };
1229
+ const stages = ['3.1', '3.2', '3.3'].map((stage) => {
1230
+ const files = [...new Set(evidence[stage])].filter(exists);
1231
+ return { stage, status: files.length ? 'done' : 'not_started', files };
1232
+ });
1233
+ return { id: spec.id, title: spec.title, projectRoot: root, pipelineKind: 'grouped-stage', dir: exists(groupDir) ? groupDir : '', manifest: null, planFile: '', plan: null, coverageFile: '', coverage: [], stages };
1234
+ }
1235
+
1236
+
1237
+
1238
+ function formatDuration(seconds) {
1239
+ const total = Math.max(0, Math.round(seconds));
1240
+ const hours = Math.floor(total / 3600);
1241
+ const minutes = Math.floor((total % 3600) / 60);
1242
+ const rest = total % 60;
1243
+ return `${hours}h ${String(minutes).padStart(2, '0')}m ${String(rest).padStart(2, '0')}s`;
1244
+ }
1245
+
1246
+ function imageDataUri(file) {
1247
+ try {
1248
+ const ext = path.extname(file).toLowerCase();
1249
+ const type = ext === '.png' ? 'image/png' : 'image/jpeg';
1250
+ return `data:${type};base64,${fs.readFileSync(file).toString('base64')}`;
1251
+ } catch { return ''; }
1252
+ }
1253
+
1254
+ function captureScreenshot(dir, preferLong = false) {
1255
+ const names = preferLong
1256
+ ? ['long_screenshot.jpeg', 'long_screenshot.png', 'long_screenshot.jpg', 'screenshot.png', 'screenshot.jpeg', 'screenshot.jpg']
1257
+ : ['screenshot.png', 'screenshot.jpeg', 'screenshot.jpg', 'long_screenshot.jpeg', 'long_screenshot.png', 'long_screenshot.jpg'];
1258
+ return firstExisting(names.map((name) => path.join(dir, name)));
1259
+ }
1260
+
1261
+ function captureFrames(dir, preferLong = false) {
1262
+ const primary = captureScreenshot(dir, preferLong);
1263
+ if (!primary) return [];
1264
+ // A meaningful stitched artifact is already the complete visual evidence.
1265
+ // Otherwise keep every live scroll frame collected by page_capture.mjs so a
1266
+ // long page does not silently collapse to its first viewport in the board.
1267
+ if (/^long_screenshot\./i.test(path.basename(primary))) return [primary];
1268
+ let files = [];
1269
+ try {
1270
+ files = fs.readdirSync(dir, { withFileTypes: true })
1271
+ .filter((item) => item.isFile() && /^screenshot_scroll_\d+\.(?:png|jpe?g)$/i.test(item.name))
1272
+ .map((item) => path.join(dir, item.name))
1273
+ .sort((left, right) => Number(path.basename(left).match(/(\d+)/)?.[1] || 0) - Number(path.basename(right).match(/(\d+)/)?.[1] || 0));
1274
+ } catch { }
1275
+ return [primary, ...files.filter((file) => path.resolve(file) !== path.resolve(primary))];
1276
+ }
1277
+
1278
+ function scrollRegionsFromXml(file, size) {
1279
+ const xml = readText(file);
1280
+ if (!xml || !size?.height) return [];
1281
+ const candidates = [];
1282
+ for (const tag of xml.match(/<node\b[^>]*>/gi) || []) {
1283
+ if (!/\bscrollable=["']true["']/i.test(tag)) continue;
1284
+ // A horizontal RecyclerView (hourly cards, tabs, carousels) is useful UI
1285
+ // evidence but it is not a vertical long-page segment. Keep vertical
1286
+ // ScrollView/ListView regions only, including nested precipitation lists.
1287
+ const nodeClass = tag.match(/\bclass=["']([^"']+)["']/i)?.[1] || '';
1288
+ if (/RecyclerView$/i.test(nodeClass)) continue;
1289
+ const bounds = tag.match(/\bbounds=["']\[(\d+),(\d+)\]\[(\d+),(\d+)\]["']/i);
1290
+ if (!bounds) continue;
1291
+ const [, x1, y1, x2, y2] = bounds.map(Number);
1292
+ const width = x2 - x1;
1293
+ const height = y2 - y1;
1294
+ if (width <= 0 || height <= 0) continue;
1295
+ candidates.push({
1296
+ left: Math.max(0, x1), top: Math.max(0, y1),
1297
+ right: Math.min(size.width, x2), bottom: Math.min(size.height, y2),
1298
+ area: width * height,
1299
+ });
1300
+ }
1301
+ return candidates.sort((left, right) => right.area - left.area);
1302
+ }
1303
+
1304
+ function xmlNodeAttributes(tag) {
1305
+ const attrs = {};
1306
+ for (const match of tag.matchAll(/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) {
1307
+ attrs[match[1]] = match[2] ?? match[3] ?? '';
1308
+ }
1309
+ return attrs;
1310
+ }
1311
+
1312
+ function textAnchorsFromXml(file, region) {
1313
+ const xml = readText(file);
1314
+ if (!xml || !region) return [];
1315
+ const anchors = [];
1316
+ for (const tag of xml.match(/<node\b[^>]*>/gi) || []) {
1317
+ const attrs = xmlNodeAttributes(tag);
1318
+ const text = String(attrs.text || attrs['content-desc'] || '').trim().toLowerCase();
1319
+ const bounds = String(attrs.bounds || '').match(/\[(-?\d+),(-?\d+)\]\[(-?\d+),(-?\d+)\]/);
1320
+ if (!text || !bounds) continue;
1321
+ const [, x1, y1, x2, y2] = bounds.map(Number);
1322
+ const centerY = (y1 + y2) / 2;
1323
+ if (centerY < region.top || centerY > region.bottom) continue;
1324
+ anchors.push({ text, className: String(attrs.class || ''), x1, x2, centerY });
1325
+ }
1326
+ return anchors;
1327
+ }
1328
+
1329
+ function median(values) {
1330
+ const sorted = [...values].sort((left, right) => left - right);
1331
+ if (!sorted.length) return 0;
1332
+ const middle = Math.floor(sorted.length / 2);
1333
+ return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
1334
+ }
1335
+
1336
+ function scrollOffsetFromXml(previousFile, nextFile, previousRegions, nextRegions) {
1337
+ const previousRegion = previousRegions[0];
1338
+ const nextRegion = nextRegions.find((candidate) => (
1339
+ Math.abs(candidate.left - previousRegion?.left) < 12
1340
+ && Math.abs(candidate.top - previousRegion?.top) < 12
1341
+ && Math.abs(candidate.right - previousRegion?.right) < 12
1342
+ && Math.abs(candidate.bottom - previousRegion?.bottom) < 12
1343
+ )) || nextRegions[0];
1344
+ if (!previousRegion || !nextRegion) return 0;
1345
+ const previous = textAnchorsFromXml(previousFile, previousRegion);
1346
+ const next = textAnchorsFromXml(nextFile, nextRegion);
1347
+ const key = (anchor) => `${anchor.className}\u0000${anchor.text}`;
1348
+ const previousGroups = new Map();
1349
+ const nextGroups = new Map();
1350
+ for (const anchor of previous) previousGroups.set(key(anchor), [...(previousGroups.get(key(anchor)) || []), anchor]);
1351
+ for (const anchor of next) nextGroups.set(key(anchor), [...(nextGroups.get(key(anchor)) || []), anchor]);
1352
+ const deltas = [];
1353
+ for (const [anchorKey, rows] of previousGroups) {
1354
+ const candidates = nextGroups.get(anchorKey) || [];
1355
+ // Repeated percentages/labels are ambiguous and can create a one-row
1356
+ // false overlap. Unique visible labels provide a deterministic scroll
1357
+ // displacement even when list rows look almost identical in pixels.
1358
+ if (rows.length !== 1 || candidates.length !== 1) continue;
1359
+ const before = rows[0];
1360
+ const after = candidates[0];
1361
+ if (Math.abs(before.x1 - after.x1) > 48 || Math.abs(before.x2 - after.x2) > 48) continue;
1362
+ const delta = before.centerY - after.centerY;
1363
+ const height = previousRegion.bottom - previousRegion.top;
1364
+ if (delta > 2 && delta < height - 2) deltas.push(delta);
1365
+ }
1366
+ if (!deltas.length) return 0;
1367
+ // Layout rounding can move matching rows by a few pixels. Select the densest
1368
+ // 12px cluster, then take its median instead of trusting one label.
1369
+ let cluster = [];
1370
+ for (const center of deltas) {
1371
+ const nearby = deltas.filter((value) => Math.abs(value - center) <= 12);
1372
+ if (nearby.length > cluster.length) cluster = nearby;
1373
+ }
1374
+ if (cluster.length < 2 && deltas.length > 1) return 0;
1375
+ return Math.round(median(cluster));
1376
+ }
1377
+
1378
+ function captureFrameOffsets(dir, frames) {
1379
+ const rows = frames.map((frame) => {
1380
+ const size = imageSize(frame);
1381
+ const name = path.basename(frame);
1382
+ const scroll = name.match(/^screenshot_scroll_(\d+)\./i)?.[1];
1383
+ const xml = path.join(dir, scroll ? `view_scroll_${scroll}.xml` : 'view.xml');
1384
+ return { xml, regions: scrollRegionsFromXml(xml, size) };
1385
+ });
1386
+ return rows.map((row, index) => index === 0 ? 0 : scrollOffsetFromXml(
1387
+ rows[index - 1].xml,
1388
+ row.xml,
1389
+ rows[index - 1].regions,
1390
+ row.regions,
1391
+ ));
1392
+ }
1393
+
1394
+ function captureFrameClips(dir, frames) {
1395
+ return frames.map((frame) => {
1396
+ const size = imageSize(frame);
1397
+ const name = path.basename(frame);
1398
+ const scroll = name.match(/^screenshot_scroll_(\d+)\./i)?.[1];
1399
+ const xml = path.join(dir, scroll ? `view_scroll_${scroll}.xml` : 'view.xml');
1400
+ return scrollRegionsFromXml(xml, size);
1401
+ });
1402
+ }
1403
+
1404
+ function stitchOverlapDecision(hintedOffset, regionHeight, hasStructuredRegion, pixelOverlap = 0) {
1405
+ const hint = Number(hintedOffset);
1406
+ const height = Number(regionHeight);
1407
+ if (Number.isFinite(hint) && Number.isFinite(height) && hint > 2 && hint < height - 2) {
1408
+ return height - hint;
1409
+ }
1410
+ // Once XML has identified a real scroll container, a missing offset means
1411
+ // that consecutive viewports share no trustworthy text anchor. Repetitive
1412
+ // cards, list rows and progress bars make pixel matching select convincing
1413
+ // but false seams. In that case append the complete new viewport. Pixel
1414
+ // overlap remains a last resort only for captures without view-tree data.
1415
+ return hasStructuredRegion ? 0 : Math.max(0, Number(pixelOverlap) || 0);
1416
+ }
1417
+
1418
+ function nestedStitchBoundary(activeRegions, tolerance = 12) {
1419
+ const area = (region) => Math.max(0, Number(region?.right) - Number(region?.left))
1420
+ * Math.max(0, Number(region?.bottom) - Number(region?.top));
1421
+ for (let index = 1; index < activeRegions.length; index += 1) {
1422
+ const outer = activeRegions[index - 1];
1423
+ const inner = activeRegions[index];
1424
+ if (!outer || !inner) continue;
1425
+ const contained = Number(inner.left) >= Number(outer.left) - tolerance
1426
+ && Number(inner.top) >= Number(outer.top) - tolerance
1427
+ && Number(inner.right) <= Number(outer.right) + tolerance
1428
+ && Number(inner.bottom) <= Number(outer.bottom) + tolerance;
1429
+ // Geometry can differ by a few pixels between dumps. Requiring a
1430
+ // meaningful area reduction prevents an ordinary outer-scroll viewport
1431
+ // from being mistaken for a nested phase.
1432
+ if (contained && area(inner) > 0 && area(inner) < area(outer) * 0.9) {
1433
+ return {
1434
+ regionIndex: index,
1435
+ previousRegionIndex: index - 1,
1436
+ footerTop: Number(inner.bottom),
1437
+ };
1438
+ }
1439
+ }
1440
+ return null;
1441
+ }
1442
+
1443
+ function imageSize(file) {
1444
+ try {
1445
+ const data = fs.readFileSync(file);
1446
+ if (data.length >= 24 && data.toString('ascii', 1, 4) === 'PNG') {
1447
+ return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) };
1448
+ }
1449
+ if (data.length >= 11 && data[0] === 0xff && data[1] === 0xd8) {
1450
+ const sofMarkers = new Set([0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf]);
1451
+ let offset = 2;
1452
+ while (offset + 9 < data.length) {
1453
+ if (data[offset] !== 0xff) { offset += 1; continue; }
1454
+ const marker = data[offset + 1];
1455
+ if (sofMarkers.has(marker)) {
1456
+ const height = data.readUInt16BE(offset + 5);
1457
+ const width = data.readUInt16BE(offset + 7);
1458
+ return width && height ? { width, height } : { width: 0, height: 0 };
1459
+ }
1460
+ if (offset + 4 > data.length) break;
1461
+ const segmentLength = data.readUInt16BE(offset + 2);
1462
+ if (segmentLength < 2) break;
1463
+ offset += 2 + segmentLength;
1464
+ }
1465
+ }
1466
+ } catch { }
1467
+ return { width: 0, height: 0 };
1468
+ }
1469
+
1470
+ function captureMarkers(dir, screenshot) {
1471
+ const meta = readJson(path.join(dir, 'meta.json')) ?? {};
1472
+ const size = imageSize(screenshot);
1473
+ if (!size.width || !size.height) return [];
1474
+ const candidates = (Array.isArray(meta.clickable_elements) ? meta.clickable_elements : [])
1475
+ .filter((item) => Number(item.scroll_index || 0) === 0)
1476
+ .map((item) => {
1477
+ const bounds = String(item.bounds || '').match(/\[(\d+),(\d+)\]\[(\d+),(\d+)\]/);
1478
+ if (!bounds) return null;
1479
+ const [, x1, y1, x2, y2] = bounds.map(Number);
1480
+ return {
1481
+ left: (x1 / size.width) * 100,
1482
+ top: (y1 / size.height) * 100,
1483
+ width: ((x2 - x1) / size.width) * 100,
1484
+ height: ((y2 - y1) / size.height) * 100,
1485
+ boundsKey: `${x1},${y1},${x2},${y2}`,
1486
+ label: item['content-desc'] || item.text || item['resource-id'] || '',
1487
+ };
1488
+ })
1489
+ .filter(Boolean);
1490
+ // Device UI dumps can expose the same visible control more than once (for
1491
+ // example an AutoCompleteTextView/TextInput duplicated with identical
1492
+ // bounds). One on-screen component must produce one hotspot and one legend
1493
+ // row; differently sized parent/child controls remain separate evidence.
1494
+ const unique = [];
1495
+ const byBounds = new Map();
1496
+ for (const candidate of candidates) {
1497
+ const prior = byBounds.get(candidate.boundsKey);
1498
+ if (prior) {
1499
+ if (!prior.label && candidate.label) prior.label = candidate.label;
1500
+ continue;
1501
+ }
1502
+ byBounds.set(candidate.boundsKey, candidate);
1503
+ unique.push(candidate);
1504
+ }
1505
+ return unique.map(({ boundsKey, ...marker }, index) => ({
1506
+ ...marker,
1507
+ number: index + 1,
1508
+ label: marker.label || `Clickable element ${index + 1}`,
1509
+ }));
1510
+ }
1511
+
1512
+ // Crawler-internal working directories (_attempts, _dyn_tmp_*): they also drop screenshots and meta
1513
+ // files, indistinguishable from real pages by content signal — they must be excluded by name; the
1514
+ // underscore prefix is the crawler's internal naming convention, far more stable than page names. Dot-prefixed
1515
+ // directories (.pending_* capture staging, etc.) are excluded for the same reason.
1516
+ const CRAWLER_INTERNAL_DIRS = [/^_attempts$/i, /^_dyn_tmp/i, /^\./];
1517
+ function isCrawlerInternalDir(name) {
1518
+ return CRAWLER_INTERNAL_DIRS.some((pattern) => pattern.test(String(name || '')));
1519
+ }
1520
+
1521
+ const CAPTURE_PAGE_SCREENSHOT = /^(?:screenshot|long_screenshot)\.(?:png|jpe?g)$/i;
1522
+ const CAPTURE_PAGE_META = /^(?:meta\.json|view\.xml|measure_pack\.json)$/i;
1523
+ function isCapturePageDir(dir) {
1524
+ let names = [];
1525
+ try { names = fs.readdirSync(dir); } catch { return false; }
1526
+ return names.some((name) => CAPTURE_PAGE_SCREENSHOT.test(name))
1527
+ && names.some((name) => CAPTURE_PAGE_META.test(name));
1528
+ }
1529
+
1530
+ const CAPTURE_ROOT_PRUNE = new Set(['node_modules', 'oh_modules', '.git', '.idea', '.hvigor', 'build', '.cxx', '.preview', '.clangd']);
1531
+ function discoverCaptureRoots(projectRoot) {
1532
+ const bases = [projectRoot, path.join(projectRoot, '.hometrans'), path.join(projectRoot, '.a2h')]
1533
+ .filter((base, index, all) => all.indexOf(base) === index && exists(base));
1534
+ const found = [];
1535
+ const seen = new Set();
1536
+ const walk = (dir, depth) => {
1537
+ let entries = [];
1538
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
1539
+ const childDirs = entries.filter((item) => item.isDirectory()
1540
+ && !isCrawlerInternalDir(item.name)
1541
+ && !CAPTURE_ROOT_PRUNE.has(item.name.toLowerCase()));
1542
+ if (childDirs.some((item) => isCapturePageDir(path.join(dir, item.name)))) {
1543
+ const key = path.resolve(dir).toLowerCase();
1544
+ if (!seen.has(key)) { seen.add(key); found.push(path.resolve(dir)); }
1545
+ return;
1546
+ }
1547
+ if (depth <= 0) return;
1548
+ for (const item of childDirs) walk(path.join(dir, item.name), depth - 1);
1549
+ };
1550
+ for (const base of bases) walk(base, 3);
1551
+ return found;
1552
+ }
1553
+
1554
+ function findCaptures(entry) {
1555
+ const configuredRoot = entry.ui_capture_dir ? path.resolve(entry.ui_capture_dir) : '';
1556
+ const projectRoot = path.resolve(entry.path);
1557
+ const configuredUiInfoRoot = uiInfoRoot(projectRoot, entry);
1558
+ const legacyRoot = path.join(projectRoot, 'ui_info');
1559
+ // Keep the Node renderer compatible with the authoritative cache written by
1560
+ // the original dashboard capture flow. This also lets static exports reuse
1561
+ // a previously captured HarmonyOS page without reconnecting a device.
1562
+ const dashboardCaptureRoot = path.join(projectRoot, '.hometrans', 'dashboard-ui-capture');
1563
+ const roots = [configuredUiInfoRoot, legacyRoot, dashboardCaptureRoot, configuredRoot, ...discoverCaptureRoots(projectRoot)]
1564
+ .filter((value, index, all) => value && all.indexOf(value) === index && exists(value));
1565
+ const pairs = new Map();
1566
+ let autoSeq = 1000;
1567
+ for (const captureRoot of roots) {
1568
+ let entries = [];
1569
+ try { entries = fs.readdirSync(captureRoot, { withFileTypes: true }); } catch { continue; }
1570
+ // pages.json rank is the seq source for crawler slug dirs (no number in the
1571
+ // name): a2h-batch-ui-align writes it and the HarmonyOS device capture numbers
1572
+ // its pages in the same batch-task order, so both sides land on one seq —
1573
+ // one alignment mechanism, no per-project tables in generic code. Names
1574
+ // missing from pages.json fall to a tail slot.
1575
+ const crawlerPages = readJson(path.join(captureRoot, 'pages.json'));
1576
+ const crawlerRank = new Map((Array.isArray(crawlerPages?.pages) ? crawlerPages.pages : [])
1577
+ .map((row, index) => [path.basename(String(row?.page_dir || '')), index + 1]));
1578
+ // Deterministic iteration order; seq comes from the chain below, not from
1579
+ // directory listing order.
1580
+ entries.sort((a, b) => a.name.localeCompare(b.name));
1581
+ for (const item of entries) {
1582
+ if (!item.isDirectory()) continue;
1583
+ if (isCrawlerInternalDir(item.name)) continue;
1584
+ const dual = item.name.match(/^(android|ios|hmos)_page_(\d+)_(.+)$/i);
1585
+ const legacy = item.name.match(/^page_(\d+)_(.+)$/i);
1586
+ // Naming is an enrichment signal, not a gate: a non-internal child that
1587
+ // carries capture artifacts (screenshot + meta/view evidence) is a page
1588
+ // whatever it is called, so future crawler naming needs no dashboard
1589
+ // change. Known conventions still donate platform/seq below.
1590
+ if (!dual && !legacy && !isCapturePageDir(path.join(captureRoot, item.name))) continue;
1591
+ const platform = dual ? dual[1].toLowerCase() : 'android';
1592
+ // Crawler slug folders take pages.json rank (which pairs with the
1593
+ // HarmonyOS capture numbering), then a tail slot for names it omits.
1594
+ let seq = Number(dual ? dual[2] : legacy?.[1])
1595
+ || crawlerRank.get(item.name) || 0
1596
+ || autoSeq++;
1597
+ // Two ANDROID/source capture dirs must never share one pairing slot: a
1598
+ // slug missing from pages.json (e.g. overlay_windSpeedPrefs) falls to the
1599
+ // tail slot and could still collide with a named slug's rank — bump
1600
+ // instead of overwriting the earlier row's screenshot. hmos dirs joining
1601
+ // an occupied slot are the intended dual-platform pairing, never a collision.
1602
+ while (pairs.has(String(seq))
1603
+ && platform !== 'hmos'
1604
+ && pairs.get(String(seq)).source
1605
+ && pairs.get(String(seq)).dirName !== item.name) seq += 1;
1606
+ const name = dual ? dual[3] : (legacy ? legacy[2] : item.name);
1607
+ const taskId = `page_${String(seq).padStart(4, '0')}_${name}`;
1608
+ // Source/Harmony snapshot directory labels can differ after migration.
1609
+ // The capture sequence is the authoritative pairing key.
1610
+ const key = String(seq);
1611
+ const row = pairs.get(key) ?? { seq, name, taskId, dirName: item.name, sourcePlatform: '', source: '', hmos: '', sourceRoot: '', hmosRoot: '', hmosVariants: [] };
1612
+ if (platform !== 'hmos') {
1613
+ row.name = name;
1614
+ row.taskId = taskId;
1615
+ }
1616
+ const captureDir = path.join(captureRoot, item.name);
1617
+ const screenshot = captureScreenshot(captureDir, platform === 'hmos');
1618
+ const viewportScreenshot = captureScreenshot(captureDir, false);
1619
+ const frames = captureFrames(captureDir, platform === 'hmos');
1620
+ // The capture round records its advisory verdict in meta.json; carry it
1621
+ // along so the board can flag the mismatched card.
1622
+ const captureMeta = readJson(path.join(captureDir, 'meta.json')) || {};
1623
+ const captureValidation = captureMeta.validation && typeof captureMeta.validation === 'object'
1624
+ ? captureMeta.validation
1625
+ : null;
1626
+ if (platform === 'hmos') {
1627
+ if (screenshot) row.hmosVariants.push({
1628
+ name, hmos: screenshot, hmosViewport: viewportScreenshot, hmosRoot: captureRoot, hmosFrames: frames,
1629
+ hmosFrameClips: captureFrameClips(captureDir, frames),
1630
+ hmosFrameOffsets: captureFrameOffsets(captureDir, frames),
1631
+ hmosMarkers: captureMarkers(captureDir, screenshot),
1632
+ validation: captureValidation,
1633
+ });
1634
+ row.hmos = screenshot || row.hmos;
1635
+ if (screenshot) {
1636
+ row.hmosRoot = captureRoot;
1637
+ row.hmosViewport = viewportScreenshot || row.hmosViewport;
1638
+ row.hmosValidation = captureValidation;
1639
+ row.hmosFrames = frames;
1640
+ row.hmosFrameClips = captureFrameClips(captureDir, frames);
1641
+ row.hmosFrameOffsets = captureFrameOffsets(captureDir, frames);
1642
+ row.hmosMarkers = captureMarkers(captureDir, screenshot);
1643
+ }
1644
+ }
1645
+ else {
1646
+ row.source = screenshot || row.source;
1647
+ row.sourcePlatform = platform;
1648
+ if (screenshot) {
1649
+ row.sourceRoot = captureRoot;
1650
+ row.sourceFrames = frames;
1651
+ row.sourceFrameClips = captureFrameClips(captureDir, frames);
1652
+ row.sourceFrameOffsets = captureFrameOffsets(captureDir, frames);
1653
+ row.sourceMarkers = captureMarkers(captureDir, screenshot);
1654
+ }
1655
+ }
1656
+ pairs.set(key, row);
1657
+ }
1658
+ }
1659
+ return [...pairs.values()].sort((a, b) => a.seq - b.seq).map((row) => ({
1660
+ ...row,
1661
+ sourceUri: row.source ? imageDataUri(row.source) : '',
1662
+ hmosUri: row.hmos ? imageDataUri(row.hmos) : '',
1663
+ hmosViewportUri: row.hmosViewport ? imageDataUri(row.hmosViewport) : '',
1664
+ sourceUris: (row.sourceFrames || (row.source ? [row.source] : [])).map(imageDataUri).filter(Boolean),
1665
+ hmosUris: (row.hmosFrames || (row.hmos ? [row.hmos] : [])).map(imageDataUri).filter(Boolean),
1666
+ hmosVariants: (row.hmosVariants || []).map((variant) => ({
1667
+ ...variant,
1668
+ hmosUri: variant.hmos ? imageDataUri(variant.hmos) : '',
1669
+ hmosViewportUri: variant.hmosViewport ? imageDataUri(variant.hmosViewport) : '',
1670
+ hmosUris: (variant.hmosFrames || (variant.hmos ? [variant.hmos] : [])).map(imageDataUri).filter(Boolean),
1671
+ })),
1672
+ }));
1673
+ }
1674
+
1675
+ function uiTasksFromCaptureCache(ui, captures) {
1676
+ if (ui.tasks.length) {
1677
+ if (!ui.inferredFromInventory) return ui;
1678
+ const tasks = ui.tasks.map((task) => {
1679
+ const sequence = Number(String(task.id).match(/^page_(\d+)_/i)?.[1] ?? 0);
1680
+ const capture = captures.find((item) => item.taskId === task.id)
1681
+ ?? captures.find((item) => sequence > 0 && Number(item.seq) === sequence);
1682
+ if (!capture?.hmos || !capture.hmosUri) return task;
1683
+ return {
1684
+ ...task,
1685
+ status: 'done',
1686
+ output: capture.hmos,
1687
+ summary: `HarmonyOS on-device display evidence was found for the UTG source page snapshot: ${capture.name || task.captureName || task.id}.`,
1688
+ captureName: capture.name || task.captureName,
1689
+ };
1690
+ });
1691
+ const done = tasks.filter((task) => task.status === 'done').length;
1692
+ return { ...ui, tasks, taskDone: done, taskTotal: tasks.length, done, total: tasks.length };
1693
+ }
1694
+ const hmosCaptures = captures.filter((capture) => capture.hmos && capture.hmosUri);
1695
+ if (!hmosCaptures.length) return ui;
1696
+ return {
1697
+ ...ui,
1698
+ captureOnly: true,
1699
+ captureSource: hmosCaptures[0].hmosRoot || path.dirname(hmosCaptures[0].hmos),
1700
+ tasks: hmosCaptures.map((capture) => ({
1701
+ id: capture.taskId,
1702
+ status: 'not_started',
1703
+ output: capture.hmos,
1704
+ summary: `Read the ${/^long_screenshot/i.test(path.basename(capture.hmos)) ? 'long screenshot' : 'screenshot'} of ${capture.name} from the HarmonyOS capture cache.`,
1705
+ captureOnly: true,
1706
+ captureName: capture.name,
1707
+ })),
1708
+ };
1709
+ }
1710
+
1711
+ function taskFriendlyTitle(task) {
1712
+ if (task.captureOnly) return task.captureName || task.id;
1713
+ // Take the first clause, then strip only a trailing migration/completion
1714
+ // suffix ("· migrated", "completed", "complete" at the very end). The previous
1715
+ // `/(?:already )?complete.*$/u` deleted from the *first* occurrence of "complete" onward,
1716
+ // which truncated legitimate titles like "loading-complete state baseline · migrated" to
1717
+ // "loading" mid-sentence.
1718
+ const first = String(task.summary || '')
1719
+ .split(/[;;]/)[0]
1720
+ .replace(/\s*[·•・]\s*migrated\s*$/, '')
1721
+ .replace(/(?:^|[^a-z])completed$/, (m) => m.endsWith('completed') ? m.slice(0, -9) : m)
1722
+ .replace(/\bcomplete$/, '')
1723
+ .trim();
1724
+ return first || task.id;
1725
+ }
1726
+
1727
+ function shortPageName(task) {
1728
+ // The page NAME is the id's X: page_0001_MainActivity -> "MainActivity",
1729
+ // activity_MainActivity -> "MainActivity", dyn_002 -> "002",
1730
+ // pref-dialog_languagePrefs -> "languagePrefs". The summary is page content
1731
+ // notes, not a name — it stays on the slide and in the hover tooltip.
1732
+ const id = String(task.captureOnly ? (task.captureName || task.id) : task.id);
1733
+ const stripped = id
1734
+ .replace(/^page_[0-9]+_/, '')
1735
+ .replace(/^activity_/, '')
1736
+ .replace(/^dyn_/, '')
1737
+ .replace(/^pref-dialog_/, '')
1738
+ .replace(/^pref_/, '');
1739
+ return stripped || id;
1740
+ }
1741
+ function evidenceExcerpt(file, limit = 5000) {
1742
+ const text = readText(file);
1743
+ if (!text) return '';
1744
+ return text.slice(0, limit).trim();
1745
+ }
1746
+
1747
+ function cleanMarkdown(value) {
1748
+ return String(value ?? '')
1749
+ .replace(/`([^`]+)`/g, '$1')
1750
+ .replace(/\*\*([^*]+)\*\*/g, '$1')
1751
+ .replace(/^\s*\*\*\s*/, '')
1752
+ .replace(/\s*\*\*\s*$/, '')
1753
+ .replace(/^\s*[-*]\s+/gm, '')
1754
+ .trim();
1755
+ }
1756
+
1757
+ function markdownField(text, names) {
1758
+ for (const name of names) {
1759
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1760
+ const match = text.match(new RegExp(`^\\s*[-*]?\\s*(?:\\*\\*)?${escaped}(?:\\*\\*)?\\s*[::]\\s*(.+)$`, 'mi'));
1761
+ if (match) return cleanMarkdown(match[1]);
1762
+ }
1763
+ return '';
1764
+ }
1765
+
1766
+ function reportBullet(text, names) {
1767
+ const wanted = new Set(names.map((name) => name.trim().toLowerCase()));
1768
+ for (const line of String(text ?? '').split(/\r?\n/)) {
1769
+ const match = line.match(/^\s*-\s*(.+?)\s*[::]\s*(.*?)\s*$/);
1770
+ if (!match) continue;
1771
+ const key = match[1].replaceAll('**', '').trim().replace(/^`|`$/g, '').trim().toLowerCase();
1772
+ if (!wanted.has(key)) continue;
1773
+ let value = match[2].trim();
1774
+ if (value.startsWith('** ')) value = value.slice(3).trim();
1775
+ else if (value === '**') value = '';
1776
+ if (value.startsWith('**') && value.endsWith('**') && value.length >= 4) value = value.slice(2, -2).trim();
1777
+ return cleanMarkdown(value);
1778
+ }
1779
+ return '';
1780
+ }
1781
+
1782
+
1783
+ function markdownSection(text, names) {
1784
+ const lines = String(text ?? '').split(/\r?\n/);
1785
+ for (const name of names) {
1786
+ const target = cleanMarkdown(name).toLowerCase();
1787
+ const start = lines.findIndex((line) => {
1788
+ const match = line.match(/^#{1,6}\s+(.+?)\s*$/);
1789
+ return match && cleanMarkdown(match[1]).toLowerCase() === target;
1790
+ });
1791
+ if (start < 0) continue;
1792
+ const section = [];
1793
+ for (let index = start + 1; index < lines.length; index += 1) {
1794
+ if (/^#{1,6}\s+/.test(lines[index])) break;
1795
+ section.push(lines[index]);
1796
+ }
1797
+ return section.join('\n').trim();
1798
+ }
1799
+ return '';
1800
+ }
1801
+
1802
+
1803
+ function evidencePath(logic, file) {
1804
+ if (!file) return '';
1805
+ const projectRoot = logic.projectRoot ?? path.dirname(path.dirname(logic.dir));
1806
+ return path.relative(projectRoot, file).replaceAll('\\', '/');
1807
+ }
1808
+
1809
+ function parseBuildEvidence(logic) {
1810
+ const report = path.join(logic.dir, 'build-fix-report.md');
1811
+ const text = readText(report) ?? '';
1812
+ if (!text) return null;
1813
+ const bullet = (...names) => reportBullet(text, names);
1814
+ const outputHap = bullet('Output HAP', 'Output HAP');
1815
+ const archivedHap = bullet('Archived HAP', 'Archived HAP');
1816
+ const artifacts = [...text.matchAll(/^\s*-\s*`([^`]+\.hap)`\s*$/gmi)].map((match) => match[1]);
1817
+ for (const item of [outputHap, archivedHap]) if (item && !artifacts.includes(item)) artifacts.push(item);
1818
+ const remaining = markdownSection(text, ['Remaining errors', 'Remaining errors']);
1819
+ return {
1820
+ buildTime: bullet('Build time', 'Start'),
1821
+ endTime: bullet('Build end time', 'End'),
1822
+ mode: bullet('Build type', 'Build Type'),
1823
+ command: bullet('Build command', 'Build Command'),
1824
+ duration: bullet('Total duration', 'Measured Duration'),
1825
+ hvigorDuration: bullet('Hvigor duration', 'Hvigor Duration'),
1826
+ compile: bullet('ArkTS Compilation') || (/`?CompileArkTS`?[\s\S]{0,80}`?UP-TO-DATE`?/i.test(text) ? 'Passed (report explicitly records UP-TO-DATE)' : ''),
1827
+ package: bullet('HAP Packaging') || (/`?PackageHap`?[\s\S]{0,80}`?UP-TO-DATE`?/i.test(text) ? 'Passed (report explicitly records UP-TO-DATE)' : ''),
1828
+ sign: bullet('HAP signing', 'Signing'),
1829
+ errors: bullet('Compile errors') || (/^\s*None[.\s]*$/mi.test(remaining) ? '0' : ''),
1830
+ errorsFixed: bullet('Errors fixed this round', 'Total Errors Fixed'),
1831
+ warnings: bullet('Compile warnings', 'Total Warnings', 'Warnings'),
1832
+ sha256: bullet('SHA-256'),
1833
+ artifacts,
1834
+ reportPath: evidencePath(logic, report),
1835
+ };
1836
+ }
1837
+
1838
+ function reviewRoundReports(logic) {
1839
+ let entries = [];
1840
+ try { entries = fs.readdirSync(logic.dir, { withFileTypes: true }); } catch { return []; }
1841
+ return entries
1842
+ .filter((entry) => entry.isDirectory() && /^review-round-\d+$/i.test(entry.name))
1843
+ .map((entry) => ({
1844
+ round: Number(entry.name.match(/(\d+)$/)?.[1] ?? 0),
1845
+ file: path.join(logic.dir, entry.name, 'code-review-report.md'),
1846
+ }))
1847
+ .filter((entry) => exists(entry.file))
1848
+ .sort((a, b) => a.round - b.round);
1849
+ }
1850
+
1851
+ function markdownSectionWithSubheadings(text, names, headingLevel = 2) {
1852
+ const lines = String(text ?? '').split(/\r?\n/);
1853
+ const wanted = new Set(names.map((name) => cleanMarkdown(name).toLowerCase()));
1854
+ const headingPattern = new RegExp(`^#{${headingLevel}}\\s+(.+?)\\s*$`);
1855
+ const start = lines.findIndex((line) => {
1856
+ const match = line.match(headingPattern);
1857
+ return match && wanted.has(cleanMarkdown(match[1]).toLowerCase());
1858
+ });
1859
+ if (start < 0) return '';
1860
+ const section = [];
1861
+ for (let index = start + 1; index < lines.length; index += 1) {
1862
+ const heading = lines[index].match(/^(#{1,6})\s+/);
1863
+ if (heading && heading[1].length <= headingLevel) break;
1864
+ section.push(lines[index]);
1865
+ }
1866
+ return section.join('\n').trim();
1867
+ }
1868
+
1869
+ function parseMarkdownTable(section) {
1870
+ const lines = String(section ?? '').split(/\r?\n/);
1871
+ for (let index = 0; index + 1 < lines.length; index += 1) {
1872
+ if (!lines[index].trim().startsWith('|') || !lines[index + 1].trim().startsWith('|')) continue;
1873
+ const separator = lines[index + 1].split('|').slice(1, -1).map((cell) => cell.trim());
1874
+ if (!separator.length || !separator.every((cell) => /^:?-{3,}:?$/.test(cell))) continue;
1875
+ const headers = lines[index].split('|').slice(1, -1).map((cell) => cleanMarkdown(cell).trim());
1876
+ const rows = [];
1877
+ for (let rowIndex = index + 2; rowIndex < lines.length; rowIndex += 1) {
1878
+ if (!lines[rowIndex].trim().startsWith('|')) break;
1879
+ const cells = lines[rowIndex].split('|').slice(1, -1).map((cell) => cleanMarkdown(cell).trim());
1880
+ if (!cells.length || cells.every((cell) => !cell)) continue;
1881
+ const row = {};
1882
+ headers.forEach((header, headerIndex) => { row[header] = cells[headerIndex] ?? ''; });
1883
+ rows.push(row);
1884
+ }
1885
+ return rows;
1886
+ }
1887
+ return [];
1888
+ }
1889
+
1890
+ function reviewScenarioTitleKey(value) {
1891
+ return cleanMarkdown(value)
1892
+ .replace(/^\s*\d+\s*[.、:]\s*/, '')
1893
+ .replace(/^\s*Scenario\s*[0-9]+\s*[:,.]\s*/, '')
1894
+ .replace(/^\s*Scenario\s*\d+\s*[:.]\s*/, '')
1895
+ .replace(/[\s`*_,。、“”'"()()::·-]+/g, '')
1896
+ .toLowerCase();
1897
+ }
1898
+
1899
+ function parseReviewDetailBody(body) {
1900
+ const fields = [];
1901
+ const blocks = [];
1902
+ let current = null;
1903
+ for (const rawLine of String(body ?? '').split(/\r?\n/)) {
1904
+ const line = rawLine.trim();
1905
+ if (!line || /^---+$/.test(line)) continue;
1906
+ const bold = line.match(/^\*\*(.+?)\*\*(?:\s*[::]\s*(.*))?$/);
1907
+ if (bold) {
1908
+ let label = cleanMarkdown(bold[1]);
1909
+ let value = cleanMarkdown(bold[2] ?? '');
1910
+ if (!value) {
1911
+ const inside = label.match(/^(.+?)\s*[::]\s*(.+)$/);
1912
+ if (inside) {
1913
+ label = cleanMarkdown(inside[1]);
1914
+ value = cleanMarkdown(inside[2]);
1915
+ }
1916
+ }
1917
+ if (value) {
1918
+ fields.push({ label, value });
1919
+ current = null;
1920
+ } else {
1921
+ current = { title: label, lines: [] };
1922
+ blocks.push(current);
1923
+ }
1924
+ continue;
1925
+ }
1926
+ const value = cleanMarkdown(line.replace(/^[-*]\s+/, ''));
1927
+ if (!value) continue;
1928
+ if (!current) {
1929
+ current = { title: 'Review notes', lines: [] };
1930
+ blocks.push(current);
1931
+ }
1932
+ current.lines.push(value);
1933
+ }
1934
+ return { fields, blocks: blocks.filter((block) => block.lines.length) };
1935
+ }
1936
+
1937
+ function parseReviewDetailSections(text) {
1938
+ const section = markdownSectionWithSubheadings(text, ['Detailed Review', 'Detailed Scenario Reviews', 'Detailed Review', 'Detailed Scenario Reviews']);
1939
+ if (!section) return [];
1940
+ const lines = section.split(/\r?\n/);
1941
+ const details = [];
1942
+ let current = null;
1943
+ for (const line of lines) {
1944
+ const heading = line.match(/^###\s+(.+?)\s*$/);
1945
+ if (heading) {
1946
+ current = { title: cleanMarkdown(heading[1]), body: [] };
1947
+ details.push(current);
1948
+ } else if (current) {
1949
+ current.body.push(line);
1950
+ }
1951
+ }
1952
+ return details.map((detail, index) => ({
1953
+ index,
1954
+ title: detail.title,
1955
+ key: reviewScenarioTitleKey(detail.title),
1956
+ ...parseReviewDetailBody(detail.body.join('\n')),
1957
+ }));
1958
+ }
1959
+
1960
+ function parseReviewScenarios(text) {
1961
+ const summary = markdownSectionWithSubheadings(text, ['Scenario Coverage Summary', 'Scenario Coverage Summary', 'Scenario Review Summary']);
1962
+ const tableRows = parseMarkdownTable(summary);
1963
+ const details = parseReviewDetailSections(text);
1964
+ const valueFor = (row, names) => {
1965
+ for (const name of names) {
1966
+ const key = Object.keys(row).find((header) => cleanMarkdown(header).toLowerCase() === name.toLowerCase());
1967
+ if (key && row[key]) return row[key];
1968
+ }
1969
+ return '';
1970
+ };
1971
+ return tableRows.map((row, index) => {
1972
+ const name = valueFor(row, ['Scenario', 'Scenario', 'Scenario Name']);
1973
+ const result = valueFor(row, ['Result', 'Verdict', 'Verdict', 'Result']);
1974
+ const conclusion = valueFor(row, ['Conclusion', 'Review conclusion']);
1975
+ const gap = valueFor(row, ['Key gaps', 'Key Gaps', 'Gap']);
1976
+ const fixStatus = valueFor(row, ['Fix status', 'Fix Status']);
1977
+ const key = reviewScenarioTitleKey(name);
1978
+ const detail = details.find((item) => item.key && item.key === key) ?? details[index] ?? null;
1979
+ return {
1980
+ number: valueFor(row, ['#', 'Number', 'No.']) || String(index + 1),
1981
+ name: name || detail?.title || `Scenario ${index + 1}`,
1982
+ result,
1983
+ conclusion,
1984
+ gap,
1985
+ fixStatus,
1986
+ detail,
1987
+ };
1988
+ });
1989
+ }
1990
+
1991
+ function reviewMetric(text, label) {
1992
+ const direct = reportBullet(text, [label]);
1993
+ if (direct && /^\d+$/.test(direct.trim())) return direct.trim();
1994
+ const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1995
+ return text.match(new RegExp(`(?:^|[|;;,,\\s])(\\d+)\\s+${escaped}(?=$|[|;;,,\\s])`, 'i'))?.[1]
1996
+ ?? text.match(new RegExp(`${escaped}\\s*[::|]\\s*(\\d+)`, 'i'))?.[1]
1997
+ ?? direct;
1998
+ }
1999
+
2000
+ function parseReviewEvidence(logic) {
2001
+ const finalReport = path.join(logic.dir, 'code-review-report.md');
2002
+ const fixReport = path.join(logic.dir, 'review-fix-report.md');
2003
+ const finalText = readText(finalReport) ?? '';
2004
+ const fixText = readText(fixReport) ?? '';
2005
+ const roundReports = reviewRoundReports(logic);
2006
+ const rounds = roundReports.map(({ round, file }) => {
2007
+ const text = readText(file) ?? '';
2008
+ const scenarios = parseReviewScenarios(text);
2009
+ return {
2010
+ round,
2011
+ verdict: reportBullet(text, ['Overall Verdict', 'Verdict', 'Final Re-review', 'Overall result', 'Overall Verdict']),
2012
+ reviewed: reportBullet(text, ['Reviewed scenarios', 'Total Scenarios', 'Reviewed scenarios']) || String(scenarios.length || ''),
2013
+ pass: reviewMetric(text, 'PASS'),
2014
+ partial: reviewMetric(text, 'PARTIAL'),
2015
+ fail: reviewMetric(text, 'FAIL'),
2016
+ unable: reviewMetric(text, 'UNABLE TO VERIFY'),
2017
+ confirmed: reportBullet(text, ['Confirmed defects', 'Confirmed issues']),
2018
+ reportPath: evidencePath(logic, file),
2019
+ scenarios,
2020
+ };
2021
+ });
2022
+ if (!finalText && !fixText && !rounds.length) return null;
2023
+ const scenarioResult = finalText.match(/^\s*-\s*(\d+\s*\/\s*\d+\s*scenarios[^\r\n]*)$/mi)?.[1]?.trim() ?? '';
2024
+ const findings = roundReports.flatMap(({ file }) => [...(readText(file) ?? '').matchAll(/^###\s+(CR-[^\r\n]+)$/gmi)].map((match) => match[1].trim()));
2025
+ const latestRound = rounds.at(-1);
2026
+ return {
2027
+ finalRound: reportBullet(finalText, ['Final Round']) || String(latestRound?.round ?? ''),
2028
+ verdict: reportBullet(finalText, ['Overall Verdict', 'Verdict', 'Final Re-review', 'Overall result', 'Overall Verdict']) || latestRound?.verdict || '',
2029
+ scenarioResult,
2030
+ stopReason: reportBullet(finalText, ['Stop reason', 'Stop reason']),
2031
+ confirmed: reportBullet(fixText, ['Confirmed issues', 'Confirmed defects']),
2032
+ fixed: reportBullet(fixText, ['Successfully fixed']),
2033
+ failed: reportBullet(fixText, ['Fix failed']),
2034
+ rounds,
2035
+ findings,
2036
+ reportPath: finalText ? evidencePath(logic, finalReport) : '',
2037
+ fixReportPath: fixText ? evidencePath(logic, fixReport) : '',
2038
+ };
2039
+ }
2040
+
2041
+ function projectModel(entry, specNames, captureState = null, config = entry.dashboard_config ?? {}) {
2042
+ const root = path.resolve(entry.path);
2043
+ const configuredSpecPipeline = Boolean(
2044
+ config.specs_json || config.spec_design_dir || config.spec_pipeline_state
2045
+ || exists(path.join(root, '.hometrans', 'spec_design'))
2046
+ || exists(path.join(root, '.hometrans', 'spec_pipeline_state.json')),
2047
+ );
2048
+ const spec = configuredSpecPipeline ? specPipelineModel(root, specNames, config) : findSpecs(root, specNames, config);
2049
+ const captures = findCaptures(entry);
2050
+ const ui = uiTasksFromCaptureCache(findUiProgress(root, entry, config), captures);
2051
+ const logic = spec.specs.map((item, index) => logicForSpec(root, item, index, config));
2052
+ // Overview/ledger consistency: the logic tab treats loose 3.x evidence
2053
+ // (commit-info / build-fix / review reports under .hometrans/spec_N) as
2054
+ // proof of stage completion, but without spec_pipeline_state.json the
2055
+ // overview Stage B row stays 0/N — two views of one dashboard then
2056
+ // disagree. Whenever the model is non-authoritative and no state record
2057
+ // marks B done, derive Stage B from the same 3.x evidence the logic tab
2058
+ // tracks.
2059
+ if (spec.authoritative !== true) {
2060
+ spec.specs.forEach((specRow, index) => {
2061
+ const b = (specRow.pipelineStages || []).find((item) => item.id === 'B');
2062
+ if (!b || ['done', 'skipped'].includes(b.status)) return;
2063
+ const logicRow = logic[index];
2064
+ if (!logicRow) return;
2065
+ const stages = logicRow.stages || [];
2066
+ if (stages.length && stages.every((stage) => ['done', 'skipped'].includes(stage.status))) {
2067
+ b.status = 'done';
2068
+ b.inferred = true;
2069
+ }
2070
+ });
2071
+ }
2072
+ return {
2073
+ name: entry.name || path.basename(root),
2074
+ root,
2075
+ androidRoot: entry.android_project_dir || '',
2076
+ ui,
2077
+ spec,
2078
+ logic,
2079
+ captures,
2080
+ uiCaptureMap: entry.ui_capture_map ?? {},
2081
+ uiPageBindings: entry.ui_page_bindings ?? {},
2082
+ uiHmosContentMap: entry.ui_hmos_content_map ?? {},
2083
+ captureState,
2084
+ };
2085
+ }
2086
+
2087
+
2088
+
2089
+ // OpenCode / DevEco Code (an isomorphic distribution of opencode) both keep sessions in local SQLite
2090
+ // (~/.local/share/<product>/xxx.db) where the session table carries aggregated token columns — reading
2091
+ // the DB directly covers more than the CLI (session list filters by cwd, export is per-session): history is only findable in the DB.
2092
+
2093
+
2094
+
2095
+ const ARCHITECTURE_BOARDS = [
2096
+ { id: 'project_design', title: 'HarmonyOS \u76ee\u6807\u67b6\u6784\u8bbe\u8ba1' },
2097
+ { id: 'database_design', title: '\u6570\u636e\u5e93\u8bbe\u8ba1' },
2098
+ { id: 'preferences_design', title: 'Preferences \u8bbe\u8ba1' },
2099
+ ]
2100
+
2101
+ function architectureModel(config = {}) {
2102
+ // Single path: artifact detection for the current tool (spec-driven pipeline) — stage status = whether the design document file exists.
2103
+ const root = (Array.isArray(config.entries) && config.entries[0] && config.entries[0].path)
2104
+ || config.root
2105
+ || (config.architectureOutputDir ? path.resolve(config.architectureOutputDir, '..') : '');
2106
+ // Artifact contract: the producers' declared locations are tried before
2107
+ // any built-in convention, so a tool that moves its outputs stays
2108
+ // recognized by editing the contract file — not this code.
2109
+ const ctx = { root: root || '', android: (Array.isArray(config.entries) && config.entries[0] && config.entries[0].android_project_dir) || '' };
2110
+ const designHit = resolveArtifact('project_design', ctx);
2111
+ const designFound = designHit.found;
2112
+ const pipelineStateFile = resolveArtifact('spec_pipeline_state', ctx).found;
2113
+ const pipelineState = pipelineStateFile && exists(pipelineStateFile) ? readJson(pipelineStateFile) : null;
2114
+ // Without a database / KV store, database/preferences are canonical empty-state documents and still count as generated
2115
+ const databaseDesignFile = resolveArtifact('database_design', ctx).found;
2116
+ const preferencesDesignFile = resolveArtifact('preferences_design', ctx).found;
2117
+ const databaseDesignFound = databaseDesignFile && exists(databaseDesignFile) ? databaseDesignFile : '';
2118
+ const preferencesDesignFound = preferencesDesignFile && exists(preferencesDesignFile) ? preferencesDesignFile : '';
2119
+ if (designFound || pipelineState) {
2120
+ // Declaration following: when the (Android) scope.json carries formal_documents (paths of the three design docs),
2121
+ // read what the producer declared instead of guessing again
2122
+ const scopeHit = resolveArtifact('scope', ctx);
2123
+ const androidScopeFile = scopeHit.found;
2124
+ const androidScope = androidScopeFile ? readJson(androidScopeFile) : null;
2125
+ const formal = androidScope?.formal_documents && typeof androidScope.formal_documents === 'object' ? androidScope.formal_documents : {};
2126
+ const formalPick = (value) => (value && exists(value) ? value : '');
2127
+ const designFinal = formalPick(formal.project_design) || designFound;
2128
+ const databaseFinal = formalPick(formal.database_design) || databaseDesignFound;
2129
+ const preferencesFinal = formalPick(formal.preferences_design) || preferencesDesignFound;
2130
+ const stages = ARCHITECTURE_BOARDS.map((def) => {
2131
+ let status = 'not_started';
2132
+ if (def.id === 'project_design') status = designFinal ? 'done' : 'not_started';
2133
+ else if (def.id === 'database_design') status = databaseFinal ? 'done' : 'not_started';
2134
+ else if (def.id === 'preferences_design') status = preferencesFinal ? 'done' : 'not_started';
2135
+ const evidence = def.id === 'project_design'
2136
+ ? [designFinal].filter(Boolean)
2137
+ : def.id === 'database_design' ? [databaseFinal].filter(Boolean)
2138
+ : def.id === 'preferences_design' ? [preferencesFinal].filter(Boolean)
2139
+ : [];
2140
+ return { ...def, status, evidence };
2141
+ });
2142
+ const completed = stages.filter((s) => s.status === 'done').length;
2143
+ const overallStatus = completed === stages.length ? 'done' : completed > 0 ? 'in_progress' : 'not_started';
2144
+ const formalDocuments = {
2145
+ projectDesign: designFinal,
2146
+ databaseDesign: databaseFinal,
2147
+ preferencesDesign: preferencesFinal,
2148
+ };
2149
+ return {
2150
+ configured: true,
2151
+ source: 'new-pipeline',
2152
+ stages, completed, total: stages.length,
2153
+ overallStatus,
2154
+ conversionMode: pipelineState?.config?.engine ? String(pipelineState.config.engine) : '',
2155
+ formalDocuments,
2156
+ };
2157
+ }
2158
+ return { configured: false, stages: ARCHITECTURE_BOARDS, completed: 0, total: 0, overallStatus: 'not_started', conversionMode: '', formalDocuments: {} };
2159
+ }
2160
+
2161
+ function tabHero(icon, title, subHtml, ringHtml, tint) {
2162
+ const sub = subHtml ? '<p class="tab-hero-sub">' + subHtml + '</p>' : '';
2163
+ return '<div class="tab-hero' + (tint ? ' tint-' + tint : '') + '"><div class="tab-hero-main"><div class="tab-hero-title"><span class="tab-hero-icon">' + icon
2164
+ + '</span><h2>' + escapeHtml(title) + '</h2></div>' + sub + '</div>' + (ringHtml || '') + '</div>';
2165
+ }
2166
+ function renderArchitectureEvidence(evidence) {
2167
+ if (!evidence || !evidence.length) return '<div class="arch-evidence-empty">' + tr('No artifact files generated for this stage yet') + '</div>';
2168
+ return '<div class="arch-evidence">' + evidence.map((file) => '<div class="arch-evidence-file">' + escapeHtml(path.basename(file)) + '<small>' + escapeHtml(file) + '</small></div>').join('') + '</div>';
2169
+ }
2170
+
2171
+ function renderArchitecture(architecture, projects = []) {
2172
+ const arch = architecture || architectureModel();
2173
+ if (!arch.configured) {
2174
+ return '<section class="tab" id="architecture">' + tabHero(ICONS.architecture, tr('Architecture'), tr('No architecture design artifacts found (project_design.md / spec_pipeline_state.json). Run a2h-arch-generate or a2h-spec-design-pipeline first to generate the architecture design documents.'), ring(0, 0, '0/0'), '') + '</section>';
2175
+ }
2176
+ // Stage cards list only the evidence files; content quality lives in the
2177
+ // arch producers' own validation reports, not in board-side line counts.
2178
+ const stageCards = arch.stages.map((stage, index) => '<details class="card arch-stage-card ' + escapeHtml(stage.status) + '" ' + '' + '><summary><span class="arch-stage-index">' + (index + 1) + '</span><span><strong>' + escapeHtml(tr(stage.title)) + '</strong></span>' + badge(stage.status) + '</summary><div class="arch-stage-body">' + renderArchitectureEvidence(stage.evidence) + '</div></details>').join('');
2179
+ return '<section class="tab" id="architecture">' + tabHero(ICONS.architecture, tr('Architecture'), '', ring(arch.completed, arch.total, arch.completed + '/' + arch.total), '') + '<h2 class="arch-subtitle">' + tr('Generation flow') + '</h2><div class="arch-stage-grid">' + stageCards + '</div></section>';
2180
+ }
2181
+ function logicStageScore(projects) {
2182
+ const specs = projects.flatMap((project) => project.spec.specs);
2183
+ if (!specs.length) return { stages: [], ratio: 0, done: 0, total: 0, strictDone: 0, specTotal: 0, started: 0 };
2184
+ const specTotal = specs.length;
2185
+ const stageDoneCount = (id) => specs.filter((spec) => {
2186
+ const stage = (spec.pipelineStages || []).find((item) => item.id === id);
2187
+ return stage && (stage.status === 'done' || stage.status === 'skipped');
2188
+ }).length;
2189
+ // B's done count shares the logic tab's evidence caliber: the spec counts as done only when 3.1/3.2/3.3 all have
2190
+ // evidence — the state file's B is the pipeline's self-report and can drift from evidence (overview and
2191
+ // detail pages must share one basis).
2192
+ const bDone = projects.reduce((sum, project) => sum + (project.logic || [])
2193
+ .filter((logic) => (logic.stages || []).length > 0
2194
+ && logic.stages.every((stage) => ['done', 'skipped'].includes(stage.status))).length, 0);
2195
+ const aDone = stageDoneCount('A');
2196
+ const aRatio = specTotal ? aDone / specTotal : 0;
2197
+ const stages = [
2198
+ { id: 'A', done: aDone, total: specTotal, ratio: aRatio },
2199
+ { id: 'B', done: bDone, total: specTotal, ratio: specTotal ? bDone / specTotal : 0 },
2200
+ { id: 'B2', done: stageDoneCount('B2'), total: specTotal, ratio: specTotal ? stageDoneCount('B2') / specTotal : 0 },
2201
+ { id: 'C', done: stageDoneCount('C'), total: specTotal, ratio: specTotal ? stageDoneCount('C') / specTotal : 0 },
2202
+ ];
2203
+ // Strict spec count: a spec counts as logic-converted only when ALL FOUR stages
2204
+ // (A / B / B2 / C) are done — B by its 3.1/3.2/3.3 evidence, the others by state.
2205
+ let strictDone = 0;
2206
+ let started = 0;
2207
+ for (const project of projects) {
2208
+ for (const spec of project.spec.specs) {
2209
+ const stageDone = (id) => {
2210
+ const stage = (spec.pipelineStages || []).find((item) => item.id === id);
2211
+ return Boolean(stage && ['done', 'skipped'].includes(stage.status));
2212
+ };
2213
+ const row = (project.logic || []).find((item) => item.id === spec.id);
2214
+ const bEvidenceDone = Boolean(row && (row.stages || []).length > 0
2215
+ && row.stages.every((stage) => ['done', 'skipped'].includes(stage.status)));
2216
+ if (stageDone('A') && bEvidenceDone && stageDone('B2') && stageDone('C')) strictDone++;
2217
+ // progress caliber: any recognized stage activity (or a 3.x evidence row) means
2218
+ // the spec's logic conversion has begun — the step-status badge must not read a
2219
+ // campaign fully inside stage B as "not started"
2220
+ const anyStageActive = (spec.pipelineStages || []).some((item) => item && ['done', 'skipped', 'in_progress', 'blocked'].includes(item.status));
2221
+ if (anyStageActive || (row && (row.stages || []).length > 0)) started++;
2222
+ }
2223
+ }
2224
+ const ratio = specTotal ? strictDone / specTotal : 0;
2225
+ return { stages, ratio, done: strictDone, total: specTotal, strictDone, specTotal, started };
2226
+ }
2227
+ function overview(projects, architecture = null) {
2228
+ const archCompleted = architecture && architecture.configured ? architecture.completed : 0;
2229
+ const archTotal = architecture && architecture.configured ? architecture.total : 0;
2230
+ const archRatio = archTotal ? Math.min(1, archCompleted / archTotal) : 0;
2231
+
2232
+ const uiDoneCount = projects.reduce((sum, project) => sum + Number(project.ui.done || 0), 0);
2233
+ const uiTotalCount = projects.reduce((sum, project) => sum + Number(project.ui.total || 0), 0);
2234
+ const specDoneCount = projects.reduce((sum, project) => sum + Number(project.spec.done || 0), 0);
2235
+ const specTotalCount = projects.reduce((sum, project) => sum + Number(project.spec.total || 0), 0);
2236
+ const uiRatio = uiTotalCount ? Math.min(1, uiDoneCount / uiTotalCount) : 0;
2237
+ const specRatio = specTotalCount ? Math.min(1, specDoneCount / specTotalCount) : 0;
2238
+ const logic = logicStageScore(projects);
2239
+ // Single caliber: every overview progress number comes straight from disk evidence (the same
2240
+ // spec.complete / ui.done as the progress boxes and detail tabs) — no stage-gate zeroing. Step ordering is
2241
+ // expressed only through card order and status badges; the weighted total stays additive with the step cards.
2242
+ const percentage = Math.round(archRatio * 10 + uiRatio * 20 + specRatio * 10 + logic.ratio * 60);
2243
+ return {
2244
+ arch: { done: archCompleted, total: archTotal, ratio: archRatio, score: archRatio * 10 },
2245
+ uiDone: uiTotalCount > 0 && uiDoneCount >= uiTotalCount,
2246
+ specDone: specTotalCount > 0 && specDoneCount >= specTotalCount,
2247
+ ui: {
2248
+ done: uiDoneCount,
2249
+ total: uiTotalCount,
2250
+ ratio: uiRatio,
2251
+ score: uiRatio * 20,
2252
+ },
2253
+ spec: {
2254
+ done: specDoneCount,
2255
+ total: specTotalCount,
2256
+ ratio: specRatio,
2257
+ score: specRatio * 10,
2258
+ },
2259
+ logic,
2260
+ percentage,
2261
+ };
2262
+ }
2263
+
2264
+ function badge(status, text = statusLabel(status), title = '') {
2265
+ return `<span class="badge ${escapeHtml(status)}"${title ? ` title="${escapeHtml(title)}"` : ''}>${escapeHtml(text)}</span>`;
2266
+ }
2267
+
2268
+ function ring(done, total, label) {
2269
+ const ratio = total ? Math.max(0, Math.min(1, done / total)) : 0;
2270
+ // Long labels (3-4 digit counts) auto-shrink the label font and grow the ring so
2271
+ // the number never overflows the inner circle (hole ≈ ring diameter - 2×inset).
2272
+ const fit = Math.min(18, Math.floor((label.length >= 7 ? 120 : 103) / Math.max(1, label.length)));
2273
+ // Hero rings are one size up (88px ring, 20px label) — same auto-fit idea, hero geometry.
2274
+ const fitHero = Math.min(20, Math.floor(110 / Math.max(1, label.length)));
2275
+ const grow = label.length >= 7 ? ';--ring-d:90px' : '';
2276
+ return `<div class="ring ${total ? '' : 'zero'}" style="--p:${ratio * 360}deg;--ring-fs:${fit}px;--ring-fs-hero:${fitHero}px${grow}"><span>${escapeHtml(label)}</span></div>`;
2277
+ }
2278
+
2279
+ function sourceLine(label, file) {
2280
+ return `<div class="source"><strong>${escapeHtml(tr(label))}${tr(': ')}</strong>${file ? escapeHtml(file) : tr('Not generated')}</div>`;
2281
+ }
2282
+
2283
+ function stepStatus(done, total) {
2284
+ // Read the status straight from the numbers: 0 done → not done; partial → in progress; complete → done
2285
+ if (!total || !done) return 'not_started';
2286
+ return done >= total ? 'done' : 'in_progress';
2287
+ }
2288
+
2289
+ // Step status uses the progress caliber (any spec activity), not the strict full-chain
2290
+ // completion caliber that rings and weights use — otherwise a campaign fully inside
2291
+ // stage B reads as "not started" while the logic tab shows work in progress.
2292
+ function logicStepStatus(logic) {
2293
+ if (!logic.specTotal) return 'not_started';
2294
+ if (logic.strictDone >= logic.specTotal) return 'done';
2295
+ return logic.started > 0 ? 'in_progress' : 'not_started';
2296
+ }
2297
+
2298
+ const LOGIC_STAGE_NAMES = {
2299
+ '3.1': 'Logic development',
2300
+ '3.2': 'Build',
2301
+ '3.3': 'Code review loop',
2302
+ };
2303
+
2304
+ function scenarioProgressFor(project, specId) {
2305
+ const spec = project.spec.specs.find((item) => item.id === specId);
2306
+ if (!spec) return { done: 0, total: 0 };
2307
+ return { done: spec.scenarios.filter((scene) => scene.complete).length, total: spec.scenarios.length };
2308
+ }
2309
+
2310
+ function logicStageProgress(row) {
2311
+ const done = row.stages.filter((stage) => ['done', 'skipped'].includes(stage.status)).length;
2312
+ return { done, total: row.stages.length };
2313
+ }
2314
+
2315
+ function usageNumber(value) {
2316
+ return value == null ? tr('not provided') : Number(value).toLocaleString('en-US');
2317
+ }
2318
+
2319
+ function renderConsumption(projects, usages, scanningNote = '') {
2320
+ // Show only agents actually used (with attributed sessions); unused tools are not displayed.
2321
+ const used = usages.filter((usage) => usage.available && (Number(usage.files) || 0) > 0);
2322
+ const usageCards = used.map((usage) => `<div class="usage-agent"><div class="usage-head"><h3>${escapeHtml(usage.label)}</h3></div><div class="metric-grid">
2323
+ <div class="metric"><span>${tr('Input tokens')}</span><strong>${usageNumber(usage.inputTokens)}</strong><small>${tr('excluding cached prompt portions')}</small></div>
2324
+ <div class="metric"><span>${tr('Cache write tokens')}</span><strong>${usageNumber(usage.cacheCreationTokens)}</strong><small>${tr('0 when the agent does not report it')}</small></div>
2325
+ <div class="metric"><span>${tr('Cache read tokens')}</span><strong>${usageNumber(usage.cacheReadTokens)}</strong><small>${tr('cache hits, priced at the model cache rate')}</small></div>
2326
+ <div class="metric"><span>${tr('Output tokens')}</span><strong>${usageNumber(usage.outputTokens)}</strong><small>${tr('content actually generated by the model')}</small></div>
2327
+ <div class="metric"><span>${tr('Reasoning tokens')}</span><strong>${usageNumber(usage.reasoningTokens)}</strong><small>${tr('shown as 0 when the platform does not record it')}</small></div>
2328
+ </div></div>`).join('');
2329
+ const scanningHtml = scanningNote ? `<p class="usage-note">${escapeHtml(scanningNote)}</p>` : '';
2330
+
2331
+ return `<section class="card consumption"><h2>${tr('Agent usage')}</h2>${usageCards}${scanningHtml}<p class="usage-note">${tr('Accounting: sessions are attributed to projects by directory (startup path match or content reference); all tokens of an attributed session are counted.')}</p></section>`;
2332
+ }
2333
+
2334
+ const ICONS = { "overview": "<svg viewBox=\"0 0 24 24\"><rect x=\"4\" y=\"4\" width=\"6\" height=\"6\"/><rect x=\"14\" y=\"4\" width=\"6\" height=\"6\"/><rect x=\"4\" y=\"14\" width=\"6\" height=\"6\"/><rect x=\"14\" y=\"14\" width=\"6\" height=\"6\"/></svg>", "architecture": "<svg viewBox=\"0 0 24 24\"><path d=\"m12 3 8 4-8 4-8-4 8-4Z\"/><path d=\"m4 12 8 4 8-4M4 17l8 4 8-4\"/></svg>", "ui": "<svg viewBox=\"0 0 24 24\"><rect x=\"7\" y=\"2.5\" width=\"10\" height=\"19\" rx=\"2\"/><path d=\"M10 18.5h4\"/></svg>", "spec": "<svg viewBox=\"0 0 24 24\"><circle cx=\"5\" cy=\"12\" r=\"2\"/><circle cx=\"19\" cy=\"6\" r=\"2\"/><circle cx=\"19\" cy=\"18\" r=\"2\"/><path d=\"M7 12h4c3 0 3-6 6-6M11 12c3 0 3 6 6 6\"/></svg>", "logic": "<svg viewBox=\"0 0 24 24\"><path d=\"m8 8-4 4 4 4M16 8l4 4-4 4M14 4l-4 16\"/></svg>", "folder": "<svg viewBox=\"0 0 24 24\"><path d=\"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z\"/></svg>", "collapse": "<svg viewBox=\"0 0 24 24\"><path d=\"m11 17-5-5 5-5M18 17l-5-5 5-5\"/></svg>" };
2335
+ function renderOverview(projects, usages, architecture = null, usageScanning = false) {
2336
+ const arch = architecture || architectureModel();
2337
+ const total = overview(projects, arch);
2338
+ const archDone = arch.configured ? arch.completed : 0;
2339
+ const archTotal = arch.configured ? arch.total : 0;
2340
+ const uiDone = projects.reduce((sum, project) => sum + project.ui.done, 0);
2341
+ const uiTotal = projects.reduce((sum, project) => sum + project.ui.total, 0);
2342
+ const specTotal = projects.reduce((sum, project) => sum + project.spec.total, 0);
2343
+ const pctOf = (done, t) => (t ? Math.min(100, Math.round((done / t) * 100)) : 0);
2344
+ const archPct = pctOf(archDone, archTotal);
2345
+ const uiPct = pctOf(uiDone, uiTotal);
2346
+ const specPct = pctOf(total.spec.done, specTotal);
2347
+ const stepStatuses = [stepStatus(archDone, archTotal), stepStatus(uiDone, uiTotal), stepStatus(total.spec.done, specTotal), logicStepStatus(total.logic)];
2348
+ const doneSteps = stepStatuses.filter((s) => s === 'done').length;
2349
+ const overallRun = stepStatuses.every((s) => s === 'done') ? 'done' : (stepStatuses.every((s) => s === 'not_started') ? 'idle' : 'partial');
2350
+ const overallRunLabel = overallRun === 'done' ? tr('Done') : overallRun === 'idle' ? tr('Not started') : tr('In progress');
2351
+ // Bar count shows the step's weighted-score contribution (achieved% / full weight%), not raw counts:
2352
+ // the four numerators sum to the overall ring (same single-caliber weighted sum as overview()).
2353
+ const fmtScore = (v) => { const r = Math.round(v * 10) / 10; return Number.isInteger(r) ? String(r) : r.toFixed(1); };
2354
+ const oBar = (label, done, t, weight) => `<div class="o-bar"><span class="o-bar-label">${escapeHtml(label)}</span><span class="o-bar-track"><i class="o-bar-fill${stepStatus(done, t) === 'done' ? '' : ' partial'}" style="width:${pctOf(done, t)}%"></i></span><span class="o-bar-count">${fmtScore((t ? done / t : 0) * weight)}% / ${weight}%</span></div>`;
2355
+ return `<section class="tab active" id="overview">
2356
+ <div class="overall card">${ring(total.percentage, 100, `${total.percentage}%`)}<div class="overall-main"><div class="overall-head"><h2>${tr('Overall progress')}</h2><span class="run-status run-status--${overallRun}"><i></i>${overallRunLabel}</span><span class="overall-detail">${doneSteps}/4${tr(' steps done')}</span></div><div class="overall-bars">${oBar(tr('Architecture'), archDone, archTotal, 10)}${oBar(tr('UI Migration'), uiDone, uiTotal, 20)}${oBar(tr('Spec Generation'), total.spec.done, specTotal, 10)}${oBar(tr('Logic Conversion'), total.logic.strictDone, total.logic.specTotal, 60)}</div></div></div>
2357
+ <div class="section-heading"><h2>${tr('Conversion steps')}</h2></div>
2358
+ <div class="step-grid">
2359
+ <article class="card step-card" role="button" tabindex="0" aria-label="${tr('View architecture details')}" onclick="show('architecture')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();show('architecture')}" title="${tr('View architecture details')}" data-status="${stepStatus(archDone, archTotal)}"><div class="step-head"><span class="step-no">01</span><span class="step-icon">${ICONS.architecture}</span><h3>${tr('Architecture')}</h3>${ring(archDone, archTotal, `${archDone}/${archTotal || 0}`)}</div></article>
2360
+ <article class="card step-card" role="button" tabindex="0" aria-label="${tr('View UI migration details')}" onclick="show('ui')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();show('ui')}" title="${tr('View UI migration details')}" data-status="${stepStatus(uiDone, uiTotal)}"><div class="step-head"><span class="step-no">02</span><span class="step-icon orange">${ICONS.ui}</span><h3>${tr('UI Migration')}</h3>${ring(uiDone, uiTotal, `${uiDone}/${uiTotal || 0}`)}</div></article>
2361
+ <article class="card step-card" role="button" tabindex="0" aria-label="${tr('View spec generation details')}" onclick="show('spec')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();show('spec')}" title="${tr('View spec generation details')}" data-status="${stepStatus(total.spec.done, specTotal)}"><div class="step-head"><span class="step-no">03</span><span class="step-icon">${ICONS.spec}</span><h3>${tr('Spec Generation')}</h3>${ring(total.spec.done, specTotal, `${total.spec.done}/${specTotal || 0}`)}</div></article>
2362
+ <article class="card step-card" role="button" tabindex="0" aria-label="${tr('View logic conversion details')}" onclick="show('logic')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();show('logic')}" title="${tr('View logic conversion details')}" data-status="${logicStepStatus(total.logic)}"><div class="step-head"><span class="step-no">04</span><span class="step-icon orange">${ICONS.logic}</span><h3>${tr('Logic Conversion')}</h3>${ring(total.logic.strictDone, total.logic.specTotal, `${total.logic.strictDone}/${total.logic.specTotal || 0}`)}</div></article>
2363
+ </div>
2364
+
2365
+ ${renderConsumption(projects, usages, usageScanning ? tr('Agent usage is being computed on a background thread and appears after an auto-refresh; the first scan of a large session store can take longer.') : '')}
2366
+ </section>`;
2367
+ }
2368
+ function renderMarkerLegend(markers = [], counterpart = []) {
2369
+ if (!markers.length) return '<div class="capture-legend-empty">' + tr('No interactive elements detected') + '</div>';
2370
+ const counterpartNumbers = new Set(counterpart.map((marker) => marker.number));
2371
+ return `<div class="capture-legend-list">${markers.map((marker) => `<div class="capture-legend-row" data-marker="${marker.number}" tabindex="0"><span class="capture-legend-no">${marker.number}</span><span class="capture-legend-label">${escapeHtml(trMarkerLabel(marker.label))}</span><span class="capture-legend-state ${counterpartNumbers.has(marker.number) ? 'matched' : 'missing'}">${counterpartNumbers.has(marker.number) ? tr('same number exists on the other side') : tr('same number not found on the other side')}</span></div>`).join('')}</div>`;
2372
+ }
2373
+
2374
+ function renderCapture(pair, side, featureHtml = '', hmosDevice = 'HarmonyOS device', hmosChip = '') {
2375
+ const uri = side === 'source' ? pair.sourceUri : pair.hmosUri;
2376
+ const frameUris = side === 'source' ? pair.sourceUris : pair.hmosUris;
2377
+ const frameRegions = side === 'source' ? pair.sourceFrameClips : pair.hmosFrameClips;
2378
+ const frameOffsets = side === 'source' ? pair.sourceFrameOffsets : pair.hmosFrameOffsets;
2379
+ const markers = side === 'source' ? pair.sourceMarkers : pair.hmosMarkers;
2380
+ const counterpart = side === 'source' ? pair.hmosMarkers : pair.sourceMarkers;
2381
+ const sourcePlatform = (pair.sourcePlatform || 'Android').toUpperCase();
2382
+ const label = side === 'source' ? `${tr('Before migration · ')}${sourcePlatform}${tr(' (UI migration artifacts)')}` : `${tr('After migration · ')}${tr(hmosDevice)}`;
2383
+ const markerHtml = (markers || []).map((marker) => `<button class="capture-marker" type="button" title="${escapeHtml(trMarkerLabel(marker.label))}" aria-label="${escapeHtml(trMarkerLabel(marker.label))}" style="left:${marker.left.toFixed(3)}%;top:${marker.top.toFixed(3)}%;width:${marker.width.toFixed(3)}%;height:${marker.height.toFixed(3)}%" data-marker="${marker.number}"><span class="capture-marker-badge">${marker.number}</span></button>`).join('');
2384
+ const frames = Array.isArray(frameUris) && frameUris.length ? frameUris : (uri ? [uri] : []);
2385
+ const regions = Array.isArray(frameRegions) ? frameRegions : [];
2386
+ const offsets = Array.isArray(frameOffsets) ? frameOffsets : [];
2387
+ const frameHtml = frames.length > 1
2388
+ ? `<div class="phone-image-layer capture-stitch" data-capture-stitch data-frame-count="${frames.length}" data-scroll-regions="${escapeHtml(JSON.stringify(regions))}" data-scroll-offsets="${escapeHtml(JSON.stringify(offsets))}"><canvas aria-label="${escapeHtml(label)}${tr(' · stitched (dedup)')}"></canvas><div hidden>${frames.map((frame, index) => `<img src="${frame}" data-stitch-frame="${index}" alt="">`).join('')}</div>${markerHtml}</div>`
2389
+ : frames.map((frame) => `<div class="phone-image-layer" data-capture-frame="0"><img src="${frame}" alt="${escapeHtml(label)}">${markerHtml}</div>`).join('');
2390
+ const emptyHint = tr('No UI migration artifact screenshot found for this page (ui_info / capture cache)');
2391
+ // Validation-failed HarmonyOS captures stay on disk as evidence, but the
2392
+ // board refuses to display them: the card states the failure reason and
2393
+ // where the capture is kept. A missing capture states why it is missing.
2394
+ const mismatched = side === 'hmos' && pair.hmosValidation?.verdict === 'mismatch';
2395
+ const bodyHtml = frames.length && !mismatched
2396
+ ? `<div class="phone-shell"><span class="phone-notch" aria-hidden="true"></span><div class="phone-screen">${frameHtml}</div></div>`
2397
+ : side === 'hmos'
2398
+ ? `<div class="capture-empty-card"><h4>${mismatched ? `${escapeHtml(tr(hmosDevice))}${tr(' screenshot validation failed')}` : RENDER_LANG === 'en' ? `${escapeHtml(tr(hmosDevice))} screenshot not shown` : `${escapeHtml(hmosDevice)} screenshot not shown`}</h4><p>${escapeHtml(mismatched
2399
+ ? `${trCaptureDetail(String(pair.hmosValidation.reason || 'does not fully match the source page'))}${Number(pair.hmosValidation.state_retries) > 0 ? `${tr(' (internal retries in the first round: ')}${pair.hmosValidation.state_retries}${tr(')')}` : ''}${tr('. The screenshot was kept in the capture cache; recapture after fixing and pass validation to display it.')}`
2400
+ : (pair.hmosEmptyReason || `${tr('No ')}${tr(hmosDevice)}${tr(' screenshot was read for this task.')}`))}</p></div>`
2401
+ : `<div class="phone-shell"><span class="phone-notch" aria-hidden="true"></span><div class="phone-screen"><div class="capture-empty"><strong>${tr('Missing UI migration artifact screenshot')}</strong><span>${escapeHtml(emptyHint)}</span></div></div></div>`;
2402
+ // Advisory capture verdict: the screenshot was kept, and the flag travels
2403
+ // with it so a mismatched page is visible right on the card.
2404
+ const mismatch = side === 'hmos' && pair.hmosValidation?.verdict === 'mismatch'
2405
+ ? `<span class="capture-mismatch" title="${escapeHtml(trCaptureDetail(String(pair.hmosValidation.reason || 'does not fully match the source page')))}">⚠ ${tr('does not fully match the source page')}</span>`
2406
+ : '';
2407
+ return `<article class="capture phone-card"><div class="compare-tag ${side === 'source' ? '' : 'compare-tag-after'}">${escapeHtml(label)}${mismatch}</div><div class="phone-card-head"><h3>${side === 'source' ? `${sourcePlatform}${tr(' migration artifact screenshot')}` : `${tr(hmosDevice)}${tr(' screenshot')}`}${frames.length > 1 ? ` · ${frames.length}${tr(' frames')}` : ''}${side === 'hmos' ? hmosChip : ''}</h3></div><div class="phone-body-row">${bodyHtml}<aside class="capture-legend"><h4>${tr('Markers · ')}${(markers || []).length}</h4><p>${tr('Numbers pair by per-side capture order and only indicate whether the same number exists on both sides.')}</p>${renderMarkerLegend(markers || [], counterpart || [])}${featureHtml}</aside></div></article>`;
2408
+ }
2409
+
2410
+ function renderUiTaskSummary(project, task, capture) {
2411
+ const sourceCount = capture.sourceMarkers?.length ?? 0;
2412
+ const hmosCount = capture.hmosMarkers?.length ?? 0;
2413
+ const delta = hmosCount - sourceCount;
2414
+ const countStatus = sourceCount === hmosCount ? 'done' : 'in_progress';
2415
+ return `<div class="ui-page-summary"><div class="ui-summary-block"><div class="ui-summary-head"><strong>${task.captureOnly ? `${tr(hmosDeviceLabel(project))}${tr(' capture cached')}` : (task.status === 'done' ? tr('Page task completed') : statusLabel(task.status))}</strong>${task.captureOnly ? badge('done', tr('Live capture cache')) : badge(countStatus, sourceCount === hmosCount ? tr('Marker counts match') : `${tr('Markers ')}${sourceCount} → ${hmosCount}`, sourceCount === hmosCount ? '' : RENDER_LANG === 'en' ? `Before migration: ${sourceCount} markers, after migration: ${hmosCount}, a difference of ${Math.abs(delta)}` : `Before migration: ${sourceCount} markers, after migration: ${hmosCount}, a difference of ${Math.abs(delta)}`)}</div><div class="ui-summary-evidence"><strong>${escapeHtml(task.id)}</strong><small>${task.output ? escapeHtml(task.output) : (task.captureOnly ? tr('No screenshot file recorded') : tr('No target code file recorded'))}</small></div></div></div>`;
2416
+ }
2417
+
2418
+ function hmosCaptureChip(project) {
2419
+ const state = project.captureState;
2420
+ if (!state) return '';
2421
+ const item = state.hmos || {};
2422
+ const bucket = item.status === 'ready' ? 'done' : item.status === 'capturing' || item.status === 'checking' ? 'in_progress' : item.status === 'error' ? 'blocked' : 'not_started';
2423
+ const mode = item.status === 'ready' ? tr('Captured from the connected device') : item.status === 'capturing' ? tr('Capturing from the connected device') : tr('Local cache fallback');
2424
+ const text = item.detail ? mode + tr(' · ') + trCaptureDetail(item.detail) : mode;
2425
+ return `<span class="hmos-capture-chip ${bucket}"><span class="dot ${bucket}"></span>${escapeHtml(text)}</span>`;
2426
+ }
2427
+
2428
+ // The board does not distinguish emulator vs real device — whatever hdc target
2429
+ // is connected is just the HarmonyOS side.
2430
+ function hmosDeviceLabel(project) {
2431
+ return tr('HarmonyOS device');
2432
+ }
2433
+
2434
+ // Empty HarmonyOS slides must say WHY instead of showing a blank phone shell.
2435
+ // Three operator-actionable cases: capture in flight (wait), no cache at all
2436
+ // (connect and run a capture), and cache exists but this page is absent
2437
+ // (pairing or coverage problem — the no-borrow rule keeps the slide empty).
2438
+ function hmosEmptyReason(project, hasHmosCaptures) {
2439
+ const state = project.captureState?.hmos || {};
2440
+ if (state.status === 'capturing' || state.status === 'checking') return tr('The HarmonyOS side is capturing; refresh the dashboard when it finishes to see the screenshots.');
2441
+ if (!hasHmosCaptures) {
2442
+ const detail = String(state.detail || '').trim();
2443
+ return `${tr('No HarmonyOS capture cache was read')}${detail ? `${tr(': ')}${trCaptureDetail(detail)}` : tr(': no HarmonyOS device capture has been run yet')}${tr('. Connect a device, finish a capture, and refresh the dashboard.')}`;
2444
+ }
2445
+ return tr('The HarmonyOS side has capture caches for other pages, but not for this one; the same-task pairing rule never borrows across tasks. Re-run the HarmonyOS capture to cover this page, or assign a capture seq for this task via ui_hmos_content_map in the dashboard config.');
2446
+ }
2447
+
2448
+ function captureForTask(project, task, index) {
2449
+ const taskId = String(task.id || '').toLowerCase();
2450
+ const sequence = Number(taskId.match(/page_(\d+)/i)?.[1]);
2451
+ // Pairing is config-driven, not keyword-heuristic. Two independent maps in
2452
+ // the dashboard config tell each task which capture seq to use on each
2453
+ // side, because the Android slug captures and the HarmonyOS page_N captures
2454
+ // use different seq spaces (Android slug seq comes from pages.json rank in
2455
+ // findCaptures; HarmonyOS seq comes from the page_N number in its folder
2456
+ // name), so a single seq cannot select both sides correctly.
2457
+ // ui_capture_map : task.id -> Android source seq
2458
+ // ui_hmos_content_map : task.id -> [HarmonyOS seq, ...] (first match wins)
2459
+ // Falls back to taskId match, then task index seq, when no map entry exists.
2460
+ const mappedSourceSeq = Number(project.uiCaptureMap?.[task.id] ?? project.uiCaptureMap?.[taskId]);
2461
+ const mappedHmosSeqs = Array.isArray(project.uiHmosContentMap?.[task.id])
2462
+ ? project.uiHmosContentMap[task.id]
2463
+ : project.uiHmosContentMap?.[taskId];
2464
+ const mappedRow = Number.isFinite(mappedSourceSeq)
2465
+ ? project.captures.find((row) => row.seq === mappedSourceSeq) || null
2466
+ : null;
2467
+ // Source and HarmonyOS sides resolve independently: an explicit
2468
+ // ui_capture_map row that carries no source screenshot (e.g. an hmos-only
2469
+ // cache row) must not swallow the task's own source pairing below.
2470
+ const taskCapture = (mappedRow && mappedRow.source ? mappedRow : null)
2471
+ || project.captures.find((row) => String(row.taskId || '').toLowerCase() === taskId)
2472
+ // Crawler-slug layouts name batch_progress task ids after the capture dir
2473
+ // itself (activity_MainActivity, dyn_001, …) while the synthesized taskId
2474
+ // carries a page_000N_ prefix. The dir name is exact evidence, not a
2475
+ // positional or keyword guess, so it is a valid pairing key.
2476
+ || project.captures.find((row) => String(row.dirName || row.name || '').toLowerCase() === taskId)
2477
+ || project.captures.find((row) => Number.isFinite(sequence) && row.seq === sequence);
2478
+ const binding = Object.values(project.uiPageBindings || {}).find((row) => String(row?.task_id || '').toLowerCase() === taskId) || {};
2479
+ // HarmonyOS side resolves INDEPENDENTLY of the Android row: the slug
2480
+ // variant named after the task id is the only automatic pairing evidence.
2481
+ // When it does not exist (page rejected / not yet captured) the slide stays
2482
+ // empty — never borrow the seq-merged screenshot of a neighbouring row.
2483
+ let hmosCapture = null;
2484
+ if (Array.isArray(mappedHmosSeqs) && mappedHmosSeqs.length) {
2485
+ hmosCapture = mappedHmosSeqs
2486
+ .map((seq) => project.captures.find((row) => row.seq === Number(seq) && row.hmos))
2487
+ .find(Boolean) || null;
2488
+ }
2489
+ if (!hmosCapture) {
2490
+ hmosCapture = project.captures
2491
+ .flatMap((row) => (Array.isArray(row.hmosVariants) ? row.hmosVariants : []))
2492
+ .filter((variant) => variant && variant.hmosUri)
2493
+ .find((variant) => String(variant.name || '').toLowerCase() === taskId) || null;
2494
+ }
2495
+ if (!hmosCapture && Number.isFinite(mappedSourceSeq)) {
2496
+ // An explicit ui_capture_map entry asserts the mapped row itself is the
2497
+ // correct pair — config wins where the operator spoke. When the mapped
2498
+ // row carries no HarmonyOS capture, fall back to the paired row's own.
2499
+ hmosCapture = mappedRow && mappedRow.hmos ? mappedRow : (taskCapture && taskCapture.hmos ? taskCapture : null);
2500
+ }
2501
+ // Never attach a capture merely because it occupies the same array slot.
2502
+ // Task ids and explicit ui_capture_map / ui_hmos_content_map entries are the
2503
+ // only valid evidence that two screenshots describe the same UI state.
2504
+ if (!taskCapture) return {};
2505
+ const hmosFile = hmosCapture ? hmosCapture.hmos : '';
2506
+ // capture_scroll=false pages display the single-viewport screenshot, never
2507
+ // the stitched long screenshot collected alongside it.
2508
+ const hmosStill = hmosCapture ? (hmosCapture.hmosViewport || hmosFile) : '';
2509
+ const hmosStillUri = hmosStill ? imageDataUri(hmosStill) : '';
2510
+ const hmosValidation = hmosCapture ? (hmosCapture.validation || hmosCapture.hmosValidation || null) : null;
2511
+ const hmosCaptureSeq = hmosCapture ? hmosCapture.seq : '';
2512
+ return binding.capture_scroll === false
2513
+ ? { ...taskCapture, hmos: hmosStill, hmosUri: hmosStillUri, hmosRoot: hmosCapture ? hmosCapture.hmosRoot : '', hmosMarkers: hmosCapture ? hmosCapture.hmosMarkers : [], hmosValidation, hmosCaptureSeq, hmosUris: hmosStillUri ? [hmosStillUri] : [], hmosFrameClips: [], hmosFrameOffsets: [], sourceUris: taskCapture.sourceUri ? [taskCapture.sourceUri] : [] }
2514
+ : { ...taskCapture, hmos: hmosFile, hmosUri: hmosCapture ? hmosCapture.hmosUri : '', hmosRoot: hmosCapture ? hmosCapture.hmosRoot : '', hmosMarkers: hmosCapture ? hmosCapture.hmosMarkers : [], hmosValidation, hmosCaptureSeq, hmosUris: hmosCapture ? hmosCapture.hmosUris : [], hmosFrameClips: hmosCapture ? hmosCapture.hmosFrameClips : [], hmosFrameOffsets: hmosCapture ? hmosCapture.hmosFrameOffsets : [] };
2515
+ }
2516
+
2517
+ function uiStatsStrip(stats) {
2518
+ const card = (cls, label, value) => '<div class="ui-stat ' + cls + '"><strong>' + value + '</strong><span>' + label + '</span></div>';
2519
+ return '<div class="ui-stats">'
2520
+ + card('stat-total', tr('Pages'), stats.total)
2521
+ + card('stat-done', tr('Migrated'), stats.done)
2522
+ + card('stat-warn', tr('Marker count mismatch'), stats.mismatchCount)
2523
+ + card('stat-miss', tr('No usable HarmonyOS capture'), stats.noHmos)
2524
+ + '</div>';
2525
+ }
2526
+ function renderUi(projects) {
2527
+ const uiDone = projects.reduce((sum, project) => sum + project.ui.done, 0);
2528
+ const uiTotal = projects.reduce((sum, project) => sum + project.ui.total, 0);
2529
+ const hmosPresence = new Map();
2530
+ for (const project of projects) {
2531
+ const originalCaptures = project.captures;
2532
+ hmosPresence.set(project, originalCaptures.some((row) => row && (row.hmos
2533
+ || (Array.isArray(row.hmosVariants) && row.hmosVariants.some((variant) => variant && variant.hmosUri)))));
2534
+ project.captures = project.ui.tasks.map((task, index) => captureForTask({ ...project, captures: originalCaptures }, task, index));
2535
+ }
2536
+ const uiStats = { total: 0, done: 0, mismatchCount: 0, noHmos: 0 };
2537
+ for (const project of projects) {
2538
+ for (const [index, task] of project.ui.tasks.entries()) {
2539
+ uiStats.total++;
2540
+ if (task.status === 'done') uiStats.done++;
2541
+ const capture = project.captures[index] || {};
2542
+ const hmosUsable = Boolean((capture.hmosUri || (Array.isArray(capture.hmosUris) && capture.hmosUris.length))
2543
+ && capture.hmosValidation?.verdict !== 'mismatch');
2544
+ if (!hmosUsable) { uiStats.noHmos++; continue; }
2545
+ if ((capture.sourceMarkers?.length ?? 0) !== (capture.hmosMarkers?.length ?? 0)) uiStats.mismatchCount++;
2546
+ }
2547
+ }
2548
+ return `<section class="tab" id="ui">${tabHero(ICONS.ui, tr('UI Migration'), '', ring(uiDone, uiTotal, `${uiDone}/${uiTotal || 0}`), 'orange')}${uiStatsStrip(uiStats)}
2549
+ ${projects.map((project, projectIndex) => `<article class="card ui-project" data-ui-project="${projectIndex}"><div class="ui-toolbar"><div class="ui-toolbar-main"><div class="ui-title-jump"><input type="search" data-ui-title-search placeholder="${tr('Search page titles, e.g. Main Page (ignores case and spaces)')}" aria-label="${tr('Jump to page title')}"><button class="outline" type="button" data-ui-title-jump>${tr('Jump')}</button></div><label class="ui-pending-filter"><input type="checkbox" data-ui-pending-only>${tr(' Pending only')}</label></div><div class="pager"><button class="outline" type="button" data-ui-prev aria-label="${tr('Previous page')}">← ${tr('Previous page')}</button><span class="page-counter" data-ui-count>1 / ${Math.max(1, project.ui.tasks.length)}</span><button class="outline" type="button" data-ui-next aria-label="${tr('Next page')}">${tr('Next page')} →</button></div></div><div class="pager-kbd">${tr('Use ← → keys to page')}</div><div class="ui-project-meta"><div>${project.ui.captureOnly ? sourceLine(tr('Capture cache directory'), project.ui.captureSource) : sourceLine(tr('Migration task source'), project.ui.file)}</div></div>
2550
+ <div class="page-grid">${project.ui.tasks.map((task, index) => { const capture = project.captures[index] || {}; const sourceCount = capture.sourceMarkers?.length ?? 0; const hmosCount = capture.hmosMarkers?.length ?? 0; return `<button type="button" class="page-card" data-page-card="${index}" data-ui-status="${escapeHtml(task.status)}" title="${escapeHtml(taskFriendlyTitle(task))}"><span class="page-card-dot ${escapeHtml(task.status)}"></span><span class="page-card-no">${String(index + 1).padStart(2, '0')}</span><strong class="page-card-title">${escapeHtml(shortPageName(task))}</strong></button>`; }).join('')}</div>
2551
+ ${project.ui.tasks.length ? `<div class="ui-stack" data-ui-stack>${project.ui.tasks.map((task, index) => { const capture = project.captures[index] || {}; if (!capture.hmosUri && !(Array.isArray(capture.hmosUris) && capture.hmosUris.length)) capture.hmosEmptyReason = hmosEmptyReason(project, hmosPresence.get(project)); const title = taskFriendlyTitle(task); return `<section class="ui-slide" data-ui-slide="${index}" data-ui-status="${escapeHtml(task.status)}" data-ui-title="${escapeHtml((shortPageName(task) + ' ' + title).toLowerCase().replace(/\s+/g, ''))}" ${index ? 'hidden' : ''}><div class="page-title"><div><h2>${escapeHtml(shortPageName(task))}</h2></div>${task.captureOnly ? badge('done', tr('Cached device capture')) : badge(task.status)}</div>${renderUiTaskSummary(project, task, capture)}<div class="capture-grid">${renderCapture(capture, 'source')}<div class="arrow" aria-hidden="true">→</div>${renderCapture(capture, 'hmos', '', hmosDeviceLabel(project), hmosCaptureChip(project))}</div></section>`; }).join('')}<div class="ui-filter-empty" data-ui-filter-empty hidden>${tr('No UI migration tasks match the current filter; untick "Pending only".')}</div></div>` : `<div class="empty">${tr('batch_progress.json was not generated or contains no UI migration tasks, and no HarmonyOS capture cache was found.')}${hmosCaptureChip(project) ? `<div class="ui-capture-state">${hmosCaptureChip(project)}</div>` : ''}</div>`}
2552
+ </article>`).join('')}
2553
+ </section>`;
2554
+ }
2555
+
2556
+ function logicStatusFor(project, specId) {
2557
+ return project.logic.find((row) => row.id === specId);
2558
+ }
2559
+
2560
+ function scenarioCoverageRow(logic, scene, sceneIndex) {
2561
+ const rows = logic?.coverage ?? [];
2562
+ return rows.find((row) => row.scene === scene.name)
2563
+ ?? rows.find((row) => row.feature && scene.description && (row.feature.includes(scene.description) || scene.description.includes(row.feature)))
2564
+ ?? rows[sceneIndex] ?? null;
2565
+ }
2566
+
2567
+
2568
+ function renderScenario31Evidence(logic, scene, sceneIndex, stage) {
2569
+ const row = scenarioCoverageRow(logic, scene, sceneIndex);
2570
+ const specification = scene.description || scene.expected || '';
2571
+ const check = row
2572
+ ? [row.status || statusLabel(stage.status), row.target].filter(Boolean).join(tr(':'))
2573
+ : tr('No matching record for this scenario in coverage-ledger.md');
2574
+ const traceRows = [
2575
+ [tr('Scenario spec'), specification],
2576
+ [tr('Trigger entry'), row?.source],
2577
+ [tr('Target symbol / call chain'), row?.target],
2578
+ ].filter((item) => item[1]);
2579
+ return `<div class="scenario-build-record scenario-stage31">
2580
+ <div class="scenario-build-head"><span class="scenario-stage-dot ${escapeHtml(stage.status)}"></span><span class="scenario-stage-heading"><strong>${tr('3.1 Scenario coding record')}</strong><span class="scenario-stage3-caption">${escapeHtml(scene.description || scene.name || '')}</span></span><span class="scenario-stage-status ${escapeHtml(stage.status)}">${escapeHtml(statusLabel(stage.status))}</span></div>
2581
+ <div class="scenario-summary-lines"><p><strong>${tr('Expected result: ')}</strong>${escapeHtml(scene.expected || scene.description || tr('Not recorded'))}</p><p><strong>${tr('3.1 coding check: ')}</strong>${escapeHtml(check)}</p></div>
2582
+ ${traceRows.length ? `<div class="scenario-inline-spec">${traceRows.map(([label, value]) => `<div class="scenario-inline-row"><strong>${escapeHtml(label)}${tr(':')}</strong>${escapeHtml(value)}</div>`).join('')}</div>` : ''}
2583
+ </div>`;
2584
+ }
2585
+
2586
+ function renderScenarioStageRecord(stage, title, note, body) {
2587
+ return `<div class="scenario-build-record"><div class="scenario-build-head"><span class="scenario-stage-dot ${escapeHtml(stage.status)}"></span><strong>${escapeHtml(title)}</strong><span class="scenario-stage-status ${escapeHtml(stage.status)}">${escapeHtml(statusLabel(stage.status))}</span></div>${note ? `<div class="scenario-substage-note">${escapeHtml(note)}</div>` : ''}${body}</div>`;
2588
+ }
2589
+
2590
+ function scenarioInlineRows(rows) {
2591
+ return rows.filter((row) => row[1]).map(([label, value]) => `<div class="scenario-inline-row"><strong>${escapeHtml(tr(label))}${tr(':')}</strong>${escapeHtml(value)}</div>`).join('');
2592
+ }
2593
+
2594
+ function renderScenario32Evidence(logic, stage) {
2595
+ const evidence = parseBuildEvidence(logic);
2596
+ if (!evidence) return renderScenarioStageRecord(stage, tr('3.2 Spec build record'), '', `<div class="scenario-stage3-empty">${stage.status === 'not_started' ? tr('Not started: no step-3 build report found.') : tr('Status updated, but no readable build report was found.')}</div>`);
2597
+ const rows = scenarioInlineRows([
2598
+ [tr('Build time'), evidence.buildTime], [tr('Build end time'), evidence.endTime], [tr('Build type'), evidence.mode],
2599
+ [tr('Build command'), evidence.command], [tr('Total duration'), evidence.duration], [tr('Hvigor duration'), evidence.hvigorDuration],
2600
+ [tr('ArkTS compile'), evidence.compile], [tr('HAP package'), evidence.package], [tr('HAP signing'), evidence.sign],
2601
+ [tr('Compile errors'), evidence.errors], [tr('Errors fixed this round'), evidence.errorsFixed], [tr('Compile warnings'), evidence.warnings], ['SHA-256', evidence.sha256],
2602
+ ]);
2603
+ const artifacts = evidence.artifacts.map((item) => `<div class="scenario-build-artifact">${escapeHtml(item)}</div>`).join('');
2604
+ const body = `<div class="scenario-inline-detail">${rows}${artifacts ? `<div class="scenario-inline-evidence-title">${tr('Build artifacts')}</div>${artifacts}` : ''}${evidence.reportPath ? `<div class="scenario-inline-row scenario-evidence-file"><strong>${tr('Build report: ')}</strong>${escapeHtml(evidence.reportPath)}</div>` : ''}</div>`;
2605
+ return renderScenarioStageRecord(stage, tr('3.2 Spec build record'), tr('This build result is shared by all scenarios of this spec; it does not mean each scenario was built individually.'), body);
2606
+ }
2607
+
2608
+ function reviewVerdictStatus(value, fallback = 'not_started') {
2609
+ const normalized = String(value ?? '').trim().toUpperCase();
2610
+ if (!normalized) return fallback;
2611
+ if (/SKIP/.test(normalized)) return 'skipped';
2612
+ if (/PARTIAL|UNABLE TO VERIFY|PASS WITH ISSUES|UNVERIFIED/.test(normalized)) return 'in_progress';
2613
+ if (/(^|\W)FAIL(?:ED)?($|\W)|FAILED|BLOCKED|NOT PASSED|DID NOT PASS/.test(normalized)) return 'blocked';
2614
+ if (/(^|\W)PASS(?:ED)?($|\W)|\bPASSED\b|\bCOMPLETED\b/.test(normalized)) return 'done';
2615
+ return fallback;
2616
+ }
2617
+
2618
+ function reviewVerdictPresentation(value, stageStatus = 'not_started') {
2619
+ const raw = String(value ?? '').trim();
2620
+ const normalized = raw.toUpperCase();
2621
+ if (/UNABLE TO VERIFY/.test(normalized)) {
2622
+ return {
2623
+ raw,
2624
+ status: stageStatus === 'done' ? 'done' : 'in_progress',
2625
+ label: stageStatus === 'done' ? tr('Static review done · runtime unverified') : tr('Runtime unverified'),
2626
+ };
2627
+ }
2628
+ return { raw, status: reviewVerdictStatus(raw, stageStatus), label: raw || tr('No verdict recorded') };
2629
+ }
2630
+
2631
+ function reviewDetailLabel(value) {
2632
+ const label = String(value ?? '').trim();
2633
+ // English mode shows the report's own labels (the map below is a zh display
2634
+ // translation of those English labels); synthesized zh fallbacks still
2635
+ // translate through the dictionary.
2636
+ if (RENDER_LANG === 'en') return (EN_STRINGS[label] ?? label) || 'Review notes';
2637
+ const translated = {
2638
+ Description: tr('Scenario description'),
2639
+ Result: tr('Detailed verdict'),
2640
+ Verdict: tr('Detailed verdict'),
2641
+ 'Fix Status': tr('Fix status'),
2642
+ 'Spec expectation': tr('Spec expectation'),
2643
+ 'Implementation evidence': tr('Implementation evidence'),
2644
+ Evidence: tr('Implementation evidence'),
2645
+ 'Why this is not marked PASS': tr('Why this is not marked PASS'),
2646
+ 'Review conclusion': tr('Review conclusion'),
2647
+ Gaps: tr('Key gaps / unverified items'),
2648
+ 'Fixes Applied': tr('Fixes applied'),
2649
+ };
2650
+ return translated[label] || label || tr('Review notes');
2651
+ }
2652
+
2653
+ function renderReviewScenario(round, scenario, index, stage) {
2654
+ const verdict = scenario.result
2655
+ || scenario.detail?.fields.find((field) => /^(Result|Verdict)$/i.test(field.label))?.value
2656
+ || tr('No verdict recorded');
2657
+ const presentation = reviewVerdictPresentation(verdict, stage.status);
2658
+ const status = presentation.status;
2659
+ const summary = scenario.conclusion || scenario.gap || scenario.detail?.fields.find((field) => /^Description$/i.test(field.label))?.value || '';
2660
+ const topRows = scenarioInlineRows([
2661
+ [tr('Raw report verdict'), presentation.label !== verdict ? verdict : ''],
2662
+ [tr('Review conclusion'), scenario.conclusion],
2663
+ [tr('Key gaps'), scenario.gap],
2664
+ [tr('Fix status'), scenario.fixStatus],
2665
+ ]);
2666
+ const detailFields = (scenario.detail?.fields ?? [])
2667
+ .filter((field) => !/^(Result|Verdict)$/i.test(field.label))
2668
+ .map((field) => `<div class="logic-review-field"><strong>${escapeHtml(reviewDetailLabel(field.label))}</strong><span>${escapeHtml(field.value)}</span></div>`)
2669
+ .join('');
2670
+ const detailBlocks = (scenario.detail?.blocks ?? []).map((block) => `<section class="logic-review-detail-section"><h5>${escapeHtml(reviewDetailLabel(block.title))}</h5><ul>${block.lines.map((line) => `<li>${escapeHtml(line)}</li>`).join('')}</ul></section>`).join('');
2671
+ const detailBody = topRows || detailFields || detailBlocks
2672
+ ? `<div class="logic-review-scenario-body">${topRows ? `<div class="logic-review-summary-rows">${topRows}</div>` : ''}${detailFields ? `<div class="logic-review-fields">${detailFields}</div>` : ''}${detailBlocks ? `<div class="logic-review-detail-grid">${detailBlocks}</div>` : ''}</div>`
2673
+ : `<div class="logic-review-scenario-empty">${tr('The review summary covers this scenario, but the report provides no finer evidence sections.')}</div>`;
2674
+ // the "Scenario N" prefix is synthesized by our parser; the title part after the
2675
+ // colon is report data and stays as produced
2676
+ const scenarioName = translateScenarioName(scenario.name || (RENDER_LANG === 'en' ? `Scenario ${index + 1}` : `Scenario ${index + 1}`));
2677
+ return `<details class="logic-review-scenario" data-review-scenario="${escapeHtml(scenario.number || index + 1)}" data-review-status="${escapeHtml(status)}" >
2678
+ <summary><span class="logic-review-scenario-index">${escapeHtml(scenario.number || index + 1)}</span><span class="logic-review-scenario-copy"><strong>${escapeHtml(scenarioName)}</strong>${summary ? `<small>${escapeHtml(summary)}</small>` : ''}</span>${badge(status, presentation.label)}<i class="logic-review-scenario-chevron" aria-hidden="true">⌄</i></summary>
2679
+ ${detailBody}
2680
+ </details>`;
2681
+ }
2682
+
2683
+ function renderReviewRound(round, stage) {
2684
+ const metrics = [
2685
+ [tr('Scenarios reviewed'), round.reviewed, 'reviewed'],
2686
+ ['PASS', round.pass, 'done'],
2687
+ ['PARTIAL', round.partial, 'in_progress'],
2688
+ ['FAIL', round.fail, 'blocked'],
2689
+ [tr('Runtime unverified'), round.unable, 'runtime'],
2690
+ [tr('Confirmed defects'), round.confirmed, 'blocked'],
2691
+ ].filter((item) => item[1] !== '' && item[1] != null);
2692
+ const metricHtml = metrics.map(([label, value, status]) => `<div class="logic-review-metric ${escapeHtml(status)}"><span>${escapeHtml(label)}</span><strong>${escapeHtml(value)}</strong></div>`).join('');
2693
+ const scenarioHtml = (round.scenarios ?? []).map((scenario, index) => renderReviewScenario(round, scenario, index, stage)).join('');
2694
+ return `<section class="logic-review-round" data-review-round="${escapeHtml(round.round || '?')}">
2695
+ <div class="logic-review-round-head"><div><strong>${tr('Round ')}${escapeHtml(round.round || '?')}${tr(' — per-scenario review')}</strong><span>${tr('Raw report verdict: ')}${escapeHtml(round.verdict || tr('Not recorded'))}</span></div>${round.reportPath ? `<small>${escapeHtml(round.reportPath)}</small>` : ''}</div>
2696
+ ${metricHtml ? `<div class="logic-review-metrics">${metricHtml}</div>` : ''}
2697
+ ${scenarioHtml ? `<div class="logic-review-scenarios"><div class="logic-review-scenarios-title"><strong>${tr('Per-scenario review details')}</strong><span>${tr('Expand a scenario to see its review evidence, unverified items, and fix status')}</span></div>${scenarioHtml}</div>` : `<div class="scenario-inline-row"><strong>${tr('This round: ')}</strong>${escapeHtml(round.verdict || tr('No verdict recorded'))}${round.reportPath ? `${tr('; ')}${escapeHtml(round.reportPath)}` : ''}</div>`}
2698
+ </section>`;
2699
+ }
2700
+
2701
+ function renderScenario33Evidence(logic, stage) {
2702
+ const evidence = parseReviewEvidence(logic);
2703
+ if (!evidence) return renderScenarioStageRecord(stage, tr('3.3 Spec code review record'), '', `<div class="scenario-stage3-empty">${stage.status === 'not_started' ? tr('Not started: no step-3 code review report found.') : tr('Status updated, but no readable code review report was found.')}</div>`);
2704
+ const lastRound = evidence.rounds.at(-1);
2705
+ const reviewCounts = [
2706
+ lastRound?.pass ? `${lastRound.pass} PASS` : '',
2707
+ lastRound?.partial ? `${lastRound.partial} PARTIAL` : '',
2708
+ lastRound?.fail ? `${lastRound.fail} FAIL` : '',
2709
+ lastRound?.unable ? `${lastRound.unable}${tr(' runtime-unverified (raw UNABLE TO VERIFY)')}` : '',
2710
+ ].filter(Boolean).join(tr(','));
2711
+ const loopState = stage.status === 'done'
2712
+ ? `${tr('Finished (')}${evidence.rounds.length || evidence.finalRound || 0}${tr(' rounds recorded)')}`
2713
+ : statusLabel(stage.status);
2714
+ const rows = scenarioInlineRows([
2715
+ [tr('3.3 loop status'), loopState], [tr('Final recorded round'), evidence.finalRound], [tr('Raw report verdict'), evidence.verdict],
2716
+ [tr('Scenario verdict summary'), reviewCounts || evidence.scenarioResult],
2717
+ [tr('Confirmed issues'), evidence.confirmed], [tr('Successfully fixed'), evidence.fixed], [tr('Fix failed'), evidence.failed], [tr('Stop reason'), evidence.stopReason],
2718
+ ]);
2719
+ const rounds = evidence.rounds.map((round) => renderReviewRound(round, stage)).join('');
2720
+ const findings = evidence.findings.map((item) => `<div class="scenario-build-artifact">${escapeHtml(item)}</div>`).join('');
2721
+ const paths = [evidence.reportPath, evidence.fixReportPath].filter(Boolean).map((item) => `<div class="scenario-build-artifact">${escapeHtml(item)}</div>`).join('');
2722
+ const body = `<div class="scenario-inline-detail logic-review-overview">${rows}${findings ? `<div class="scenario-inline-evidence-title">${tr('Confirmed and handled issues')}</div>${findings}` : ''}${paths ? `<div class="scenario-inline-evidence-title">${tr('Review evidence files')}</div>${paths}` : ''}</div>${rounds}`;
2723
+ return renderScenarioStageRecord(stage, tr('3.3 Spec code review record'), tr('Stage completion is judged by the review reports under spec_group_{G}/review-round_*/. UNABLE TO VERIFY means the static review finished but runtime results are unverified — it does not mean 3.3 is incomplete.'), body);
2724
+ }
2725
+
2726
+ function renderScenarioLogicEvidence(logic, scene, sceneIndex) {
2727
+ if (!logic) return `<div class="stage-empty">${tr('No step-3 artifacts found for this spec.')}</div>`;
2728
+ const stages = ['3.1', '3.2', '3.3'].map((stageId) => logic.stages.find((stage) => stage.stage === stageId) || { stage: stageId, status: 'not_started', files: [] });
2729
+ return `<p class="scenario-note">${tr('3.1 shows the current scenario\'s coding record only; 3.2-3.3 show the shared results of the current spec.')}</p>
2730
+ <div class="stage-strip">${stages.map((stage) => `<div><span>${stage.stage} · ${escapeHtml(tr(LOGIC_STAGE_NAMES[stage.stage] || stage.stage))}</span>${badge(stage.status)}</div>`).join('')}</div>
2731
+ <div class="scenario-evidence">${renderScenario31Evidence(logic, scene, sceneIndex, stages[0])}<div class="scenario-shared-divider"><strong>${tr('Current spec shared results')}</strong><span>${tr('The build and review records below belong to this spec — not to other specs, and not repeated per scenario.')}</span></div>${renderScenario32Evidence(logic, stages[1])}${renderScenario33Evidence(logic, stages[2])}</div>`;
2732
+ }
2733
+
2734
+ function renderSpec(projects) {
2735
+ const specDone = projects.reduce((sum, project) => sum + project.spec.done, 0);
2736
+ const specTotal = projects.reduce((sum, project) => sum + project.spec.total, 0);
2737
+ // Spec explorer: left = spec overview list, right = the selected spec's full
2738
+ // detail (all of its scenarios stacked) — mirrors the example's two-column layout.
2739
+ const dot = (complete) => `<i class="spec-dot ${complete ? 'done' : ''}"></i>`;
2740
+ const completeCount = (spec) => spec.scenarios.filter((scene) => scene.complete).length;
2741
+ return `<section class="tab" id="spec">${tabHero(ICONS.spec, tr('Spec Generation'), '', ring(specDone, specTotal, `${specDone}/${specTotal || 0}`), '')}
2742
+ ${projects.map((project, projectIndex) => `<article class="spec-explorer" data-spec-board="${projectIndex}">${project.spec.specs.length ? `<div class="spec-side"><div class="spec-search"><input type="search" data-spec-search placeholder="${tr('Search ')}${project.spec.specs.length}${tr(' specs')}" aria-label="${tr('Search specs')}"></div><div class="spec-name-list" aria-label="${tr('Spec overview')}">${project.spec.specs.map((spec, specIndex) => {
2743
+ const total = spec.scenarios.length;
2744
+ const complete = total > 0 && completeCount(spec) === total;
2745
+ return `<button type="button" class="spec-name-item ${specIndex === 0 ? 'is-active' : ''}" data-spec-index="${specIndex}" data-spec-title="${escapeHtml(spec.title.toLowerCase())}"><span class="spec-name-head">${dot(complete)}<strong>${escapeHtml(spec.title)}</strong></span><small>${total ? `${completeCount(spec)}/${total}${tr(' scenarios fully generated')}` : tr('No scenarios generated')}</small></button>`;
2746
+ }).join('')}</div><div class="spec-scene-empty" data-spec-empty hidden>${tr('No matching specs')}</div></div>${project.spec.specs.map((spec, specIndex) => {
2747
+ const total = spec.scenarios.length;
2748
+ const complete = total > 0 && completeCount(spec) === total;
2749
+ return `<article class="spec-detail-panel" data-spec-detail="${specIndex}" ${specIndex ? 'hidden' : ''}><header class="spec-detail-head"><h3>${escapeHtml(spec.title)}</h3><span class="spec-detail-meta">${total}${tr(' scenarios')}</span>${badge(complete ? 'done' : 'in_progress', complete ? tr('Fully generated') : tr('Not fully generated'))}</header>${sourceLine(tr('Spec file'), spec.file)}<div class="spec-scene-list">${spec.scenarios.map((scene) => `<section class="scenario-intro spec-scene"><h4>${dot(scene.complete)}${escapeHtml(scene.name)}</h4><strong>${tr('Scenario overview')}</strong><p>${escapeHtml(scene.description || tr('Not generated'))}</p><strong>${tr('Scenario logic steps')}</strong><div class="scenario-steps">${escapeHtml(scene.steps || tr('Not generated'))}</div></section>`).join('') || `<div class="spec-scene-empty">${tr('This spec has no scenarios generated yet.')}</div>`}</div></article>`;
2750
+ }).join('')}` : `<div class="card empty">${tr('No spec artifacts found.')}</div>`}</article>`).join('')}
2751
+ </section>`;
2752
+ }
2753
+
2754
+ function renderLogic(projects) {
2755
+ const allSpecs = projects.flatMap((project) => project.spec.specs);
2756
+ const allLogic = projects.flatMap((project) => project.logic || []);
2757
+ const specTotal = allSpecs.length;
2758
+ const stageLabels = { A: tr('Design doc'), B: tr('Logic conversion'), B2: tr('Semantic docs'), C: tr('Spec commit') };
2759
+ // The stage summary strip shares its source with the step-4 ring / overview ledger (logicStageScore):
2760
+ // A/B2/C read spec_pipeline_state.json, B uses the 3.1-3.3 disk-evidence caliber — one basis for overview and detail pages.
2761
+ const score = logicStageScore(projects);
2762
+ const hasWaveEvidence = allLogic.some((logic) => (logic.stages ?? []).length > 0);
2763
+ const strip = '<div class="logic-stage-strip">' + ['A', 'B', 'B2', 'C'].map((id) => {
2764
+ const scored = score.stages.find((stage) => stage.id === id) || { done: 0, total: specTotal };
2765
+ let status = 'not_started';
2766
+ let detail = '';
2767
+ if (id === 'B' && !hasWaveEvidence) {
2768
+ detail = tr('No grouped-pipeline artifacts found');
2769
+ } else {
2770
+ status = scored.total > 0 && scored.done >= scored.total ? 'done' : (scored.done > 0 || (id === 'B' && hasWaveEvidence)) ? 'in_progress' : 'not_started';
2771
+ detail = scored.done + '/' + scored.total + tr(' specs done');
2772
+ }
2773
+ return '<button type="button" class="logic-stage-chip" data-logic-stage="' + escapeHtml(id) + '" title="' + escapeHtml(tr('Click to show only pending specs of this stage')) + '"><span class="logic-stage-chip-id">' + escapeHtml(id) + '</span><span class="logic-stage-chip-text"><strong>' + escapeHtml('Stage ' + id + ' · ' + stageLabels[id]) + '</strong><small>' + escapeHtml(detail) + '</small></span>' + badge(status) + '</button>';
2774
+ }).join('') + '</div>';
2775
+
2776
+ // Spec cards: one card presents the spec's full A → B(3.1/3.2/3.3) → B2 → C trail.
2777
+ // B only trusts disk evidence (same caliber as logicStageScore's bDone); the state file's B is the
2778
+ // pipeline's self-report and can drift from evidence — not used for display. skipped is shown honestly
2779
+ // as skipped, never folded into done; the totals count done+skipped as processed.
2780
+ const specEntries = projects.flatMap((project) => (project.spec.specs || []).map((spec) => {
2781
+ const stageOf = (id) => (spec.pipelineStages || []).find((item) => item.id === id);
2782
+ const logicEntry = (project.logic || []).find((logic) => logic.id === spec.id) || null;
2783
+ const bStages = ['3.1', '3.2', '3.3'].map((id) => ((logicEntry && Array.isArray(logicEntry.stages) ? logicEntry.stages.find((s) => s.stage === id) : null)) || { stage: id, status: 'not_started', files: [] });
2784
+ const bProcessed = bStages.filter((s) => ['done', 'skipped'].includes(s.status)).length;
2785
+ const bStatus = bStages.some((s) => s.status === 'blocked') ? 'blocked' : bProcessed === bStages.length ? 'done' : bStages.some((s) => s.status !== 'not_started') ? 'in_progress' : 'not_started';
2786
+ const trail = [
2787
+ { key: 'A', status: (stageOf('A') || {}).status || 'not_started' },
2788
+ ...bStages.map((s) => ({ key: s.stage, status: s.status })),
2789
+ { key: 'B2', status: (stageOf('B2') || {}).status || 'not_started' },
2790
+ { key: 'C', status: (stageOf('C') || {}).status || 'not_started' },
2791
+ ];
2792
+ const processed = trail.filter((item) => ['done', 'skipped'].includes(item.status)).length;
2793
+ const cardStatus = trail.some((item) => item.status === 'blocked') ? 'blocked' : processed === trail.length ? 'done' : processed > 0 ? 'in_progress' : 'not_started';
2794
+
2795
+ const pipelineRow = (id) => {
2796
+ const stage = stageOf(id);
2797
+ const status = stage ? stage.status : 'not_started';
2798
+ const note = stage && stage.note ? stage.note : statusLabel(status);
2799
+ let evidence = escapeHtml(note);
2800
+ if (id === 'A') {
2801
+ // A only reads the state file: the design doc name is written by a2h-spec-design-pipeline into
2802
+ // the design_file field — no disk search or existence check; whether the document exists in the
2803
+ // project copy does not affect the status caliber.
2804
+ const configuredDesign = String(spec.designFile || '').trim().replace(/\\/g, '/');
2805
+ if (configuredDesign) evidence = escapeHtml(path.basename(configuredDesign));
2806
+ }
2807
+ return '<div class="logic-spec-row"><div><span class="logic-spec-stage-head"><i class="scenario-stage-dot ' + escapeHtml(status) + '"></i><strong>' + escapeHtml('Stage ' + id + ' · ' + stageLabels[id]) + '</strong></span><small>' + evidence + '</small></div>' + badge(status) + '</div>';
2808
+ };
2809
+ const bHeadline = bProcessed === bStages.length ? tr('3.1-3.3 all processed') : bProcessed + '/' + bStages.length + tr(' stages processed');
2810
+ const bBlocks = bStages.map((s) => {
2811
+ const fileList = (s.files ?? []).filter(exists).map((file) => path.basename(file)).join(' · ');
2812
+ return '<div class="logic-progress-stage"><div class="logic-progress-stage-summary"><i class="scenario-stage-dot ' + escapeHtml(s.status) + '"></i><strong>' + escapeHtml(s.stage + ' · ' + (LOGIC_STAGE_NAMES[s.stage] ? tr(LOGIC_STAGE_NAMES[s.stage]) : s.stage)) + '</strong>' + badge(s.status) + '</div>' + (fileList ? '<small>' + tr('Evidence: ') + escapeHtml(fileList) + '</small>' : '') + '</div>';
2813
+ }).join('');
2814
+ const bRow = '<div class="logic-spec-stage-block"><div class="logic-progress-summary"><strong>Stage B · ' + escapeHtml(stageLabels.B) + '</strong><span class="logic-progress-segments">' + bStages.map((s) => '<i class="' + escapeHtml(s.status) + '"></i>').join('') + '</span><span class="logic-progress-headline' + (bStatus === 'blocked' ? ' blocked' : '') + '">' + escapeHtml(bHeadline) + '</span></div>' + bBlocks + '</div>';
2815
+ const trailDots = trail.map((item) => '<i class="scenario-stage-dot ' + escapeHtml(item.status) + '" title="' + escapeHtml(item.key) + '"></i>').join('');
2816
+ return {
2817
+ rank: ({ blocked: 0, in_progress: 1, not_started: 2, skipped: 3, done: 4 }[cardStatus] ?? 4), html: '<details data-logic-card data-logic-title="' + escapeHtml(spec.title.toLowerCase()) + '" data-stage-status="' + escapeHtml('A=' + trail[0].status + ';B=' + bStatus + ';B2=' + trail[4].status + ';C=' + trail[5].status) + '" class="logic-progress-spec logic-spec-card ' + escapeHtml(cardStatus) + '"><summary><span class="logic-progress-summary"><strong>' + escapeHtml(tr('Spec:')) + escapeHtml(spec.title) + '</strong><span class="logic-spec-trail">' + trailDots + '</span><span class="logic-spec-card-count">' + escapeHtml(processed + '/' + trail.length + tr(' stages processed')) + '</span></span>' + badge(cardStatus) + '</summary><div class="logic-progress-body">'
2818
+ + pipelineRow('A')
2819
+ + bRow
2820
+ + pipelineRow('B2')
2821
+ + pipelineRow('C')
2822
+ + '</div></details>'
2823
+ };
2824
+ }));
2825
+ specEntries.sort((a, b) => a.rank - b.rank);
2826
+ const specCards = specEntries.map((entry) => entry.html).join('');
2827
+
2828
+ return '<section class="tab" id="logic" data-logic-board>' + tabHero(ICONS.logic, tr('Logic Conversion'), '', ring(score.strictDone, score.specTotal, score.strictDone + '/' + score.specTotal), 'orange') + strip + '<div class="spec-search logic-search-row"><input type="search" data-logic-search placeholder="' + escapeHtml(tr('Search ') + specTotal + tr(' specs')) + '" aria-label="' + escapeHtml(tr('Search specs')) + '"></div>' + '<div class="logic-progress-list">' + (specCards || '<div class="card empty">' + tr('No spec artifacts found.') + '</div>') + '</div><div class="spec-scene-empty" data-logic-empty hidden>' + tr('No matching specs') + '</div></section>';
2829
+ }
2830
+
2831
+
2832
+ // Dashboard stylesheet lives next to this script; re-read on every render so CSS
2833
+ // edits take effect with the 30-second auto-refresh without restarting the server.
2834
+ const DASHBOARD_CSS_PATH = path.join(path.dirname(fileURLToPath(import.meta.url)), 'dashboard.css');
2835
+ function dashboardCss() {
2836
+ try {
2837
+ return fs.readFileSync(DASHBOARD_CSS_PATH, 'utf8');
2838
+ } catch (error) {
2839
+ throw new Error('dashboard.css is missing next to dashboard.mjs (' + DASHBOARD_CSS_PATH + '): ' + error.message);
2840
+ }
2841
+ }
2842
+ function renderHtml(projects, usages = [], architecture = null, options = {}) {
2843
+ const arch = architecture || architectureModel();
2844
+ // Nav status dots derive from the same overview() caliber as the overview page — no second source of truth.
2845
+ const navOv = overview(projects, arch);
2846
+ const navArch = stepStatus(navOv.arch.done, navOv.arch.total);
2847
+ const navUi = stepStatus(navOv.ui.done, navOv.ui.total);
2848
+ const navSpec = stepStatus(navOv.spec.done, navOv.spec.total);
2849
+ const navLogic = logicStepStatus(navOv.logic);
2850
+ const dotCls = (s) => (s === 'done' ? ' nav-state--done' : s === 'in_progress' ? ' nav-state--active' : '');
2851
+ const generated = new Date().toLocaleString(RENDER_LANG === 'en' ? 'en-US' : 'zh-CN', { hour12: false });
2852
+ const shutdownControl = options.shutdownButton
2853
+ ? `<div class="shutdown-wrap"><button id="shutdown-btn" type="button" title="${escapeHtml(tr('Stop the dashboard server (equivalent to Ctrl+C in the launching terminal)'))}">${tr('Stop dashboard')}</button></div>`
2854
+ : '';
2855
+ const shutdownScript = options.shutdownButton
2856
+ ? `document.getElementById('shutdown-btn')?.addEventListener('click',async()=>{if(!confirm('${tr("Stop the dashboard server? This page becomes unavailable; rerun the command in the launching terminal to view it again.")}'))return;window.__a2hShutdown=true;const btn=document.getElementById('shutdown-btn');btn.disabled=true;btn.textContent='${tr("Stopping…")}';try{await fetch('/shutdown',{method:'POST',cache:'no-store'})}catch{/* the server may already be stopped */}document.body.insertAdjacentHTML('beforeend','<div class="shutdown-overlay"><div>${tr("<strong>Dashboard server stopped</strong><br>This page is no longer available; you can close this tab.<br><small>To view it again, rerun the command in the terminal that launched the dashboard.</small>")}</div></div>')});`
2857
+ : '';
2858
+ const shutdownCss = options.shutdownButton
2859
+ ? '.shutdown-wrap{margin-top:10px;padding:0 18px 16px}#shutdown-btn{width:100%;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--secondary);font:inherit;font-size:13px;cursor:pointer;transition:color .15s,border-color .15s,background .15s}#shutdown-btn:hover{color:var(--red);border-color:var(--red);background:var(--danger-dim)}#shutdown-btn:disabled{opacity:.55;cursor:default}.shutdown-overlay{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:var(--scrim)}.shutdown-overlay>div{background:var(--panel);border-radius:12px;padding:28px 32px;max-width:420px;text-align:center;color:var(--text);font-size:15px;line-height:1.8;box-shadow:0 12px 40px rgba(0,0,0,.25)}.shutdown-overlay strong{font-size:17px}'
2860
+ : '';
2861
+ return `<!doctype html><html lang="${RENDER_LANG === 'en' ? 'en' : 'zh-CN'}" data-theme="light"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${tr('HomeTrans Conversion Dashboard')}</title><script>(function(){try{var t=localStorage.getItem('a2h-dashboard-render-theme');if(t==='dark'||t==='light')document.documentElement.dataset.theme=t}catch(e){}})()</script>
2862
+ <style>${dashboardCss()}${shutdownCss}</style></head><body><div class="layout" id="layout"><aside><div class="brand"><b class="logo" aria-hidden="true"><i></i><i></i></b><div class="brand-copy">HomeTrans<span>${tr('Conversion Dashboard')}</span></div></div><div class="workspace"><div class="workspace-label">${tr('Workspace')}</div><div class="workspace-button" title="${escapeHtml(projects.map((p) => p.name).join(', '))}">${ICONS.folder}<span>${escapeHtml(projects.length === 0 ? tr('No project selected') : projects.length === 1 ? projects[0].name : RENDER_LANG === 'en' ? `${projects[0].name} + ${projects.length - 1} more` : projects[0].name + ' and others, ' + projects.length + ' projects in total')}</span></div></div><nav><button data-tab="overview"><svg viewBox="0 0 24 24"><rect x="4" y="4" width="6" height="6"/><rect x="14" y="4" width="6" height="6"/><rect x="4" y="14" width="6" height="6"/><rect x="14" y="14" width="6" height="6"/></svg><span>${tr('Overview')}</span></button><button data-tab="architecture"><svg viewBox="0 0 24 24"><path d="m12 3 8 4-8 4-8-4 8-4Z"/><path d="m4 12 8 4 8-4M4 17l8 4 8-4"/></svg><span>${tr('Architecture')}</span><i class="nav-state${dotCls(navArch)}"></i></button><button data-tab="ui"><svg viewBox="0 0 24 24"><rect x="7" y="2.5" width="10" height="19" rx="2"/><path d="M10 18.5h4"/></svg><span>${tr('UI Migration')}</span><i class="nav-state${dotCls(navUi)}"></i></button><button data-tab="spec"><svg viewBox="0 0 24 24"><circle cx="5" cy="12" r="2"/><circle cx="19" cy="6" r="2"/><circle cx="19" cy="18" r="2"/><path d="M7 12h4c3 0 3-6 6-6M11 12c3 0 3 6 6 6"/></svg><span>${tr('Spec Generation')}</span><i class="nav-state${dotCls(navSpec)}"></i></button><button data-tab="logic"><svg viewBox="0 0 24 24"><path d="m8 8-4 4 4 4M16 8l4 4-4 4M14 4l-4 16"/></svg><span>${tr('Logic Conversion')}</span><i class="nav-state${dotCls(navLogic)}"></i></button></nav><div class="sidebar-footer">${shutdownControl}<button id="collapse-btn" class="collapse-button" type="button" title="${escapeHtml(tr('Collapse / expand nav'))}">${ICONS.collapse}<span>${tr('Collapse nav')}</span></button></div></aside><main><header class="top"><h1>${tr('HomeTrans Conversion Dashboard')}</h1><p>${options.once ? `<span class="live snapshot">${tr('Static snapshot')}</span>` : `<span class="live"><i class="live-dot"></i>${tr('Live · auto-refresh every 30s')}</span>`}${tr('Generated: ')}${escapeHtml(generated)}${options.once ? '' : tr(' (auto-refresh rescans artifacts on disk only; device screenshots are captured once at dashboard startup)')}</p><button id="theme-toggle" class="theme-toggle" type="button" title="${escapeHtml(tr('Switch light / dark theme'))}" aria-label="${escapeHtml(tr('Switch between light and dark themes'))}"><svg class="icon-moon" viewBox="0 0 24 24"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8Z"/></svg><svg class="icon-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4M2 12h2m16 0h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg></button></header>${renderOverview(projects, usages, arch, options.usageScanning === true)}${renderArchitecture(arch, projects)}${renderUi(projects)}${renderSpec(projects)}${renderLogic(projects)}</main></div>
2863
+ <script>
2864
+ const tabKey='a2h-dashboard-render-node-tab', scrollKey='a2h-dashboard-render-scroll', openKey='a2h-dashboard-render-open', sceneKey='a2h-dashboard-render-scene', uiPageKey='a2h-dashboard-render-ui-page';
2865
+ function replay(node){if(!node)return;node.classList.remove('hm-reenter');void node.offsetWidth;node.classList.add('hm-reenter')}
2866
+ function framePixels(img,width,height){const canvas=document.createElement('canvas');canvas.width=width;canvas.height=height;const ctx=canvas.getContext('2d',{willReadFrequently:true});ctx.drawImage(img,0,0,width,height);return {canvas,ctx,data:ctx.getImageData(0,0,width,height).data}}
2867
+ function clampRegion(region,width,height){const left=Math.max(0,Math.min(width,Number(region?.left)||0)),top=Math.max(0,Math.min(height,Number(region?.top)||0)),right=Math.max(left,Math.min(width,Number(region?.right)||width)),bottom=Math.max(top,Math.min(height,Number(region?.bottom)||height));return {left,top,right,bottom,area:(right-left)*(bottom-top)}}
2868
+ function regionDifference(a,b,region,width){const xs=Math.max(2,Math.floor((region.right-region.left)/48)),ys=Math.max(2,Math.floor((region.bottom-region.top)/90));let error=0,count=0;for(let y=region.top;y<region.bottom;y+=ys){for(let x=region.left;x<region.right;x+=xs){const p=(Math.floor(y)*width+Math.floor(x))*4;error+=Math.abs(a.data[p]-b.data[p])+Math.abs(a.data[p+1]-b.data[p+1])+Math.abs(a.data[p+2]-b.data[p+2]);count+=3}}return error/Math.max(1,count)}
2869
+ function sameRegion(a,b){return Math.abs(a.left-b.left)<12&&Math.abs(a.top-b.top)<12&&Math.abs(a.right-b.right)<12&&Math.abs(a.bottom-b.bottom)<12}
2870
+ function activeScrollRegion(prev,next,prevRegions,nextRegions,width,height){const fallback={left:0,top:0,right:width,bottom:height,area:width*height};const stable=nextRegions.map((item)=>clampRegion(item,width,height)).filter((item)=>prevRegions.map((old)=>clampRegion(old,width,height)).some((old)=>sameRegion(old,item))).map((item)=>({item,diff:regionDifference(prev,next,item,width)})).filter((row)=>row.diff>2.2).sort((a,b)=>a.item.area-b.item.area);if(stable.length)return stable[0].item;const outer=nextRegions.map((item)=>clampRegion(item,width,height)).sort((a,b)=>b.area-a.area)[0];return outer||fallback}
2871
+ function regionOverlap(prev,next,region,width){const h=Math.floor(region.bottom-region.top),w=Math.floor(region.right-region.left),lo=Math.max(8,Math.floor(h*.08)),hi=Math.max(lo+1,Math.floor(h*.94)),candidateStep=Math.max(1,Math.floor(h/260)),xStep=Math.max(3,Math.floor(w/52));let best=0,bestScore=Infinity;for(let overlap=lo;overlap<=hi;overlap+=candidateStep){const yStep=Math.max(2,Math.floor(overlap/42));let error=0,count=0;for(let y=0;y<overlap;y+=yStep){const py=Math.floor(region.bottom-overlap+y),ny=Math.floor(region.top+y);for(let x=Math.floor(region.left);x<region.right;x+=xStep){const p=(py*width+x)*4,n=(ny*width+x)*4;error+=Math.abs(prev.data[p]-next.data[n])+Math.abs(prev.data[p+1]-next.data[n+1])+Math.abs(prev.data[p+2]-next.data[n+2]);count+=3}}const score=error/Math.max(1,count);if(score<bestScore){bestScore=score;best=overlap}}return bestScore<38?best:0}
2872
+ ${stitchOverlapDecision.toString()}
2873
+ ${nestedStitchBoundary.toString()}
2874
+ async function stitchCapture(box){
2875
+ const imgs=[...box.querySelectorAll('[data-stitch-frame]')];
2876
+ await Promise.all(imgs.map((img)=>img.complete&&img.naturalWidth?Promise.resolve():img.decode().catch(()=>{})));
2877
+ const valid=imgs.filter((img)=>img.naturalWidth&&img.naturalHeight);
2878
+ if(valid.length<2)return;
2879
+ const width=Math.min(...valid.map((img)=>img.naturalWidth)),height=Math.min(...valid.map((img)=>img.naturalHeight));
2880
+ const frames=valid.map((img)=>framePixels(img,width,height));
2881
+ let regions=[],offsets=[];
2882
+ try{regions=JSON.parse(box.dataset.scrollRegions||'[]')}catch{}
2883
+ try{offsets=JSON.parse(box.dataset.scrollOffsets||'[]')}catch{}
2884
+ while(regions.length<frames.length)regions.push([]);
2885
+
2886
+ const fallback={left:0,top:0,right:width,bottom:height,area:width*height};
2887
+ const firstOuter=(regions[0]||[]).map((item)=>clampRegion(item,width,height)).sort((a,b)=>b.area-a.area)[0]||fallback;
2888
+ const transitions=[];
2889
+ for(let i=1;i<frames.length;i++){
2890
+ const region=activeScrollRegion(frames[i-1],frames[i],regions[i-1]||[],regions[i]||[],width,height);
2891
+ const diff=regionDifference(frames[i-1],frames[i],region,width);
2892
+ if(diff<1.2)continue;
2893
+ const regionHeight=region.bottom-region.top;
2894
+ const hintedOffset=Number(offsets[i]);
2895
+ const hasStructuredRegion=(regions[i]||[]).length>0;
2896
+ const overlap=stitchOverlapDecision(hintedOffset,regionHeight,hasStructuredRegion,regionOverlap(frames[i-1],frames[i],region,width));
2897
+ const cropTop=Math.min(region.bottom,region.top+overlap);
2898
+ const cropHeight=Math.max(0,region.bottom-cropTop);
2899
+ if(cropHeight>3)transitions.push({frame:frames[i],top:cropTop,height:cropHeight,region,frameIndex:i});
2900
+ }
2901
+
2902
+ const phaseRegions=[firstOuter,...transitions.map((item)=>item.region)];
2903
+ const nestedBoundary=nestedStitchBoundary(phaseRegions);
2904
+ let segments=transitions.map((item,index)=>({...item,transitionIndex:index}));
2905
+ const possibleOuterFooter=height-firstOuter.bottom;
2906
+ const useOuterFooter=possibleOuterFooter>2&&possibleOuterFooter<height*.15;
2907
+ let baseHeight=useOuterFooter?firstOuter.bottom:height;
2908
+ let trailingFooter=useOuterFooter?{frame:frames.at(-1),top:height-possibleOuterFooter,height:possibleOuterFooter}:null;
2909
+
2910
+ if(nestedBoundary){
2911
+ const footerTop=Math.max(0,Math.min(height,nestedBoundary.footerTop));
2912
+ const previousTransitionIndex=nestedBoundary.previousRegionIndex-1;
2913
+ if(previousTransitionIndex<0){
2914
+ baseHeight=Math.min(baseHeight,footerTop);
2915
+ }else{
2916
+ const previous=segments.find((item)=>item.transitionIndex===previousTransitionIndex);
2917
+ if(previous){
2918
+ const trimmedBottom=Math.min(previous.top+previous.height,footerTop);
2919
+ previous.height=Math.max(0,trimmedBottom-previous.top);
2920
+ }
2921
+ }
2922
+ segments=segments.filter((item)=>item.height>3);
2923
+ if(footerTop<height-2)trailingFooter={frame:frames.at(-1),top:footerTop,height:height-footerTop};
2924
+ else trailingFooter=null;
2925
+ }
2926
+
2927
+ const total=baseHeight+segments.reduce((sum,item)=>sum+item.height,0)+(trailingFooter?trailingFooter.height:0);
2928
+ const canvas=box.querySelector('canvas');
2929
+ canvas.width=width;
2930
+ canvas.height=Math.max(1,total);
2931
+ const ctx=canvas.getContext('2d');
2932
+ let y=0;
2933
+ ctx.drawImage(frames[0].canvas,0,0,width,baseHeight,0,y,width,baseHeight);
2934
+ y+=baseHeight;
2935
+ for(const item of segments){
2936
+ ctx.drawImage(item.frame.canvas,0,item.top,width,item.height,0,y,width,item.height);
2937
+ y+=item.height;
2938
+ }
2939
+ if(trailingFooter)ctx.drawImage(trailingFooter.frame.canvas,0,trailingFooter.top,width,trailingFooter.height,0,y,width,trailingFooter.height);
2940
+ box.querySelectorAll('.capture-marker').forEach((marker)=>{const ratio=height/Math.max(1,total);marker.style.top=(parseFloat(marker.style.top||'0')*ratio)+'%';marker.style.height=(parseFloat(marker.style.height||'0')*ratio)+'%'});
2941
+ box.dataset.stitched='true';
2942
+ }
2943
+ document.querySelectorAll('[data-capture-stitch]').forEach((box)=>stitchCapture(box));
2944
+ function show(id){document.querySelectorAll('.tab').forEach(x=>x.classList.toggle('active',x.id===id));document.querySelectorAll('nav button').forEach(x=>x.classList.toggle('active',x.dataset.tab===id));localStorage.setItem(tabKey,id);window.scrollTo({top:0,left:0,behavior:'auto'})}
2945
+ window.show=show;document.querySelectorAll('nav button').forEach(x=>x.onclick=()=>show(x.dataset.tab));show(location.hash.slice(1)||localStorage.getItem(tabKey)||'overview');
2946
+ const themeToggle=document.getElementById('theme-toggle');themeToggle?.addEventListener('click',()=>{const next=document.documentElement.dataset.theme==='dark'?'light':'dark';document.documentElement.dataset.theme=next;try{localStorage.setItem('a2h-dashboard-render-theme',next)}catch{}dispatchEvent(new Event('resize'))});
2947
+ const navKey='a2h-dashboard-render-nav';
2948
+ function navCollapsed(){try{return localStorage.getItem(navKey)==='collapsed'}catch{return false}}
2949
+ function applyNavState(){document.getElementById('layout')?.classList.toggle('nav-collapsed',navCollapsed());const span=document.querySelector('#collapse-btn span');if(span)span.textContent=navCollapsed()?'${tr("Expand nav")}':'${tr("Collapse nav")}'}
2950
+ document.getElementById('collapse-btn')?.addEventListener('click',()=>{try{localStorage.setItem(navKey,navCollapsed()?'expanded':'collapsed')}catch{}applyNavState()});
2951
+ try{applyNavState()}catch{}
2952
+ function storedObject(key){try{const value=JSON.parse(localStorage.getItem(key)||'{}');return value&&typeof value==='object'?value:{}}catch{return {}}}
2953
+ function detailOpenId(detail,index){const summary=(detail.querySelector(':scope > summary')?.textContent||'').trim();const stage=(detail.closest('.logic-spec-card')?.querySelector(':scope > summary .logic-progress-summary > strong')?.textContent||'').trim();return detail.dataset.openKey||detail.id||[detail.closest('.tab')?.id||'page',stage,summary||index].join(':')}
2954
+ const savedOpen=storedObject(openKey);document.querySelectorAll('details').forEach((d,i)=>{const id=detailOpenId(d,i);if(Object.prototype.hasOwnProperty.call(savedOpen,id))d.open=Boolean(savedOpen[id]);d.addEventListener('toggle',()=>{const now=storedObject(openKey);now[id]=d.open;localStorage.setItem(openKey,JSON.stringify(now))})});
2955
+ const uiSaved=storedObject(uiPageKey),uiControllers=[];let activeUiController=null;
2956
+ document.querySelectorAll('.ui-project').forEach(box=>{const slides=[...box.querySelectorAll('[data-ui-slide]')],pageCards=[...box.querySelectorAll('[data-page-card]')],projectId=box.dataset.uiProject||String(uiControllers.length),pendingOnlyInput=box.querySelector('[data-ui-pending-only]'),titleSearch=box.querySelector('[data-ui-title-search]'),titleJump=box.querySelector('[data-ui-title-jump]'),count=box.querySelector('[data-ui-count]'),stack=box.querySelector('[data-ui-stack]'),empty=box.querySelector('[data-ui-filter-empty]');const saved=uiSaved[projectId];let pendingOnly=Boolean(typeof saved==='object'&&saved?.pendingOnly);let i=Math.max(0,Math.min(slides.length-1,Number(typeof saved==='object'&&saved?saved.index:saved)||0));
2957
+ function inScope(slide){return !pendingOnly||slide.dataset.uiStatus!=='done'}
2958
+ function visible(){return slides.filter(inScope)}
2959
+ function persist(){uiSaved[projectId]={index:i,pendingOnly};localStorage.setItem(uiPageKey,JSON.stringify(uiSaved))}
2960
+ function paint(direction=0){const scoped=visible();if(!scoped.some((slide)=>Number(slide.dataset.uiSlide)===i)&&scoped.length)i=Number(scoped[0].dataset.uiSlide);slides.forEach((slide)=>{const active=Number(slide.dataset.uiSlide)===i&&inScope(slide);slide.hidden=!active;slide.classList.remove('ui-enter-next','ui-enter-prev');slide.tabIndex=active?0:-1});pageCards.forEach((card)=>{const idx=Number(card.dataset.pageCard);card.hidden=pendingOnly&&card.dataset.uiStatus==='done';card.classList.toggle('is-active',idx===i&&(!pendingOnly||card.dataset.uiStatus!=='done'))});const current=slides.find((slide)=>Number(slide.dataset.uiSlide)===i&&inScope(slide));if(current&&direction){void current.offsetWidth;current.classList.add(direction>0?'ui-enter-next':'ui-enter-prev')}const rank=current?scoped.indexOf(current)+1:0;if(count)count.textContent=rank+' / '+scoped.length;const activeCard=pageCards.find((card)=>Number(card.dataset.pageCard)===i&&card.offsetParent);if(activeCard){const grid=activeCard.closest('.page-grid');if(grid){const g=grid.getBoundingClientRect(),c=activeCard.getBoundingClientRect();if(c.top<g.top)grid.scrollTop+=c.top-g.top;else if(c.bottom>g.bottom)grid.scrollTop+=c.bottom-g.bottom}}if(empty)empty.hidden=scoped.length>0||!slides.length;if(pendingOnlyInput)pendingOnlyInput.checked=pendingOnly;persist()}
2961
+ function go(delta){const scoped=visible();if(!scoped.length)return;const current=scoped.findIndex((slide)=>Number(slide.dataset.uiSlide)===i);const next=(Math.max(0,current)+delta+scoped.length)%scoped.length;i=Number(scoped[next].dataset.uiSlide);paint(delta)}
2962
+ function jumpToTitle(){const query=String(titleSearch?.value||'').toLowerCase().replace(/\\s+/g,'');const match=query?visible().find((slide)=>(slide.dataset.uiTitle||'').includes(query)):null;if(!match){titleSearch?.classList.remove('is-invalid');void titleSearch?.offsetWidth;titleSearch?.classList.add('is-invalid');setTimeout(()=>titleSearch?.classList.remove('is-invalid'),420);return}i=Number(match.dataset.uiSlide);paint(1)}
2963
+ const controller={box,go};uiControllers.push(controller);activeUiController??=controller;box.addEventListener('pointerenter',()=>{activeUiController=controller});box.addEventListener('focusin',()=>{activeUiController=controller});box.querySelector('[data-ui-prev]')?.addEventListener('click',(event)=>{event.stopPropagation();go(-1)});box.querySelector('[data-ui-next]')?.addEventListener('click',(event)=>{event.stopPropagation();go(1)});pageCards.forEach((card)=>card.addEventListener('click',function(){i=Number(card.dataset.pageCard);paint(1);var target=box.querySelector('[data-ui-slide="'+i+'"]');if(target)target.scrollIntoView({behavior:'smooth',block:'nearest'})}));pendingOnlyInput?.addEventListener('change',()=>{pendingOnly=pendingOnlyInput.checked;i=Number(visible()[0]?.dataset.uiSlide||0);paint(1)});titleJump?.addEventListener('click',(event)=>{event.stopPropagation();jumpToTitle()});titleSearch?.addEventListener('keydown',(event)=>{if(event.key==='Enter'){event.preventDefault();jumpToTitle()}});paint()});
2964
+ function markerLinkTarget(node){return node?.closest?.('[data-marker]')||null}
2965
+ function setMarkerLink(target){const keyed=markerLinkTarget(target);if(!keyed)return;const scope=keyed.closest('.ui-slide');if(!scope)return;const key=keyed.dataset.marker;scope.classList.add('marker-linking');scope.querySelectorAll('[data-marker]').forEach((peer)=>peer.classList.toggle('marker-peer-active',peer.dataset.marker===key))}
2966
+ function clearMarkerLink(scope){if(!scope)return;scope.classList.remove('marker-linking');scope.querySelectorAll('.marker-peer-active').forEach((peer)=>peer.classList.remove('marker-peer-active'))}
2967
+ document.addEventListener('pointerover',(event)=>{if(markerLinkTarget(event.target))setMarkerLink(event.target)});
2968
+ document.addEventListener('pointerout',(event)=>{const from=markerLinkTarget(event.target);if(!from)return;const to=markerLinkTarget(event.relatedTarget);if(to&&to.dataset.marker===from.dataset.marker)return;clearMarkerLink(from.closest('.ui-slide'))});
2969
+ document.addEventListener('focusin',(event)=>{if(markerLinkTarget(event.target))setMarkerLink(event.target)});
2970
+ document.addEventListener('focusout',(event)=>{const from=markerLinkTarget(event.target);if(!from)return;const to=markerLinkTarget(event.relatedTarget);if(to&&to.dataset.marker===from.dataset.marker)return;clearMarkerLink(from.closest('.ui-slide'))});
2971
+ addEventListener('keydown',(event)=>{if(!document.getElementById('ui')?.classList.contains('active'))return;if(event.altKey||event.ctrlKey||event.metaKey||event.shiftKey)return;const target=event.target;if(target?.matches?.('input,textarea,select,[contenteditable="true"]'))return;if(event.key==='ArrowLeft'||event.key==='ArrowRight'){event.preventDefault();(activeUiController||uiControllers[0])?.go(event.key==='ArrowLeft'?-1:1)}});
2972
+ const sceneState=storedObject(sceneKey);
2973
+ document.querySelectorAll('[data-spec-board]').forEach((board)=>{const boardId=board.dataset.specBoard;const items=[...board.querySelectorAll('.spec-name-item')];const panels=[...board.querySelectorAll('[data-spec-detail]')];const saved=sceneState[boardId]||{};const savedActive=Number(saved.activeSpec);const current={activeSpec:items[savedActive]?savedActive:0};
2974
+ function paint(){sceneState[boardId]={activeSpec:current.activeSpec};localStorage.setItem(sceneKey,JSON.stringify(sceneState));items.forEach((x)=>{const active=Number(x.dataset.specIndex)===current.activeSpec;x.classList.toggle('is-active',active);x.setAttribute('aria-current',active?'true':'false')});panels.forEach((x)=>x.hidden=Number(x.dataset.specDetail)!==current.activeSpec);const activeItem=items[current.activeSpec];if(activeItem&&!activeItem.hidden){const list=activeItem.closest('.spec-name-list');if(list){const l=list.getBoundingClientRect(),a=activeItem.getBoundingClientRect();if(a.top<l.top)list.scrollTop+=a.top-l.top;else if(a.bottom>l.bottom)list.scrollTop+=a.bottom-l.bottom}}replay(panels.find((x)=>!x.hidden))}
2975
+ items.forEach((x)=>x.addEventListener('click',()=>{current.activeSpec=Number(x.dataset.specIndex);paint()}));const search=board.querySelector('[data-spec-search]'),empty=board.querySelector('[data-spec-empty]');if(search)search.addEventListener('input',()=>{const query=search.value.trim().toLowerCase();let any=false;items.forEach((x)=>{const hit=!query||String(x.dataset.specTitle).includes(query);x.hidden=!hit;any=any||hit});if(empty)empty.hidden=any||!items.length});paint();});
2976
+ document.querySelectorAll('[data-logic-board]').forEach((board)=>{const cards=[...board.querySelectorAll('[data-logic-card]')];const chips=[...board.querySelectorAll('[data-logic-stage]')];const search=board.querySelector('[data-logic-search]');const empty=board.querySelector('[data-logic-empty]');const problems=['blocked','in_progress','not_started'];let stageFilter=null,query='';
2977
+ function paint(){let any=false;cards.forEach((x)=>{const okStage=!stageFilter||String(x.dataset.stageStatus).split(';').some((pair)=>pair.startsWith(stageFilter+'=')&&problems.includes(pair.slice(stageFilter.length+1)));const okQuery=!query||String(x.dataset.logicTitle).includes(query);const show=okStage&&okQuery;x.hidden=!show;any=any||show});if(empty)empty.hidden=any||!cards.length;chips.forEach((x)=>x.classList.toggle('is-active',x.dataset.logicStage===stageFilter))}
2978
+ chips.forEach((x)=>x.addEventListener('click',()=>{stageFilter=stageFilter===x.dataset.logicStage?null:x.dataset.logicStage;paint()}));
2979
+ if(search)search.addEventListener('input',()=>{query=search.value.trim().toLowerCase();paint()});
2980
+ paint();});
2981
+ function snapshotState(){const now={};document.querySelectorAll('details').forEach((d,i)=>{now[detailOpenId(d,i)]=d.open});localStorage.setItem(openKey,JSON.stringify(now));localStorage.setItem(scrollKey,JSON.stringify({tab:document.querySelector('.tab.active')?.id||'overview',y:scrollY}))}
2982
+ let savedScroll={};try{const parsed=JSON.parse(localStorage.getItem(scrollKey)||'{}');savedScroll=typeof parsed==='number'?{y:parsed}:parsed||{}}catch{savedScroll={y:Number(localStorage.getItem(scrollKey))||0}}requestAnimationFrame(()=>scrollTo(0,Number(savedScroll.y)||0));addEventListener('pagehide',snapshotState);addEventListener('beforeunload',snapshotState);
2983
+ ${options.once ? '' : ` // Probe before reloading: a healthy server picks up new artifacts every 30
2984
+ // seconds; a stopped server leaves the current rendered dashboard visible.
2985
+ // Reloading only rebuilds HTML and never starts another device capture.
2986
+ setTimeout(async()=>{if(window.__a2hShutdown)return;try{const response=await fetch(location.href,{cache:'no-store',headers:{'x-a2h-dashboard-render-probe':'1'}});if(!response.ok)return;snapshotState();location.reload()}catch{/* Keep the current dashboard visible while the server is unavailable. */}},30000);`}
2987
+ ${shutdownScript}
2988
+ </script></body></html>`;
2989
+ }
2990
+
2991
+ function build(config, captureState = null) {
2992
+ return config.entries.map((entry) => projectModel(entry, config.specNames, captureState));
2993
+ }
2994
+
2995
+ function listenWithFallback(server, startPort, maxAttempts = 20, onFallback = null) {
2996
+ return new Promise((resolve, reject) => {
2997
+ if (!Number.isInteger(startPort) || startPort < 1 || startPort > 65535) {
2998
+ reject(new Error(`Invalid port: ${startPort}`));
2999
+ return;
3000
+ }
3001
+ const attemptsAllowed = Math.max(1, Math.min(Number(maxAttempts) || 1, 65536 - startPort));
3002
+ let attempts = 0;
3003
+ const retryable = (error) => error && (error.code === 'EADDRINUSE' || error.code === 'EACCES');
3004
+ const tryListen = (port) => {
3005
+ attempts += 1;
3006
+ const onError = (error) => {
3007
+ server.removeListener('listening', onListening);
3008
+ if (retryable(error) && attempts < attemptsAllowed) {
3009
+ onFallback?.(port, port + 1, error);
3010
+ tryListen(port + 1);
3011
+ return;
3012
+ }
3013
+ reject(error);
3014
+ };
3015
+ const onListening = () => {
3016
+ server.removeListener('error', onError);
3017
+ resolve(port);
3018
+ };
3019
+ server.once('error', onError);
3020
+ server.once('listening', onListening);
3021
+ server.listen(port, '127.0.0.1');
3022
+ };
3023
+ tryListen(startPort);
3024
+ });
3025
+ }
3026
+
3027
+ function openBrowser(url) {
3028
+ const command = process.platform === 'win32' ? ['cmd', ['/c', 'start', '', url]] : process.platform === 'darwin' ? ['open', [url]] : ['xdg-open', [url]];
3029
+ const child = spawn(command[0], command[1], { detached: true, stdio: 'ignore', windowsHide: true });
3030
+ // In non-interactive shells (agent tool sessions, services) the desktop open
3031
+ // can fail; never let that surface as an uncaught exception — just tell the
3032
+ // user where the board lives.
3033
+ child.on('error', (error) => {
3034
+ console.error(`[a2h-dashboard-render] Failed to open the browser automatically: ${error.message}; visit ${url} manually`);
3035
+ });
3036
+ child.unref();
3037
+ }
3038
+
3039
+ async function main() {
3040
+ try {
3041
+ if (!supportsNodeVersion()) {
3042
+ throw new Error(`Node.js version too old: running ${process.versions.node}, >=22.18.0 required`);
3043
+ }
3044
+ const args = parseArgs(process.argv.slice(2));
3045
+ if (args.help) { console.log(helpText()); return; }
3046
+ const config = loadEntries(args);
3047
+ const captureManager = new DeviceCaptureManager(config.entries);
3048
+ if (args.once) {
3049
+ const out = path.resolve(args.out || 'dashboard-node.html');
3050
+ console.log('[a2h-dashboard-render] Capturing screenshots from the connected HarmonyOS device (the Android side reuses UI migration artifacts, no device attached); on failure the local cache is kept as fallback...');
3051
+ await captureManager.refresh({ force: true });
3052
+ const projects = build(config, captureManager.snapshot());
3053
+ const usageSources = resolveUsageSources(config.usageSources);
3054
+ let usages = [];
3055
+ if (usageSources.length) {
3056
+ console.log(`[a2h-dashboard-render] Collecting Agent usage (${usageSources.join(', ')}); a large local session store can take minutes...`);
3057
+ const usageStartedAt = Date.now();
3058
+ usages = collectUsage(projects, config.usageSources);
3059
+ console.log(`[a2h-dashboard-render] Agent usage collected in ${((Date.now() - usageStartedAt) / 1000).toFixed(1)}s.`);
3060
+ }
3061
+ fs.mkdirSync(path.dirname(out), { recursive: true });
3062
+ fs.writeFileSync(out, renderHtml(projects, usages, architectureModel(config), { once: true }), 'utf8');
3063
+ console.log(`[a2h-dashboard-render] Node static dashboard written: ${out}`);
3064
+ if (args.open) openBrowser(out);
3065
+ return;
3066
+ }
3067
+ captureManager.start();
3068
+ // Usage stats refresh on a background worker thread: collectUsage scans the local session database
3069
+ // synchronously — minutes on large libraries; it must never enter the request path. Requests only ever
3070
+ // read usageCache; the page shows "collecting" until the first scan completes.
3071
+ const usageCache = { value: [], scanning: false };
3072
+ const usageRefresh = () => {
3073
+ if (usageCache.scanning) return;
3074
+ usageCache.scanning = true;
3075
+ let worker;
3076
+ try {
3077
+ // The payload is rebuilt every round: during an active migration the manifest's TOTAL End moves later
3078
+ // and new Specs join logic — reusing the startup window would freeze the token totals at stale values.
3079
+ worker = new Worker(usageWorkerUrl, { workerData: { projects: usageProjectsPayload(build(config, null)), requested: config.usageSources } });
3080
+ } catch (error) {
3081
+ usageCache.scanning = false;
3082
+ console.error(`[a2h-dashboard-render] Usage scan worker failed to start: ${error?.message || error}`);
3083
+ return;
3084
+ }
3085
+ const timeout = setTimeout(() => {
3086
+ console.error('[a2h-dashboard-render] Usage scan exceeded 5 minutes; this round is discarded.');
3087
+ try { worker.terminate(); } catch { /* already dead */ }
3088
+ }, 5 * 60_000).unref();
3089
+ worker.on('message', (msg) => {
3090
+ clearTimeout(timeout);
3091
+ usageCache.scanning = false;
3092
+ if (msg?.ok) usageCache.value = msg.usage;
3093
+ else console.error(`[a2h-dashboard-render] Usage scan failed: ${msg?.error || 'unknown error'}`);
3094
+ });
3095
+ worker.on('error', (error) => {
3096
+ clearTimeout(timeout);
3097
+ usageCache.scanning = false;
3098
+ console.error(`[a2h-dashboard-render] Usage scan worker crashed: ${error?.message || error}`);
3099
+ });
3100
+ worker.on('exit', () => {
3101
+ clearTimeout(timeout);
3102
+ usageCache.scanning = false;
3103
+ });
3104
+ };
3105
+ usageRefresh();
3106
+ const usageTimer = setInterval(usageRefresh, 30_000);
3107
+ usageTimer.unref();
3108
+ const server = http.createServer((request, response) => {
3109
+ if (request.url === '/favicon.ico') { response.writeHead(204); response.end(); return; }
3110
+ if (request.url === '/shutdown') {
3111
+ if (request.method !== 'POST') {
3112
+ response.writeHead(405, { 'content-type': 'text/plain; charset=utf-8', allow: 'POST' });
3113
+ response.end('Send a POST request to shut down (the "Stop dashboard" button in the page\'s bottom-left corner).');
3114
+ return;
3115
+ }
3116
+ console.error('[a2h-dashboard-render] Received a shutdown request from the web page; stopping the dashboard server.');
3117
+ response.writeHead(200, { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' });
3118
+ response.end('ok');
3119
+ response.on('finish', () => {
3120
+ clearInterval(keepAlive);
3121
+ clearInterval(usageTimer);
3122
+ captureManager.stop();
3123
+ server.closeAllConnections?.();
3124
+ server.close(() => {
3125
+ console.error('[a2h-dashboard-render] Dashboard server stopped.');
3126
+ process.exit(0);
3127
+ });
3128
+ setTimeout(() => process.exit(0), 1500).unref();
3129
+ });
3130
+ return;
3131
+ }
3132
+ try {
3133
+ const projects = build(config, captureManager.snapshot());
3134
+ const body = renderHtml(projects, usageCache.value, architectureModel(config), { shutdownButton: true, usageScanning: usageCache.scanning && !usageCache.value.length });
3135
+ response.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' });
3136
+ response.end(body);
3137
+ } catch (error) {
3138
+ response.writeHead(500, { 'content-type': 'text/plain; charset=utf-8' });
3139
+ response.end(`Dashboard render failed: ${error.stack || error}`);
3140
+ }
3141
+ });
3142
+ let listeningPort = args.port;
3143
+ try {
3144
+ listeningPort = await listenWithFallback(server, args.port, args.portExplicit ? 1 : 20, (from, to) => {
3145
+ console.error(`[a2h-dashboard-render] Port ${from} is in use; falling back to ${to}.`);
3146
+ });
3147
+ } catch (error) {
3148
+ console.error(`[a2h-dashboard-render] Cannot listen on port ${args.port}: ${error.code ? `${error.code} ` : ''}${error.message}`);
3149
+ console.error(args.portExplicit
3150
+ ? 'This port was explicitly requested via --port and will not be shifted; free it or pick another one.'
3151
+ : 'The default port and all its fallback candidates are busy; pass --port explicitly with a free port.');
3152
+ captureManager.stop();
3153
+ process.exit(1);
3154
+ }
3155
+ server.on('error', (error) => {
3156
+ console.error(`[a2h-dashboard-render] HTTP server error: ${error.stack || error}`);
3157
+ });
3158
+ const url = `http://127.0.0.1:${listeningPort}/`;
3159
+ console.log(`[a2h-dashboard-render] Node.js ${process.version}`);
3160
+ console.log(`[a2h-dashboard-render] Tracking ${config.entries.length} project(s)`);
3161
+ console.log(`[a2h-dashboard-render] Open ${url} (stop via Ctrl+C or the "Stop dashboard" button in the page's bottom-left corner)`);
3162
+ if (args.open) openBrowser(url);
3163
+ // Keep one explicit referenced handle for the dashboard lifetime. The
3164
+ // service may only shut itself down after a foreground Ctrl+C (SIGINT);
3165
+ // capture completion, an empty event loop, or a recoverable error must not
3166
+ // make the PowerShell prompt return by itself.
3167
+ const keepAlive = setInterval(() => { }, 60_000);
3168
+ const stop = () => {
3169
+ console.error('[a2h-dashboard-render] Received Ctrl+C; stopping the dashboard server.');
3170
+ clearInterval(keepAlive);
3171
+ captureManager.stop();
3172
+ server.close(() => console.error('[a2h-dashboard-render] Dashboard server stopped.'));
3173
+ };
3174
+ process.once('SIGINT', stop);
3175
+ process.on('SIGTERM', () => {
3176
+ console.error('[a2h-dashboard-render] Received SIGTERM; per the run rules the server keeps running — stop it with a foreground Ctrl+C.');
3177
+ });
3178
+ process.on('uncaughtException', (error, origin) => {
3179
+ console.error(`[a2h-dashboard-render] Uncaught exception (${origin}); the dashboard server keeps running: ${error.stack || error}`);
3180
+ });
3181
+ process.on('unhandledRejection', (reason) => {
3182
+ console.error(`[a2h-dashboard-render] Unhandled rejection; the dashboard server keeps running: ${reason?.stack || reason}`);
3183
+ });
3184
+ process.once('beforeExit', (code) => {
3185
+ console.error(`[a2h-dashboard-render] Node event loop ended unexpectedly (exitCode=${code}).`);
3186
+ });
3187
+ process.once('exit', (code) => {
3188
+ console.error(`[a2h-dashboard-render] Node process exiting (exitCode=${code}).`);
3189
+ });
3190
+ } catch (error) {
3191
+ console.error(`[a2h-dashboard-render] ${error.message}`);
3192
+ process.exitCode = 1;
3193
+ }
3194
+ }
3195
+
3196
+ export {
3197
+ architectureModel,
3198
+ build,
3199
+ captureFrameOffsets,
3200
+ captureFrames,
3201
+ collectUsage,
3202
+ findSpecs,
3203
+ findUiProgress,
3204
+ listenWithFallback,
3205
+ loadEntries,
3206
+ logicForSpec,
3207
+ logicStepStatus,
3208
+ overview,
3209
+ parseArgs,
3210
+ parseScenarios,
3211
+ projectModel,
3212
+ renderArchitecture,
3213
+ renderHtml,
3214
+ trCaptureDetail,
3215
+ resolveUsageSources,
3216
+ specPipelineModel,
3217
+ reviewScenarioTitleKey,
3218
+ reviewVerdictStatus,
3219
+ statusBucket,
3220
+ statusLabel,
3221
+ supportsNodeVersion,
3222
+ tr,
3223
+ trMarkerLabel,
3224
+ translateScenarioName,
3225
+ nestedStitchBoundary,
3226
+ stitchOverlapDecision,
3227
+ usageProjectsPayload,
3228
+ };
3229
+
3230
+ // Node realpaths import.meta.url (the main module) but keeps process.argv[1]
3231
+ // as typed, and neither normalises the Windows drive-letter case; comparing
3232
+ // the two naively made a symlinked/junctioned invocation (a common way to
3233
+ // install skills) a silent no-op exit 0 — for a gate script that means the
3234
+ // gate silently PASSES. Compare canonical real paths instead.
3235
+ function canonicalScriptPath(p) {
3236
+ let out;
3237
+ try {
3238
+ out = fs.realpathSync.native(p);
3239
+ } catch {
3240
+ out = path.resolve(p);
3241
+ }
3242
+ return process.platform === "win32" ? out.toLowerCase() : out;
3243
+ }
3244
+
3245
+ if (canonicalScriptPath(process.argv[1] || '') === canonicalScriptPath(fileURLToPath(import.meta.url))) await main();