@buaa_smat/hometrans 0.1.20 → 26.0.0-devecocli.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 (992) hide show
  1. package/LICENSE +21 -21
  2. package/agents/build-fixer.md +406 -0
  3. package/agents/code-reviewer.md +461 -496
  4. package/agents/model-render-worker.md +34 -0
  5. package/agents/model-worker.md +23 -0
  6. package/agents/specgen-worker.md +18 -0
  7. package/commands/hometrans.md +17 -0
  8. package/devecocli-plugin/common.ts +2203 -0
  9. package/devecocli-plugin/install.ts +61 -0
  10. package/devecocli-plugin/uninstall.ts +26 -0
  11. package/devecocli-plugin/update.ts +66 -0
  12. package/index.js +1418 -0
  13. package/package.json +81 -64
  14. package/platforms/atomcode/agents/build-fixer.frontmatter.md +6 -0
  15. package/platforms/atomcode/agents/code-reviewer.frontmatter.md +6 -0
  16. package/platforms/atomcode/agents/model-render-worker.frontmatter.md +6 -0
  17. package/platforms/atomcode/agents/model-worker.frontmatter.md +6 -0
  18. package/platforms/atomcode/agents/specgen-worker.frontmatter.md +6 -0
  19. package/platforms/deveco/agents/build-fixer.frontmatter.md +5 -0
  20. package/platforms/deveco/agents/code-reviewer.frontmatter.md +5 -0
  21. package/platforms/deveco/agents/model-render-worker.frontmatter.md +5 -0
  22. package/platforms/deveco/agents/model-worker.frontmatter.md +5 -0
  23. package/platforms/deveco/agents/specgen-worker.frontmatter.md +5 -0
  24. package/platforms/opencode/agents/build-fixer.frontmatter.md +5 -0
  25. package/platforms/opencode/agents/code-reviewer.frontmatter.md +5 -0
  26. package/platforms/opencode/agents/model-render-worker.frontmatter.md +5 -0
  27. package/platforms/opencode/agents/model-worker.frontmatter.md +5 -0
  28. package/platforms/opencode/agents/specgen-worker.frontmatter.md +5 -0
  29. package/plugin.jsonc +12 -0
  30. package/skills/a2h-app-migrate/SKILL.md +181 -0
  31. package/skills/a2h-app-migrate/references/config.example.json +27 -0
  32. package/skills/a2h-app-migrate/references/specs.example.json +19 -0
  33. package/skills/a2h-app-migrate/references/stage-map.md +33 -0
  34. package/skills/a2h-app-migrate/references/workflow.yaml +1600 -0
  35. package/skills/a2h-app-migrate/scripts/android_index.mjs +109 -0
  36. package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +80 -0
  37. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +95 -0
  38. package/skills/a2h-app-migrate/scripts/check_signing.mjs +152 -0
  39. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
  40. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +277 -0
  41. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +77 -0
  42. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +147 -0
  43. package/skills/a2h-app-migrate/scripts/cli_values.mjs +32 -0
  44. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1412 -0
  45. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +651 -0
  46. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +53 -0
  47. package/skills/a2h-app-migrate/scripts/json_io.mjs +35 -0
  48. package/skills/a2h-app-migrate/scripts/ledger.mjs +104 -0
  49. package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +288 -0
  50. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +881 -0
  51. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +205 -0
  52. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +121 -0
  53. package/skills/a2h-app-migrate/scripts/run_dir.mjs +212 -0
  54. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +30 -0
  55. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +455 -0
  56. package/skills/a2h-app-migrate/test/test_android_index.mjs +80 -0
  57. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  58. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  59. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +92 -0
  60. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  61. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +93 -0
  62. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +544 -0
  63. package/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
  64. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  65. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  66. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +91 -0
  67. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  68. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  69. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +109 -0
  70. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +53 -0
  71. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  72. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  73. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +144 -0
  74. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
  75. package/skills/a2h-app-migrate/test/test_run_dir.mjs +315 -0
  76. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +133 -0
  77. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +133 -0
  78. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +158 -0
  79. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +181 -0
  80. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  81. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +53 -0
  82. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  83. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  84. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +39 -0
  85. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +168 -0
  86. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  87. package/skills/a2h-arch-generate/SKILL.md +375 -0
  88. package/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  89. package/skills/a2h-arch-generate/examples/simple-conversion-android.md +103 -0
  90. package/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  91. package/skills/a2h-arch-generate/examples/simple-conversion-uniapp.md +106 -0
  92. package/skills/{hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md → a2h-arch-generate/references/arkts-mvvm-v2.md} +1407 -1407
  93. package/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  94. package/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  95. package/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  96. package/skills/a2h-arch-generate/references/clustering-guidance.md +33 -0
  97. package/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  98. package/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  99. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  100. package/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  101. package/skills/a2h-arch-generate/references/homegraph-workflow.md +120 -0
  102. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +45 -0
  103. package/skills/a2h-arch-generate/references/reconciliation-model.md +204 -0
  104. package/skills/a2h-arch-generate/references/scope-policy.md +28 -0
  105. package/skills/a2h-arch-generate/references/semantic-review.md +65 -0
  106. package/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  107. package/skills/a2h-arch-generate/references/source-ecosystems.md +54 -0
  108. package/skills/a2h-arch-generate/references/transformation-model.md +78 -0
  109. package/skills/a2h-arch-generate/scripts/check_module_staleness.mjs +284 -0
  110. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +260 -0
  111. package/skills/a2h-arch-generate/scripts/compute_processing_order.mjs +325 -0
  112. package/skills/a2h-arch-generate/scripts/create_project.mjs +149 -0
  113. package/skills/a2h-arch-generate/scripts/dump_core_facts.mjs +151 -0
  114. package/skills/a2h-arch-generate/scripts/extract_core_components.mjs +167 -0
  115. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +363 -0
  116. package/skills/a2h-arch-generate/scripts/generate_state.mjs +60 -0
  117. package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +326 -0
  118. package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +3739 -0
  119. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +800 -0
  120. package/skills/a2h-arch-generate/scripts/inspect_project.mjs +251 -0
  121. package/skills/a2h-arch-generate/scripts/inspect_uniapp_project.mjs +809 -0
  122. package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1454 -0
  123. package/skills/a2h-arch-generate/scripts/module_create/create.mjs +136 -0
  124. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +636 -0
  125. package/skills/a2h-arch-generate/scripts/module_create/hap/build-profile.json5 +33 -0
  126. package/skills/a2h-arch-generate/scripts/module_create/hap/hvigorfile.ts +6 -0
  127. package/skills/a2h-arch-generate/scripts/module_create/hap/obfuscation-rules.txt +23 -0
  128. package/skills/a2h-arch-generate/scripts/module_create/hap/oh-package.json5 +10 -0
  129. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/applicationability/ApplicationAbility.ets +43 -0
  130. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +23 -0
  131. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/module.json5 +26 -0
  132. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/color.json +8 -0
  133. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/float.json +8 -0
  134. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/string.json +16 -0
  135. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/background.png +0 -0
  136. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/foreground.png +0 -0
  137. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/layered_image.json +7 -0
  138. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/startIcon.png +0 -0
  139. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/profile/main_pages.json +5 -0
  140. package/skills/a2h-arch-generate/scripts/module_create/hap/src/mock/mock-config.json5 +2 -0
  141. package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/Ability.test.ets +35 -0
  142. package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/List.test.ets +5 -0
  143. package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/module.json5 +11 -0
  144. package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/List.test.ets +5 -0
  145. package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/LocalUnit.test.ets +33 -0
  146. package/skills/a2h-arch-generate/scripts/module_create/har/Index.ets +1 -0
  147. package/skills/a2h-arch-generate/scripts/module_create/har/build-profile.json5 +36 -0
  148. package/skills/a2h-arch-generate/scripts/module_create/har/hvigorfile.ts +6 -0
  149. package/skills/a2h-arch-generate/scripts/module_create/har/obfuscation-rules.txt +23 -0
  150. package/skills/a2h-arch-generate/scripts/module_create/har/oh-package.json5 +9 -0
  151. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +19 -0
  152. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/module.json5 +9 -0
  153. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/float.json +8 -0
  154. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/string.json +8 -0
  155. package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/Ability.test.ets +35 -0
  156. package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/List.test.ets +5 -0
  157. package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/module.json5 +11 -0
  158. package/skills/a2h-arch-generate/scripts/module_create/har/src/test/List.test.ets +5 -0
  159. package/skills/a2h-arch-generate/scripts/module_create/har/src/test/LocalUnit.test.ets +33 -0
  160. package/skills/a2h-arch-generate/scripts/module_create/hsp/Index.ets +1 -0
  161. package/skills/a2h-arch-generate/scripts/module_create/hsp/build-profile.json5 +36 -0
  162. package/skills/a2h-arch-generate/scripts/module_create/hsp/consumer-rules.txt +0 -0
  163. package/skills/a2h-arch-generate/scripts/module_create/hsp/hvigorfile.ts +6 -0
  164. package/skills/a2h-arch-generate/scripts/module_create/hsp/obfuscation-rules.txt +23 -0
  165. package/skills/a2h-arch-generate/scripts/module_create/hsp/oh-package.json5 +10 -0
  166. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +20 -0
  167. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/utils/Calc.ets +3 -0
  168. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/module.json5 +12 -0
  169. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/float.json +8 -0
  170. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/string.json +8 -0
  171. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/profile/main_pages.json +5 -0
  172. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/Ability.test.ets +35 -0
  173. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/List.test.ets +5 -0
  174. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/module.json5 +11 -0
  175. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/List.test.ets +5 -0
  176. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/LocalUnit.test.ets +33 -0
  177. package/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  178. package/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  179. package/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  180. package/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  181. package/skills/a2h-arch-generate/scripts/resolve_android_stores.mjs +529 -0
  182. package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +230 -0
  183. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  184. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  185. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  186. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  187. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  188. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  189. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  190. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  191. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  192. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  193. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  194. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  195. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  196. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  197. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  198. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  199. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  200. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  201. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  202. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  203. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  204. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  205. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  206. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  207. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  208. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  209. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  210. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1122 -0
  211. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +191 -0
  212. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  213. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  214. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
  215. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +829 -0
  216. package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +937 -0
  217. package/skills/a2h-arch-generate/scripts/validate_homegraph_artifacts.mjs +542 -0
  218. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +415 -0
  219. package/skills/a2h-arkts-logic-coder/SKILL.md +125 -0
  220. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +6 -0
  221. package/skills/a2h-arkts-logic-coder/references/code-generation.md +124 -0
  222. package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +224 -0
  223. package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +377 -0
  224. package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +443 -0
  225. package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +211 -0
  226. package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +81 -0
  227. package/skills/a2h-batch-ui-align/SKILL.md +321 -0
  228. package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +81 -0
  229. package/skills/a2h-batch-ui-align/flowchart.html +271 -0
  230. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +572 -0
  231. package/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
  232. package/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  233. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -2533
  234. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +558 -555
  235. package/skills/{hmos-incremental-ui-align/references → a2h-batch-ui-align/references/mappings}/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
  236. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
  237. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
  238. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
  239. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
  240. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
  241. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
  242. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
  243. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
  244. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
  245. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
  246. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
  247. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
  248. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
  249. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -206
  250. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -373
  251. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -158
  252. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -750
  253. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -1704
  254. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -1012
  255. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -164
  256. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -840
  257. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -856
  258. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -83
  259. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -294
  260. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -1407
  261. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -1220
  262. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -47
  263. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -133
  264. package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -840
  265. package/skills/a2h-batch-ui-align/references/source-only-tier.md +32 -0
  266. package/skills/a2h-batch-ui-align/references/step3-capture.md +214 -0
  267. package/skills/a2h-batch-ui-align/references/step4-prepare.md +196 -0
  268. package/skills/a2h-batch-ui-align/references/step5-convert.md +205 -0
  269. package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +572 -0
  270. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/scripts/android_parse_fast.ts +246 -39
  271. package/skills/a2h-batch-ui-align/scripts/answers_check.mjs +86 -0
  272. package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +3858 -0
  273. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1675 -0
  274. package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  275. package/skills/a2h-batch-ui-align/scripts/detach.mjs +258 -0
  276. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1644 -0
  277. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  278. package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +166 -0
  279. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1627 -0
  280. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1869 -0
  281. package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +696 -0
  282. package/skills/a2h-batch-ui-align/scripts/harmony_index.mjs +218 -0
  283. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +208 -0
  284. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1229 -0
  285. package/skills/a2h-batch-ui-align/scripts/occlusion.mjs +141 -0
  286. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1179 -0
  287. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1036 -0
  288. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +217 -0
  289. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +253 -0
  290. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  291. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +241 -0
  292. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +341 -0
  293. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  294. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  295. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  296. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +445 -0
  297. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +356 -0
  298. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +290 -0
  299. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +74 -0
  300. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  301. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +564 -0
  302. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  303. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  304. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +241 -0
  305. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1451 -0
  306. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  307. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  308. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  309. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +170 -0
  310. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  311. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +244 -0
  312. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +166 -0
  313. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  314. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +219 -0
  315. package/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  316. package/skills/a2h-coldstart-smoke-gate/SKILL.md +57 -0
  317. package/skills/a2h-dashboard-render/SKILL.md +65 -0
  318. package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +147 -0
  319. package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  320. package/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  321. package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +83 -0
  322. package/skills/a2h-dashboard-render/scripts/artifact_contract.mjs +138 -0
  323. package/skills/a2h-dashboard-render/scripts/check-registry.mjs +87 -0
  324. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +3215 -0
  325. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +2010 -0
  326. package/skills/a2h-dashboard-render/scripts/page_capture.mjs +828 -0
  327. package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +459 -0
  328. package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +13 -0
  329. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  330. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  331. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  332. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  333. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  334. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +170 -0
  335. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  336. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +182 -0
  337. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +64 -0
  338. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1172 -0
  339. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +251 -0
  340. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  341. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  342. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +303 -0
  343. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  344. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +444 -0
  345. package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/SKILL.md +305 -293
  346. package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/arkts-strict-patterns.md +219 -219
  347. package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/known-patterns.md +157 -157
  348. package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/rdb-entity-pattern.md +131 -131
  349. package/skills/a2h-module-semantic-docs/SKILL.md +227 -0
  350. package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +168 -0
  351. package/skills/a2h-module-semantic-docs/scripts/lib/py_compat.mjs +688 -0
  352. package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +1021 -0
  353. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  354. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  355. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  356. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  357. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  358. package/skills/a2h-resource-convert/SKILL.md +369 -0
  359. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/code-vector-icon-rules.md +335 -335
  360. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/conversion-rules.md +687 -676
  361. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/dependency-analysis-rules.md +410 -410
  362. package/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
  363. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/lottie-conversion-rules.md +219 -219
  364. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/resource-mapping-rules.md +493 -482
  365. package/skills/a2h-resource-convert/references/step3_5-dependency-filter.md +54 -0
  366. package/skills/a2h-resource-convert/references/step4-qualifiers-and-values.md +142 -0
  367. package/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
  368. package/skills/a2h-resource-convert/references/step5-reference-resolution.md +154 -0
  369. package/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  370. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/xml-drawable-to-svg-rules.md +630 -592
  371. package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/a2h_resource_convert.ts +2529 -2163
  372. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +1072 -0
  373. package/skills/a2h-resource-convert/scripts/app_identity.ts +947 -0
  374. package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/code_vector_icons.ts +607 -591
  375. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +989 -0
  376. package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +1464 -0
  377. package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/svg_fidelity_check.ts +632 -632
  378. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  379. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  380. package/skills/a2h-spec-design/SKILL.md +336 -0
  381. package/skills/a2h-spec-design/scripts/inspect_spec_design_inputs.mjs +146 -0
  382. package/skills/a2h-spec-design/scripts/lib/py_compat.mjs +481 -0
  383. package/skills/a2h-spec-design/scripts/move_spec_technical_reference.mjs +159 -0
  384. package/skills/a2h-spec-design/scripts/resolve_module_design.mjs +102 -0
  385. package/skills/a2h-spec-design/scripts/validate_spec_design_output.mjs +285 -0
  386. package/skills/a2h-spec-design/test/golden/inspect_happy.json +20 -0
  387. package/skills/a2h-spec-design/test/golden/move_design.md +18 -0
  388. package/skills/a2h-spec-design/test/golden/move_design_crlf.md +18 -0
  389. package/skills/a2h-spec-design/test/golden/move_spec.md +7 -0
  390. package/skills/a2h-spec-design/test/golden/resolve_cases.json +36 -0
  391. package/skills/a2h-spec-design/test/golden/validate_issue_file.md +12 -0
  392. package/skills/a2h-spec-design/test/golden/validate_issues.json +57 -0
  393. package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +381 -0
  394. package/skills/a2h-spec-design-pipeline/SKILL.md +228 -0
  395. package/skills/a2h-spec-design-pipeline/package.json +4 -0
  396. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +63 -0
  397. package/skills/a2h-spec-design-pipeline/references/execution-model.md +69 -0
  398. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +24 -0
  399. package/skills/a2h-spec-design-pipeline/references/initialization.md +57 -0
  400. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +21 -0
  401. package/skills/a2h-spec-design-pipeline/references/scripts.md +27 -0
  402. package/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  403. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +21 -0
  404. package/skills/a2h-spec-design-pipeline/scripts/atomic_write.ts +42 -0
  405. package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +252 -0
  406. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +77 -0
  407. package/skills/a2h-spec-design-pipeline/scripts/deps_ready.ts +195 -0
  408. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +651 -0
  409. package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +124 -0
  410. package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +944 -0
  411. package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +95 -0
  412. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +502 -0
  413. package/skills/a2h-spec-design-pipeline/scripts/plan_waves.ts +475 -0
  414. package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +218 -0
  415. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +164 -0
  416. package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +44 -0
  417. package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +301 -0
  418. package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +64 -0
  419. package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +87 -0
  420. package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +265 -0
  421. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +675 -0
  422. package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +105 -0
  423. package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +452 -0
  424. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +375 -0
  425. package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +561 -0
  426. package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +182 -0
  427. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +138 -0
  428. package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +289 -0
  429. package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +441 -0
  430. package/skills/a2h-spec-generate/SKILL.md +285 -0
  431. package/skills/a2h-spec-generate/package.json +9 -0
  432. package/skills/a2h-spec-generate/references/batch-mode.md +151 -0
  433. package/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  434. package/skills/a2h-spec-generate/references/fusion-task-contract.md +114 -0
  435. package/skills/a2h-spec-generate/references/input-formats.md +27 -0
  436. package/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  437. package/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  438. package/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  439. package/skills/a2h-spec-generate/references/recall-guide.md +83 -0
  440. package/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  441. package/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  442. package/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  443. package/skills/a2h-spec-generate/references/review-checklist.md +21 -0
  444. package/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  445. package/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  446. package/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  447. package/skills/a2h-spec-generate/references/specs.schema.json +79 -0
  448. package/skills/a2h-spec-generate/references/synthesis-rules.md +143 -0
  449. package/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  450. package/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  451. package/skills/a2h-spec-generate/references/worker-rules.md +126 -0
  452. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +514 -0
  453. package/skills/a2h-spec-generate/scripts/check_spec.ts +361 -0
  454. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +470 -0
  455. package/skills/a2h-spec-generate/scripts/detect-project.mjs +271 -0
  456. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +188 -0
  457. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +150 -0
  458. package/skills/a2h-spec-generate/scripts/inspect-uniapp.mjs +733 -0
  459. package/skills/{hmos-spec-generate → a2h-spec-generate}/scripts/parse_requirements.ts +515 -515
  460. package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +307 -0
  461. package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +171 -0
  462. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +280 -0
  463. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +399 -0
  464. package/skills/a2h-spec-generate/scripts/report.mjs +132 -0
  465. package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +149 -0
  466. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +49 -0
  467. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +140 -0
  468. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +16 -0
  469. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +42 -0
  470. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-splitters.js +78 -0
  471. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-state.js +47 -0
  472. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +194 -0
  473. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-virtual-list.js +118 -0
  474. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.css +245 -0
  475. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +99 -0
  476. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +220 -0
  477. package/skills/a2h-spec-generate/scripts/reqgen/package-lock.json +47 -0
  478. package/skills/a2h-spec-generate/scripts/reqgen/package.json +23 -0
  479. package/skills/a2h-spec-generate/scripts/reqgen/src/agent-render/serve.ts +95 -0
  480. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/callback-call-sites.ts +82 -0
  481. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/area-ownership.ts +496 -0
  482. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  483. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/callback-flow.ts +386 -0
  484. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  485. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/index.ts +24 -0
  486. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/index.ts +22 -0
  487. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  488. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  489. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1270 -0
  490. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/index.ts +10 -0
  491. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/projection.ts +804 -0
  492. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/render-projection.ts +51 -0
  493. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/android-interaction-registry.ts +286 -0
  494. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/builder.ts +453 -0
  495. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/compose-api-registry.ts +526 -0
  496. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/index.ts +15 -0
  497. package/skills/a2h-spec-generate/scripts/reqgen/src/connector/index.ts +1 -0
  498. package/skills/a2h-spec-generate/scripts/reqgen/src/connector/utg-inbound.ts +763 -0
  499. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/area-graph.ts +383 -0
  500. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/artifact.ts +68 -0
  501. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/common.ts +88 -0
  502. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/diagnostic.ts +64 -0
  503. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/gap-audit.ts +113 -0
  504. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/index.ts +12 -0
  505. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/name-traceability.ts +108 -0
  506. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/raw-fact.ts +377 -0
  507. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/req-model.ts +238 -0
  508. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/run.ts +134 -0
  509. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/semantic-completeness.ts +35 -0
  510. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/source-facts.ts +48 -0
  511. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/utg.ts +133 -0
  512. package/skills/a2h-spec-generate/scripts/reqgen/src/core/output-guard.ts +42 -0
  513. package/skills/a2h-spec-generate/scripts/reqgen/src/core/stable-id.ts +118 -0
  514. package/skills/a2h-spec-generate/scripts/reqgen/src/cross-area-tally-cli.ts +179 -0
  515. package/skills/a2h-spec-generate/scripts/reqgen/src/dashboard-cli.ts +188 -0
  516. package/skills/a2h-spec-generate/scripts/reqgen/src/dump/dump.ts +1184 -0
  517. package/skills/a2h-spec-generate/scripts/reqgen/src/dump/index.ts +1 -0
  518. package/skills/a2h-spec-generate/scripts/reqgen/src/dump-cli.ts +373 -0
  519. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1014 -0
  520. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +32 -0
  521. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +142 -0
  522. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +312 -0
  523. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +310 -0
  524. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +685 -0
  525. package/skills/a2h-spec-generate/scripts/reqgen/src/graph/paths.ts +575 -0
  526. package/skills/a2h-spec-generate/scripts/reqgen/src/homegraph-cli.ts +50 -0
  527. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/android-resource-resolver.ts +391 -0
  528. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/androidx-preference-contracts.ts +44 -0
  529. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +640 -0
  530. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/cross-area.ts +207 -0
  531. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/finalizer.ts +1297 -0
  532. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/identity.ts +186 -0
  533. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/index.ts +16 -0
  534. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/planner.ts +312 -0
  535. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/preference-enrichment.ts +793 -0
  536. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/raw-facts.ts +355 -0
  537. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/rules.ts +271 -0
  538. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/scanner.ts +666 -0
  539. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +365 -0
  540. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/stable-key.ts +144 -0
  541. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +301 -0
  542. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  543. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/uniapp-utg-adapter.ts +543 -0
  544. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/xml-adapter.ts +262 -0
  545. package/skills/a2h-spec-generate/scripts/reqgen/src/model/assemble.ts +2079 -0
  546. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +157 -0
  547. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +809 -0
  548. package/skills/a2h-spec-generate/scripts/reqgen/src/model/index.ts +17 -0
  549. package/skills/a2h-spec-generate/scripts/reqgen/src/model/io.ts +165 -0
  550. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +806 -0
  551. package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +360 -0
  552. package/skills/a2h-spec-generate/scripts/reqgen/src/model/seeds.ts +218 -0
  553. package/skills/a2h-spec-generate/scripts/reqgen/src/model/spec-bindings-sidecar.ts +240 -0
  554. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +359 -0
  555. package/skills/a2h-spec-generate/scripts/reqgen/src/model-cli.ts +500 -0
  556. package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/index.ts +7 -0
  557. package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/output.ts +307 -0
  558. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +172 -0
  559. package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/index.ts +1 -0
  560. package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/source-cov.ts +176 -0
  561. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  562. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/area-graph.ts +490 -0
  563. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/index.ts +23 -0
  564. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-model.ts +957 -0
  565. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +248 -0
  566. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/semantic-area-graph.ts +1600 -0
  567. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/types.ts +10 -0
  568. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/artifact-data.ts +201 -0
  569. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +74 -0
  570. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +180 -0
  571. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +18 -0
  572. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +55 -0
  573. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-splitters.ts +78 -0
  574. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-state.ts +66 -0
  575. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +232 -0
  576. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-virtual-list.ts +179 -0
  577. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +240 -0
  578. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/contracts.d.ts +86 -0
  579. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/index.ts +3 -0
  580. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/server.ts +239 -0
  581. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/source-project.ts +316 -0
  582. package/skills/a2h-spec-generate/scripts/reqgen/src/viz-cli.ts +200 -0
  583. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  584. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  585. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  586. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  587. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +290 -0
  588. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1323 -0
  589. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +574 -0
  590. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  591. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +831 -0
  592. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +548 -0
  593. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  594. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +396 -0
  595. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  596. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +298 -0
  597. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  598. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  599. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  600. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  601. package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.json +16 -0
  602. package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.viz-client.json +12 -0
  603. package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.txt +22 -22
  604. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +632 -0
  605. package/skills/a2h-spec-generate/test/check-spec.test.ts +200 -0
  606. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +538 -0
  607. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  608. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +45 -0
  609. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +147 -0
  610. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  611. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  612. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  613. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  614. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  615. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  616. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  617. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  618. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  619. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  620. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  621. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  622. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  623. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  624. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  625. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  626. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  627. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +157 -0
  628. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +282 -0
  629. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +593 -0
  630. package/skills/a2h-utg-explorer/SKILL.md +120 -0
  631. package/skills/a2h-utg-explorer/assets/final_viewer.html +64 -0
  632. package/skills/a2h-utg-explorer/assets/u2.LICENSE +21 -0
  633. package/skills/a2h-utg-explorer/assets/u2.NOTICE +25 -0
  634. package/skills/a2h-utg-explorer/assets/u2.jar +0 -0
  635. package/skills/a2h-utg-explorer/references/architecture.md +270 -0
  636. package/skills/a2h-utg-explorer/references/protocol.md +9 -0
  637. package/skills/a2h-utg-explorer/scripts/app_settings.mjs +143 -0
  638. package/skills/a2h-utg-explorer/scripts/audit.mjs +167 -0
  639. package/skills/a2h-utg-explorer/scripts/close_phases.mjs +66 -0
  640. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +749 -0
  641. package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +597 -0
  642. package/skills/a2h-utg-explorer/scripts/device_health.mjs +227 -0
  643. package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +276 -0
  644. package/skills/a2h-utg-explorer/scripts/evidence.mjs +108 -0
  645. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +428 -0
  646. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +89 -0
  647. package/skills/a2h-utg-explorer/scripts/plan.mjs +258 -0
  648. package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +170 -0
  649. package/skills/a2h-utg-explorer/scripts/recover.mjs +467 -0
  650. package/skills/a2h-utg-explorer/scripts/recover_b.mjs +542 -0
  651. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +369 -0
  652. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +203 -0
  653. package/skills/a2h-utg-explorer/scripts/report.mjs +143 -0
  654. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +844 -0
  655. package/skills/a2h-utg-explorer/scripts/run_device.mjs +137 -0
  656. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  657. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  658. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +243 -0
  659. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  660. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +223 -0
  661. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +88 -0
  662. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  663. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  664. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +136 -0
  665. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  666. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  667. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +251 -0
  668. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +42 -0
  669. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +162 -0
  670. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  671. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +204 -0
  672. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +355 -0
  673. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  674. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  675. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  676. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +267 -0
  677. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  678. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  679. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +453 -0
  680. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +131 -0
  681. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  682. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  683. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  684. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  685. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  686. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  687. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  688. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  689. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  690. package/skills/a2h-utg-explorer/scripts/utg_explorer/_device_io.mjs +244 -0
  691. package/skills/a2h-utg-explorer/scripts/utg_explorer/_py.mjs +2097 -0
  692. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +1231 -0
  693. package/skills/a2h-utg-explorer/scripts/utg_explorer/attest.mjs +63 -0
  694. package/skills/a2h-utg-explorer/scripts/utg_explorer/chain.mjs +63 -0
  695. package/skills/a2h-utg-explorer/scripts/utg_explorer/coverage.mjs +89 -0
  696. package/skills/a2h-utg-explorer/scripts/utg_explorer/device_lock.mjs +46 -0
  697. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1200 -0
  698. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +1558 -0
  699. package/skills/a2h-utg-explorer/scripts/variant.mjs +75 -0
  700. package/skills/a2h-utg-explorer/scripts/worklist_parts.mjs +122 -0
  701. package/skills/a2h-utg-static/SKILL.md +361 -0
  702. package/skills/a2h-utg-static/config.json +19 -0
  703. package/skills/a2h-utg-static/references/extractors.md +217 -0
  704. package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  705. package/skills/a2h-utg-static/references/view-interactions.md +215 -0
  706. package/skills/a2h-utg-static/scripts/_graph.mjs +361 -0
  707. package/skills/a2h-utg-static/scripts/_py.mjs +2177 -0
  708. package/skills/a2h-utg-static/scripts/_spawn.mjs +45 -0
  709. package/skills/a2h-utg-static/scripts/activity_nav.mjs +738 -0
  710. package/skills/a2h-utg-static/scripts/activity_widgets.mjs +254 -0
  711. package/skills/a2h-utg-static/scripts/adapter_nav.mjs +229 -0
  712. package/skills/a2h-utg-static/scripts/androidfragment_nav.mjs +208 -0
  713. package/skills/a2h-utg-static/scripts/assemble.mjs +2065 -0
  714. package/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  715. package/skills/a2h-utg-static/scripts/carry_answers.mjs +201 -0
  716. package/skills/a2h-utg-static/scripts/click_paths.mjs +594 -0
  717. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +226 -0
  718. package/skills/a2h-utg-static/scripts/compose_merge.mjs +263 -0
  719. package/skills/a2h-utg-static/scripts/compose_nav.mjs +1216 -0
  720. package/skills/a2h-utg-static/scripts/compose_navbar_nav.mjs +238 -0
  721. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +2760 -0
  722. package/skills/a2h-utg-static/scripts/compose_titles.mjs +365 -0
  723. package/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  724. package/skills/a2h-utg-static/scripts/dialog_listener_nav.mjs +237 -0
  725. package/skills/a2h-utg-static/scripts/dialogshow_nav.mjs +308 -0
  726. package/skills/a2h-utg-static/scripts/fragfactory_nav.mjs +170 -0
  727. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +1136 -0
  728. package/skills/a2h-utg-static/scripts/guard_subjects.mjs +162 -0
  729. package/skills/a2h-utg-static/scripts/hg_query.mjs +137 -0
  730. package/skills/a2h-utg-static/scripts/host_resolve.mjs +393 -0
  731. package/skills/a2h-utg-static/scripts/hybrid_bundle.mjs +165 -0
  732. package/skills/a2h-utg-static/scripts/hybrid_pages.mjs +713 -0
  733. package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
  734. package/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  735. package/skills/a2h-utg-static/scripts/io_utils.mjs +59 -0
  736. package/skills/a2h-utg-static/scripts/label_resolve.mjs +864 -0
  737. package/skills/a2h-utg-static/scripts/launch_extras.mjs +91 -0
  738. package/skills/a2h-utg-static/scripts/layout_resolve.mjs +148 -0
  739. package/skills/a2h-utg-static/scripts/manifest.mjs +483 -0
  740. package/skills/a2h-utg-static/scripts/measure/measure_corpus.mjs +297 -0
  741. package/skills/a2h-utg-static/scripts/measure/measure_guards.mjs +98 -0
  742. package/skills/a2h-utg-static/scripts/media_browse_nav.mjs +356 -0
  743. package/skills/a2h-utg-static/scripts/menu_nav.mjs +603 -0
  744. package/skills/a2h-utg-static/scripts/navactions_nav.mjs +255 -0
  745. package/skills/a2h-utg-static/scripts/nl_hints.mjs +453 -0
  746. package/skills/a2h-utg-static/scripts/orphan_overlay_nav.mjs +89 -0
  747. package/skills/a2h-utg-static/scripts/phase_plan.mjs +108 -0
  748. package/skills/a2h-utg-static/scripts/phase_planner.mjs +119 -0
  749. package/skills/a2h-utg-static/scripts/plaindialog_nav.mjs +411 -0
  750. package/skills/a2h-utg-static/scripts/preference_nav.mjs +761 -0
  751. package/skills/a2h-utg-static/scripts/preference_widgets.mjs +142 -0
  752. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  753. package/skills/a2h-utg-static/scripts/registry_nav.mjs +288 -0
  754. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +870 -0
  755. package/skills/a2h-utg-static/scripts/scope_utils.mjs +430 -0
  756. package/skills/a2h-utg-static/scripts/screen_merge.mjs +287 -0
  757. package/skills/a2h-utg-static/scripts/screen_nav.mjs +279 -0
  758. package/skills/a2h-utg-static/scripts/single_host_nav.mjs +291 -0
  759. package/skills/a2h-utg-static/scripts/starter_nav.mjs +198 -0
  760. package/skills/a2h-utg-static/scripts/state_guard.mjs +579 -0
  761. package/skills/a2h-utg-static/scripts/static_prior.mjs +904 -0
  762. package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
  763. package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
  764. package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
  765. package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
  766. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  767. package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +90 -0
  768. package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
  769. package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
  770. package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
  771. package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  772. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
  773. package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  774. package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  775. package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
  776. package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
  777. package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
  778. package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
  779. package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +284 -0
  780. package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
  781. package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
  782. package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
  783. package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
  784. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
  785. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
  786. package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  787. package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  788. package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
  789. package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
  790. package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
  791. package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
  792. package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
  793. package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
  794. package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
  795. package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
  796. package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
  797. package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
  798. package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +119 -0
  799. package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
  800. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  801. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  802. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
  803. package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  804. package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
  805. package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
  806. package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
  807. package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  808. package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  809. package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  810. package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
  811. package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
  812. package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
  813. package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
  814. package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
  815. package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
  816. package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  817. package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +33 -0
  818. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
  819. package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
  820. package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
  821. package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  822. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  823. package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
  824. package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  825. package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
  826. package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
  827. package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
  828. package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
  829. package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
  830. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
  831. package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
  832. package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
  833. package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
  834. package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
  835. package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
  836. package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  837. package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  838. package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
  839. package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
  840. package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
  841. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
  842. package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
  843. package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
  844. package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  845. package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
  846. package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
  847. package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
  848. package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
  849. package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
  850. package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
  851. package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  852. package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  853. package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
  854. package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +58 -0
  855. package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
  856. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
  857. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  858. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
  859. package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
  860. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
  861. package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
  862. package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
  863. package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
  864. package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  865. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
  866. package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
  867. package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
  868. package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
  869. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1119 -0
  870. package/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  871. package/skills/a2h-utg-static/scripts/utg_html.mjs +721 -0
  872. package/skills/a2h-utg-static/scripts/view_interactions.mjs +799 -0
  873. package/skills/a2h-utg-static/scripts/view_widgets.mjs +512 -0
  874. package/skills/a2h-utg-static/scripts/viewpage_nav.mjs +589 -0
  875. package/skills/a2h-utg-static/scripts/vm_nav.mjs +422 -0
  876. package/skills/a2h-utg-static/scripts/window_nav.mjs +240 -0
  877. package/skills/a2h-utg-static/scripts/worklist_parts.mjs +154 -0
  878. package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  879. package/skills/a2h-utg-static/tools/package.json +3 -0
  880. package/README.md +0 -445
  881. package/agents/logic-coder.md +0 -224
  882. package/agents/logic-context-builder.md +0 -212
  883. package/agents/scripts/hmos-precheck/backends/arkts.mjs +0 -567
  884. package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +0 -159
  885. package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +0 -398
  886. package/agents/scripts/hmos-precheck/backends/codelinter.mjs +0 -250
  887. package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +0 -321
  888. package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +0 -247
  889. package/agents/scripts/hmos-precheck/core/config.mjs +0 -184
  890. package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +0 -20
  891. package/agents/scripts/hmos-precheck/core/process_adapter.mjs +0 -47
  892. package/agents/scripts/hmos-precheck/core/project_catalog.mjs +0 -50
  893. package/agents/scripts/hmos-precheck/core/result_projection.mjs +0 -147
  894. package/agents/scripts/hmos-precheck/core/scope_plan.mjs +0 -131
  895. package/agents/scripts/hmos-precheck/core/sdk_context.mjs +0 -67
  896. package/agents/scripts/hmos-precheck/docs/architecture.md +0 -37
  897. package/agents/scripts/hmos-precheck/docs/performance-optimization.md +0 -28
  898. package/agents/scripts/hmos-precheck/docs/upstream-reference.json +0 -19
  899. package/agents/scripts/hmos-precheck/docs/validation.md +0 -50
  900. package/agents/scripts/hmos-precheck/index.mjs +0 -17
  901. package/agents/scripts/hmos-precheck/invocation.mjs +0 -231
  902. package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +0 -32
  903. package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +0 -64
  904. package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +0 -59
  905. package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +0 -54
  906. package/agents/scripts/platform_query.mjs +0 -626
  907. package/agents/scripts/platform_query.test.mjs +0 -422
  908. package/agents/self-test-fixer.md +0 -298
  909. package/agents/self-tester.md +0 -55
  910. package/agents/test-case-generation-generator.md +0 -317
  911. package/agents/test-case-generation-validator.md +0 -231
  912. package/dist/cli/config-store.js +0 -310
  913. package/dist/cli/config.js +0 -44
  914. package/dist/cli/env-vars.js +0 -127
  915. package/dist/cli/index.js +0 -56
  916. package/dist/cli/init.js +0 -1187
  917. package/dist/cli/uninstall.js +0 -427
  918. package/dist/utils/regex.js +0 -8
  919. package/env-requirements.json +0 -179
  920. package/resource/choose_editor.png +0 -0
  921. package/resource/convert_pipeline_process.svg +0 -103
  922. package/resource/project_architecture.svg +0 -122
  923. package/resource/set_environment.png +0 -0
  924. package/resource/set_multimodel.png +0 -0
  925. package/resource/set_sdk.png +0 -0
  926. package/resource/title_dark.png +0 -0
  927. package/skills/hmos-batch-ui-align/SKILL.md +0 -413
  928. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +0 -661
  929. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -117
  930. package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -648
  931. package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -1183
  932. package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +0 -576
  933. package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +0 -297
  934. package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +0 -395
  935. package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -903
  936. package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -1178
  937. package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -355
  938. package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +0 -11
  939. package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +0 -206
  940. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +0 -750
  941. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +0 -840
  942. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -856
  943. package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -294
  944. package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -1220
  945. package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +0 -840
  946. package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +0 -1592
  947. package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +0 -752
  948. package/skills/hmos-convert-pipeline/SKILL.md +0 -486
  949. package/skills/hmos-incremental-ui-align/README.md +0 -251
  950. package/skills/hmos-incremental-ui-align/SKILL.md +0 -375
  951. package/skills/hmos-incremental-ui-align/diff_analysis.md +0 -53
  952. package/skills/hmos-incremental-ui-align/page_align.md +0 -62
  953. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +0 -38
  954. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +0 -2089
  955. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +0 -1033
  956. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +0 -106
  957. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +0 -911
  958. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +0 -373
  959. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +0 -158
  960. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +0 -1704
  961. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +0 -1012
  962. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +0 -164
  963. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +0 -83
  964. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +0 -47
  965. package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +0 -74
  966. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +0 -34
  967. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +0 -2533
  968. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +0 -555
  969. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +0 -937
  970. package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +0 -343
  971. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +0 -76
  972. package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +0 -977
  973. package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +0 -188
  974. package/skills/hmos-integration-test/README.md +0 -341
  975. package/skills/hmos-integration-test/SKILL.md +0 -464
  976. package/skills/hmos-integration-test/scripts/report-tool.ts +0 -791
  977. package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +0 -125
  978. package/skills/hmos-integration-test/scripts/self-test-runner.ts +0 -756
  979. package/skills/hmos-integration-test/scripts/testcases-tool.ts +0 -239
  980. package/skills/hmos-resources-convert/SKILL.md +0 -891
  981. package/skills/hmos-spec-generate/SKILL.md +0 -404
  982. package/skills/hmos-test-case-generation/README.md +0 -241
  983. package/skills/hmos-test-case-generation/SKILL.md +0 -324
  984. package/skills/hmos-test-case-generation/references/contract.md +0 -315
  985. package/skills/hmos-test-case-generation/references/review-notes-template.md +0 -84
  986. package/skills/hmos-test-case-generation/references/ui-elements-schema.md +0 -142
  987. package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +0 -550
  988. package/skills/hmos-test-case-generation/tools/validate.ts +0 -1312
  989. package/tools/bfs-crawl/README.md +0 -73
  990. package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +0 -1662
  991. /package/{README.en.md → skills/a2h-arch-generate/scripts/module_create/har/consumer-rules.txt} +0 -0
  992. /package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.xlsx +0 -0
@@ -0,0 +1,1675 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * build_conversion_set.mjs — make the static UTG, not the capture, decide what
4
+ * gets converted.
5
+ *
6
+ * node build_conversion_set.mjs <utg_static_ws> --ui-info <ui_info_root>
7
+ *
8
+ * (Node >= 22.18, ESM, zero dependencies. Behaviour-identical port of
9
+ * build_conversion_set.py: same args, exit codes, stdout and output files.)
10
+ *
11
+ * Run AFTER export_ui_info.mjs. Every static node gets exactly one role:
12
+ *
13
+ * page converted on its own. Tier `captured` when export_ui_info wrote
14
+ * a snapshot for it, else tier `source-only`: a page_NNNN_<Name>/
15
+ * directory is created with a meta.json that carries source hints
16
+ * (declared_at, layout files, ids, widgets, edges) and no screenshot.
17
+ * attach a menu / ui-state / mode / panel / embedded fragment. Converted as
18
+ * part of its host page's unit, never as a page of its own.
19
+ * skip not an app screen (out of scope, container, UI-less shell,
20
+ * unreachable). Listed with its reason, never silently dropped.
21
+ *
22
+ * Input : <ws>/utg.json, <ws>/click_paths.json,
23
+ * <ui_info>/export_manifest.json, <ui_info>/pages.json (both optional:
24
+ * without them every page is source-only).
25
+ * Output: <ui_info>/page_NNNN_<Name>/meta.json (source-only pages)
26
+ * <ui_info>/pages.json (captured first, then source-only)
27
+ * <ui_info>/conversion_set.json (every node's role, tier, reason;
28
+ * `plan`: the Step 4.2 groups, their
29
+ * predicted writes, class, lane, stage,
30
+ * `after` / `reuse_from` dependencies)
31
+ *
32
+ * Re-runnable: a source-only directory whose node has since been captured is
33
+ * removed, so it is not converted twice. Everything else is stable across
34
+ * re-runs: a source-only page keeps its directory and a group keeps its id
35
+ * (keyed by anchor; `--renumber` resets), so the builder can run after every
36
+ * explorer step while group_queue.mjs is already converting (`--exploring` holds
37
+ * source-only groups until the final run without it).
38
+ *
39
+ * Incremental mode (`--scope <json>`, the user-confirmed SCOPE of
40
+ * references/incremental-scope.md I4): only the scope's pages are converted. Every
41
+ * other page becomes `skip` (`out-of-incremental-scope`), and its source-only
42
+ * directory, if an earlier run made one, is left alone. The entry node is still
43
+ * inferred over the whole graph, so a group mounted on the existing launch page
44
+ * keeps `ENTRY_PAGE`. `--existing <json>` lists the .ets files the Harmony
45
+ * project already has (I3, relative to the ETS root): a group predicted to write
46
+ * one is `host-chain` with `existing_writes`. With no entry group in scope, the
47
+ * first host-chain group (else the first group) becomes stage 0: it reads the
48
+ * existing conventions before anything else converts.
49
+ */
50
+
51
+ import * as fs from 'node:fs';
52
+ import * as path from 'node:path';
53
+ import { pathToFileURL } from 'node:url';
54
+ import { _replace } from './group_watch.mjs';
55
+
56
+ // ---------------------------------------------------------------- Python 兼容层
57
+ // 这些输出是其它脚本与 agent 读取的契约,必须与原 Python 版逐字节一致:
58
+ // JSON 用 json.dumps(indent=2, ensure_ascii=False) 的格式(浮点按 repr 写、
59
+ // 整数大数不丢精度、对象键按插入顺序),Windows 上文本按 \r\n 写出,
60
+ // 排序按 Python 的比较规则(字符串按码点、元组逐项、None 不可比)。
61
+
62
+ const IS_WIN = process.platform === 'win32';
63
+ const EOL = IS_WIN ? '\r\n' : '\n';
64
+
65
+ /** json.loads 读到的浮点数:保留「它是 float」这一事实,写回时按 Python repr 输出。 */
66
+ export class PyFloat {
67
+ constructor(value) { this.value = value; }
68
+ valueOf() { return this.value; }
69
+ }
70
+
71
+ // 解析出的对象若含整数形键("0"、"12"),JS 普通对象会把它们提前;记下原始键序。
72
+ const KEY_ORDER = Symbol('pyKeyOrder');
73
+ const INDEX_KEY = /^(?:0|[1-9][0-9]*)$/;
74
+
75
+ function floatRepr(x, json) {
76
+ if (!Number.isFinite(x)) {
77
+ if (Number.isNaN(x)) { return json ? 'NaN' : 'nan'; }
78
+ return x > 0 ? (json ? 'Infinity' : 'inf') : (json ? '-Infinity' : '-inf');
79
+ }
80
+ if (x === 0) { return Object.is(x, -0) ? '-0.0' : '0.0'; }
81
+ const [m, e] = Math.abs(x).toExponential().split('e');
82
+ const digits = m.replace('.', '');
83
+ const exp = Number(e);
84
+ let s;
85
+ if (exp >= -4 && exp < 16) {
86
+ if (exp >= 0) {
87
+ const ip = digits.slice(0, exp + 1).padEnd(exp + 1, '0');
88
+ s = ip + '.' + (digits.slice(exp + 1) || '0');
89
+ } else {
90
+ s = '0.' + '0'.repeat(-exp - 1) + digits;
91
+ }
92
+ } else {
93
+ s = digits[0] + (digits.length > 1 ? '.' + digits.slice(1) : '') + 'e' + (exp < 0 ? '-' : '+') +
94
+ String(Math.abs(exp)).padStart(2, '0');
95
+ }
96
+ return (x < 0 ? '-' : '') + s;
97
+ }
98
+
99
+ /** json.loads:浮点 → PyFloat,超出安全整数范围的整数 → BigInt,其余同 JSON.parse。 */
100
+ function pyJsonLoads(text) {
101
+ let i = 0;
102
+ const n = text.length;
103
+ const fail = (msg) => { throw new SyntaxError(`${msg}: char ${i}`); };
104
+ const ws = () => {
105
+ while (i < n) {
106
+ const c = text.charCodeAt(i);
107
+ if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d) { i++; } else { break; }
108
+ }
109
+ };
110
+ const NUM = /-?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?/y;
111
+ const str = () => {
112
+ i++;
113
+ let out = '';
114
+ let start = i;
115
+ for (;;) {
116
+ if (i >= n) { fail('Unterminated string'); }
117
+ const c = text.charCodeAt(i);
118
+ if (c === 0x22) { out += text.slice(start, i); i++; return out; }
119
+ if (c < 0x20) { fail('Invalid control character'); }
120
+ if (c === 0x5c) {
121
+ out += text.slice(start, i);
122
+ const esc = text[i + 1];
123
+ const simple = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }[esc];
124
+ if (simple !== undefined) {
125
+ out += simple;
126
+ i += 2;
127
+ } else if (esc === 'u') {
128
+ const hex = text.slice(i + 2, i + 6);
129
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) { fail('Invalid \\uXXXX escape'); }
130
+ out += String.fromCharCode(parseInt(hex, 16));
131
+ i += 6;
132
+ } else {
133
+ fail('Invalid \\escape');
134
+ }
135
+ start = i;
136
+ continue;
137
+ }
138
+ i++;
139
+ }
140
+ };
141
+ const value = () => {
142
+ ws();
143
+ const c = text[i];
144
+ if (c === '{') {
145
+ i++;
146
+ const o = {};
147
+ const order = [];
148
+ let hasIndex = false;
149
+ ws();
150
+ if (text[i] === '}') { i++; return o; }
151
+ for (;;) {
152
+ ws();
153
+ if (text[i] !== '"') { fail('Expecting property name enclosed in double quotes'); }
154
+ const k = str();
155
+ ws();
156
+ if (text[i] !== ':') { fail("Expecting ':' delimiter"); }
157
+ i++;
158
+ const v = value();
159
+ if (!Object.hasOwn(o, k)) {
160
+ order.push(k);
161
+ if (INDEX_KEY.test(k)) { hasIndex = true; }
162
+ }
163
+ if (k === '__proto__') {
164
+ Object.defineProperty(o, k, { value: v, enumerable: true, writable: true, configurable: true });
165
+ } else {
166
+ o[k] = v;
167
+ }
168
+ ws();
169
+ if (text[i] === ',') { i++; continue; }
170
+ if (text[i] === '}') { i++; break; }
171
+ fail("Expecting ',' delimiter");
172
+ }
173
+ if (hasIndex) { o[KEY_ORDER] = order; }
174
+ return o;
175
+ }
176
+ if (c === '[') {
177
+ i++;
178
+ const a = [];
179
+ ws();
180
+ if (text[i] === ']') { i++; return a; }
181
+ for (;;) {
182
+ a.push(value());
183
+ ws();
184
+ if (text[i] === ',') { i++; continue; }
185
+ if (text[i] === ']') { i++; break; }
186
+ fail("Expecting ',' delimiter");
187
+ }
188
+ return a;
189
+ }
190
+ if (c === '"') { return str(); }
191
+ if (text.startsWith('null', i)) { i += 4; return null; }
192
+ if (text.startsWith('true', i)) { i += 4; return true; }
193
+ if (text.startsWith('false', i)) { i += 5; return false; }
194
+ if (text.startsWith('NaN', i)) { i += 3; return new PyFloat(NaN); }
195
+ if (text.startsWith('Infinity', i)) { i += 8; return new PyFloat(Infinity); }
196
+ if (text.startsWith('-Infinity', i)) { i += 9; return new PyFloat(-Infinity); }
197
+ NUM.lastIndex = i;
198
+ const m = NUM.exec(text);
199
+ if (!m) { fail('Expecting value'); }
200
+ i += m[0].length;
201
+ if (m[1] !== undefined || m[2] !== undefined) { return new PyFloat(Number(m[0])); }
202
+ const num = Number(m[0]);
203
+ return Number.isSafeInteger(num) ? (num === 0 ? 0 : num) : BigInt(m[0]);
204
+ };
205
+ const v = value();
206
+ ws();
207
+ if (i !== n) { fail('Extra data'); }
208
+ return v;
209
+ }
210
+
211
+ function keysOf(o) {
212
+ const ks = Object.keys(o);
213
+ const ord = o[KEY_ORDER];
214
+ if (!ord) { return ks; }
215
+ const present = new Set(ks);
216
+ const out = ord.filter((k) => present.has(k));
217
+ const seen = new Set(out);
218
+ for (const k of ks) { if (!seen.has(k)) { out.push(k); } }
219
+ return out;
220
+ }
221
+
222
+ /** json.dumps(v, ensure_ascii=False, indent=indent)。undefined 视同 None(对应 dict.get 缺省)。 */
223
+ function pyJsonDumps(v, indent, level = 0) {
224
+ if (v === null || v === undefined) { return 'null'; }
225
+ if (v === true) { return 'true'; }
226
+ if (v === false) { return 'false'; }
227
+ if (typeof v === 'bigint') { return v.toString(); }
228
+ if (v instanceof PyFloat) { return floatRepr(v.value, true); }
229
+ if (typeof v === 'number') { return Number.isInteger(v) ? (Object.is(v, -0) ? '0' : String(v)) : floatRepr(v, true); }
230
+ if (typeof v === 'string') { return JSON.stringify(v); }
231
+ const pad = '\n' + ' '.repeat(indent * (level + 1));
232
+ const end = '\n' + ' '.repeat(indent * level);
233
+ if (Array.isArray(v)) {
234
+ if (v.length === 0) { return '[]'; }
235
+ return '[' + pad + v.map((x) => pyJsonDumps(x, indent, level + 1)).join(',' + pad) + end + ']';
236
+ }
237
+ const ks = keysOf(v);
238
+ if (ks.length === 0) { return '{}'; }
239
+ return '{' + pad + ks.map((k) => JSON.stringify(k) + ': ' + pyJsonDumps(v[k], indent, level + 1)).join(',' + pad) +
240
+ end + '}';
241
+ }
242
+
243
+ const UTF8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
244
+
245
+ /** Path.read_text(encoding="utf-8"):严格解码,保留 BOM,通用换行。 */
246
+ function readText(p) {
247
+ return UTF8.decode(fs.readFileSync(p)).replace(/\r\n?/g, '\n');
248
+ }
249
+
250
+
251
+ function out(s = '') { process.stdout.write(s + EOL); }
252
+ function err(s = '') { process.stderr.write(s + EOL); }
253
+
254
+ function isFile(p) {
255
+ try { return fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false; } catch { return false; }
256
+ }
257
+ function isDir(p) {
258
+ try { return fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false; } catch { return false; }
259
+ }
260
+ function exists(p) {
261
+ try { return fs.statSync(p, { throwIfNoEntry: false }) !== undefined; } catch { return false; }
262
+ }
263
+
264
+ /** dict.get(k, d):只有键不存在才用缺省,值为 null 时照样返回 null。 */
265
+ function get(o, k, d = undefined) {
266
+ return o !== null && typeof o === 'object' && !Array.isArray(o) && Object.hasOwn(o, k) ? o[k] : d;
267
+ }
268
+
269
+ function truthy(v) {
270
+ if (v === null || v === undefined || v === false) { return false; }
271
+ if (v === true) { return true; }
272
+ if (typeof v === 'number') { return v !== 0; }
273
+ if (typeof v === 'bigint') { return v !== 0n; }
274
+ if (v instanceof PyFloat) { return v.value !== 0; }
275
+ if (typeof v === 'string' || Array.isArray(v)) { return v.length > 0; }
276
+ if (v instanceof Map || v instanceof Set) { return v.size > 0; }
277
+ return Object.keys(v).length > 0;
278
+ }
279
+
280
+ /** Python 的 `a or b`。 */
281
+ function or(a, b) { return truthy(a) ? a : b; }
282
+
283
+ function pyLen(v) {
284
+ if (typeof v === 'string') { return [...v].length; }
285
+ if (Array.isArray(v)) { return v.length; }
286
+ if (v !== null && typeof v === 'object' && !(v instanceof PyFloat)) { return Object.keys(v).length; }
287
+ throw new TypeError(`object of type '${pyType(v)}' has no len()`);
288
+ }
289
+
290
+ function pyType(v) {
291
+ if (v === null || v === undefined) { return 'NoneType'; }
292
+ if (typeof v === 'boolean') { return 'bool'; }
293
+ if (typeof v === 'number') { return Number.isInteger(v) ? 'int' : 'float'; }
294
+ if (typeof v === 'bigint') { return 'int'; }
295
+ if (v instanceof PyFloat) { return 'float'; }
296
+ if (typeof v === 'string') { return 'str'; }
297
+ if (Array.isArray(v)) { return 'list'; }
298
+ return 'dict';
299
+ }
300
+
301
+ /** Python 的 `x in container`(list 判等、str 判子串、dict 判键)。 */
302
+ function pyIn(x, c) {
303
+ if (typeof c === 'string') { return typeof x === 'string' && c.includes(x); }
304
+ if (Array.isArray(c)) { return c.some((y) => pyEq(x, y)); }
305
+ if (c !== null && typeof c === 'object') { return typeof x === 'string' && Object.hasOwn(c, x); }
306
+ throw new TypeError(`argument of type '${pyType(c)}' is not iterable`);
307
+ }
308
+
309
+ function numOf(v) {
310
+ if (typeof v === 'boolean') { return v ? 1 : 0; }
311
+ if (v instanceof PyFloat) { return v.value; }
312
+ if (typeof v === 'number' || typeof v === 'bigint') { return v; }
313
+ return undefined;
314
+ }
315
+
316
+ function pyEq(a, b) {
317
+ if (a === undefined) { a = null; }
318
+ if (b === undefined) { b = null; }
319
+ const na = numOf(a);
320
+ const nb = numOf(b);
321
+ if (na !== undefined && nb !== undefined) { return na == nb; } // eslint-disable-line eqeqeq
322
+ if (na !== undefined || nb !== undefined) { return false; }
323
+ if (a === null || b === null || typeof a === 'string' || typeof b === 'string') { return a === b; }
324
+ if (Array.isArray(a) || Array.isArray(b)) {
325
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((x, i) => pyEq(x, b[i]));
326
+ }
327
+ const ka = Object.keys(a);
328
+ return ka.length === Object.keys(b).length && ka.every((k) => Object.hasOwn(b, k) && pyEq(a[k], b[k]));
329
+ }
330
+
331
+ const SURROGATE = /[\uD800-\uDFFF]/;
332
+
333
+ function cmpStr(a, b) {
334
+ if (!SURROGATE.test(a) && !SURROGATE.test(b)) { return a < b ? -1 : a > b ? 1 : 0; }
335
+ const x = [...a];
336
+ const y = [...b];
337
+ for (let i = 0; i < Math.min(x.length, y.length); i++) {
338
+ const d = x[i].codePointAt(0) - y[i].codePointAt(0);
339
+ if (d !== 0) { return d < 0 ? -1 : 1; }
340
+ }
341
+ return x.length - y.length < 0 ? -1 : x.length > y.length ? 1 : 0;
342
+ }
343
+
344
+ /** Python 的 `<` 比较(用于 sorted 的 key):数值互比、str 按码点、tuple/list 逐项;其它组合抛 TypeError。 */
345
+ function pyCmp(a, b) {
346
+ const na = numOf(a);
347
+ const nb = numOf(b);
348
+ if (na !== undefined && nb !== undefined) { return na < nb ? -1 : na > nb ? 1 : 0; }
349
+ if (typeof a === 'string' && typeof b === 'string') { return cmpStr(a, b); }
350
+ if (Array.isArray(a) && Array.isArray(b)) {
351
+ for (let i = 0; i < Math.min(a.length, b.length); i++) {
352
+ if (!pyEq(a[i], b[i])) { return pyCmp(a[i], b[i]); }
353
+ }
354
+ return a.length < b.length ? -1 : a.length > b.length ? 1 : 0;
355
+ }
356
+ throw new TypeError(`'<' not supported between instances of '${pyType(a)}' and '${pyType(b)}'`);
357
+ }
358
+
359
+ /** sorted(items, key=key, reverse=reverse):稳定排序。 */
360
+ function sortedBy(items, key = (x) => x, reverse = false) {
361
+ const dec = [...items].map((v, i) => [key(v), i, v]);
362
+ dec.sort((p, q) => (reverse ? pyCmp(q[0], p[0]) : pyCmp(p[0], q[0])) || p[1] - q[1]);
363
+ return dec.map((d) => d[2]);
364
+ }
365
+
366
+ const NON_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
367
+
368
+ function strRepr(s) {
369
+ const q = s.includes("'") && !s.includes('"') ? '"' : "'";
370
+ let r = q;
371
+ for (const ch of s) {
372
+ const cp = ch.codePointAt(0);
373
+ if (ch === q || ch === '\\') { r += '\\' + ch; }
374
+ else if (ch === '\t') { r += '\\t'; }
375
+ else if (ch === '\n') { r += '\\n'; }
376
+ else if (ch === '\r') { r += '\\r'; }
377
+ else if (ch !== ' ' && NON_PRINTABLE.test(ch)) {
378
+ r += cp < 0x100 ? '\\x' + cp.toString(16).padStart(2, '0')
379
+ : cp < 0x10000 ? '\\u' + cp.toString(16).padStart(4, '0') : '\\U' + cp.toString(16).padStart(8, '0');
380
+ } else { r += ch; }
381
+ }
382
+ return r + q;
383
+ }
384
+
385
+ /** repr(v)。 */
386
+ function pyRepr(v) {
387
+ if (v === null || v === undefined) { return 'None'; }
388
+ if (v === true) { return 'True'; }
389
+ if (v === false) { return 'False'; }
390
+ if (typeof v === 'bigint') { return v.toString(); }
391
+ if (v instanceof PyFloat) { return floatRepr(v.value, false); }
392
+ if (typeof v === 'number') { return Number.isInteger(v) ? String(v === 0 ? 0 : v) : floatRepr(v, false); }
393
+ if (typeof v === 'string') { return strRepr(v); }
394
+ if (Array.isArray(v)) { return '[' + v.map(pyRepr).join(', ') + ']'; }
395
+ return '{' + keysOf(v).map((k) => strRepr(k) + ': ' + pyRepr(v[k])).join(', ') + '}';
396
+ }
397
+
398
+ /** str(v) / f"{v}"。 */
399
+ function pyStr(v) { return typeof v === 'string' ? v : pyRepr(v); }
400
+
401
+ /** int() of a re `\d+` match (Unicode decimal digits: each Nd run is aligned blocks of ten). */
402
+ function pyInt(digits) {
403
+ let s = '';
404
+ for (const ch of digits) {
405
+ let cp = ch.codePointAt(0);
406
+ let k = 0;
407
+ while (/\p{Nd}/u.test(String.fromCodePoint(cp - 1))) { cp--; k++; }
408
+ s += String(k % 10);
409
+ }
410
+ const n = Number(s);
411
+ return Number.isSafeInteger(n) ? n : BigInt(s);
412
+ }
413
+
414
+ function setdefault(m, k, d) {
415
+ if (!m.has(k)) { m.set(k, d); }
416
+ return m.get(k);
417
+ }
418
+
419
+ // ---------------------------------------------------------------- 路径(pathlib 语义)
420
+
421
+ function splitPath(p) {
422
+ if (IS_WIN) {
423
+ const s = String(p).replace(/\//g, '\\');
424
+ let drive = '';
425
+ let rest = s;
426
+ const unc = /^\\\\([^\\]+)\\([^\\]+)/.exec(s);
427
+ if (unc) { drive = unc[0]; rest = s.slice(drive.length); }
428
+ else if (/^[A-Za-z]:/.test(s)) { drive = s.slice(0, 2); rest = s.slice(2); }
429
+ const root = rest.startsWith('\\') ? '\\' : '';
430
+ return { drive, root, parts: rest.split('\\').filter((x) => x !== '' && x !== '.') };
431
+ }
432
+ const s = String(p);
433
+ const root = s.startsWith('//') && !s.startsWith('///') ? '//' : s.startsWith('/') ? '/' : '';
434
+ return { drive: '', root, parts: s.split('/').filter((x) => x !== '' && x !== '.') };
435
+ }
436
+
437
+ /** str(Path(p))。 */
438
+ function pathStr(p) {
439
+ const { drive, root, parts } = splitPath(p);
440
+ const s = drive + root + parts.join(IS_WIN ? '\\' : '/');
441
+ return s || '.';
442
+ }
443
+
444
+ /** Path(p).name。 */
445
+ function pathName(p) {
446
+ const { parts } = splitPath(p);
447
+ return parts.length ? parts[parts.length - 1] : '';
448
+ }
449
+
450
+ /** Path(p).resolve():存在的最长前缀做 realpath,其余照抄。 */
451
+ function pathResolve(p) {
452
+ let abs = path.resolve(String(p));
453
+ const tail = [];
454
+ for (;;) {
455
+ try {
456
+ const real = fs.realpathSync.native(abs);
457
+ return tail.length ? path.join(real, ...tail.reverse()) : real;
458
+ } catch {
459
+ const parent = path.dirname(abs);
460
+ if (parent === abs) { return path.resolve(String(p)); }
461
+ tail.push(path.basename(abs));
462
+ abs = parent;
463
+ }
464
+ }
465
+ }
466
+
467
+ /** Path(p).absolute():只补 cwd,不规整 `..`。 */
468
+ function pathAbsolute(p) {
469
+ const { drive, root, parts } = splitPath(p);
470
+ const sep = IS_WIN ? '\\' : '/';
471
+ if (IS_WIN ? (drive && root) || /^\\\\/.test(drive) : root) { return pathStr(p); }
472
+ const cwd = process.cwd();
473
+ if (root) { return splitPath(cwd).drive + root + parts.join(sep); }
474
+ const base = drive ? path.resolve(drive) : cwd;
475
+ return [base.replace(/[\\/]+$/, ''), ...parts].join(sep) || base;
476
+ }
477
+
478
+ /** Path(dir).glob(prefix + '*'):文件系统原始顺序(os.scandir),Windows 不分大小写。 */
479
+ function globPrefix(dir, prefix) {
480
+ const names = [];
481
+ let d;
482
+ try { d = fs.opendirSync(dir); } catch { return names; }
483
+ try {
484
+ for (let e = d.readSync(); e !== null; e = d.readSync()) {
485
+ const nm = e.name;
486
+ if (IS_WIN ? nm.toLowerCase().startsWith(prefix.toLowerCase()) : nm.startsWith(prefix)) { names.push(nm); }
487
+ }
488
+ } finally { d.closeSync(); }
489
+ return names.map((nm) => path.join(String(dir), nm));
490
+ }
491
+
492
+ // ---------------------------------------------------------------- argparse 等价物
493
+ // 复刻 argparse 的可观察行为:长选项唯一前缀、`--opt=value`、`--`、
494
+ // `-h/--help` 的排版(宽度 = 终端列数 - 2)、错误时打印 usage 到 stderr 并以 2 退出。
495
+
496
+ function termColumns() {
497
+ const env = Number.parseInt(process.env.COLUMNS ?? '', 10);
498
+ if (env > 0) { return env; }
499
+ // shutil.get_terminal_size(): COLUMNS, else the stdout tty, else 80.
500
+ return process.stdout.isTTY && process.stdout.columns ? process.stdout.columns : 80;
501
+ }
502
+
503
+ /** textwrap.wrap(width) 的常用子集:按空白断行,超长单词硬切。 */
504
+ function wrapText(text, width) {
505
+ const words = text.split(' ').filter((w) => w !== '');
506
+ const lines = [];
507
+ let cur = '';
508
+ for (let w of words) {
509
+ while (w.length > width && cur === '') { lines.push(w.slice(0, width)); w = w.slice(width); }
510
+ if (cur === '') { cur = w; }
511
+ else if (cur.length + 1 + w.length <= width) { cur += ' ' + w; }
512
+ else {
513
+ lines.push(cur);
514
+ cur = '';
515
+ while (w.length > width) { lines.push(w.slice(0, width)); w = w.slice(width); }
516
+ cur = w;
517
+ }
518
+ }
519
+ if (cur !== '') { lines.push(cur); }
520
+ return lines;
521
+ }
522
+
523
+ /**
524
+ * spec: { prog, description, args: [{ name, positional?, metavar?, help?, required?, type?: 'int', def? }] }
525
+ * 返回 { dest: value }(dest = 去掉前导 `--`、`-` 换成 `_`)。
526
+ */
527
+ function parseArgs(spec, argv) {
528
+ const width = termColumns() - 2;
529
+ const actions = [{ name: '-h', alias: '--help', help: 'show this help message and exit', flag: true }, ...spec.args];
530
+ const dest = (a) => a.name.replace(/^-+/, '').replace(/-/g, '_');
531
+ const metavar = (a) => a.metavar ?? dest(a).toUpperCase();
532
+ const invocation = (a) => (a.positional ? a.name : a.flag ? `${a.name}, ${a.alias}` : a.bool ? a.name : `${a.name} ${metavar(a)}`);
533
+ const usagePart = (a) => {
534
+ if (a.positional) { return a.name; }
535
+ const s = a.flag || a.bool ? a.name : `${a.name} ${metavar(a)}`;
536
+ return a.required ? s : `[${s}]`;
537
+ };
538
+ const opts = actions.filter((a) => !a.positional);
539
+ const poss = actions.filter((a) => a.positional);
540
+
541
+ const formatUsage = () => {
542
+ const prefix = 'usage: ';
543
+ const prog = spec.prog;
544
+ const optParts = opts.map(usagePart);
545
+ const posParts = poss.map(usagePart);
546
+ let usage = [prog, ...optParts, ...posParts].join(' ');
547
+ if (prefix.length + usage.length > width) {
548
+ const getLines = (parts, indent, pfx) => {
549
+ const lines = [];
550
+ let line = [];
551
+ let len = pfx !== undefined ? pfx.length - 1 : indent.length - 1;
552
+ for (const part of parts) {
553
+ if (len + 1 + part.length > width && line.length) {
554
+ lines.push(indent + line.join(' '));
555
+ line = [];
556
+ len = indent.length - 1;
557
+ }
558
+ line.push(part);
559
+ len += part.length + 1;
560
+ }
561
+ if (line.length) { lines.push(indent + line.join(' ')); }
562
+ if (pfx !== undefined) { lines[0] = lines[0].slice(indent.length); }
563
+ return lines;
564
+ };
565
+ let lines;
566
+ if (prefix.length + prog.length <= 0.75 * width) {
567
+ const indent = ' '.repeat(prefix.length + prog.length + 1);
568
+ lines = getLines([prog, ...optParts], indent, prefix);
569
+ lines.push(...getLines(posParts, indent));
570
+ } else {
571
+ const indent = ' '.repeat(prefix.length);
572
+ lines = getLines([...optParts, ...posParts], indent);
573
+ if (lines.length > 1) { lines = [...getLines(optParts, indent), ...getLines(posParts, indent)]; }
574
+ lines = [prog, ...lines];
575
+ }
576
+ usage = lines.join('\n');
577
+ }
578
+ return prefix + usage;
579
+ };
580
+
581
+ const formatHelp = () => {
582
+ const maxHelpPos = Math.min(24, Math.max(width - 20, 4));
583
+ const maxLen = Math.max(...actions.map((a) => invocation(a).length + 2));
584
+ const helpPos = Math.min(maxLen + 2, maxHelpPos);
585
+ const helpWidth = Math.max(width - helpPos, 11);
586
+ const actionWidth = helpPos - 2 - 2;
587
+ const item = (a) => {
588
+ const inv = invocation(a);
589
+ const rows = [];
590
+ let first;
591
+ if (!a.help) { rows.push(' ' + inv); return rows; }
592
+ if (inv.length <= actionWidth) { first = ' ' + inv.padEnd(actionWidth) + ' '; }
593
+ else { rows.push(' ' + inv); first = ' '.repeat(helpPos); }
594
+ const hl = wrapText(a.help.replace(/\s+/g, ' ').trim(), helpWidth);
595
+ rows.push(first + hl[0]);
596
+ for (const l of hl.slice(1)) { rows.push(' '.repeat(helpPos) + l); }
597
+ return rows;
598
+ };
599
+ const parts = [formatUsage(), ''];
600
+ if (spec.description) { parts.push(...wrapText(spec.description.replace(/\s+/g, ' ').trim(), width), ''); }
601
+ if (poss.length) { parts.push('positional arguments:', ...poss.flatMap(item), ''); }
602
+ parts.push('options:', ...opts.flatMap(item));
603
+ return parts.join('\n');
604
+ };
605
+
606
+ const fail = (msg) => {
607
+ err(formatUsage());
608
+ err(`${spec.prog}: error: ${msg}`);
609
+ process.exit(2);
610
+ };
611
+
612
+ const result = {};
613
+ for (const a of spec.args) { result[dest(a)] = a.bool ? false : (a.def ?? null); }
614
+ const seen = new Set();
615
+ const positionals = [];
616
+ const extras = [];
617
+ const longNames = opts.flatMap((a) => (a.alias ? [[a.name, a], [a.alias, a]] : [[a.name, a]]));
618
+ const looksNegative = (s) => /^-\d+$|^-\d*\.\d+$/.test(s);
619
+ const isOptionLike = (s) => s.startsWith('-') && s !== '-' && !looksNegative(s) && !(s.includes(' ') && !findOpt(s));
620
+ function findOpt(s) {
621
+ const [k] = s.split('=', 1);
622
+ const exact = longNames.find(([n]) => n === k);
623
+ if (exact) { return exact[1]; }
624
+ if (!k.startsWith('--')) { return null; }
625
+ const hits = longNames.filter(([n]) => n.startsWith(k));
626
+ const uniq = [...new Set(hits.map((h) => h[1]))];
627
+ if (uniq.length > 1) { fail(`ambiguous option: ${k} could match ${hits.map((h) => h[0]).join(', ')}`); }
628
+ return uniq[0] ?? null;
629
+ }
630
+ let i = 0;
631
+ let rest = false;
632
+ while (i < argv.length) {
633
+ const s = argv[i];
634
+ if (!rest && s === '--') { rest = true; i++; continue; }
635
+ if (rest || !isOptionLike(s)) { positionals.push(s); i++; continue; }
636
+ const a = findOpt(s);
637
+ if (!a) { extras.push(s); i++; continue; }
638
+ const eq = s.indexOf('=');
639
+ const name = a.name;
640
+ if (a.flag) {
641
+ if (eq >= 0) { fail(`argument -h/--help: ignored explicit argument '${s.slice(eq + 1)}'`); }
642
+ process.stdout.write((formatHelp() + '\n').replace(/\n/g, EOL));
643
+ process.exit(0);
644
+ }
645
+ if (a.bool) {
646
+ if (eq >= 0) { fail(`argument ${name}: ignored explicit argument '${s.slice(eq + 1)}'`); }
647
+ result[dest(a)] = true;
648
+ seen.add(a);
649
+ i++;
650
+ continue;
651
+ }
652
+ let val;
653
+ if (eq >= 0 && s.startsWith('--')) { val = s.slice(eq + 1); i++; }
654
+ else if (i + 1 < argv.length && !(argv[i + 1] === '--' || isOptionLike(argv[i + 1]))) { val = argv[i + 1]; i += 2; }
655
+ else { fail(`argument ${name}: expected one argument`); }
656
+ if (a.type === 'int') {
657
+ const t = val.trim();
658
+ if (!/^[+-]?\p{Nd}+(?:_\p{Nd}+)*$/u.test(t)) { fail(`argument ${name}: invalid int value: ${pyRepr(val)}`); }
659
+ val = Number(pyInt(t.replace(/^[+-]|_/g, ''))) * (t.startsWith('-') ? -1 : 1);
660
+ }
661
+ result[dest(a)] = val;
662
+ seen.add(a);
663
+ }
664
+ poss.forEach((a, k) => { if (k < positionals.length) { result[dest(a)] = positionals[k]; seen.add(a); } });
665
+ extras.push(...positionals.slice(poss.length));
666
+ const missing = actions.filter((a) => (a.positional || a.required) && !seen.has(a)).map((a) => a.name);
667
+ if (missing.length) { fail(`the following arguments are required: ${missing.join(', ')}`); }
668
+ if (extras.length) { fail(`unrecognized arguments: ${extras.join(' ')}`); }
669
+ return result;
670
+ }
671
+
672
+ // ---------------------------------------------------------------- roles
673
+
674
+ // Same container kinds export_ui_info refuses to export, minus the ones
675
+ // that are UI attached to a host (they become `attach`, not `skip`).
676
+ export const SKIP_KINDS = new Set(['host-activity', 'sentinel', 'media-browse', 'media-player', 'unknown', 'hybrid']);
677
+ export const ATTACH_KINDS = new Set(['menu', 'ui-state', 'mode', 'panel']);
678
+ export const PAGE_PREFIXES = ['activity:', 'fragment:', 'dialog:', 'pref-dialog:', 'overlay:'];
679
+ export const ARROW = ' → ';
680
+ export const MAX_TEMPLATES = 3;
681
+ export const GENERIC_BASES = new Set(['Fragment', 'DialogFragment', 'AppCompatDialogFragment', 'BottomSheetDialogFragment',
682
+ 'Activity', 'AppCompatActivity', 'FragmentActivity', 'PreferenceFragmentCompat']);
683
+
684
+ const startsWithAny = (s, prefixes) => prefixes.some((p) => s.startsWith(p));
685
+
686
+ export function readJson(p, dflt = null) {
687
+ if (!isFile(p)) { return dflt; }
688
+ return pyJsonLoads(readText(p));
689
+ }
690
+
691
+ /**
692
+ * Atomic (tmp + rename, Windows EPERM retried: group_watch._replace): group_queue / group_watch
693
+ * read these files while a refresh rewrites them, and an in-place write showed them half a file.
694
+ */
695
+ export function writeJson(p, data) {
696
+ _replace(p, pyJsonDumps(data, 2));
697
+ }
698
+
699
+ export function safeName(node) {
700
+ // str(node.get("id", "")).split(":", 1)[-1]
701
+ const sid = pyStr(get(node, 'id', ''));
702
+ const colon = sid.indexOf(':');
703
+ const raw = or(get(node, 'name'), or(colon < 0 ? sid : sid.slice(colon + 1), 'Page'));
704
+ const name = raw.replace(/[^A-Za-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
705
+ return name || 'Page';
706
+ }
707
+
708
+ /** `res/layout/x.xml:22` → `res/layout/x.xml`. */
709
+ export function stripLine(loc) {
710
+ if (!truthy(loc)) { return null; }
711
+ return pyStr(loc).replace(/:\p{Nd}+(?=\n?$)/u, '');
712
+ }
713
+
714
+ export function layoutFiles(node) {
715
+ const files = [];
716
+ for (const w of or(get(node, 'widgets'), [])) {
717
+ for (const loc of [get(w, 'via'), get(w, 'at')]) {
718
+ const f = stripLine(loc);
719
+ if (f && f.endsWith('.xml') && !files.includes(f)) { files.push(f); }
720
+ }
721
+ }
722
+ return files;
723
+ }
724
+
725
+ export function shortName(nodeId) {
726
+ const parts = nodeId.split(':');
727
+ const at = parts[parts.length - 1].split('@');
728
+ return at[at.length - 1].split('#')[0];
729
+ }
730
+
731
+ export class Graph {
732
+ constructor(utg) {
733
+ this.nodes = new Map(get(utg, 'nodes', []).map((n) => [n.id, n]));
734
+ this.inbound = new Map();
735
+ this.outbound = new Map();
736
+ for (const e of get(utg, 'links', get(utg, 'edges', []))) {
737
+ const s = get(e, 'source');
738
+ const t = get(e, 'target');
739
+ if (this.nodes.has(s) && this.nodes.has(t)) {
740
+ setdefault(this.inbound, t, []).push(e);
741
+ setdefault(this.outbound, s, []).push(e);
742
+ }
743
+ }
744
+ this.byShort = new Map();
745
+ for (const nid of this.nodes.keys()) {
746
+ if (startsWithAny(nid, PAGE_PREFIXES)) { setdefault(this.byShort, shortName(nid), nid); }
747
+ }
748
+ }
749
+
750
+ /** Where an attachable node lives. None when the node is page-level. */
751
+ directHost(node) {
752
+ for (const key of ['embedded_in', 'host_node']) {
753
+ const h = get(node, key);
754
+ if (this.nodes.has(h)) { return h; }
755
+ }
756
+ if (!ATTACH_KINDS.has(get(node, 'kind'))) { return null; }
757
+ const nid = node.id;
758
+ if (nid.includes('@')) { // menu:queue@QueueFragment
759
+ const h = this.byShort.get(nid.slice(nid.lastIndexOf('@') + 1));
760
+ if (truthy(h)) { return h; }
761
+ }
762
+ for (const e of this.inbound.get(nid) ?? []) { // mode entered from a menu, etc.
763
+ if (e.source !== nid) { return e.source; }
764
+ }
765
+ return null;
766
+ }
767
+ }
768
+
769
+ /** (role, reason) before host resolution; role in page|attach|skip. */
770
+ export function classify(g, node) {
771
+ if (get(node, 'status') === 'unreachable') {
772
+ return ['skip', 'unreachable' + (truthy(get(node, 'unreachable_reason')) ? `: ${pyStr(node.unreachable_reason)}` : '')];
773
+ }
774
+ if (truthy(get(node, 'out_of_scope'))) { return ['skip', `out-of-scope: ${pyStr(node.out_of_scope)}`]; }
775
+ if (truthy(get(node, 'ui_less_shell'))) { return ['skip', 'ui-less-shell']; }
776
+ if (SKIP_KINDS.has(get(node, 'kind'))) {
777
+ return ['skip', `kind:${pyStr(get(node, 'kind'))} (container, its pages are converted individually)`];
778
+ }
779
+ if (truthy(g.directHost(node))) { return ['attach', null]; }
780
+ if (ATTACH_KINDS.has(get(node, 'kind'))) { return ['skip', 'attachable node with no resolvable host']; }
781
+ if (get(node, 'denominator') === false) { return ['skip', 'denominator:false (static stage marked it not-a-page)']; }
782
+ return ['page', null];
783
+ }
784
+
785
+ export function resolveRoles(g) {
786
+ const roles = new Map([...g.nodes].map(([nid, n]) => [nid, classify(g, n)]));
787
+ const roleOf = (x) => (roles.has(x) ? roles.get(x)[0] : 'skip');
788
+ const res = new Map();
789
+ for (const [nid, [role, reason]] of roles) {
790
+ if (role !== 'attach') {
791
+ res.set(nid, { role, reason });
792
+ continue;
793
+ }
794
+ // Walk up until a page; a host chain may pass through other attach nodes.
795
+ let cur = nid;
796
+ const seen = new Set();
797
+ while (truthy(cur) && roleOf(cur) === 'attach' && !seen.has(cur)) {
798
+ seen.add(cur);
799
+ cur = g.directHost(g.nodes.get(cur));
800
+ }
801
+ if (truthy(cur) && roleOf(cur) === 'page') {
802
+ res.set(nid, { role: 'attach', host: cur });
803
+ } else {
804
+ res.set(nid, { role: 'skip', reason: `attachable node whose host chain ends at ${pyStr(or(cur, 'nothing'))}` });
805
+ }
806
+ }
807
+ return res;
808
+ }
809
+
810
+ export function templateKeys(node) {
811
+ const keys = [];
812
+ if (truthy(get(node, 'extends_base'))) { keys.push(['base', node.extends_base]); }
813
+ for (const f of layoutFiles(node)) { keys.push(['layout', f]); }
814
+ if (node.id.startsWith('pref-dialog:')) { keys.push(['family', 'pref-dialog']); }
815
+ // `fragment;base:ItemFilterDialog` names a real shared base; `base:Fragment`
816
+ // names the framework class every page shares, which is no template at all.
817
+ const m = /base:([A-Za-z0-9_]+)/.exec(pyStr(or(get(node, 'launch_hint'), '')));
818
+ if (m && !GENERIC_BASES.has(m[1])) { keys.push(['base', m[1]]); }
819
+ return keys;
820
+ }
821
+
822
+ const tkey = (k) => pyRepr(k[0]) + '\u0000' + pyRepr(k[1]);
823
+
824
+ export function edgeView(e, end) {
825
+ return { [end]: e[end], mechanism: get(e, 'mechanism'), trigger: get(e, 'trigger') };
826
+ }
827
+
828
+ const isEmptyish = (v) => v === null || v === undefined || (Array.isArray(v) && v.length === 0) ||
829
+ (typeof v === 'object' && !Array.isArray(v) && !(v instanceof PyFloat) && Object.keys(v).length === 0);
830
+
831
+ export function hintsOf(node) {
832
+ const widgets = (or(get(node, 'widgets'), [])).map((w) => {
833
+ const o = {};
834
+ for (const k of ['widget', 'kind', 'view_id', 'text', 'placeholder', 'preference_type', 'at']) {
835
+ const v = get(w, k);
836
+ if (v !== null && v !== undefined) { o[k] = w[k]; }
837
+ }
838
+ return o;
839
+ });
840
+ const h = {
841
+ declared_at: get(node, 'declared_at'), layout_files: layoutFiles(node),
842
+ layout_ids: or(get(node, 'layout_ids'), []), layout_hidden_ids: or(get(node, 'layout_hidden_ids'), []),
843
+ widgets, extends_base: get(node, 'extends_base'), launch_hint: get(node, 'launch_hint'),
844
+ required_state: or(get(node, 'required_state'), []),
845
+ content_state_evidence: get(node, 'content_state_evidence'),
846
+ observable: get(node, 'observable'), expected: get(node, 'expected'),
847
+ };
848
+ const res = {};
849
+ for (const [k, v] of Object.entries(h)) { if (!isEmptyish(v)) { res[k] = v; } }
850
+ return res;
851
+ }
852
+
853
+ // ---------------------------------------------------------------- grouping
854
+ // A group is the unit one sub-agent converts. It is built around an *anchor*
855
+ // page; a member joins its anchor only when splitting them would make two
856
+ // agents write one file: an embedded child is instantiated inside the
857
+ // parent's build(), and a single-host overlay is mounted in its host page.
858
+ // A routed child (tap → pushUrl) gets its own group — the parent registers
859
+ // the route in Step 5.5, so nothing is shared.
860
+
861
+ export const OVERLAY_PREFIXES = ['dialog:', 'pref-dialog:', 'overlay:'];
862
+ export const EMBED_VIA = ['pager-', 'child-fragment', 'layout-inflate'];
863
+ export const MOUNT_VIA = ['drawer-panel', 'bottom-sheet'];
864
+ export const MAX_GROUP = 8;
865
+
866
+ const BIG = 10 ** 6;
867
+
868
+ export function isOverlay(node) {
869
+ return pyIn(get(node, 'kind'), ['dialog', 'panel', 'window']) || startsWithAny(node.id, OVERLAY_PREFIXES);
870
+ }
871
+
872
+ export function edgeArgs(e) {
873
+ return or(get(e, 'args'), {});
874
+ }
875
+
876
+ export function isMount(e) {
877
+ return MOUNT_VIA.includes(pyStr(get(edgeArgs(e), 'via')));
878
+ }
879
+
880
+ /** The edge renders the target inside the source, with no navigation. */
881
+ export function isEmbed(e) {
882
+ const a = edgeArgs(e);
883
+ const via = pyStr(get(a, 'via'));
884
+ const scope = pyStr(get(a, 'commit_scope'));
885
+ const action = get(a, 'action');
886
+ if (get(e, 'mechanism') === 'fragment-embed' || startsWithAny(via, EMBED_VIA)) { return true; }
887
+ const auto = via === 'auto-load' || pyIn('auto-load', or(get(a, 'also_via'), []));
888
+ if (auto && scope.startsWith('lifecycle-fn')) { return true; }
889
+ if (via === 'instantiation' && scope.startsWith('lifecycle-fn') && pyIn(action ?? null, [null, 'default'])) { return true; }
890
+ // A section a host dispatches into its own layout: no gesture on the edge.
891
+ return via === 'dispatch-table' && (action === null || action === undefined) && get(e, 'mechanism') === 'fragment-transaction';
892
+ }
893
+
894
+ /**
895
+ * roles: Map nid → role row; rows: Map nid → conversion_set node row;
896
+ * pageOrder: Map page-dir name → pages.json index; ranked: click-path order.
897
+ */
898
+ export function planGroups(g, roles, rows, pageOrder, ranked, entryOverride = null, prevIds = null, fullRoles = null) {
899
+ const roleOf = (nid) => (roles.get(nid) ?? {}).role; // roles.get(nid, {}).get("role")
900
+ const pageIds = [...roles].filter(([, r]) => r.role === 'page').map(([nid]) => nid);
901
+
902
+ const pindex = (nid) => {
903
+ let best = BIG;
904
+ for (const d of get(rows.get(nid), 'page_dirs', [])) {
905
+ const v = pageOrder.has(d) ? pageOrder.get(d) : BIG;
906
+ if (v < best) { best = v; }
907
+ }
908
+ return best;
909
+ };
910
+
911
+ // Launcher host = the first host-activity on a click path; entry = its
912
+ // first page in pages.json order that it reaches without a mount/embed.
913
+ const rank = new Map(ranked.map((nid, i) => [nid, i]));
914
+ const hosts = sortedBy([...g.nodes].filter(([nid, n]) => get(n, 'kind') === 'host-activity' && rank.has(nid))
915
+ .map(([nid]) => nid), (nid) => rank.get(nid));
916
+ const launcher = hosts.length ? hosts[0] : null;
917
+ let entry = entryOverride ?? null;
918
+ let how = truthy(entry) ? '--entry' : '';
919
+ if (!truthy(entry) && truthy(launcher)) {
920
+ let cands = (g.outbound.get(launcher) ?? []).filter((e) => roleOf(e.target) === 'page' && !isMount(e) &&
921
+ !isEmbed(e) && !isOverlay(g.nodes.get(e.target))).map((e) => e.target);
922
+ // Key is total (ends with the id), so set order does not matter.
923
+ cands = sortedBy([...new Set(cands)], (n) => [pindex(n), rank.has(n) ? rank.get(n) : BIG, n]);
924
+ if (cands.length) {
925
+ entry = cands[0];
926
+ how = `first page of launcher host ${launcher} in pages.json order`;
927
+ } else {
928
+ entry = null;
929
+ how = '';
930
+ }
931
+ }
932
+ // No host-activity (e.g. a single-Activity app whose launcher Activity is
933
+ // itself a page): fall back to the manifest launcher. Without it the entry
934
+ // stays null and no group is placed in the entry lane.
935
+ if (!truthy(entry)) {
936
+ const isLauncher = (n) => get(n, 'is_launcher') === true || get(n, 'entry_kind') === 'launcher' ||
937
+ get(or(get(n, 'launch_hint'), {}), 'is_launcher') === true;
938
+ const asPage = (nid) => {
939
+ const r = roles.get(nid) ?? {};
940
+ if (r.role === 'page') { return nid; }
941
+ if (r.role === 'attach' && (roles.get(r.host) ?? {}).role === 'page') { return r.host; }
942
+ return null;
943
+ };
944
+ const launchers = sortedBy([...g.nodes].filter(([nid, n]) => isLauncher(n) && truthy(asPage(nid)))
945
+ .map(([nid]) => nid), (nid) => [rank.has(nid) ? rank.get(nid) : BIG, nid]);
946
+ if (launchers.length) {
947
+ entry = asPage(launchers[0]);
948
+ how = `manifest launcher ${launchers[0]}`;
949
+ }
950
+ }
951
+
952
+ const defaultPage = (host) => {
953
+ if (host === launcher) { return entry; }
954
+ for (const e of g.outbound.get(host) ?? []) {
955
+ const a = edgeArgs(e);
956
+ if ((pyIn('auto-load', or(get(a, 'also_via'), [])) || get(a, 'via') === 'auto-load') &&
957
+ pyStr(get(a, 'commit_scope')).startsWith('lifecycle-fn') && roleOf(e.target) === 'page') {
958
+ return e.target;
959
+ }
960
+ }
961
+ return null;
962
+ };
963
+
964
+ /** An edge source as a page id: attach → its host, host-activity → its default page. */
965
+ const resolve = (src) => {
966
+ const r = roles.get(src) ?? {};
967
+ if (r.role === 'attach') { return r.host; }
968
+ if (r.role === 'page') { return src; }
969
+ if (get(g.nodes.get(src) ?? {}, 'kind') === 'host-activity') { return defaultPage(src); }
970
+ return null;
971
+ };
972
+ // What a member is mounted on, over the whole app: an incremental scope leaves the existing
973
+ // launch page outside, and a drawer mounted on it still writes into it (ENTRY_PAGE).
974
+ const mountHost = (src) => {
975
+ const own = resolve(src);
976
+ if (truthy(own) || !fullRoles) { return own; }
977
+ const r = fullRoles.get(src) ?? {};
978
+ if (r.role === 'attach') { return r.host; }
979
+ if (r.role === 'page') { return src; }
980
+ if (src === launcher) { return entry; }
981
+ return null;
982
+ };
983
+
984
+ const parent = new Map();
985
+ const rel = new Map();
986
+ const mountedOn = new Map();
987
+ for (const nid of pageIds) {
988
+ const node = g.nodes.get(nid);
989
+ const inbound = (g.inbound.get(nid) ?? []).filter((e) => e.source !== nid);
990
+ for (const e of inbound) {
991
+ if (isMount(e) && truthy(mountHost(e.source))) { mountedOn.set(nid, mountHost(e.source)); }
992
+ }
993
+ // Only its size and (when size 1) its single element are used: order-free.
994
+ const srcs = new Set(inbound.map((e) => resolve(e.source)).filter((s) => truthy(s) && s !== nid));
995
+ const explicit = or(get(node, 'embedded_in'), get(node, 'host_node'));
996
+ if (roles.has(explicit) && roles.get(explicit).role === 'page') {
997
+ parent.set(nid, explicit);
998
+ rel.set(nid, 'embedded');
999
+ } else if (isOverlay(node)) {
1000
+ if (srcs.size === 1) {
1001
+ parent.set(nid, [...srcs][0]);
1002
+ rel.set(nid, 'overlay');
1003
+ }
1004
+ } else if (srcs.size === 1 && inbound.length && inbound.every(isEmbed) && !mountedOn.has(nid)) {
1005
+ parent.set(nid, [...srcs][0]);
1006
+ rel.set(nid, 'embedded');
1007
+ }
1008
+ }
1009
+
1010
+ const anchor = (nid) => {
1011
+ const seen = [];
1012
+ while (parent.has(nid) && !seen.includes(nid)) {
1013
+ seen.push(nid);
1014
+ nid = parent.get(nid);
1015
+ }
1016
+ return nid;
1017
+ };
1018
+
1019
+ const members = new Map();
1020
+ for (const nid of pageIds) { setdefault(members, anchor(nid), []).push(nid); }
1021
+
1022
+ const base = (nid) => {
1023
+ const name = shortName(nid);
1024
+ return name.replace(/(Fragment|Activity|DialogFragment|Dialog)(?=\n?$)/, '') || name;
1025
+ };
1026
+
1027
+ let groups = [];
1028
+ for (let [anc, mem] of members) {
1029
+ mem = sortedBy(mem, (n) => [n !== anc, pindex(n), n]);
1030
+ const tiers = new Set(mem.map((n) => rows.get(n).tier));
1031
+ const writes = new Set();
1032
+ const aNode = g.nodes.get(anc);
1033
+ if (isOverlay(aNode)) {
1034
+ writes.add(`components/${base(anc)}Dialog.ets`);
1035
+ } else {
1036
+ writes.add(`pages/${base(anc)}Page.ets`);
1037
+ writes.add(`viewmodel/${base(anc)}ViewModel.ets`);
1038
+ }
1039
+ for (const n of mem.slice(1)) {
1040
+ writes.add(`components/${base(n)}${isOverlay(g.nodes.get(n)) ? 'Dialog' : 'Component'}.ets`);
1041
+ }
1042
+ // With no entry, an unmounted member used to compare equal to it (null ===
1043
+ // null), making every group an entry hit and the whole plan one serial lane.
1044
+ const entryHit = truthy(entry) &&
1045
+ (mem.includes(entry) || mem.some((n) => mountedOn.has(n) && mountedOn.get(n) === entry));
1046
+ if (entryHit) { writes.add('ENTRY_PAGE'); }
1047
+ const fam = new Set();
1048
+ for (const n of mem) {
1049
+ for (const k of templateKeys(g.nodes.get(n))) { fam.add(`${pyStr(k[0])}:${pyStr(k[1])}`); }
1050
+ }
1051
+ groups.push({
1052
+ anchor: anc,
1053
+ members: mem.map((n) => ({ node: n, tier: rows.get(n).tier, relation: n === anc ? 'anchor' : (rel.get(n) ?? 'embedded') })),
1054
+ page_dirs: mem.flatMap((n) => get(rows.get(n), 'page_dirs', [])),
1055
+ tier: tiers.has('captured') ? 'captured' : 'source-only',
1056
+ mixed_tier: tiers.size > 1,
1057
+ predicted_writes: sortedBy([...writes]),
1058
+ _fam: fam, _entry: entryHit, _is_entry: mem.includes(entry),
1059
+ _order: Math.min(...mem.map(pindex)),
1060
+ });
1061
+ }
1062
+
1063
+ // Captured attach nodes (a menu or panel that was screenshotted as its own
1064
+ // page dir) are evidence for their host's group, never a group of their own.
1065
+ const byMember = new Map();
1066
+ for (const gr of groups) { for (const m of gr.members) { byMember.set(m.node, gr); } }
1067
+ for (const [nid, r] of roles) {
1068
+ if (r.role === 'attach' && truthy(get(rows.get(nid), 'page_dirs')) && byMember.has(r.host)) {
1069
+ const gr = byMember.get(r.host);
1070
+ gr.members.push({ node: nid, tier: 'captured', relation: 'attached' });
1071
+ gr.page_dirs.push(...rows.get(nid).page_dirs);
1072
+ gr._order = Math.min(gr._order, pindex(nid));
1073
+ const tiers = new Set(gr.members.map((m) => m.tier));
1074
+ gr.tier = tiers.has('captured') ? 'captured' : 'source-only';
1075
+ gr.mixed_tier = tiers.size > 1;
1076
+ }
1077
+ }
1078
+
1079
+ // Stage: 0 = the entry group alone (it sets the conventions), 1 = groups
1080
+ // with a capture, 2 = source-only. Within a stage, pages.json order.
1081
+ for (const gr of groups) { gr.stage = gr._is_entry ? 0 : (gr.tier === 'captured' ? 1 : 2); }
1082
+ groups = sortedBy(groups, (gr) => [gr.stage, gr._order, gr.anchor]);
1083
+ // Stable ids across re-runs: a re-export during exploration must not
1084
+ // renumber groups whose prompts, queue state and reports already exist.
1085
+ // A known anchor keeps its id (its stage may change); a new one numbers on.
1086
+ const known = prevIds ?? new Map();
1087
+ let nxt = 0;
1088
+ for (const v of known.values()) {
1089
+ const m = /^G(\d+)$/.exec(v);
1090
+ if (m) nxt = Math.max(nxt, Number(m[1]));
1091
+ }
1092
+ for (const gr of groups) {
1093
+ if (known.has(gr.anchor)) gr.id = known.get(gr.anchor);
1094
+ else { nxt += 1; gr.id = `G${String(nxt).padStart(3, '0')}`; }
1095
+ }
1096
+
1097
+ // Lanes: groups sharing a predicted write run serially; ENTRY_PAGE is the
1098
+ // host chain. Union-find over write tokens.
1099
+ const owner = new Map();
1100
+ const laneOf = new Map();
1101
+ for (const gr of groups) { laneOf.set(gr.id, gr.id); }
1102
+ const find = (x) => {
1103
+ while (laneOf.get(x) !== x) {
1104
+ laneOf.set(x, laneOf.get(laneOf.get(x)));
1105
+ x = laneOf.get(x);
1106
+ }
1107
+ return x;
1108
+ };
1109
+ for (const gr of groups) {
1110
+ for (const w of gr.predicted_writes) {
1111
+ if (owner.has(w)) {
1112
+ // Python evaluates the right-hand side first, then the subscript.
1113
+ const rhs = find(owner.get(w));
1114
+ laneOf.set(find(gr.id), rhs);
1115
+ } else {
1116
+ owner.set(w, gr.id);
1117
+ }
1118
+ }
1119
+ }
1120
+ const lanes = new Map();
1121
+ for (const gr of groups) { setdefault(lanes, find(gr.id), []).push(gr.id); }
1122
+ // A group whose every predicted write is owned by an earlier group of its
1123
+ // lane converts nothing of its own: a source-only host Activity whose
1124
+ // name collides with its default child (MainActivity -> MainPage.ets,
1125
+ // written by the MainFragment group). It verifies the host shell and
1126
+ // reports. Its files exist before it is dispatched, so "nothing written"
1127
+ // is its normal outcome, not a failure to redispatch.
1128
+ for (const gr of groups) {
1129
+ const ws = gr.predicted_writes.filter((w) => w !== 'ENTRY_PAGE');
1130
+ gr.verify_only = ws.length > 0 && ws.every((w) => owner.has(w) && owner.get(w) !== gr.id);
1131
+ }
1132
+ for (const gr of groups) {
1133
+ const peers = lanes.get(find(gr.id));
1134
+ if (gr._entry) {
1135
+ gr.class = 'host-chain';
1136
+ gr.lane = 'entry';
1137
+ } else if (peers.length > 1) {
1138
+ gr.class = 'serial';
1139
+ gr.lane = `lane-${peers[0]}`;
1140
+ } else {
1141
+ gr.class = 'self-contained';
1142
+ gr.lane = null;
1143
+ }
1144
+ }
1145
+
1146
+ // Families: a shared base class / layout / pref-dialog family. The first
1147
+ // group to convert one builds the shared component; later groups reuse it
1148
+ // (read-only) and, inside the same stage, wait for it.
1149
+ const leader = new Map();
1150
+ for (const gr of groups) {
1151
+ const reuse = [];
1152
+ const after = [];
1153
+ for (const f of sortedBy([...gr._fam])) {
1154
+ const holders = groups.filter((o) => o._fam.has(f));
1155
+ if (holders.length < 2) { continue; }
1156
+ const lead = setdefault(leader, f, gr);
1157
+ if (lead !== gr) {
1158
+ reuse.push({ family: f, from: lead.id });
1159
+ if (lead.stage === gr.stage && !after.includes(lead.id)) { after.push(lead.id); }
1160
+ }
1161
+ }
1162
+ gr.reuse_from = reuse;
1163
+ gr.after = after;
1164
+ if (gr.members.length > MAX_GROUP) {
1165
+ gr.warning = `${gr.members.length} members > ${MAX_GROUP}: review in Step 4.2, split routed-looking members`;
1166
+ }
1167
+ }
1168
+ for (const gr of groups) {
1169
+ for (const k of ['_fam', '_entry', '_is_entry', '_order']) { delete gr[k]; }
1170
+ }
1171
+ return { entry_node: entry, entry_chosen_by: how, launcher_host: launcher, groups };
1172
+ }
1173
+
1174
+ // ---------------------------------------------------------------- build
1175
+
1176
+ /**
1177
+ * Remove source-only dirs whose node is now captured (or no longer a page);
1178
+ * return [removed, Map node -> slug] of the ones kept, so a re-run reuses the
1179
+ * same directory name for a group that may already be converting it.
1180
+ */
1181
+ /**
1182
+ * Mark the groups whose pages live inside a shell host (shell_contract.json `shell_hosts`:
1183
+ * an Activity that swaps Fragments or Views inside a persistent chrome). Such a group is content the
1184
+ * shell mounts, not a routed page: no @Entry, no chrome of its own, and it is reached through
1185
+ * the shell rather than router.pushUrl. The entry group writes the shell itself.
1186
+ *
1187
+ * Adds `host_activity` + `presentation` (`shell` | `shell-content`) to those groups only.
1188
+ * Without shell_hosts (no shell_contract.json yet, or an app with no such Activity) nothing is
1189
+ * added, so the plan is identical to the one written before this existed.
1190
+ *
1191
+ * A host's reach is its own fragment-transaction / view-swap targets plus, transitively, the
1192
+ * fragments / view-pages those swap in: all of them render inside the host's container. Whether a given one is a chrome tab or a
1193
+ * pushed child is the host's dispatch code and the shell's business, not the plan's.
1194
+ */
1195
+ export function annotateShellContent(g, plan, contract) {
1196
+ const hosts = get(or(contract, {}), 'shell_hosts', null);
1197
+ if (!truthy(hosts)) { return; }
1198
+ const hostOf = new Map();
1199
+ for (const hid of keysOf(hosts)) {
1200
+ const queue = [...get(hosts[hid], 'host_destinations', [])];
1201
+ while (queue.length) {
1202
+ const nid = queue.shift();
1203
+ if (hostOf.has(nid)) { continue; }
1204
+ hostOf.set(nid, hid);
1205
+ for (const e of g.outbound.get(nid) ?? []) {
1206
+ const mech = get(e, 'mechanism');
1207
+ const t = pyStr(get(e, 'target'));
1208
+ if ((mech === 'fragment-transaction' && t.startsWith('fragment:')) ||
1209
+ (mech === 'view-swap' && t.startsWith('view-page:'))) {
1210
+ queue.push(e.target);
1211
+ }
1212
+ }
1213
+ }
1214
+ }
1215
+ for (const gr of plan.groups) {
1216
+ const hid = hostOf.get(gr.anchor);
1217
+ if (!hid) { continue; }
1218
+ gr.host_activity = hid;
1219
+ gr.presentation = gr.anchor === plan.entry_node ? 'shell' : 'shell-content';
1220
+ }
1221
+ }
1222
+
1223
+ export function clearPrevious(uiInfo, keep = new Set(), protect = new Set()) {
1224
+ let n = 0;
1225
+ const kept = new Map();
1226
+ for (const d of sortedBy(globPrefix(uiInfo, 'page_'))) {
1227
+ const meta = isDir(d) ? readJson(path.join(d, 'meta.json'), {}) : {};
1228
+ if (get(meta, 'evidence_tier') !== 'source-only') continue;
1229
+ const nid = get(meta, 'static_node');
1230
+ if (protect.has(nid)) continue; // outside an incremental scope: not this run's to judge
1231
+ if (keep.has(nid) && !kept.has(nid)) kept.set(nid, pathName(d));
1232
+ else {
1233
+ fs.rmSync(d, { recursive: true });
1234
+ n += 1;
1235
+ }
1236
+ }
1237
+ return [n, kept];
1238
+ }
1239
+
1240
+ /** --scope / --existing file: a JSON list, or an object holding it under one of `keys`. */
1241
+ export function readList(p, keys) {
1242
+ const v = readJson(p, null);
1243
+ let xs = Array.isArray(v) ? v : null;
1244
+ for (const k of keys) { if (xs === null && Array.isArray(get(v, k))) { xs = v[k]; } }
1245
+ if (xs === null) { throw new Error(`${pathStr(p)}: expected a JSON list, or an object with ${keys.map((k) => `"${k}"`).join(' / ')}`); }
1246
+ return xs.map((x) => (typeof x === 'string' ? x : or(get(x, 'node'), get(x, 'id')))).filter(truthy);
1247
+ }
1248
+
1249
+ /** An existing .ets path as a predicted write: relative to the ETS root, forward slashes. */
1250
+ export function etsRel(p) {
1251
+ const s = pyStr(p).replace(/\\/g, '/');
1252
+ const i = s.lastIndexOf('/src/main/ets/');
1253
+ const rel = i >= 0 ? s.slice(i + '/src/main/ets/'.length) : s.startsWith('src/main/ets/') ? s.slice('src/main/ets/'.length) : s;
1254
+ return rel.replace(/^\.\//, '');
1255
+ }
1256
+
1257
+ /**
1258
+ * Restrict roles to an incremental scope: a page outside it, and a node attached to such a
1259
+ * page, become `skip`. Throws on ids the graph does not have (a typo would scope to nothing).
1260
+ */
1261
+ export function scopeRoles(g, roles, scopeIds) {
1262
+ const unknown = sortedBy([...new Set(scopeIds.filter((x) => !g.nodes.has(x)))]);
1263
+ if (unknown.length) { throw new Error(`--scope names nodes the static UTG does not have: ${unknown.join(', ')}`); }
1264
+ const want = new Set(scopeIds);
1265
+ const res = new Map();
1266
+ for (const [nid, r] of roles) {
1267
+ // an attach node lives in its host's group: named without its host, there is no group for it
1268
+ if (r.role === 'attach' && want.has(nid) && !want.has(r.host)) {
1269
+ res.set(nid, { role: 'skip', reason: `out-of-incremental-scope: its host ${pyStr(r.host)} is not in the scope` });
1270
+ continue;
1271
+ }
1272
+ const inScope = r.role === 'page' ? want.has(nid) : r.role === 'attach' ? want.has(r.host) : true;
1273
+ res.set(nid, inScope ? r : { role: 'skip', reason: 'out-of-incremental-scope' });
1274
+ }
1275
+ if (![...res.values()].some((r) => r.role === 'page')) {
1276
+ throw new Error('--scope holds no convertible page (every id is a container, skipped or attached elsewhere)');
1277
+ }
1278
+ return res;
1279
+ }
1280
+
1281
+ /** Incremental: mark groups that write existing files, and make sure one group goes first. */
1282
+ export function applyIncremental(plan, existing) {
1283
+ const have = new Set([...existing].map(etsRel));
1284
+ for (const gr of plan.groups) {
1285
+ const hits = gr.predicted_writes.filter((w) => have.has(w));
1286
+ if (!hits.length) { continue; }
1287
+ gr.existing_writes = hits;
1288
+ if (gr.class === 'host-chain') { continue; }
1289
+ // its lane serialises shared writes: move the whole lane, or a peer left behind
1290
+ // would run alongside it on the same file
1291
+ const peers = truthy(gr.lane) ? plan.groups.filter((o) => o.lane === gr.lane) : [gr];
1292
+ for (const o of peers) {
1293
+ o.class = 'host-chain';
1294
+ o.lane = 'entry';
1295
+ }
1296
+ }
1297
+ if (plan.groups.some((gr) => gr.stage === 0)) { return; }
1298
+ // What a group builds on: the family leaders it reuses a component from and the captured
1299
+ // groups it borrows measurements from. Promoted alone, such a group would convert before
1300
+ // them while they wait (stage >= 1) for stage 0: the dependency inverted.
1301
+ const needs = (gr) => [...new Set([...(gr.reuse_from ?? []).map((r) => r.from), ...(gr.template_groups ?? [])])]
1302
+ .filter((id) => id !== gr.id);
1303
+ const hosts = plan.groups.filter((gr) => gr.class === 'host-chain');
1304
+ const first = hosts.find((gr) => !needs(gr).length) ?? hosts[0]
1305
+ ?? plan.groups.find((gr) => !needs(gr).length) ?? plan.groups[0];
1306
+ if (!first) { return; }
1307
+ // stage 0 = the chosen group and, transitively, everything it builds on
1308
+ const byId = new Map(plan.groups.map((gr) => [gr.id, gr]));
1309
+ const pulled = [first];
1310
+ for (let i = 0; i < pulled.length; i += 1) {
1311
+ for (const id of needs(pulled[i])) {
1312
+ const o = byId.get(id);
1313
+ if (o && !pulled.includes(o)) { pulled.push(o); }
1314
+ }
1315
+ }
1316
+ // `after` is same-stage only: inside stage 0 each pulled group waits for what it builds on.
1317
+ // reuse_from points at a family's first holder in plan order, so those waits never cycle;
1318
+ // a measurement borrow can point back (leader L borrows from its own reuser P), and a wait
1319
+ // that would close a cycle is dropped, or group_queue would never find either ready.
1320
+ const inPulled = new Set(pulled.map((gr) => gr.id));
1321
+ const waits = new Map(pulled.map((gr) => [gr.id,
1322
+ [...new Set((gr.reuse_from ?? []).map((r) => r.from))].filter((id) => id !== gr.id && inPulled.has(id))]));
1323
+ const reaches = (from, to) => {
1324
+ const stack = [from];
1325
+ const seen = new Set();
1326
+ while (stack.length) {
1327
+ const x = stack.pop();
1328
+ if (x === to) { return true; }
1329
+ if (seen.has(x)) { continue; }
1330
+ seen.add(x);
1331
+ stack.push(...(waits.get(x) ?? []));
1332
+ }
1333
+ return false;
1334
+ };
1335
+ for (const gr of pulled) {
1336
+ for (const id of gr.template_groups ?? []) {
1337
+ const w = waits.get(gr.id);
1338
+ if (id !== gr.id && inPulled.has(id) && !w.includes(id) && !reaches(id, gr.id)) { w.push(id); }
1339
+ }
1340
+ }
1341
+ for (const gr of pulled) {
1342
+ gr.stage = 0;
1343
+ gr.after = waits.get(gr.id);
1344
+ }
1345
+ plan.stage0_chosen_by = (first.class === 'host-chain'
1346
+ ? 'incremental: first host-chain group (the launch page is outside the scope)'
1347
+ : 'incremental: first group (no group touches the existing shared surface)')
1348
+ + (pulled.length > 1 ? `; with ${pulled.slice(1).map((gr) => gr.id).join(', ')} it builds on` : '');
1349
+ // the groups it builds on first, in dependency order (`waits` is acyclic)
1350
+ const head = [];
1351
+ const visit = (gr) => {
1352
+ if (head.includes(gr)) { return; }
1353
+ for (const id of waits.get(gr.id)) { visit(byId.get(id)); }
1354
+ head.push(gr);
1355
+ };
1356
+ for (const gr of [...pulled].reverse()) { visit(gr); }
1357
+ plan.groups = [...head, ...plan.groups.filter((gr) => !head.includes(gr))];
1358
+ }
1359
+
1360
+ /**
1361
+ * True when the capture directory has view trees but no screenshot at all because every frame was
1362
+ * FLAG_SECURE-blocked (export_ui_info writes `screenshots_blocked` and drops the black PNGs).
1363
+ * Such a page stays `captured` (the tree is real device evidence) but nothing can check pixels.
1364
+ */
1365
+ export function pixelsBlocked(uiInfo, dir) {
1366
+ const meta = readJson(path.join(uiInfo, pathName(String(dir)), 'meta.json'));
1367
+ if (!meta || typeof meta !== 'object') return false;
1368
+ const shots = Array.isArray(meta.screenshots) ? meta.screenshots.filter(Boolean) : [];
1369
+ const blocked = Array.isArray(meta.screenshots_blocked) ? meta.screenshots_blocked : [];
1370
+ return blocked.length > 0 && shots.length === 0 && !meta.screenshot;
1371
+ }
1372
+
1373
+ export function build(ws, uiInfo, entry = null, renumber = false, exploring = false,
1374
+ { scope = null, existing = null } = {}) {
1375
+ const g = new Graph(readJson(path.join(ws, 'utg.json')));
1376
+ const prevSet = or(readJson(path.join(uiInfo, 'conversion_set.json'), {}), {});
1377
+ const rawPaths = get(or(readJson(path.join(ws, 'click_paths.json'), {}), {}), 'paths', {});
1378
+ // Map, not a plain object: node ids are keys and insertion order is the contract.
1379
+ const paths = new Map(Array.isArray(rawPaths) ? rawPaths : keysOf(rawPaths).map((k) => [k, rawPaths[k]]));
1380
+ const ranked = sortedBy([...paths.keys()],
1381
+ (k) => [pyLen(get(paths.get(k), 'steps', [])), get(paths.get(k), 'clicks', 0)]);
1382
+ const order = new Map(ranked.map((nid, i) => [nid, i]));
1383
+
1384
+ fs.mkdirSync(uiInfo, { recursive: true });
1385
+ const manifest = or(readJson(path.join(uiInfo, 'export_manifest.json'), {}), {});
1386
+ const scopeIds = truthy(scope) ? readList(scope, ['scope', 'nodes']) : null;
1387
+ // Incremental: each scope explores in a new campaign, and its export rewrites the manifest.
1388
+ // export_ui_info carries an earlier campaign's pages over as `earlier`; a node this campaign
1389
+ // did not capture again keeps that capture instead of turning source-only.
1390
+ const manifestPages = [...get(manifest, 'pages', [])];
1391
+ const listed = new Set(manifestPages.map((p) => p.static_node));
1392
+ for (const p of scopeIds ? get(manifest, 'earlier', []) : []) {
1393
+ if (!listed.has(p.static_node) && isDir(path.join(uiInfo, pathName(p.page_dir)))) { manifestPages.push(p); }
1394
+ }
1395
+ const captured = new Map();
1396
+ for (const p of manifestPages) { setdefault(captured, p.static_node, []).push(p.page_dir); }
1397
+
1398
+ const fullRoles = resolveRoles(g);
1399
+ const roles = scopeIds ? scopeRoles(g, fullRoles, scopeIds) : fullRoles;
1400
+ const keepIds = new Set([...roles].filter(([nid, r]) => r.role === 'page' && !captured.has(nid)).map(([nid]) => nid));
1401
+ const protect = new Set(scopeIds ? [...fullRoles].filter(([nid, r]) => r.role === 'page' && roles.get(nid).role === 'skip')
1402
+ .map(([nid]) => nid) : []);
1403
+ const [removed, prevUnit] = clearPrevious(uiInfo, keepIds, protect);
1404
+ const attached = new Map();
1405
+ for (const [nid, r] of roles) {
1406
+ if (r.role === 'attach') { setdefault(attached, r.host, []).push(nid); }
1407
+ }
1408
+
1409
+ const tmplIndex = new Map();
1410
+ for (const [nid, dirs] of captured) {
1411
+ if (g.nodes.has(nid)) {
1412
+ for (const k of templateKeys(g.nodes.get(nid))) { setdefault(tmplIndex, tkey(k), []).push(...dirs); }
1413
+ }
1414
+ }
1415
+
1416
+ const attachedView = (host) => sortedBy(attached.get(host) ?? []).map((a) => ({
1417
+ id: a, kind: get(g.nodes.get(a), 'kind'), label: get(g.nodes.get(a), 'label'),
1418
+ captured_page_dirs: captured.get(a) ?? [], ...hintsOf(g.nodes.get(a)),
1419
+ }));
1420
+
1421
+ // Captured entries keep export_ui_info's order; drop stale source-only rows.
1422
+ // A scoped run writes only its scope to pages.json; pages_captured.json keeps every
1423
+ // capture, so a later run (another scope, or none) without export_ui_info still sees them.
1424
+ const old = [];
1425
+ const oldNames = new Set();
1426
+ const inPages = new Set(get(or(readJson(path.join(uiInfo, 'pages.json'), {}), {}), 'pages', []).map((e) => pathName(e.page_dir)));
1427
+ for (const f of ['pages.json', 'pages_captured.json']) {
1428
+ for (const e of get(or(readJson(path.join(uiInfo, f), {}), {}), 'pages', [])) {
1429
+ if (!oldNames.has(pathName(e.page_dir))) { oldNames.add(pathName(e.page_dir)); old.push(e); }
1430
+ }
1431
+ }
1432
+ const pages = [];
1433
+ const allCaptured = [];
1434
+ const slugNode = new Map(manifestPages.map((p) => [p.page_dir, p.static_node]));
1435
+ // an earlier campaign's capture no pages file lists any more (a full run deleted
1436
+ // pages_captured.json, then this campaign's export rewrote pages.json)
1437
+ for (const p of manifestPages.slice(get(manifest, 'pages', []).length)) {
1438
+ if (!oldNames.has(pathName(p.page_dir))) {
1439
+ oldNames.add(pathName(p.page_dir));
1440
+ old.push({ page_dir: p.page_dir, ui_sequence: or(get(p, 'ui_sequence'), '根页面') });
1441
+ }
1442
+ }
1443
+ for (let e of old) {
1444
+ // Rebase onto this ui_info: a copied project still holds the original's
1445
+ // absolute page_dir, which would silently point every page at the source.
1446
+ const pdir = path.join(uiInfo, pathName(e.page_dir));
1447
+ if (get(e, 'evidence_tier') === 'source-only' || !isDir(pdir)) { continue; }
1448
+ const nodeId = slugNode.get(pathName(pdir));
1449
+ // a remembered capture the current export no longer lists is stale
1450
+ if (!truthy(nodeId) && slugNode.size && !inPages.has(pathName(pdir))) { continue; }
1451
+ allCaptured.push({ ...e, page_dir: pathResolve(pdir), evidence_tier: 'captured' });
1452
+ // incremental: a capture of a node outside the scope stays on disk, out of pages.json
1453
+ if (scopeIds && (!truthy(nodeId) || get(roles.get(nodeId), 'role', 'skip') === 'skip')) { continue; }
1454
+ e = { ...e, page_dir: pathResolve(pdir), evidence_tier: 'captured' };
1455
+ if (truthy(nodeId) && truthy(attached.get(nodeId))) { e.attached_nodes = attachedView(nodeId); }
1456
+ pages.push(e);
1457
+ }
1458
+
1459
+ const nums = [];
1460
+ for (const d of globPrefix(uiInfo, 'page_')) {
1461
+ const m = /^page_(\p{Nd}+)_/u.exec(pathName(d));
1462
+ if (m) { nums.push(pyInt(m[1])); }
1463
+ }
1464
+ let seq = nums.reduce((a, b) => (b > a ? b : a), 0);
1465
+ const todo = sortedBy([...roles].filter(([nid, r]) => r.role === 'page' && !captured.has(nid)).map(([nid]) => nid),
1466
+ (nid) => [order.has(nid) ? order.get(nid) : order.size, nid]);
1467
+ const units = new Map();
1468
+ const tmplOf = new Map();
1469
+ for (const nid of todo) {
1470
+ const node = g.nodes.get(nid);
1471
+ let slug = prevUnit.get(nid);
1472
+ if (!slug) {
1473
+ seq += 1;
1474
+ slug = `page_${String(seq).padStart(4, '0')}_${safeName(node)}`;
1475
+ }
1476
+ const pdir = path.join(uiInfo, slug);
1477
+ fs.mkdirSync(pdir, { recursive: true });
1478
+ const templates = [];
1479
+ for (const k of templateKeys(node)) {
1480
+ for (const d of tmplIndex.get(tkey(k)) ?? []) {
1481
+ if (!pyIn(d, templates)) { templates.push(d); }
1482
+ }
1483
+ }
1484
+ const p = or(paths.get(nid), {});
1485
+ const labels = get(p, 'steps', []).map((s) => get(s, 'label')).filter(truthy);
1486
+ const route = or(get(p, 'nl_path_text'), get(p, 'path_text'));
1487
+ const meta = {
1488
+ page_id: slug, static_node: nid, kind: get(node, 'kind'), label: get(node, 'label'),
1489
+ declared_at: get(node, 'declared_at'),
1490
+ evidence_tier: 'source-only',
1491
+ // Deliberately empty: there is no capture. Step 4.1 must not treat
1492
+ // this as a failed read, and no agent may invent one.
1493
+ screenshots: [], view_xmls: [],
1494
+ source_hints: hintsOf(node),
1495
+ attached_nodes: attachedView(nid),
1496
+ reached_from: (g.inbound.get(nid) ?? []).map((e) => edgeView(e, 'source')),
1497
+ navigates_to: (g.outbound.get(nid) ?? []).map((e) => edgeView(e, 'target')),
1498
+ template_pages: templates.slice(0, MAX_TEMPLATES),
1499
+ click_path: get(p, 'steps', []),
1500
+ breadcrumb: labels.join(' > '),
1501
+ click_path_text: or(route, ''),
1502
+ source: { backend: 'a2h-utg-static', builder: 'build_conversion_set.mjs' },
1503
+ };
1504
+ writeJson(path.join(pdir, 'meta.json'), meta);
1505
+ pages.push({
1506
+ page_dir: pathResolve(pdir),
1507
+ ui_sequence: ['根页面', ...(truthy(route) ? [route] : labels)].join(ARROW),
1508
+ evidence_tier: 'source-only',
1509
+ });
1510
+ units.set(nid, slug);
1511
+ tmplOf.set(nid, templates.slice(0, MAX_TEMPLATES));
1512
+ }
1513
+
1514
+ const nodesOut = [];
1515
+ for (const nid of sortedBy([...g.nodes.keys()])) {
1516
+ const r = roles.get(nid);
1517
+ const row = { node: nid, kind: get(g.nodes.get(nid), 'kind'), role: r.role };
1518
+ if (r.role === 'page') {
1519
+ row.tier = captured.has(nid) ? 'captured' : 'source-only';
1520
+ row.page_dirs = or(captured.get(nid), [units.get(nid)]);
1521
+ // captured but every frame FLAG_SECURE-blocked: view tree only, no pixel verification possible
1522
+ if (row.tier === 'captured' && row.page_dirs.every((d) => pixelsBlocked(uiInfo, d))) { row.pixels = 'blocked'; }
1523
+ } else if (r.role === 'attach') {
1524
+ row.host = r.host;
1525
+ if (captured.has(nid)) { row.page_dirs = captured.get(nid); }
1526
+ } else {
1527
+ row.reason = r.reason;
1528
+ if (captured.has(nid)) { row.page_dirs = captured.get(nid); }
1529
+ }
1530
+ nodesOut.push(row);
1531
+ }
1532
+
1533
+ const count = (pred) => nodesOut.filter(pred).length;
1534
+ const summary = {
1535
+ static_nodes: nodesOut.length,
1536
+ pages_captured: count((r) => r.tier === 'captured'),
1537
+ pages_tree_only: count((r) => r.pixels === 'blocked'),
1538
+ pages_source_only: count((r) => r.tier === 'source-only'),
1539
+ attached: count((r) => r.role === 'attach'),
1540
+ skipped: count((r) => r.role === 'skip'),
1541
+ page_dirs_total: pages.length,
1542
+ stale_source_only_removed: removed,
1543
+ ...(scopeIds ? { out_of_scope: [...roles.values()].filter((r) => pyStr(r.reason).startsWith('out-of-incremental-scope')).length,
1544
+ scoped_without_host: sortedBy([...roles].filter(([, r]) => / its host .* is not in the scope$/.test(pyStr(r.reason))).map(([nid]) => nid)) } : {}),
1545
+ };
1546
+ const pageOrder = new Map(pages.map((p, i) => [pathName(p.page_dir), i]));
1547
+ let prevPlan = renumber ? {} : or(get(prevSet, 'plan'), {});
1548
+ if (truthy(entry) && truthy(prevPlan) && entry !== get(prevPlan, 'entry_node')) {
1549
+ prevPlan = {}; // a new entry reshapes the plan: done before the queue starts
1550
+ }
1551
+ const prevIds = new Map(get(prevPlan, 'groups', []).map((gr) => [gr.anchor, gr.id]));
1552
+ // Keep the entry chosen last time (often an --entry override): an early,
1553
+ // partial export would otherwise re-infer it on every re-run.
1554
+ entry = or(entry, get(prevPlan, 'entry_node') ?? null);
1555
+ if (scopeIds && !truthy(entry)) {
1556
+ // the launch page exists already and is usually outside the scope: infer it over the whole app
1557
+ const full = new Map([...fullRoles].filter(([, r]) => r.role === 'page')
1558
+ .map(([nid]) => [nid, { tier: captured.has(nid) ? 'captured' : 'source-only', page_dirs: captured.get(nid) ?? [] }]));
1559
+ // ordered by the unfiltered pages.json: the scoped one dropped the captures outside the scope
1560
+ const fullOrder = new Map(old.map((p, i) => [pathName(p.page_dir), i]));
1561
+ entry = planGroups(g, fullRoles, full, fullOrder, ranked, null, null).entry_node;
1562
+ }
1563
+ const plan = planGroups(g, roles, new Map(nodesOut.map((r) => [r.node, r])), pageOrder, ranked, entry, prevIds,
1564
+ scopeIds ? fullRoles : null);
1565
+ const gs = plan.groups;
1566
+ // The captured groups a source-only group borrows measurements from: it
1567
+ // waits for exactly those (group_queue), not for every captured group.
1568
+ const owner = new Map();
1569
+ for (const gr of gs) for (const d of gr.page_dirs) owner.set(d, gr.id);
1570
+ for (const gr of gs) {
1571
+ const tg = new Set();
1572
+ for (const m of gr.members) {
1573
+ for (const d of tmplOf.get(m.node) ?? []) {
1574
+ const o = owner.get(pathName(d));
1575
+ if (o && o !== gr.id) tg.add(o);
1576
+ }
1577
+ }
1578
+ gr.template_groups = sortedBy([...tg]);
1579
+ }
1580
+ // Exploration still running: captured groups may start, source-only ones
1581
+ // are held -- their tier is not final until the explorer settles.
1582
+ if (scopeIds) {
1583
+ applyIncremental(plan, truthy(existing) ? readList(existing, ['existing', 'files']) : []);
1584
+ plan.mode = 'incremental';
1585
+ plan.scope = sortedBy([...new Set(scopeIds)]);
1586
+ }
1587
+ annotateShellContent(g, plan, readJson(path.join(path.dirname(path.resolve(ws)), 'shell_contract.json'), null));
1588
+ plan.exploring = truthy(exploring);
1589
+ // The captures this plan's tiers reflect, and how it was built: group_queue.mjs
1590
+ // rebuilds the plan the same way when the campaign's captures have moved on.
1591
+ plan.capture_digest = manifest.capture_digest ?? null;
1592
+ plan.built_from = { static_ws: pathStr(ws), entry: entry ?? null,
1593
+ ...(scopeIds ? { scope: pathStr(pathResolve(scope)), existing: truthy(existing) ? pathStr(pathResolve(existing)) : null } : {}) };
1594
+ const byClass = {};
1595
+ for (const c of ['host-chain', 'serial', 'self-contained']) { byClass[c] = gs.filter((x) => x.class === c).length; }
1596
+ const byStage = {};
1597
+ for (const st of [0, 1, 2]) { byStage[String(st)] = gs.filter((x) => x.stage === st).length; }
1598
+ Object.assign(summary, {
1599
+ groups: gs.length, entry_node: plan.entry_node,
1600
+ groups_by_class: byClass,
1601
+ groups_by_stage: byStage,
1602
+ group_warnings: gs.filter((x) => truthy(x.warning)).length,
1603
+ });
1604
+ writeJson(path.join(uiInfo, 'pages.json'), { pages });
1605
+ if (scopeIds) {
1606
+ writeJson(path.join(uiInfo, 'pages_captured.json'), { pages: allCaptured });
1607
+ } else {
1608
+ fs.rmSync(path.join(uiInfo, 'pages_captured.json'), { force: true }); // pages.json holds them all again
1609
+ }
1610
+ writeJson(path.join(uiInfo, 'conversion_set.json'), { summary, nodes: nodesOut, plan });
1611
+ return summary;
1612
+ }
1613
+
1614
+ const DESCRIPTION = 'build_conversion_set.mjs — make the static UTG, not the capture, decide what\ngets converted.';
1615
+
1616
+ export function main(argv = process.argv.slice(2)) {
1617
+ const a = parseArgs({
1618
+ prog: 'build_conversion_set.mjs', description: DESCRIPTION,
1619
+ args: [
1620
+ { name: 'static_ws', positional: true, help: 'a2h-utg-static workspace (utg.json, click_paths.json)' },
1621
+ { name: '--ui-info', required: true, help: 'ui_info_root (export_ui_info.mjs output)' },
1622
+ { name: '--entry', help: "static node rendered by the app's launch page (default: inferred, see plan.entry_chosen_by)" },
1623
+ { name: '--exploring', bool: true, help: 'explorer still running: mark the plan so group_queue holds source-only groups' },
1624
+ { name: '--renumber', bool: true, help: "assign group ids afresh instead of keeping the previous run's ids per anchor" },
1625
+ { name: '--scope', help: 'incremental: JSON list of the static node ids to convert (the confirmed SCOPE); every other page is skipped' },
1626
+ { name: '--existing', help: 'incremental: JSON list of the .ets files the Harmony project already has (relative to the ETS root)' },
1627
+ ],
1628
+ }, argv);
1629
+ if (!isFile(path.join(a.static_ws, 'utg.json'))) {
1630
+ err(`[ERR] ${pathStr(a.static_ws)}/utg.json missing — run Step 3.1 first`);
1631
+ return 2;
1632
+ }
1633
+ if (a.existing && !a.scope) {
1634
+ err('[ERR] --existing needs --scope');
1635
+ return 2;
1636
+ }
1637
+ for (const k of ['scope', 'existing']) {
1638
+ if (a[k] && !isFile(a[k])) {
1639
+ err(`[ERR] --${k} ${pathStr(a[k])}: no such file`);
1640
+ return 2;
1641
+ }
1642
+ }
1643
+ let s;
1644
+ try {
1645
+ s = build(pathResolve(a.static_ws), pathResolve(a.ui_info), a.entry, a.renumber, a.exploring,
1646
+ { scope: a.scope, existing: a.existing });
1647
+ } catch (e) {
1648
+ if (!a.scope || !/^--scope|: expected a JSON list/.test(e.message)) { throw e; }
1649
+ err(`[ERR] ${e.message}`);
1650
+ return 2;
1651
+ }
1652
+ out(`static nodes ${s.static_nodes}: pages ${s.pages_captured} captured + ` +
1653
+ `${s.pages_source_only} source-only, ${s.attached} attached to a host, ${s.skipped} skipped` +
1654
+ (s.out_of_scope !== undefined ? ` (${s.out_of_scope} outside the incremental scope)` : '') + '; ' +
1655
+ `pages.json has ${s.page_dirs_total} entries`);
1656
+ out(`groups ${s.groups} (entry ${pyStr(s.entry_node)}): ${pyRepr(s.groups_by_class)}, by stage ${pyRepr(s.groups_by_stage)}` +
1657
+ (s.group_warnings ? `; ${s.group_warnings} oversized — review` : ''));
1658
+ if (!truthy(s.entry_node)) {
1659
+ err('[WARN] no entry page inferred (no launcher host-activity, no manifest launcher page): ' +
1660
+ 'no group carries ENTRY_PAGE — re-run with --entry <static node of the launch page>');
1661
+ }
1662
+ if (truthy(s.scoped_without_host)) {
1663
+ err(`[WARN] --scope names ${s.scoped_without_host.join(', ')} without its host page: not converted — ` +
1664
+ 'add the host page to the scope (an attached node is converted inside its host group)');
1665
+ }
1666
+ if (s.pages_captured === 0) {
1667
+ err('[WARN] no captured page: every page would be source-only and no project token ' +
1668
+ "(colour, density, spacing) can be measured — see Step 3.3's gate");
1669
+ }
1670
+ return 0;
1671
+ }
1672
+
1673
+ if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
1674
+ process.exitCode = main();
1675
+ }