@buaa_smat/hometrans 26.0.2 → 26.0.3

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 (1053) hide show
  1. package/README.md +7 -6
  2. package/agents/code-reviewer.md +25 -138
  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 +364 -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 +198 -0
  14. package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
  15. package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
  16. package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
  17. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +1760 -0
  18. package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
  19. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1588 -0
  20. package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +657 -0
  21. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
  22. package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +131 -0
  23. package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  24. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  25. package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  26. package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  27. package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +698 -0
  28. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
  29. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  30. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  31. package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  32. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +219 -0
  33. package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +196 -0
  34. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
  35. package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +488 -0
  36. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  37. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +146 -0
  38. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +161 -0
  39. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  40. package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  41. package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  42. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +171 -0
  43. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  44. package/i18n/skills/a2h-arch-generate/SKILL.md +375 -0
  45. package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  46. package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  47. package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
  48. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  49. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  50. package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  51. package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  52. package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  53. package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  54. package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  55. package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +120 -0
  56. package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  57. package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
  58. package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
  59. package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  60. package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
  61. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  62. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  63. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  64. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  65. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  66. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  67. package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
  68. package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  69. package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
  70. package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
  71. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +9 -0
  72. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +192 -0
  73. package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +303 -0
  74. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
  75. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
  76. package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +587 -0
  77. package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  78. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  79. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  80. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  81. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  82. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  83. package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  84. package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +352 -0
  85. package/i18n/skills/a2h-batch-ui-align/SKILL.md +323 -0
  86. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +31 -0
  87. package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  88. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  89. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  90. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +80 -0
  91. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +22 -0
  92. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +87 -0
  93. package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  94. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  95. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +57 -0
  96. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +29 -0
  97. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +705 -0
  98. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +417 -0
  99. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
  100. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  101. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2549 -0
  102. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
  103. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +148 -0
  104. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +220 -0
  105. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
  106. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +216 -0
  107. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +203 -0
  108. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +210 -0
  109. package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
  110. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1748 -0
  111. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  112. package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  113. package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  114. package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1787 -0
  115. package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  116. package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  117. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1836 -0
  118. package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
  119. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1406 -0
  120. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1226 -0
  121. package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1220 -0
  122. package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +412 -0
  123. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  124. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
  125. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +173 -0
  126. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +629 -0
  127. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  128. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +67 -0
  129. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  130. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  131. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  132. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
  133. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  134. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
  135. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  136. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  137. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  138. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  139. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  140. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  141. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  142. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  143. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  144. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +551 -0
  145. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  146. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +374 -0
  147. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  148. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  149. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +119 -0
  150. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  151. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  152. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +80 -0
  153. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
  154. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  155. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  156. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  157. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +97 -0
  158. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  159. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -0
  160. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  161. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  162. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  163. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  164. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  165. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  166. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  167. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  168. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  169. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  170. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +123 -0
  171. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  172. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  173. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
  174. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  175. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  176. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  177. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  178. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +427 -0
  179. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  180. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  181. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  182. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  183. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  184. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +560 -0
  185. package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
  186. package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  187. package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  188. package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  189. package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  190. package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +324 -0
  191. package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  192. package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +325 -0
  193. package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +48 -0
  194. package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +387 -0
  195. package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  196. package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  197. package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  198. package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +59 -0
  199. package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
  200. package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
  201. package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  202. package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  203. package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  204. package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
  205. package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2048 -0
  206. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  207. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  208. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  209. package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  210. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  211. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  212. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
  213. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  214. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  215. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  216. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  217. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  218. package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  219. package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  220. package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
  221. package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  222. package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  223. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +227 -0
  224. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  225. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  226. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  227. package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  228. package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  229. package/i18n/skills/a2h-page-specgen/SKILL.md +136 -0
  230. package/i18n/skills/a2h-page-specgen/references/body-language.md +177 -0
  231. package/i18n/skills/a2h-page-specgen/references/gates.md +262 -0
  232. package/i18n/skills/a2h-page-specgen/references/page-inventory.md +173 -0
  233. package/i18n/skills/a2h-page-specgen/references/spec-template.md +207 -0
  234. package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1504 -0
  235. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1528 -0
  236. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +576 -0
  237. package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +138 -0
  238. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +262 -0
  239. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +176 -0
  240. package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +248 -0
  241. package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  242. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +506 -0
  243. package/i18n/skills/a2h-page-specgen/scripts/render.mjs +299 -0
  244. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +616 -0
  245. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +234 -0
  246. package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1166 -0
  247. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +74 -0
  248. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
  249. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
  250. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
  251. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  252. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +758 -0
  253. package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  254. package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +54 -0
  255. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +271 -0
  256. package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +54 -0
  257. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +171 -0
  258. package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +301 -0
  259. package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +83 -0
  260. package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +139 -0
  261. package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +774 -0
  262. package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1011 -0
  263. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +77 -0
  264. package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +419 -0
  265. package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  266. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +323 -0
  267. package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +546 -0
  268. package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +511 -0
  269. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +701 -0
  270. package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  271. package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1765 -0
  272. package/i18n/skills/a2h-resource-convert/SKILL.md +367 -0
  273. package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +335 -0
  274. package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
  275. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +219 -0
  276. package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
  277. package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
  278. package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  279. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2532 -0
  280. package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  281. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +278 -0
  282. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +260 -0
  283. package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +163 -0
  284. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +44 -0
  285. package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  286. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +589 -0
  287. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +506 -0
  288. package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
  289. package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
  290. package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  291. package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  292. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
  293. package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
  294. package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  295. package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  296. package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  297. package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
  298. package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  299. package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  300. package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  301. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
  302. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  303. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  304. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  305. package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
  306. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
  307. package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  308. package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  309. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
  310. package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
  311. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
  312. package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
  313. package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
  314. package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
  315. package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
  316. package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
  317. package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
  318. package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
  319. package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
  320. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  321. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  322. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  323. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  324. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
  325. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
  326. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
  327. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
  328. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  329. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
  330. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
  331. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
  332. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
  333. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
  334. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
  335. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  336. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
  337. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
  338. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
  339. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  340. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
  341. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  342. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  343. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  344. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  345. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  346. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  347. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
  348. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
  349. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
  350. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
  351. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  352. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  353. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  354. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  355. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  356. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  357. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  358. package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
  359. package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  360. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
  361. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
  362. package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
  363. package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  364. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  365. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  366. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  367. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  368. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  369. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  370. package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  371. package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  372. package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  373. package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  374. package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  375. package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  376. package/i18n/skills/a2h-utg-explorer/SKILL.md +120 -0
  377. package/i18n/skills/a2h-utg-explorer/references/architecture.md +279 -0
  378. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +918 -0
  379. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
  380. package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
  381. package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  382. package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
  383. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +380 -0
  384. package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  385. package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  386. package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  387. package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  388. package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  389. package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  390. package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  391. package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +492 -0
  392. package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +199 -0
  393. package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  394. package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  395. package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  396. package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  397. package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  398. package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  399. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  400. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  401. package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  402. package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  403. package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  404. package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  405. package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  406. package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  407. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1412 -0
  408. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2037 -0
  409. package/i18n/skills/a2h-utg-static/SKILL.md +368 -0
  410. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  411. package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
  412. package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2120 -0
  413. package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  414. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +609 -0
  415. package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
  416. package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
  417. package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  418. package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
  419. package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
  420. package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  421. package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +913 -0
  422. package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +517 -0
  423. package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  424. package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
  425. package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  426. package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  427. package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  428. package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  429. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
  430. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  431. package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  432. package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  433. package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  434. package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  435. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  436. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  437. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
  438. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  439. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  440. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  441. package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  442. package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
  443. package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  444. package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
  445. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  446. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  447. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  448. package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  449. package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  450. package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  451. package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  452. package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  453. package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  454. package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  455. package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  456. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  457. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  458. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
  459. package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  460. package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1351 -0
  461. package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  462. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  463. package/package.json +13 -160
  464. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  465. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  466. package/skills/a2h-app-migrate/SKILL.md +17 -6
  467. package/skills/a2h-app-migrate/references/config.example.json +1 -0
  468. package/skills/a2h-app-migrate/references/stage-map.md +3 -1
  469. package/skills/a2h-app-migrate/references/workflow.yaml +138 -47
  470. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +1 -2
  471. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +105 -39
  472. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +7 -8
  473. package/skills/a2h-app-migrate/scripts/ledger.mjs +17 -5
  474. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +43 -7
  475. package/skills/a2h-app-migrate/scripts/run_dir.mjs +127 -41
  476. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
  477. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
  478. package/skills/a2h-app-migrate/test/test_android_index.mjs +131 -0
  479. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  480. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  481. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  482. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  483. package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
  484. package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  485. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
  486. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +698 -0
  487. package/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
  488. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  489. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  490. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
  491. package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  492. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +91 -0
  493. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  494. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  495. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +111 -0
  496. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +53 -0
  497. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  498. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  499. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +219 -0
  500. package/skills/a2h-app-migrate/test/test_resume_summary.mjs +196 -0
  501. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
  502. package/skills/a2h-app-migrate/test/test_run_dir.mjs +488 -0
  503. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  504. package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
  505. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +147 -0
  506. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +146 -0
  507. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +161 -0
  508. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +344 -0
  509. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  510. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +53 -0
  511. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  512. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  513. package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  514. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
  515. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +178 -0
  516. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  517. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  518. package/skills/a2h-arch-generate/SKILL.md +1 -1
  519. package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
  520. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
  521. package/skills/a2h-arch-generate/references/homegraph-workflow.md +15 -6
  522. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
  523. package/skills/a2h-arch-generate/references/source-baseline.md +2 -2
  524. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
  525. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
  526. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
  527. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  528. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  529. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  530. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  531. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  532. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  533. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  534. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  535. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  536. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  537. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  538. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  539. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  540. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  541. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  542. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  543. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  544. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  545. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  546. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  547. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  548. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  549. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  550. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  551. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  552. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  553. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  554. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
  555. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +191 -0
  556. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  557. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  558. package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  559. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
  560. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
  561. package/skills/a2h-arkts-logic-coder/SKILL.md +21 -2
  562. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -0
  563. package/skills/a2h-arkts-logic-coder/references/code-generation.md +62 -0
  564. package/skills/a2h-arkts-logic-coder/references/spec-design.md +4 -0
  565. package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
  566. package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +583 -0
  567. package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
  568. package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  569. package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  570. package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  571. package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
  572. package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  573. package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  574. package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  575. package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +352 -0
  576. package/skills/a2h-batch-ui-align/SKILL.md +6 -4
  577. package/skills/a2h-batch-ui-align/references/cards/geometry.md +1 -1
  578. package/skills/a2h-batch-ui-align/references/cards/resources.md +4 -0
  579. package/skills/a2h-batch-ui-align/references/cards/widgets.md +22 -3
  580. package/skills/a2h-batch-ui-align/references/checker-rules.md +66 -3
  581. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +45 -8
  582. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +7 -5
  583. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
  584. package/skills/a2h-batch-ui-align/references/step4-prepare.md +4 -2
  585. package/skills/a2h-batch-ui-align/references/step5-convert.md +7 -5
  586. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
  587. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +84 -7
  588. package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  589. package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +229 -0
  590. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1 -2
  591. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
  592. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +88 -26
  593. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +305 -12
  594. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
  595. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +8 -9
  596. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +18 -5
  597. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +103 -3
  598. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
  599. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
  600. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +14 -8
  601. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
  602. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
  603. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
  604. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
  605. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
  606. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
  607. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  608. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
  609. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
  610. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +66 -2
  611. package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +119 -0
  612. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
  613. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  614. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +123 -0
  615. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
  616. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +6 -0
  617. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +217 -0
  618. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  619. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
  620. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  621. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  622. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  623. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  624. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +427 -0
  625. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  626. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  627. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +235 -0
  628. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  629. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  630. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
  631. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  632. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
  633. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  634. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +567 -0
  635. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +290 -0
  636. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +74 -0
  637. package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
  638. package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
  639. package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +420 -0
  640. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  641. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  642. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  643. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  644. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  645. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1628 -0
  646. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  647. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  648. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  649. package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  650. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +324 -0
  651. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  652. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +325 -0
  653. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +297 -0
  654. package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +48 -0
  655. package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +387 -0
  656. package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  657. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  658. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  659. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
  660. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
  661. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  662. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  663. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  664. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  665. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  666. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  667. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  668. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  669. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  670. package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
  671. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  672. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  673. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  674. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  675. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  676. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  677. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  678. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  679. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  680. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  681. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  682. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  683. package/skills/a2h-page-specgen/SKILL.md +136 -0
  684. package/skills/a2h-page-specgen/references/body-language.md +177 -0
  685. package/skills/a2h-page-specgen/references/evidence.md +70 -0
  686. package/skills/a2h-page-specgen/references/execution-model.md +255 -0
  687. package/skills/a2h-page-specgen/references/footprint-and-grouping.md +250 -0
  688. package/skills/a2h-page-specgen/references/gates.md +255 -0
  689. package/skills/a2h-page-specgen/references/page-inventory.md +173 -0
  690. package/skills/a2h-page-specgen/references/spec-template.md +207 -0
  691. package/skills/a2h-page-specgen/scripts/dispatch.mjs +209 -0
  692. package/skills/a2h-page-specgen/scripts/facts-build.mjs +1504 -0
  693. package/skills/a2h-page-specgen/scripts/finalize.mjs +422 -0
  694. package/skills/a2h-page-specgen/scripts/footprint.mjs +1528 -0
  695. package/skills/a2h-page-specgen/scripts/gate.mjs +558 -0
  696. package/skills/a2h-page-specgen/scripts/interactions.mjs +137 -0
  697. package/skills/a2h-page-specgen/scripts/inventory.mjs +269 -0
  698. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +255 -0
  699. package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
  700. package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +137 -0
  701. package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
  702. package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
  703. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +175 -0
  704. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +355 -0
  705. package/skills/a2h-page-specgen/scripts/lib/prose.mjs +234 -0
  706. package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  707. package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +391 -0
  708. package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
  709. package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
  710. package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
  711. package/skills/a2h-page-specgen/scripts/prepare.mjs +492 -0
  712. package/skills/a2h-page-specgen/scripts/render.mjs +317 -0
  713. package/skills/a2h-page-specgen/scripts/report.mjs +7 -0
  714. package/skills/a2h-page-specgen/scripts/submission.mjs +532 -0
  715. package/skills/a2h-page-specgen/scripts/submit.mjs +79 -0
  716. package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
  717. package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +590 -0
  718. package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
  719. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +207 -0
  720. package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
  721. package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1164 -0
  722. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +74 -0
  723. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
  724. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
  725. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
  726. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
  727. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
  728. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
  729. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
  730. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
  731. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
  732. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
  733. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
  734. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
  735. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
  736. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
  737. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
  738. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
  739. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
  740. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
  741. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
  742. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
  743. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
  744. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
  745. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
  746. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
  747. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
  748. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
  749. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
  750. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
  751. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
  752. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
  753. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
  754. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
  755. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
  756. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
  757. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
  758. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
  759. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
  760. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
  761. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
  762. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
  763. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
  764. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
  765. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
  766. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
  767. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
  768. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
  769. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
  770. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
  771. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
  772. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
  773. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
  774. package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
  775. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +94 -0
  776. package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
  777. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
  778. package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
  779. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  780. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
  781. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
  782. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +758 -0
  783. package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
  784. package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  785. package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +54 -0
  786. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +222 -0
  787. package/skills/a2h-page-specgen/scripts/test/helpers.mjs +54 -0
  788. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +171 -0
  789. package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +301 -0
  790. package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +45 -0
  791. package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +139 -0
  792. package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +774 -0
  793. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
  794. package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1011 -0
  795. package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +120 -0
  796. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +68 -0
  797. package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +390 -0
  798. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +167 -0
  799. package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  800. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +323 -0
  801. package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +546 -0
  802. package/skills/a2h-page-specgen/scripts/test/render.test.mjs +503 -0
  803. package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
  804. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +701 -0
  805. package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  806. package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
  807. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1765 -0
  808. package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1979 -0
  809. package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +313 -0
  810. package/skills/a2h-page-specgen/scripts/waker.mjs +1234 -0
  811. package/skills/a2h-page-specgen/scripts/watchdog.mjs +298 -0
  812. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +49 -51
  813. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  814. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  815. package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  816. package/skills/a2h-spec-design-pipeline/SKILL.md +79 -78
  817. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +51 -12
  818. package/skills/a2h-spec-design-pipeline/references/execution-model.md +24 -6
  819. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +3 -2
  820. package/skills/a2h-spec-design-pipeline/references/initialization.md +15 -4
  821. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +82 -41
  822. package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +61 -0
  823. package/skills/a2h-spec-design-pipeline/references/scripts.md +19 -10
  824. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +267 -0
  825. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +61 -8
  826. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +62 -13
  827. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +8 -0
  828. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +8 -0
  829. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-cn.md +55 -0
  830. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-en.md +60 -0
  831. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/HttpExtraDataEmptyStringCheck.js +488 -0
  832. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +11 -0
  833. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +17 -0
  834. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
  835. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +40 -5
  836. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +18 -0
  837. package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +74 -0
  838. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +1 -1
  839. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +1 -1
  840. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
  841. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +128 -5
  842. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +98 -35
  843. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +218 -37
  844. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
  845. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
  846. package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
  847. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +6 -7
  848. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
  849. package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +348 -0
  850. package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
  851. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +15 -5
  852. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +7 -2
  853. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +104 -1
  854. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +24 -0
  855. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +394 -0
  856. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +24 -1
  857. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +14 -0
  858. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +163 -5
  859. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +15 -7
  860. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
  861. package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +350 -0
  862. package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
  863. package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
  864. package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
  865. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +121 -0
  866. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
  867. package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
  868. package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
  869. package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
  870. package/skills/a2h-spec-generate/SKILL.md +87 -21
  871. package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
  872. package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  873. package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
  874. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  875. package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
  876. package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
  877. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
  878. package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
  879. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
  880. package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
  881. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
  882. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
  883. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
  884. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
  885. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
  886. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
  887. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
  888. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
  889. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
  890. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
  891. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
  892. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
  893. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  894. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
  895. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
  896. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
  897. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
  898. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
  899. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
  900. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
  901. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
  902. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
  903. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
  904. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
  905. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  906. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  907. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  908. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  909. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
  910. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
  911. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  912. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  913. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  914. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
  915. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  916. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
  917. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
  918. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
  919. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
  920. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
  921. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  922. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  923. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  924. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  925. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  926. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  927. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  928. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  929. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  930. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  931. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  932. package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
  933. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
  934. package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
  935. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
  936. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  937. package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
  938. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +230 -0
  939. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  940. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  941. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  942. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  943. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  944. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  945. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  946. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  947. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  948. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  949. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  950. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  951. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  952. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  953. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  954. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  955. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  956. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  957. package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  958. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
  959. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  960. package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  961. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  962. package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  963. package/skills/a2h-utg-explorer/references/architecture.md +4 -0
  964. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +64 -80
  965. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
  966. package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
  967. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
  968. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  969. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
  970. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  971. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  972. package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  973. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  974. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
  975. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
  976. package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
  977. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  978. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  979. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
  980. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  981. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  982. package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
  983. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  984. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  985. package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
  986. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +492 -0
  987. package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +199 -0
  988. package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
  989. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  990. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  991. package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  992. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  993. package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  994. package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  995. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  996. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  997. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  998. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  999. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  1000. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  1001. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +454 -0
  1002. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  1003. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  1004. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  1005. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  1006. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
  1007. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  1008. package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
  1009. package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
  1010. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  1011. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  1012. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  1013. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  1014. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  1015. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +13 -3
  1016. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +107 -65
  1017. package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +155 -0
  1018. package/skills/a2h-utg-static/scripts/assemble.mjs +28 -3
  1019. package/skills/a2h-utg-static/scripts/click_paths.mjs +19 -20
  1020. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +102 -2
  1021. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
  1022. package/skills/a2h-utg-static/scripts/nl_hints.mjs +2 -3
  1023. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
  1024. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
  1025. package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
  1026. package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
  1027. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
  1028. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
  1029. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
  1030. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
  1031. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
  1032. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
  1033. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
  1034. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
  1035. package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
  1036. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
  1037. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
  1038. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
  1039. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
  1040. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
  1041. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
  1042. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
  1043. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
  1044. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
  1045. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
  1046. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
  1047. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
  1048. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
  1049. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
  1050. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
  1051. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
  1052. package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
  1053. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
@@ -0,0 +1,1528 @@
1
+ // footprint.mjs — page -> source file, per-page footprint, grouping, and plan construction.
2
+
3
+ import crypto from "node:crypto";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { types } from "node:util";
7
+ import { slugify, toPosix } from "./lib/fsx.mjs";
8
+ import { bfsFiles, findLabelFile } from "./lib/hg.mjs";
9
+ import { RUNTIME_RE, roleOf, bucketOf } from "./lib/footprint-roles.mjs";
10
+
11
+ // source resolution rung 1/2: a `declared_at` that already names a source file.
12
+ const SOURCE_EXT_RE = /\.(java|kt|kts|vue|nvue|uvue|ets|js|mjs|cjs|jsx|ts|tsx)$/i;
13
+
14
+ // source resolution rung 3: the Android page table.
15
+ const MANIFEST_RE = /(^|\/)AndroidManifest\.xml$/i;
16
+
17
+ // source resolution rung 4: uniapp's route table.
18
+ const PAGES_JSON_RE = /(^|\/)pages\.json$/i;
19
+
20
+ // source resolution rung 4: the extensions a uniapp route may resolve to, in probe order.
21
+ const UNIAPP_PAGE_EXTS = [".vue", ".nvue", ".uvue", ".js", ".ts"];
22
+
23
+ // BFS depth for footprint traversal.
24
+ export const FOOTPRINT_DEPTH = 3;
25
+
26
+ /**
27
+ * The five values `resolvePageFiles` returns in `by`, as the single source of
28
+ * truth for both the literals below and any consumer that needs the ladder's
29
+ * outcome set (the grouping report records which rung resolved each page).
30
+ * Key order is rung order.
31
+ */
32
+ export const RESOLVE_BY = Object.freeze({
33
+ DECLARED_AT: "declared_at",
34
+ REG_LABEL: "reg-label",
35
+ MANIFEST_LABEL: "manifest-label",
36
+ UNIAPP_ROUTE: "uniapp-route",
37
+ UNRESOLVED: "unresolved",
38
+ });
39
+
40
+ /**
41
+ * POSIX form with `.`/empty segments dropped and runs of `/` collapsed.
42
+ *
43
+ * Absoluteness is preserved, exactly as `roleOf` does it: `roleOf`'s
44
+ * `sourceRoots` gate compares paths against roots with the same leading-slash
45
+ * rule, so stripping it here would make an absolute `file_path` compare as if
46
+ * it were repo-relative and silently fall outside every root.
47
+ */
48
+ function normalize(p) {
49
+ const raw = toPosix(p);
50
+ const absolute = raw.startsWith("/");
51
+ const parts = [];
52
+ for (const seg of raw.split("/")) {
53
+ if (seg === "" || seg === ".") continue;
54
+ parts.push(seg);
55
+ }
56
+ const joined = parts.join("/");
57
+ return absolute ? `/${joined}` : joined;
58
+ }
59
+
60
+ /**
61
+ * Strip a trailing `:line` (or `:line:col`) suffix.
62
+ *
63
+ * source resolution rung 2 looks `declared_at` up in `sharedDeclaredAt`, which is counted
64
+ * without line numbers. Strip the suffix before lookup so shared registration files are
65
+ * disambiguated through the page label.
66
+ */
67
+ export function stripDeclaredLine(declaredAt) {
68
+ if (typeof declaredAt !== "string") return null;
69
+ return declaredAt.replace(/(?::\d+)+$/, "");
70
+ }
71
+
72
+ /**
73
+ * source resolution: the set of source files that more than one page declares.
74
+ *
75
+ * Computed over ALL pages at once — a single page cannot know it shares its
76
+ * `declared_at` with others. Counting happens on the `:line`-stripped path;
77
+ * only source files participate (an `AndroidManifest.xml` shared by many
78
+ * activities is normal and is rung 3's business, not rung 2's).
79
+ *
80
+ * @param {{declared_at?: string|null}[]} pages
81
+ * @returns {Set<string>} repo-relative paths declared by >1 page
82
+ */
83
+ export function sharedDeclaredAtOf(pages) {
84
+ const counts = new Map();
85
+ for (const page of pages) {
86
+ const raw = stripDeclaredLine(page?.declared_at ?? null);
87
+ if (raw === null) continue;
88
+ const p = normalize(raw);
89
+ if (!SOURCE_EXT_RE.test(p)) continue;
90
+ counts.set(p, (counts.get(p) ?? 0) + 1);
91
+ }
92
+ return new Set([...counts].filter(([, n]) => n > 1).map(([p]) => p));
93
+ }
94
+
95
+ /**
96
+ * Route table from `<sourceProject>/pages.json` (source resolution rung 4): `pages[].path`
97
+ * (and each `subPackages[]` entry's root+path) mapped to the first existing
98
+ * `<sourceProject>/src/<path><ext>`.
99
+ *
100
+ * Absent `pages.json` is not an error — it just means this project has no
101
+ * uniapp routes. A *malformed* one throws: an unreadable route table would
102
+ * otherwise produce a footprint of 0 for every uniapp page, which reads as
103
+ * "no shared files, no conflicts" instead of "not computable" (footprint).
104
+ *
105
+ * @param {string} sourceProject
106
+ * @returns {Map<string, string>} route -> repo-relative file path
107
+ */
108
+ export function pagesJsonRoutesFrom(sourceProject) {
109
+ const file = path.join(sourceProject, "pages.json");
110
+ const routes = new Map();
111
+ if (!fs.existsSync(file)) return routes;
112
+
113
+ let json;
114
+ try {
115
+ // HBuilderX writes `pages.json` with a UTF-8 BOM, and `JSON.parse` rejects
116
+ // it. Stripping it is a decode of the same document, not a lenient parse:
117
+ // genuinely malformed JSON still throws below.
118
+ json = JSON.parse(fs.readFileSync(file, "utf8").replace(/^/, ""));
119
+ } catch (err) {
120
+ throw new Error(`pages.json is not valid JSON (${file}): ${err.message}`);
121
+ }
122
+
123
+ const candidates = [];
124
+ for (const page of json?.pages ?? []) {
125
+ if (typeof page?.path === "string") candidates.push(page.path);
126
+ }
127
+ for (const sub of json?.subPackages ?? json?.subpackages ?? []) {
128
+ const root = typeof sub?.root === "string" ? sub.root : "";
129
+ for (const page of sub?.pages ?? []) {
130
+ if (typeof page?.path !== "string") continue;
131
+ candidates.push(root ? `${root}/${page.path}` : page.path);
132
+ }
133
+ }
134
+
135
+ for (const raw of candidates) {
136
+ const route = normalize(raw);
137
+ if (route === "" || routes.has(route)) continue;
138
+ const found = UNIAPP_PAGE_EXTS
139
+ .map((ext) => `src/${route}${ext}`)
140
+ .find((rel) => fs.existsSync(path.join(sourceProject, ...rel.split("/"))));
141
+ if (found) routes.set(route, found);
142
+ }
143
+ return routes;
144
+ }
145
+
146
+ /**
147
+ * Route a uniapp page id names, e.g.
148
+ * `hybrid-page:__UNI__A/pages/index/index` -> `pages/index/index`.
149
+ *
150
+ * Two prefixes are stripped, in order:
151
+ *
152
+ * 1. the kind prefix (`hybrid-page:`), which is colon-terminated;
153
+ * 2. the uniapp app-id segment (`__UNI__A/`).
154
+ *
155
+ * What is left IS the route, `pages/` and all. Stripping the app-id matters for
156
+ * subpackages: `hybrid-page:__UNI__A/subpkg/pages/list/index` must route to
157
+ * `subpkg/pages/list/index`, not to the bare `pages/list/index` tail — which
158
+ * would happily hit a top-level `src/pages/list/index.vue` if one exists, i.e. a
159
+ * wrong-but-plausible file that feeds a complete, believable footprint for the
160
+ * wrong page.
161
+ *
162
+ * The final `pages/` extraction is GREEDY (`.*[:/]`), so for any id that still
163
+ * carries prefix segments the LAST `pages/` wins rather than the first.
164
+ */
165
+ function routeOfPageId(pageId) {
166
+ const id = String(pageId ?? "");
167
+ const rest = id.replace(/^[^:/]*:/, "");
168
+
169
+ // With an app-id segment the remainder IS the route, subpackage prefix and
170
+ // all. Collapsing to the last `pages/` here would drop `subpkg/`, which is
171
+ // the wrong-but-plausible-file subpackage case.
172
+ const appId = /^__UNI__[^/]*\/(.+)$/.exec(rest);
173
+ if (appId) return appId[1].includes("/") ? appId[1] : null;
174
+
175
+ // No app id: fall back to the last `pages/` segment. Greedy (`.*[:/]`) so a
176
+ // route carrying its own `pages/` prefix resolves at the LAST one.
177
+ const m = /(?:^|.*[:/])(pages\/[^/].*)$/.exec(rest);
178
+ return m ? m[1] : null;
179
+ }
180
+
181
+ /**
182
+ * `pagesJsonRoutes` lookup: exact, then a unique suffix match so a subpackage
183
+ * route (`pages/x/y` filed under `subpkg/`) still resolves. Two suffix matches
184
+ * are ambiguous and therefore no match — a guess here would attach the page to
185
+ * an arbitrary file.
186
+ */
187
+ function routeLookup(routes, route) {
188
+ if (!(routes instanceof Map) || route === null) return null;
189
+ if (routes.has(route)) return routes.get(route);
190
+ const suffix = `/${route}`;
191
+ const hits = [...routes].filter(([k]) => normalize(k).endsWith(suffix));
192
+ return hits.length === 1 ? hits[0][1] : null;
193
+ }
194
+
195
+ /**
196
+ * Ask the graph for the file of the node named `label` (source resolution rung 2/3).
197
+ *
198
+ * Uses `findLabelFile`, not `findClassFile`: Compose routes are registered as
199
+ * `composable(...)` **function** nodes, so a class-only lookup returns null for
200
+ * exactly the pages rung 2 exists to disambiguate. Accepts either a real
201
+ * `DatabaseSync` (openReadOnly) or the two-method stand-in used by the tests.
202
+ *
203
+ * A label equal to `exclude` is treated as a miss: when the registration
204
+ * file declares the route under the filename's own name, the graph resolves the
205
+ * label back to the very file `declared_at` named, and "succeeding" with it
206
+ * would hand this page the registration file's footprint — the identical-surface
207
+ * ambiguity rung 2 rejects.
208
+ */
209
+ function labelFile(db, label, exclude = null) {
210
+ if (!db || typeof label !== "string" || label === "") return null;
211
+ // A stand-in db may expose only one of the two lookups; a real DatabaseSync
212
+ // exposes neither and is queried through `findLabelFile(db, ...)`.
213
+ const found = typeof db.findLabelFile === "function"
214
+ ? db.findLabelFile(label)
215
+ : typeof db.findClassFile === "function"
216
+ ? db.findClassFile(label)
217
+ : findLabelFile(db, label);
218
+ if (found === null || found === undefined) return null;
219
+ const p = normalize(found);
220
+ if (exclude !== null && p === exclude) return null;
221
+ return p;
222
+ }
223
+
224
+ /**
225
+ * source resolution — resolve one page to its source file.
226
+ *
227
+ * The four rungs are tried in order and the first hit wins; nothing else is
228
+ * inferred. In particular a rung-2 miss does NOT fall back to the shared
229
+ * registration file, because that would hand several routes the same footprint.
230
+ *
231
+ * @param {object} args
232
+ * @param {{page_id?: string, kind?: string|null, label?: string|null,
233
+ * declared_at?: string|null}} args.page
234
+ * @param {string} args.sourceProject
235
+ * @param {object|null} args.db homegraph handle (needed by rungs 2 and 3)
236
+ * @param {Map<string,string>} [args.pagesJsonRoutes] route -> file
237
+ * @param {Set<string>} [args.sharedDeclaredAt] files declared by >1 page
238
+ * @returns {{file: string|null, by: string}}
239
+ * @throws {TypeError} when `page` is not an object.
240
+ */
241
+ export function resolvePageFiles({
242
+ page,
243
+ sourceProject,
244
+ db = null,
245
+ pagesJsonRoutes = new Map(),
246
+ sharedDeclaredAt = new Set(),
247
+ } = {}) {
248
+ if (!page || typeof page !== "object") {
249
+ throw new TypeError("resolvePageFiles: page must be an object");
250
+ }
251
+ const declaredRaw = stripDeclaredLine(page.declared_at ?? null);
252
+ const declared = declaredRaw === null ? null : normalize(declaredRaw);
253
+
254
+ // Rung 1 / 2 — declared_at is already a source file.
255
+ if (declared !== null && SOURCE_EXT_RE.test(declared)) {
256
+ const shared = sharedDeclaredAt instanceof Set
257
+ ? sharedDeclaredAt.has(declared)
258
+ : false;
259
+ if (!shared) return { file: declared, by: RESOLVE_BY.DECLARED_AT };
260
+ const viaLabel = labelFile(db, page.label, declared);
261
+ if (viaLabel) return { file: viaLabel, by: RESOLVE_BY.REG_LABEL };
262
+ return { file: null, by: RESOLVE_BY.UNRESOLVED };
263
+ }
264
+
265
+ // Rung 3 — AndroidManifest.xml: the label is the activity class.
266
+ if (declared !== null && MANIFEST_RE.test(declared)) {
267
+ const viaLabel = labelFile(db, page.label);
268
+ if (viaLabel) return { file: viaLabel, by: RESOLVE_BY.MANIFEST_LABEL };
269
+ }
270
+
271
+ // Rung 4 — uniapp: the route is the file path.
272
+ const isUniapp = page.kind === "hybrid-page"
273
+ || (declared !== null && PAGES_JSON_RE.test(declared));
274
+ if (isUniapp) {
275
+ const route = routeOfPageId(page.page_id);
276
+ if (route !== null) {
277
+ const hit = routeLookup(pagesJsonRoutes, route);
278
+ if (hit) return { file: normalize(hit), by: RESOLVE_BY.UNIAPP_ROUTE };
279
+ // The table may be missing an entry the caller never built; probing the
280
+ // documented locations is a presence test, not a guess.
281
+ if (typeof sourceProject === "string" && sourceProject !== "") {
282
+ for (const ext of UNIAPP_PAGE_EXTS) {
283
+ const rel = `src/${route}${ext}`;
284
+ if (fs.existsSync(path.join(sourceProject, ...rel.split("/")))) {
285
+ return { file: rel, by: RESOLVE_BY.UNIAPP_ROUTE };
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+
292
+ return { file: null, by: RESOLVE_BY.UNRESOLVED };
293
+ }
294
+
295
+ /**
296
+ * source resolution RUNTIME: is this path SDK/vendor output that the footprint must exclude?
297
+ *
298
+ * RUNTIME_RE is frozen verbatim, so three of its alternatives (`/www/`,
299
+ * `/assets/apps/`, `/dist/`) carry a leading slash and only match a rooted
300
+ * path. The bare filenames it also names (`uni-app-view.umd.js`,
301
+ * `vite.config.js`) are normally handed in unrooted, so the path is tested in
302
+ * both forms — the same rooting `roleOf` uses internally.
303
+ *
304
+ * `uni_modules/` is deliberately NOT here: footprint places it in role
305
+ * classification (`roleOf`), and duplicating it would split one rule in two.
306
+ */
307
+ export function isRuntime(file) {
308
+ if (typeof file !== "string") {
309
+ throw new TypeError(`isRuntime expects a path string, got ${typeof file}`);
310
+ }
311
+ const p = normalize(file);
312
+ return RUNTIME_RE.test(p) || RUNTIME_RE.test(`/${p}`);
313
+ }
314
+
315
+ /**
316
+ * `ctx` handed to `roleOf`, with null/undefined values dropped.
317
+ *
318
+ * `roleOf` THROWS on `wiringPaths: null` and on a null `sourceRoots`, but for
319
+ * our callers both mean the same thing as an absent key: "not determined".
320
+ * Dropping them is the one conversion that keeps that meaning, so a caller can
321
+ * pass a plain result object without pre-filtering it. Every other value is
322
+ * forwarded untouched — `roleOf`'s strictness is the point, and swallowing it
323
+ * here would let a vendored file be classified writable.
324
+ */
325
+ function normalizeCtx(ctx) {
326
+ if (ctx === null || ctx === undefined) return {};
327
+ if (typeof ctx !== "object") {
328
+ throw new TypeError(`computeFootprint: ctx must be an object, got ${typeof ctx}`);
329
+ }
330
+ const out = {};
331
+ for (const [k, v] of Object.entries(ctx)) {
332
+ if (v === null || v === undefined) continue;
333
+ out[k] = v;
334
+ }
335
+ return out;
336
+ }
337
+
338
+ /**
339
+ * footprint — per-page implementation surface.
340
+ *
341
+ * For each page: resolve its file (source resolution), BFS it at depth 3 over the traversed
342
+ * edge kinds, drop runtime, then split what is left by `roleOf`:
343
+ *
344
+ * - `all` — everything reachable that is business code (consumed, wiring,
345
+ * writable). Runtime files are absent: they are SDK output, not the page.
346
+ * - `writable` — only role `writable`. `consumed` never enters it; a shared UI
347
+ * component or base class is not this page's contract to change.
348
+ * - `resolvedFile` — the source resolution result, or null. The estimator reads it for the
349
+ * `widgets`-empty `est` fallback, so it must always be present.
350
+ *
351
+ * @param {object} args
352
+ * @param {{page_id: string}[]} args.pages
353
+ * @param {string} args.sourceProject
354
+ * @param {object} args.db open homegraph handle; never null (索引前置条件 — no index,
355
+ * no downgrade)
356
+ * @param {object} [args.ctx] forwarded to `roleOf` (`wiringPaths`, `sourceRoots`)
357
+ * @returns {Map<string, {all: Set<string>, writable: Set<string>,
358
+ * resolvedFile: string|null}>}
359
+ * @throws {TypeError} without a usable `db` or `sourceProject`, or when `ctx`
360
+ * is unusable.
361
+ */
362
+ export function computeFootprint({ pages, sourceProject, db, ctx } = {}) {
363
+ if (!db) {
364
+ throw new TypeError(
365
+ "computeFootprint: db is required; never degrade to name heuristics",
366
+ );
367
+ }
368
+ if (!Array.isArray(pages)) {
369
+ throw new TypeError("computeFootprint: pages must be an array");
370
+ }
371
+ // Named up front: without it `path.join` throws a bare "The path argument
372
+ // must be of type string" from several frames down, which says nothing about
373
+ // which argument was wrong.
374
+ if (typeof sourceProject !== "string" || sourceProject === "") {
375
+ throw new TypeError("computeFootprint: sourceProject must be a non-empty string");
376
+ }
377
+ const roleCtx = normalizeCtx(ctx);
378
+ // Derived once for the whole run: a page cannot know it shares its
379
+ // `declared_at` with another, and rung 2 is the only defence against several
380
+ // pages inheriting one registration file's footprint.
381
+ const sharedDeclaredAt = sharedDeclaredAtOf(pages);
382
+ const pagesJsonRoutes = pagesJsonRoutesFrom(sourceProject);
383
+
384
+ const out = new Map();
385
+ for (const page of pages) {
386
+ const { file } = resolvePageFiles({
387
+ page, sourceProject, db, pagesJsonRoutes, sharedDeclaredAt,
388
+ });
389
+ if (file === null) {
390
+ out.set(page.page_id, { all: new Set(), writable: new Set(), resolvedFile: null });
391
+ continue;
392
+ }
393
+
394
+ const all = new Set();
395
+ const writable = new Set();
396
+ const reached = bfsFiles(db, [file], { depth: FOOTPRINT_DEPTH });
397
+ for (const raw of reached) {
398
+ const f = normalize(raw);
399
+ // `roleOf` is the single runtime authority: it tests the same frozen
400
+ // RUNTIME_RE against `"/" + p` and also carries the `uni_modules/` rule.
401
+ // A second `isRuntime` filter here would be dead (it can never change the
402
+ // outcome) and untestable — a stage two classifiers disagree on is how a
403
+ // vendored file slips into g00, so there is exactly one.
404
+ const role = roleOf(f, roleCtx);
405
+ if (role === "runtime") continue;
406
+ all.add(f);
407
+ if (role === "writable") writable.add(f);
408
+ }
409
+
410
+ out.set(page.page_id, {
411
+ all: new Set([...all].sort()),
412
+ writable: new Set([...writable].sort()),
413
+ resolvedFile: file,
414
+ });
415
+ }
416
+ return out;
417
+ }
418
+
419
+ // ---------------------------------------------------------------------------
420
+ // Candidate keys, de-duplication, SPLIT and computed span.
421
+ // ---------------------------------------------------------------------------
422
+
423
+ /** Candidate keys, coarse to fine. Tie-breaks follow this order. */
424
+ export const KEY_ORDER = Object.freeze(["module", "feature", "parent", "route"]);
425
+
426
+ // Defaults. Callers may override via `params`.
427
+ const DEFAULT_MAX_PAGES = 12; // MAX_PAGES_PER_GROUP
428
+ const DEFAULT_CONCURRENCY = 8;
429
+ const DEFAULT_CONTRACTS_PER_GROUP = 8;
430
+
431
+ // Span convention: a group of N pages is predicted to need
432
+ // max(1, ceil(N / 4)) serial chunks. The acceptance runner imports the same constant.
433
+ export const PAGES_PER_CHUNK = 4;
434
+
435
+ // Foundation filter constants. `foundationFilter` is the single implementation;
436
+ // `g00Files` delegates to it so span uses the foundation-filtered g00.
437
+ const FOUNDATION_MIN_GROUPS = 10;
438
+ const FOUNDATION_FRACTION = 0.2;
439
+ const FOUNDATION_MIN_THRESHOLD = 3;
440
+
441
+ // `feature` markers (key selection `ui/screen/<域>/<功能>`, `pages/<x>`, `features/<x>`):
442
+ // `screen` keeps the domain AND function segment, `features` keeps one, and
443
+ // `pages`/`views` keep the whole route-like directory (`pages/order/list`).
444
+ // A marker with nothing after it names no feature and yields null.
445
+ const FEATURE_MARKERS = new Map([
446
+ ["screen", { extra: 2, withParent: "ui" }],
447
+ ["screens", { extra: 2, withParent: "ui" }],
448
+ ["features", { extra: 1 }],
449
+ ["feature", { extra: 1 }],
450
+ ["pages", { extra: Infinity }],
451
+ ["views", { extra: Infinity }],
452
+ ]);
453
+
454
+ /** Gradle module root of `file`: the path before its first `src/<sourceSet>/`. */
455
+ function moduleRootOf(file) {
456
+ const m = /^(?:(.*?)\/)?src\/[^/]+\//.exec(file);
457
+ if (!m) return null; // decompiled trees have no `src/<set>/` layer
458
+ return m[1] === undefined || m[1] === "" ? "." : m[1];
459
+ }
460
+
461
+ /** key selection `feature`: a directory path, never the file name; null when unmatched. */
462
+ function featureOf(dirs) {
463
+ for (let i = 0; i < dirs.length; i++) {
464
+ const rule = FEATURE_MARKERS.get(dirs[i].toLowerCase());
465
+ if (!rule) continue;
466
+ const after = dirs.length - i - 1;
467
+ if (after < 1) continue; // marker with no function directory under it
468
+ const start = rule.withParent && i > 0 && dirs[i - 1].toLowerCase() === rule.withParent
469
+ ? i - 1
470
+ : i;
471
+ const end = i + 1 + Math.min(after, rule.extra);
472
+ return dirs.slice(start, end).join("/");
473
+ }
474
+ return null;
475
+ }
476
+
477
+ /**
478
+ * key selection — the four candidate keys of one page.
479
+ *
480
+ * A key that cannot be derived is `null`, never `parent`: `module` needs a
481
+ * Gradle project (`ctx.hasGradle`) AND a `src/<set>/` layer, `route` needs a
482
+ * `pages.json` (`ctx.hasPagesJson`) AND a page id that carries a route,
483
+ * `feature` needs a marker directory. `parent` is always derivable from a
484
+ * resolved file. If a key is null for every page it is unavailable for the
485
+ * project (key selection "该键不参与"), and it never becomes a `parent` copy.
486
+ *
487
+ * @param {string} pageId
488
+ * @param {string|null} file repo-relative source file, or null when unresolved
489
+ * @param {{hasGradle?: boolean, hasPagesJson?: boolean}} [ctx]
490
+ * @returns {{module: string|null, feature: string|null,
491
+ * parent: string|null, route: string|null}}
492
+ */
493
+ export function keysFor(pageId, file, ctx = {}) {
494
+ const c = ctx ?? {};
495
+ const out = { module: null, feature: null, parent: null, route: null };
496
+
497
+ // key selection: the route comes from the page id, colon-prefixed — not from the file.
498
+ if (c.hasPagesJson) out.route = routeOfPageId(pageId);
499
+
500
+ if (typeof file !== "string" || file === "") return out;
501
+ const p = normalize(file);
502
+ if (p === "") return out;
503
+ // Absoluteness is kept, so `/a/b/C.java` and `a/b/C.java` stay distinct
504
+ // group keys instead of silently collapsing into one directory.
505
+ const absolute = p.startsWith("/");
506
+ const parts = p.split("/").filter((s) => s !== "");
507
+ const dirs = parts.slice(0, -1); // the file name is never part of a key
508
+ const joined = dirs.join("/");
509
+
510
+ out.parent = dirs.length === 0 ? (absolute ? "/" : ".") : (absolute ? `/${joined}` : joined);
511
+ out.feature = featureOf(dirs);
512
+ // `p` (not `joined`) so an absolute file yields an absolute module root, the
513
+ // same way `parent` keeps it; otherwise `/w/app/...` and `w/app/...` collide.
514
+ if (c.hasGradle) out.module = moduleRootOf(p);
515
+ return out;
516
+ }
517
+
518
+ /** `keys` may be a Map or a plain object keyed by page id. */
519
+ function keyOfPage(keys, id, key) {
520
+ const entry = keys instanceof Map ? keys.get(id) : keys?.[id];
521
+ const v = entry?.[key];
522
+ return typeof v === "string" && v !== "" ? v : null;
523
+ }
524
+
525
+ /**
526
+ * Canonical form of a grouping: a new Map whose entries are sorted by group
527
+ * name and whose member arrays are sorted ascending.
528
+ *
529
+ * Group names are unique strings, so the name sort is total; that makes the
530
+ * grouping a function of the page SET alone, never of the order the caller
531
+ * enumerated pages in. `inventory.mjs` emits pages in `utg.json` node order,
532
+ * which is unsorted, so without this the same page set produced two different
533
+ * groupings depending on where the pages happened to sit in the file.
534
+ */
535
+ function canonicalGroups(groups) {
536
+ return new Map([...groups]
537
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
538
+ .map(([name, members]) => [name, [...members].sort()]));
539
+ }
540
+
541
+ /**
542
+ * Fold page ids into groups by `keyFn`, returning the canonical grouping:
543
+ * entries sorted by group name, members sorted ascending, so the result depends
544
+ * only on the page set and not on the order `ids` was given in (over-cap splitting
545
+ * "确定性切分"). Group order is therefore alphabetical, not first-appearance.
546
+ *
547
+ * A page whose key is null/undefined/"" is an orphan (key selection "页面缺键当孤儿
548
+ * 处理"): it gets its own `orphan/<id>` group, so one unresolved page cannot
549
+ * make the whole key unusable nor join a group it does not belong to.
550
+ *
551
+ * A repeated id is folded once. Two entries for one page are the same page, and
552
+ * letting them through would inflate `largest` (and so the chunk count, the
553
+ * span, and possibly the fit/over-cap verdict) for a reason that has nothing to
554
+ * do with the grouping — a page listed twice is not two pages.
555
+ *
556
+ * @param {string[]} ids
557
+ * @param {(id: string) => string|null|undefined} keyFn
558
+ * @returns {Map<string, string[]>}
559
+ */
560
+ export function groupsFrom(ids, keyFn) {
561
+ const groups = new Map();
562
+ const seen = new Set();
563
+ for (const id of ids) {
564
+ if (seen.has(id)) continue;
565
+ seen.add(id);
566
+ const k = keyFn(id);
567
+ const name = typeof k === "string" && k !== "" ? k : `orphan/${id}`;
568
+ if (!groups.has(name)) groups.set(name, []);
569
+ groups.get(name).push(id);
570
+ }
571
+ return canonicalGroups(groups);
572
+ }
573
+
574
+ /**
575
+ * over-cap splitting — bring an over-cap key's groups under `maxPages`.
576
+ *
577
+ * Each over-cap group is re-split by the next finer key that actually divides
578
+ * it, descending KEY_ORDER after `key`; a finer key that yields a single
579
+ * sub-group is skipped rather than silently accepted. Whatever is still over
580
+ * the cap after every finer key is cut deterministically: ids sorted, dealt
581
+ * round-robin into `ceil(n / maxPages)` slices, each reported in `artificial`
582
+ * (lossy — one slice may hold unrelated pages, so the report lists them).
583
+ *
584
+ * Every output order here — group order, member order, slice order — depends
585
+ * only on the page SET, never on the order `ids` was given in. That is what
586
+ * makes the grouping report reproducible across runs; the caller writes it to
587
+ * disk so consumers can compare it byte for byte. Concretely: members are
588
+ * sorted ascending, group names are sorted ascending on the way out, and
589
+ * `artificial` is sorted by `group`. The `#N` slice suffixes are assigned
590
+ * before the sort, so sorting never renumbers a slice.
591
+ *
592
+ * @param {string[]} ids
593
+ * @param {Map|object} keys page id -> keysFor() result
594
+ * @param {string} key the over-cap key
595
+ * @param {{maxPages?: number}} [opts]
596
+ * @returns {{groups: Map<string,string[]>,
597
+ * artificial: {group: string, from: string, pages: string[]}[]}}
598
+ */
599
+ export function splitOverCap(ids, keys, key, { maxPages = DEFAULT_MAX_PAGES } = {}) {
600
+ const at = KEY_ORDER.indexOf(key);
601
+ if (at < 0) throw new TypeError(`splitOverCap: unknown key ${JSON.stringify(key)}`);
602
+ if (!Number.isInteger(maxPages) || maxPages < 1) {
603
+ throw new TypeError(`splitOverCap: maxPages must be a positive integer, got ${maxPages}`);
604
+ }
605
+ const groups = new Map();
606
+ const artificial = [];
607
+
608
+ const refine = (name, members, finer) => {
609
+ if (members.length <= maxPages) {
610
+ groups.set(name, members);
611
+ return;
612
+ }
613
+ if (finer.length === 0) {
614
+ const sorted = [...members].sort();
615
+ const n = Math.ceil(sorted.length / maxPages);
616
+ const slices = Array.from({ length: n }, () => []);
617
+ sorted.forEach((id, i) => slices[i % n].push(id));
618
+ slices.forEach((pages, i) => {
619
+ const slice = `${name}#${i + 1}`;
620
+ groups.set(slice, pages);
621
+ artificial.push({ group: slice, from: name, pages });
622
+ });
623
+ return;
624
+ }
625
+ const [next, ...rest] = finer;
626
+ // `members` arrives sorted (see the entry loop), so `sub`'s insertion order
627
+ // — which is the emitted group order — and the member order inside each
628
+ // sub-group are both a function of the page SET, not of the order the
629
+ // caller happened to enumerate pages in.
630
+ const sub = new Map();
631
+ for (const id of members) {
632
+ const v = keyOfPage(keys, id, next);
633
+ const sk = v === null ? `${name}|(none)` : `${name}|${v}`;
634
+ if (!sub.has(sk)) sub.set(sk, []);
635
+ sub.get(sk).push(id);
636
+ }
637
+ if (sub.size === 1) {
638
+ refine(name, members, rest); // this key does not divide the group
639
+ return;
640
+ }
641
+ for (const [sk, m] of sub) refine(sk, m, rest);
642
+ };
643
+
644
+ // `groupsFrom` hands back the canonical grouping (groups sorted by name,
645
+ // members sorted ascending), so every branch below — the finer-key descent
646
+ // included — sees members in an order that is a function of the page set.
647
+ // Both returned collections are canonicalised again on the way out, because
648
+ // this function appends to them in descent order rather than name order.
649
+ const base = groupsFrom(ids, (id) => keyOfPage(keys, id, key));
650
+ const finer = KEY_ORDER.slice(at + 1);
651
+ for (const [name, members] of base) refine(name, members, finer);
652
+ // Sort AFTER the slices were built: the `#N` suffixes are already fixed, so
653
+ // this reorders the report without renumbering a slice.
654
+ artificial.sort((a, b) => (a.group < b.group ? -1 : a.group > b.group ? 1 : 0));
655
+ return { groups: canonicalGroups(groups), artificial };
656
+ }
657
+
658
+ /**
659
+ * Writable file set of one page; accepts a Map or object, Set or `{writable}`.
660
+ *
661
+ * Brand-based `types.isMap`, not `instanceof`: `buildPlan` accepts a `Map` whose
662
+ * prototype has been rearranged (see `isFootprintIndex`), and `instanceof` would
663
+ * then fall through to the object lookup and silently find nothing.
664
+ */
665
+ function writableOf(footprint, id) {
666
+ // `Map.prototype.get.call`, not `footprint.get`: a brand-Map whose prototype
667
+ // has been rearranged has no own `.get`, and `map.get(...)` would throw on it.
668
+ const v = types.isMap(footprint) ? Map.prototype.get.call(footprint, id) : footprint?.[id];
669
+ if (v instanceof Set) return v;
670
+ if (v && v.writable instanceof Set) return v.writable;
671
+ return new Set();
672
+ }
673
+
674
+ /**
675
+ * g00 file set for one grouping: writable files owned by >= 2 groups, minus foundation files
676
+ * once there are >= 10 groups. `foundationFilter` owns the threshold; this function builds the
677
+ * owners map and delegates.
678
+ */
679
+ function g00Files(ids, footprint, groups) {
680
+ const groupOf = new Map();
681
+ for (const [name, members] of groups) for (const id of members) groupOf.set(id, name);
682
+ const owners = new Map();
683
+ for (const id of ids) {
684
+ const g = groupOf.get(id);
685
+ if (g === undefined) continue;
686
+ for (const f of writableOf(footprint, id)) {
687
+ if (!owners.has(f)) owners.set(f, new Set());
688
+ owners.get(f).add(g);
689
+ }
690
+ }
691
+ return [...foundationFilter(owners, groups.size, {}).g00].sort();
692
+ }
693
+
694
+ function spanParams(opts = {}) {
695
+ const concurrency = opts.concurrency ?? DEFAULT_CONCURRENCY;
696
+ const contractsPerGroup = opts.contractsPerGroup ?? DEFAULT_CONTRACTS_PER_GROUP;
697
+ for (const [k, v] of [["concurrency", concurrency], ["contractsPerGroup", contractsPerGroup]]) {
698
+ if (!Number.isInteger(v) || v < 1) {
699
+ throw new TypeError(`${k} must be a positive integer, got ${v}`);
700
+ }
701
+ }
702
+ return { concurrency, contractsPerGroup };
703
+ }
704
+
705
+ /** Span plus the g00 size used for the calculation. */
706
+ function measure(ids, footprint, groups, opts) {
707
+ const { concurrency, contractsPerGroup } = spanParams(opts);
708
+ const g00 = g00Files(ids, footprint, groups);
709
+
710
+ const buckets = new Map();
711
+ for (const f of g00) {
712
+ const b = bucketOf(f);
713
+ buckets.set(b, (buckets.get(b) ?? 0) + 1);
714
+ }
715
+ const bucketChunks = [...buckets.values()].map((n) => Math.ceil(n / contractsPerGroup));
716
+ const wave1 = bucketChunks.length ? Math.max(...bucketChunks) : 0;
717
+
718
+ const groupChunks = [...groups.values()]
719
+ .map((m) => Math.max(1, Math.ceil(m.length / PAGES_PER_CHUNK)));
720
+ const maxGroup = groupChunks.length ? Math.max(...groupChunks) : 0;
721
+ // span/estimation "wave2 = max(最大功能组的 chunk 数, ceil((总功能 chunk + 总契约 chunk) / 8))".
722
+ const total = groupChunks.reduce((a, b) => a + b, 0)
723
+ + bucketChunks.reduce((a, b) => a + b, 0);
724
+ const wave2 = Math.max(maxGroup, Math.ceil(total / concurrency));
725
+ return { span: wave1 + wave2, g00: g00.length };
726
+ }
727
+
728
+ /**
729
+ * span = wave1 + wave2 (a parallel-depth proxy, not wall time).
730
+ *
731
+ * - wave1 = the largest g00 bucket's chunks, `ceil(bucketSize / contractsPerGroup)`;
732
+ * - wave2 = `max(maxGroupChunks, ceil(totalChunks / concurrency))`, with
733
+ * `chunk = max(1, ceil(groupPages / 4))` and totalChunks counting functional
734
+ * groups plus g00 bucket chunks.
735
+ *
736
+ * g00 is foundation-filtered so the span uses the same g00 the pipeline will create.
737
+ *
738
+ * @param {string[]} ids
739
+ * @param {Map|object} footprintByPage page id -> writable Set | {writable}
740
+ * @param {Map<string,string[]>} groups
741
+ * @param {{concurrency?: number, contractsPerGroup?: number}} [opts]
742
+ * @returns {number}
743
+ */
744
+ export function computeSpan(ids, footprintByPage, groups, opts = {}) {
745
+ return measure(ids, footprintByPage, groups, opts).span;
746
+ }
747
+
748
+ /**
749
+ * The four numbers `grouping-report.json` publishes per candidate. Two
750
+ * candidates with the same tuple are indistinguishable in the report, which is
751
+ * exactly the acceptance failure ("两条 groups/largest/g00/span 全等而 key 不同").
752
+ *
753
+ * Gating de-duplication on this tuple instead of on set equality is both
754
+ * sufficient and strictly stronger: an identical partition necessarily has the
755
+ * same group count, the same largest group, the same writable-file sets — hence
756
+ * the same g00 and span — so `frozenset(frozenset(group))` equality always
757
+ * lands in the same tuple. Testing the tuple therefore covers partition equality and additionally
758
+ * catches distinct partitions that happen to report identical numbers.
759
+ */
760
+ function reportTuple(candidate) {
761
+ return `${candidate.groups}|${candidate.largest}|${candidate.g00}|${candidate.span}`;
762
+ }
763
+
764
+ /**
765
+ * key selection — pick the grouping key with the smallest computed span.
766
+ *
767
+ * Per key in KEY_ORDER:
768
+ * - null for every page -> `unavailable[]`; NOT a candidate and never a parent
769
+ * copy (that degradation is what produced twin candidates);
770
+ * - largest group <= maxPages -> candidate `<key>`, verdict `fit`;
771
+ * - otherwise the SPLIT result is the candidate `<key>+SPLIT`, verdict
772
+ * `over-cap`, with `bare_largest` recording how far the bare key overflowed —
773
+ * over-cap is a different outcome from unavailable, not the same bucket;
774
+ * - a candidate whose `groups`/`largest`/`g00`/`span` tuple equals an earlier
775
+ * one is withheld from `candidates[]` and listed in `deduped[]` as
776
+ * `dedup_of:<kept key>`. That tuple is how the report presents a candidate and
777
+ * how acceptance judges twins, and an identical partition always lands in it (see
778
+ * {@link reportTuple}), so this also covers identical `frozenset` partitions.
779
+ * Keys are visited coarse to fine, so the kept one is the coarser / more apt
780
+ * label; withholding a twin cannot change the outcome, since equal numbers
781
+ * require equal span and the tie-break already prefers the kept coarser key.
782
+ *
783
+ * The winner has the minimum span; ties go to the coarser key (KEY_ORDER, i.e.
784
+ * module > feature > parent > route). Fewest-groups is not a valid span proxy.
785
+ *
786
+ * Both `chosen.groups` and `chosen.artificial` come from `groupsFrom` /
787
+ * `splitOverCap`, so they are canonical: group order and `artificial` order are
788
+ * sorted by name, and members ascending. The output depends only on the page
789
+ * SET, not on the order `ids` was given in. `g<NN>-<slug>` directory numbering and the byte-for-byte
790
+ * `grouping-report.json` comparison rely on. Group order is alphabetical
791
+ * rather than first-appearance; no consumer depends on first-appearance.
792
+ *
793
+ * `chosen` is null when no key is available at all: there is nothing to group
794
+ * by, and inventing a grouping would be the silent fallback key selection forbids.
795
+ *
796
+ * @param {object} args
797
+ * @param {string[]} args.ids
798
+ * @param {Map|object} args.keys page id -> keysFor() result
799
+ * @param {Map|object} args.footprint page id -> writable Set | {writable}
800
+ * @param {{concurrency?: number, contractsPerGroup?: number, maxPages?: number}} [args.params]
801
+ * @returns {{chosen: {label: string, groups: Map<string,string[]>,
802
+ * artificial: object[]}|null,
803
+ * candidates: {key: string, groups: number, largest: number,
804
+ * g00: number, span: number, verdict: "fit"|"over-cap"}[],
805
+ * unavailable: {key: string, verdict: "unavailable"}[],
806
+ * deduped: {key: string, verdict: string}[]}}
807
+ */
808
+ export function chooseCandidate({ ids, keys, footprint, params } = {}) {
809
+ if (!Array.isArray(ids)) throw new TypeError("chooseCandidate: ids must be an array");
810
+ // `params` destructured without a default and then guarded: `params: null`
811
+ // would otherwise surface as "Cannot read properties of null", which names
812
+ // nothing. An absent params means "all defaults", a null one is a caller bug.
813
+ if (params === undefined) params = {};
814
+ if (params === null || typeof params !== "object") {
815
+ throw new TypeError(`chooseCandidate: params must be an object, got ${params}`);
816
+ }
817
+ const maxPages = params.maxPages ?? DEFAULT_MAX_PAGES;
818
+ if (!Number.isInteger(maxPages) || maxPages < 1) {
819
+ throw new TypeError(`chooseCandidate: maxPages must be a positive integer, got ${maxPages}`);
820
+ }
821
+ const spanOpts = { concurrency: params.concurrency, contractsPerGroup: params.contractsPerGroup };
822
+ spanParams(spanOpts);
823
+
824
+ const unavailable = [];
825
+ const deduped = [];
826
+ const kept = []; // {order, candidate, groups, artificial}
827
+ const seen = new Map(); // report tuple -> kept label
828
+
829
+ KEY_ORDER.forEach((key, order) => {
830
+ if (ids.every((id) => keyOfPage(keys, id, key) === null)) {
831
+ unavailable.push({ key, verdict: "unavailable" });
832
+ return;
833
+ }
834
+ const bare = groupsFrom(ids, (id) => keyOfPage(keys, id, key));
835
+ const bareLargest = Math.max(...[...bare.values()].map((m) => m.length));
836
+ let label = key;
837
+ let groups = bare;
838
+ let artificial = [];
839
+ let verdict = "fit";
840
+ if (bareLargest > maxPages) {
841
+ ({ groups, artificial } = splitOverCap(ids, keys, key, { maxPages }));
842
+ label = `${key}+SPLIT`;
843
+ verdict = "over-cap";
844
+ }
845
+
846
+ const { span, g00 } = measure(ids, footprint, groups, spanOpts);
847
+ const candidate = {
848
+ key: label,
849
+ groups: groups.size,
850
+ largest: Math.max(...[...groups.values()].map((m) => m.length)),
851
+ g00,
852
+ span,
853
+ verdict,
854
+ };
855
+
856
+ const tuple = reportTuple(candidate);
857
+ if (seen.has(tuple)) {
858
+ deduped.push({ key: label, verdict: `dedup_of:${seen.get(tuple)}` });
859
+ return;
860
+ }
861
+ // Claim the tuple only once this label is retained, so a withheld candidate
862
+ // can never become the `dedup_of` target of a later one.
863
+ seen.set(tuple, label);
864
+
865
+ if (verdict === "over-cap") candidate.bare_largest = bareLargest;
866
+ kept.push({ order, candidate, groups, artificial });
867
+ });
868
+
869
+ let best = null;
870
+ for (const k of kept) {
871
+ if (best === null
872
+ || k.candidate.span < best.candidate.span
873
+ || (k.candidate.span === best.candidate.span && k.order < best.order)) {
874
+ best = k;
875
+ }
876
+ }
877
+ return {
878
+ chosen: best === null
879
+ ? null
880
+ : { label: best.candidate.key, groups: best.groups, artificial: best.artificial },
881
+ candidates: kept.map((k) => k.candidate),
882
+ unavailable,
883
+ deduped,
884
+ };
885
+ }
886
+
887
+ // ---------------------------------------------------------------------------
888
+ // Foundation filtering, dependencies, estimation, SPEC units, and the downstream plan object.
889
+ //
890
+ // Shapes (this project has no TypeScript; these comments are the contract):
891
+ // Plan = {plan_version, inputs, params, page_enumeration, pages,
892
+ // unclassified, orphan_overlays, foundation_files,
893
+ // key_context, spec_units, groups, grouping}
894
+ // SpecUnit = {spec_id, page_id, part, parts, dir, est, status_domain}
895
+ // Group = {group_id, dir, kind: "shared"|"page", pages: string[],
896
+ // spec_ids: string[], deps: string[], est_scenarios: number}
897
+ // ---------------------------------------------------------------------------
898
+
899
+ // EST trigger patterns for the source-file fallback. ViewModel injection is an architecture
900
+ // pattern, not a user-visible trigger, so `hiltViewModel` / `viewModel` are absent.
901
+ const EST_SIG_RE =
902
+ /\bsetOnClickListener\b|\bonClick\s*[=({]|\bsetOnRefreshListener\b|\bonRefresh\b/;
903
+
904
+ // Comment lines start with `*`, `//` or `/*` after trimming.
905
+ function isCommentLine(line) {
906
+ const t = line.trim();
907
+ return t.startsWith("//") || t.startsWith("*") || t.startsWith("/*");
908
+ }
909
+
910
+ /** SIG hits in `file`, or `null` when the file cannot be read. */
911
+ function countSigHits(file) {
912
+ if (typeof file !== "string" || file === "") return null;
913
+ let text;
914
+ try {
915
+ text = fs.readFileSync(file, "utf8");
916
+ } catch {
917
+ // A page whose source could not be resolved is the ladder's rung 5 — a
918
+ // normal outcome, not an error (source resolution). No throw.
919
+ return null;
920
+ }
921
+ let hits = 0;
922
+ for (const line of text.split(/\r?\n/)) {
923
+ if (isCommentLine(line)) continue;
924
+ if (EST_SIG_RE.test(line)) hits += 1;
925
+ }
926
+ return hits;
927
+ }
928
+
929
+ /**
930
+ * Trigger widgets: `kind === "action"`, `role ∈ {action, trigger}`,
931
+ * `is_trigger === true`, or a present `gesture_param` / `composable`.
932
+ *
933
+ * "Present" excludes `null`/`undefined`/`""`/`false`: the interaction scanner
934
+ * emits `gesture_param: null` on every signal, and treating that as a trigger
935
+ * would count each signal twice.
936
+ */
937
+ function isTriggerWidget(w) {
938
+ if (!w || typeof w !== "object") return false;
939
+ if (w.kind === "action") return true;
940
+ if (w.role === "action" || w.role === "trigger") return true;
941
+ if (w.is_trigger === true) return true;
942
+ if (w.gesture_param !== null && w.gesture_param !== undefined && w.gesture_param !== "") {
943
+ return true;
944
+ }
945
+ if (w.composable !== null && w.composable !== undefined
946
+ && w.composable !== false && w.composable !== "") {
947
+ return true;
948
+ }
949
+ return false;
950
+ }
951
+
952
+ const countOf = (v) => (Array.isArray(v) ? v.length : 0);
953
+
954
+ /**
955
+ * Expected scenario count of one page.
956
+ *
957
+ * `est(P) = 1 + |out_edges(P)| + 触发控件数 + 交互信号数`
958
+ *
959
+ * When `widgets` is empty (or absent) utg-static extracted no widget evidence —
960
+ * the Compose `entry<Route> { Screen() }` shape — so the formula switches to
961
+ * `1 + |out_edges| + SIG hits` over the resolved UI source file. The interaction
962
+ * term is NOT added there: both scan the same file for the same patterns, and
963
+ * adding them double-counts (span/estimation "不重复计数"). Unreadable or absent
964
+ * `resolvedFile` degrades to `1 + |out_edges|`.
965
+ *
966
+ * `resolvedFile` is a path this function can open. `buildPlan` resolves the
967
+ * footprint entry (a repo-relative path) against `inputs.sourceProject` before
968
+ * calling; a caller holding an absolute path may pass it straight through.
969
+ *
970
+ * @param {{out_edges?: object[], widgets?: object[]|null,
971
+ * interactions?: object[]}} page
972
+ * @param {string|null} [resolvedFile]
973
+ * @returns {number}
974
+ * @throws {TypeError} when `page` is not an object.
975
+ */
976
+ export function estOf(page, resolvedFile = null) {
977
+ if (!page || typeof page !== "object") {
978
+ throw new TypeError("estOf: page must be an object");
979
+ }
980
+ const edges = countOf(page.out_edges);
981
+ const widgets = Array.isArray(page.widgets) ? page.widgets : null;
982
+ if (widgets !== null && widgets.length > 0) {
983
+ const triggers = widgets.filter(isTriggerWidget).length;
984
+ return 1 + edges + triggers + countOf(page.interactions);
985
+ }
986
+ const hits = countSigHits(resolvedFile);
987
+ return hits === null ? 1 + edges : 1 + edges + hits;
988
+ }
989
+
990
+ /**
991
+ * Split the shared-file set into g00 (contract writers) and foundation
992
+ * (project-wide infrastructure).
993
+ *
994
+ * `foundationFilter` owns this threshold. `g00Files` delegates here, so span uses exactly the g00
995
+ * the plan publishes.
996
+ *
997
+ * - `nGroups >= 10`: `threshold = max(3, ceil(nGroups * 0.20))`; a file with
998
+ * `|owners| >= threshold` is foundation (excluded, no contract); a file with
999
+ * `2 <= |owners| < threshold` is g00.
1000
+ * - otherwise no foundation filter: `|owners| >= 2` is g00.
1001
+ *
1002
+ * Foundation files are not "unspecified": they are the project's runtime base,
1003
+ * referenced on demand by downstream coders and outside this skill's remit
1004
+ * (g00/foundation). They are returned in their own set so the report can list them.
1005
+ *
1006
+ * @param {Map<string, Set<string>>} owners file -> owning group names
1007
+ * @param {number} nGroups
1008
+ * @param {{minGroups?: number, fraction?: number, minThreshold?: number}} [params]
1009
+ * optional overrides of the three foundation constants.
1010
+ * @returns {{g00: Set<string>, foundation: Set<string>}}
1011
+ * @throws {TypeError} on a non-Map `owners`, a non-integer `nGroups`, a
1012
+ * non-Set owner value, or an unusable override.
1013
+ */
1014
+ export function foundationFilter(owners, nGroups, params = {}) {
1015
+ if (!(owners instanceof Map)) {
1016
+ throw new TypeError("foundationFilter: owners must be a Map of file -> Set<group>");
1017
+ }
1018
+ if (!Number.isInteger(nGroups) || nGroups < 0) {
1019
+ throw new TypeError(
1020
+ `foundationFilter: nGroups must be a non-negative integer, got ${nGroups}`,
1021
+ );
1022
+ }
1023
+ const p = params === undefined ? {} : params;
1024
+ if (p === null || typeof p !== "object") {
1025
+ throw new TypeError(`foundationFilter: params must be an object, got ${p}`);
1026
+ }
1027
+ const minGroups = p.minGroups ?? FOUNDATION_MIN_GROUPS;
1028
+ const fraction = p.fraction ?? FOUNDATION_FRACTION;
1029
+ const minThreshold = p.minThreshold ?? FOUNDATION_MIN_THRESHOLD;
1030
+ if (!Number.isInteger(minGroups) || minGroups < 0) {
1031
+ throw new TypeError(`foundationFilter: minGroups must be a non-negative integer, got ${minGroups}`);
1032
+ }
1033
+ if (typeof fraction !== "number" || !(fraction > 0) || fraction > 1) {
1034
+ throw new TypeError(`foundationFilter: fraction must be in (0, 1], got ${fraction}`);
1035
+ }
1036
+ if (!Number.isInteger(minThreshold) || minThreshold < 1) {
1037
+ throw new TypeError(`foundationFilter: minThreshold must be a positive integer, got ${minThreshold}`);
1038
+ }
1039
+
1040
+ const threshold = nGroups >= minGroups
1041
+ ? Math.max(minThreshold, Math.ceil(nGroups * fraction))
1042
+ : Infinity;
1043
+ const g00 = new Set();
1044
+ const foundation = new Set();
1045
+ for (const [file, set] of owners) {
1046
+ if (!(set instanceof Set)) {
1047
+ throw new TypeError(
1048
+ `foundationFilter: owners.get(${JSON.stringify(file)}) must be a Set of group names`,
1049
+ );
1050
+ }
1051
+ if (set.size >= threshold) foundation.add(file);
1052
+ else if (set.size >= 2) g00.add(file);
1053
+ }
1054
+ return { g00, foundation };
1055
+ }
1056
+
1057
+ // SPEC-unit planning / Global Constraints: the per-SPEC scenario budget, the same knob the
1058
+ // downstream `packChunks` measures with.
1059
+ const DEFAULT_CHUNK_BUDGET = 32;
1060
+
1061
+ /** Normalised + validated build parameters (Global Constraints defaults). */
1062
+ function planParams(params) {
1063
+ const p = params === undefined ? {} : params;
1064
+ if (p === null || typeof p !== "object") {
1065
+ throw new TypeError(`buildPlan: params must be an object, got ${p}`);
1066
+ }
1067
+ const out = {
1068
+ concurrency: p.concurrency ?? DEFAULT_CONCURRENCY,
1069
+ chunkBudget: p.chunkBudget ?? DEFAULT_CHUNK_BUDGET,
1070
+ contractsPerGroup: p.contractsPerGroup ?? DEFAULT_CONTRACTS_PER_GROUP,
1071
+ maxPages: p.maxPages ?? DEFAULT_MAX_PAGES,
1072
+ };
1073
+ for (const [k, v] of Object.entries(out)) {
1074
+ if (!Number.isInteger(v) || v < 1) {
1075
+ throw new TypeError(`buildPlan: ${k} must be a positive integer, got ${v}`);
1076
+ }
1077
+ }
1078
+ return out;
1079
+ }
1080
+
1081
+ /**
1082
+ * key selection platform applicability, detected from the source root.
1083
+ *
1084
+ * `keysFor` takes these as `ctx` flags so it stays a pure function; `buildPlan`
1085
+ * has the source root and derives them once. Detection is deliberately here and
1086
+ * nowhere else — a caller-supplied flag and a detection rule would be two
1087
+ * sources of truth for the same gate, and the failure mode of getting it wrong
1088
+ * is silent (every page falls to `parent`, key selection "键有平台适用性"). Because it is
1089
+ * silent, the result is published in the Plan as `key_context`.
1090
+ *
1091
+ * Absent/unreadable `sourceProject` is a supported mode and yields both false —
1092
+ * it does NOT throw, so a caller without a source tree still gets a plan, with
1093
+ * every page as a `parent` group or an orphan.
1094
+ *
1095
+ * Limit: `hasPagesJson` checks only
1096
+ * `<sourceProject>/pages.json`. A uniapp project that keeps `pages.json` in a
1097
+ * subdirectory therefore has `route` disabled, and `key_context.hasPagesJson`
1098
+ * reports what this function actually detected, not what the project is.
1099
+ */
1100
+ function keyContextOf(sourceProject) {
1101
+ const none = { hasGradle: false, hasPagesJson: false };
1102
+ if (typeof sourceProject !== "string" || sourceProject === "") return none;
1103
+ let hasPagesJson = false;
1104
+ try {
1105
+ hasPagesJson = fs.existsSync(path.join(sourceProject, "pages.json"));
1106
+ } catch {
1107
+ hasPagesJson = false;
1108
+ }
1109
+ let hasGradle = false;
1110
+ try {
1111
+ hasGradle = fs.readdirSync(sourceProject)
1112
+ .some((e) => /^(settings\.gradle|build\.gradle)/i.test(e));
1113
+ } catch {
1114
+ hasGradle = false;
1115
+ }
1116
+ return { hasGradle, hasPagesJson };
1117
+ }
1118
+
1119
+ /**
1120
+ * `g<NN>-<slug>` for a page group (g00/foundation / output directory layout).
1121
+ *
1122
+ * `NN` comes from the group's position in the canonical (alphabetical) grouping,
1123
+ * so the same page set always numbers the same way. The prefix is unique per NN,
1124
+ * so two groups can never share a directory even when their names slugify
1125
+ * identically — and a shared directory would silently merge two coders'
1126
+ * worktrees (format).
1127
+ */
1128
+ function pageDirOf(n, name) {
1129
+ return `g${String(n).padStart(2, "0")}-${slugify(name) || "group"}`;
1130
+ }
1131
+
1132
+ // Built-ins that are object-shaped but are never a page-id index. Checked by
1133
+ // brand (`util.types`) rather than `instanceof` for the same reason
1134
+ // `isFootprintIndex` does: `instanceof` reads the prototype, and the prototype
1135
+ // is the thing a caller can change.
1136
+ //
1137
+ // Arrays are NOT in this list only because `node:util`'s `types` has no
1138
+ // `isArray`; they are rejected by an explicit `Array.isArray` in
1139
+ // `isFootprintIndex` before this table is consulted. `Array.isArray` is itself a
1140
+ // brand check and does not read the prototype, so a rearranged array is still
1141
+ // caught — see the comments there.
1142
+ //
1143
+ // `Map` is deliberately absent: `types.isMap(v)` returns true before this table
1144
+ // is reached, so an entry would be dead code that reads as if Maps were rejected.
1145
+ const NON_INDEX_BRANDS = [
1146
+ ["Set", types.isSet],
1147
+ ["Date", types.isDate],
1148
+ ["RegExp", types.isRegExp],
1149
+ ["Promise", types.isPromise],
1150
+ ["WeakMap", types.isWeakMap],
1151
+ ["WeakSet", types.isWeakSet],
1152
+ ["ArrayBuffer", types.isArrayBuffer],
1153
+ ["typed array", types.isTypedArray],
1154
+ ["Error", types.isNativeError],
1155
+ ];
1156
+
1157
+ /**
1158
+ * Is `v` an acceptable `footprint` argument?
1159
+ *
1160
+ * The rule, stated plainly: **a `Map`, or an object whose prototype is
1161
+ * `Object.prototype` or `null` and which carries none of the `NON_INDEX_BRANDS`
1162
+ * above and is not an array.** Nothing else is accepted, apart from the limits
1163
+ * recorded at the end of this comment.
1164
+ *
1165
+ * Why the bar is this narrow: `footprintOf` does exactly two lookups —
1166
+ * `map.get(id)` and `obj[id]`. Any other value is read as "every page
1167
+ * unresolved", which yields a valid-looking plan with no g00, no contract units
1168
+ * and no deps — the silent empty-plan failure this guard exists to prevent.
1169
+ *
1170
+ * Why `null`-prototype objects ARE accepted: `Object.create(null)` is the
1171
+ * ordinary way to build a lookup table in JS, and it is a legitimate page-id
1172
+ * index. But a `null` prototype alone does not mean "plain index" —
1173
+ * `Object.setPrototypeOf(new Set(), null)` also has one. So the prototype test
1174
+ * is paired with brand tests: a non-index built-in is rejected however its
1175
+ * prototype has been rearranged. `Object.create(null)` carries none of those
1176
+ * brands and passes; a `Set`, a `Date`, a `RegExp`, a `Promise` or an array
1177
+ * does not, prototype or no prototype. Arrays are caught by `Array.isArray`,
1178
+ * also a brand check, kept out of the table only because `node:util`'s `types`
1179
+ * has no `isArray`.
1180
+ *
1181
+ * `instanceof` is deliberately NOT used: it walks the prototype chain, so
1182
+ * `Object.setPrototypeOf(new Set(), Object.prototype)` claims to be a plain
1183
+ * object and `Object.setPrototypeOf(new Set(), null)` claims to have no
1184
+ * prototype.
1185
+ *
1186
+ * Recorded limit: a **class instance** whose prototype has been set to
1187
+ * `Object.prototype` or `null` IS accepted, and so are `arguments` objects and
1188
+ * module namespace objects, which pass with no spoofing at all. Classes have no
1189
+ * `util.types` brand, so the class case cannot be closed by brand checking, and
1190
+ * rejecting every such object would also reject the legitimate
1191
+ * `Object.create(null)` index.
1192
+ *
1193
+ * The cost of that limit is **unbounded, not bounded**: the instance's own
1194
+ * properties are read as page ids, and unless those properties happen to be
1195
+ * exact page ids the result is the same silent plan as an empty index — no g00,
1196
+ * no contract units, no deps — which is the failure this guard exists to
1197
+ * prevent. The guard narrows the hole to values that already look like plain
1198
+ * data; it does not close it. `NON_INDEX_BRANDS` is likewise curated rather
1199
+ * than exhaustive (`Proxy`-wrapped built-ins report no brand, and `DataView`,
1200
+ * `SharedArrayBuffer` and boxed primitives need spoofing to slip through). No
1201
+ * caller in this repo can produce any of these: `computeFootprint` always
1202
+ * returns a real `Map`.
1203
+ */
1204
+ function isFootprintIndex(v) {
1205
+ if (v === null || typeof v !== "object") return false;
1206
+ if (types.isMap(v)) return true;
1207
+ // Brand check for arrays: `Array.isArray` ignores the prototype, so a
1208
+ // rearranged array (`setPrototypeOf([], null)`) is still rejected. This must
1209
+ // come before the prototype test, which such an array would pass.
1210
+ if (Array.isArray(v)) return false;
1211
+ const proto = Object.getPrototypeOf(v);
1212
+ if (proto !== Object.prototype && proto !== null) return false;
1213
+ // A plain-object prototype is necessary but not sufficient: brand-check.
1214
+ return !NON_INDEX_BRANDS.some(([, test]) => test(v));
1215
+ }
1216
+
1217
+ /**
1218
+ * A value's shape for an error message: `null`, `array`, `Set`, `Date`, a
1219
+ * named class, `object with null prototype`, … Honest for a null-prototype
1220
+ * `Set`, which `typeof` and prototype-name lookup both report as "object".
1221
+ *
1222
+ * Best-effort beyond the brands: for a class instance whose prototype has been
1223
+ * set to `Object.prototype` or `null` there is no brand and no prototype name
1224
+ * left to read, so it is reported as `plain object` / `object with null
1225
+ * prototype`. The message describes what the value looks like, which by then is
1226
+ * what it is.
1227
+ */
1228
+ function describeValue(v) {
1229
+ if (v === null) return "null";
1230
+ if (v === undefined) return "undefined";
1231
+ if (typeof v !== "object") return typeof v;
1232
+ if (Array.isArray(v)) return "array";
1233
+ for (const [name, test] of NON_INDEX_BRANDS) {
1234
+ if (test(v)) return name;
1235
+ }
1236
+ const proto = Object.getPrototypeOf(v);
1237
+ const name = proto && proto.constructor && proto.constructor.name;
1238
+ if (typeof name === "string" && name !== "" && name !== "Object") {
1239
+ return `instance of ${name}`;
1240
+ }
1241
+ return proto === null ? "object with null prototype" : "plain object";
1242
+ }
1243
+
1244
+ /** `shared:<file-stem>` with a deterministic suffix on a stem collision (g00/foundation). */
1245
+ function sharedIdOf(file, taken) {
1246
+ const base = file.slice(file.lastIndexOf("/") + 1).replace(/\.[^.]+$/, "");
1247
+ let id = `shared:${base}`;
1248
+ let k = 2;
1249
+ while (taken.has(id)) id = `shared:${base}#${k++}`;
1250
+ taken.add(id);
1251
+ return id;
1252
+ }
1253
+
1254
+ /**
1255
+ * Stable `plan_version`: two runs whose grouping inputs and outputs agree
1256
+ * produce the same value, so the ledger can tell "same plan" from "new plan".
1257
+ *
1258
+ * Built from an explicit array, never from object key order, so the digest is a
1259
+ * function of the plan's content alone.
1260
+ */
1261
+ function planVersionOf(params, groups, units) {
1262
+ const payload = JSON.stringify({
1263
+ params,
1264
+ groups: groups.map((g) => [g.group_id, g.kind, g.deps, g.spec_ids]),
1265
+ units: units.map((u) => [u.spec_id, u.dir, u.est]),
1266
+ });
1267
+ return `p-${crypto.createHash("sha256").update(payload).digest("hex").slice(0, 8)}`;
1268
+ }
1269
+
1270
+ /**
1271
+ * Assemble the plan object.
1272
+ *
1273
+ * 1. Derive candidate keys and choose the grouping with the smallest computed span. If no key is
1274
+ * available, keep each page in its `orphan/<id>` group.
1275
+ * 2. Collect writable files owned by at least two groups, apply the foundation filter, and bucket
1276
+ * them by role. Each non-empty bucket is one `g00-<role>` group.
1277
+ * 3. Add deps only from buckets that a page group actually uses.
1278
+ * 4. Emit g00 units first, then page units clustered by canonical group and `pages[]` order. Keep
1279
+ * split-page parts contiguous and preserve that order in `specs.json`.
1280
+ *
1281
+ * `pages`, `unclassified`, `orphan_overlays`, and `page_enumeration` come from the caller.
1282
+ * `foundation_files` and `key_context` make filtering and platform-gate decisions auditable.
1283
+ *
1284
+ * @param {object} args
1285
+ * @param {object[]} args.pages page records in emit order
1286
+ * @param {Map|object} args.footprint page id -> {all, writable, resolvedFile}; must be a Map or a
1287
+ * plain object index accepted by `isFootprintIndex`
1288
+ * @param {object} [args.params] concurrency, chunkBudget, contractsPerGroup, and maxPages
1289
+ * @param {object} [args.inputs] passed through; `sourceProject` resolves source files and platform
1290
+ * gates. When absent, both gates are false and pages group by `parent`.
1291
+ * @returns {object} a byte-stable plan
1292
+ */
1293
+ export function buildPlan({ pages, footprint, params, inputs } = {}) {
1294
+ if (!Array.isArray(pages)) {
1295
+ throw new TypeError("buildPlan: pages must be an array");
1296
+ }
1297
+ const planParamsOut = planParams(params);
1298
+ const inputsOut = inputs === undefined || inputs === null ? {} : inputs;
1299
+ if (typeof inputsOut !== "object") {
1300
+ throw new TypeError(`buildPlan: inputs must be an object, got ${typeof inputsOut}`);
1301
+ }
1302
+ // An absent footprint is a caller bug, not "no writable files": substituting
1303
+ // an empty Map would return a valid-looking plan with no g00, no contract
1304
+ // units and no deps — every g00/foundation obligation silently dropped. An explicitly
1305
+ // empty Map (or `{}`) is that real "no writable files" result and stays valid.
1306
+ //
1307
+ // The accepted shapes are exactly a Map or a plain object: an index of page id
1308
+ // -> footprint. `[]` and `new Set()` are object-shaped but are not indexes,
1309
+ // and a bare `typeof === "object"` check let them through to produce the same
1310
+ // empty plan this guard exists to prevent — so they are rejected by name
1311
+ // rather than left to fail later as a silent empty lookup.
1312
+ if (!isFootprintIndex(footprint)) {
1313
+ throw new TypeError(
1314
+ `buildPlan: footprint must be a Map or object of page id -> footprint, got ${describeValue(footprint)}`,
1315
+ );
1316
+ }
1317
+ const fp = footprint;
1318
+ const sourceProject = inputsOut.sourceProject;
1319
+
1320
+ // A repeated page id is one page (SPEC-unit planning invariant 1: no page counted twice).
1321
+ // Both `ids` and `pageById` are first-wins, from the same loop, so they cannot
1322
+ // disagree about which record describes the page.
1323
+ const ids = [];
1324
+ const seen = new Set();
1325
+ for (const page of pages) {
1326
+ if (!page || typeof page !== "object") {
1327
+ throw new TypeError("buildPlan: every page must be an object");
1328
+ }
1329
+ if (seen.has(page.page_id)) continue;
1330
+ seen.add(page.page_id);
1331
+ ids.push(page.page_id);
1332
+ }
1333
+ const pageById = new Map();
1334
+ for (const page of pages) {
1335
+ if (!page || typeof page !== "object") continue;
1336
+ if (!pageById.has(page.page_id)) pageById.set(page.page_id, page);
1337
+ }
1338
+
1339
+ // `Map.prototype.get.call`, not `fp.get`: see `writableOf` — a brand-Map with
1340
+ // a rearranged prototype has no own `.get`.
1341
+ const fpIsMap = types.isMap(fp);
1342
+ const footprintOf = (id) => (fpIsMap ? Map.prototype.get.call(fp, id) : fp?.[id]);
1343
+ const resolvedOf = (id) => {
1344
+ const entry = footprintOf(id);
1345
+ return entry && typeof entry === "object" && typeof entry.resolvedFile === "string"
1346
+ ? entry.resolvedFile
1347
+ : null;
1348
+ };
1349
+ // The footprint stores a repo-relative path; resolve it
1350
+ // against the source root before reading. `path.resolve` keeps an absolute
1351
+ // `resolvedFile` as given, so a caller holding an absolute path still works.
1352
+ const estFileOf = (id) => {
1353
+ const rel = resolvedOf(id);
1354
+ if (rel === null) return null;
1355
+ if (typeof sourceProject !== "string" || sourceProject === "") return rel;
1356
+ return path.resolve(sourceProject, rel);
1357
+ };
1358
+
1359
+ const keyCtx = keyContextOf(sourceProject);
1360
+ const keys = new Map(ids.map((id) => [
1361
+ id, keysFor(id, resolvedOf(id), keyCtx),
1362
+ ]));
1363
+
1364
+ const choice = chooseCandidate({ ids, keys, footprint: fp, params: planParamsOut });
1365
+ // With no key available at all there is nothing to group by; the orphan
1366
+ // grouping is what key selection assigns every key-less page anyway.
1367
+ const chosenGroups = choice.chosen === null
1368
+ ? groupsFrom(ids, () => null)
1369
+ : choice.chosen.groups;
1370
+ const groupNames = [...chosenGroups.keys()];
1371
+ const groupNameOf = new Map();
1372
+ for (const [name, members] of chosenGroups) for (const id of members) groupNameOf.set(id, name);
1373
+
1374
+ const dirs = new Map(groupNames.map((name, i) => [name, pageDirOf(i + 1, name)]));
1375
+
1376
+ // span/estimation est, once per page: it feeds both the split decision and est_scenarios.
1377
+ const est = new Map(ids.map((id) => [id, estOf(pageById.get(id), estFileOf(id))]));
1378
+
1379
+ // --- g00 -----------------------------------------------------------------
1380
+ const owners = new Map();
1381
+ const writableById = new Map();
1382
+ for (const id of ids) {
1383
+ const set = writableOf(fp, id);
1384
+ writableById.set(id, set);
1385
+ const name = groupNameOf.get(id);
1386
+ if (name === undefined) continue;
1387
+ for (const f of set) {
1388
+ if (!owners.has(f)) owners.set(f, new Set());
1389
+ owners.get(f).add(name);
1390
+ }
1391
+ }
1392
+ const { g00, foundation } = foundationFilter(owners, chosenGroups.size, {});
1393
+
1394
+ const buckets = new Map();
1395
+ for (const f of [...g00].sort()) {
1396
+ const b = bucketOf(f);
1397
+ if (!buckets.has(b)) buckets.set(b, []);
1398
+ buckets.get(b).push(f);
1399
+ }
1400
+ const bucketNames = [...buckets.keys()].sort();
1401
+ const sharedDirOf = new Map(bucketNames.map((b) => [b, `g00-${b}`]));
1402
+
1403
+ // --- spec_units: g00 contract units first (g00/foundation so-id from 1) -------------
1404
+ const units = [];
1405
+ const groupSpecIds = new Map();
1406
+ for (const name of groupNames) groupSpecIds.set(name, []);
1407
+ for (const b of bucketNames) groupSpecIds.set(`g00-${b}`, []);
1408
+ const takenIds = new Set();
1409
+ for (const b of bucketNames) {
1410
+ const groupId = sharedDirOf.get(b);
1411
+ for (const file of buckets.get(b)) {
1412
+ const specId = sharedIdOf(file, takenIds);
1413
+ units.push({
1414
+ spec_id: specId,
1415
+ page_id: specId,
1416
+ part: 1,
1417
+ parts: 1,
1418
+ dir: groupId,
1419
+ est: 1,
1420
+ status_domain: null,
1421
+ });
1422
+ groupSpecIds.get(groupId).push(specId);
1423
+ }
1424
+ }
1425
+
1426
+ // --- spec_units: page units, clustered by group (format rule 1) --------------
1427
+ //
1428
+ // Rows must be "按组聚集、组内按页面顺序排": `finalize` builds specs.json rows
1429
+ // in `spec_units` order, and output layout's resume detection refuses non-contiguous
1430
+ // so-id inputs. UTG emits nodes grouped by kind, so two pages of one group are
1431
+ // routinely far apart in `pages[]`; emitting in that order would give
1432
+ // g01, g02, g01, g02 for two groups. Iterate the canonical group order and,
1433
+ // inside a group, its members by `pages[]` index — `chosenGroups`' arrays are
1434
+ // sorted for determinism, which is NOT page order.
1435
+ const pageRank = new Map(ids.map((id, i) => [id, i]));
1436
+ for (const name of groupNames) {
1437
+ // Iterating `groupNames` (which holds every id, orphans included) preserves
1438
+ // SPEC-unit planning invariant 1 — every page is emitted exactly once.
1439
+ const members = [...chosenGroups.get(name)].sort((a, b) => pageRank.get(a) - pageRank.get(b));
1440
+ const dir = dirs.get(name);
1441
+ for (const id of members) {
1442
+ const total = est.get(id);
1443
+ const budget = planParamsOut.chunkBudget;
1444
+ const parts = total <= budget ? 1 : Math.ceil(total / budget);
1445
+ const per = Math.ceil(total / parts);
1446
+ for (let i = 1; i <= parts; i++) {
1447
+ const specId = parts === 1 ? id : `${id}#${i}`;
1448
+ units.push({
1449
+ spec_id: specId,
1450
+ page_id: id,
1451
+ part: i,
1452
+ parts,
1453
+ dir,
1454
+ est: per,
1455
+ status_domain: null,
1456
+ });
1457
+ groupSpecIds.get(name).push(specId);
1458
+ }
1459
+ }
1460
+ }
1461
+
1462
+ // --- dependencies: only the buckets this group's pages actually write -------------------
1463
+ const groups = [];
1464
+ for (const b of bucketNames) {
1465
+ const groupId = sharedDirOf.get(b);
1466
+ groups.push({
1467
+ group_id: groupId,
1468
+ dir: groupId,
1469
+ kind: "shared",
1470
+ pages: [],
1471
+ spec_ids: groupSpecIds.get(groupId),
1472
+ deps: [],
1473
+ est_scenarios: buckets.get(b).length,
1474
+ });
1475
+ }
1476
+ for (const name of groupNames) {
1477
+ const members = chosenGroups.get(name);
1478
+ const hit = new Set();
1479
+ for (const id of members) {
1480
+ for (const f of writableById.get(id) ?? []) {
1481
+ if (g00.has(f)) hit.add(bucketOf(f));
1482
+ }
1483
+ }
1484
+ const deps = [...hit].sort().map((b) => `g00-${b}`);
1485
+ groups.push({
1486
+ group_id: dirs.get(name),
1487
+ dir: dirs.get(name),
1488
+ kind: "page",
1489
+ pages: [...members],
1490
+ spec_ids: groupSpecIds.get(name),
1491
+ deps,
1492
+ est_scenarios: members.reduce((sum, id) => sum + (est.get(id) ?? 0), 0),
1493
+ });
1494
+ }
1495
+
1496
+ return {
1497
+ plan_version: planVersionOf(planParamsOut, groups, units),
1498
+ inputs: inputsOut,
1499
+ params: planParamsOut,
1500
+ page_enumeration: inputsOut.pageEnumeration ?? null,
1501
+ pages,
1502
+ unclassified: inputsOut.unclassified ?? [],
1503
+ orphan_overlays: inputsOut.orphanOverlays ?? [],
1504
+ // g00/foundation: the foundation set is excluded from g00 but is not "unspecified" —
1505
+ // grouping-report.json lists it for human review, and nothing else produces
1506
+ // it. Sorted so the report is byte-stable across runs.
1507
+ foundation_files: [...foundation].sort(),
1508
+ // The key selection platform-gate detection, published so a wrong detection (or
1509
+ // an absent `sourceProject`, which disables `module` and `route`) is
1510
+ // auditable rather than invisible.
1511
+ key_context: keyCtx,
1512
+ spec_units: units,
1513
+ groups,
1514
+ // three outcome arrays are carried through unflattened; unifying
1515
+ // them into the flat `candidates[]` report.
1516
+ // `chosen.groups` is a Map and would serialise to `{}` in plan.json, so the
1517
+ // partition itself lives in `groups[]` (JSON-safe) and only the label and
1518
+ // the lossy slices are carried here.
1519
+ grouping: {
1520
+ chosen: choice.chosen === null
1521
+ ? null
1522
+ : { label: choice.chosen.label, artificial: choice.chosen.artificial },
1523
+ candidates: choice.candidates,
1524
+ unavailable: choice.unavailable,
1525
+ deduped: choice.deduped,
1526
+ },
1527
+ };
1528
+ }