@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,2079 @@
1
+ import type {
2
+ AnalysisContext,
3
+ UnresolvedItem
4
+ } from "../contracts/artifact.ts";
5
+ import type {
6
+ Action,
7
+ Area,
8
+ AreaGraphArtifact,
9
+ AreaGraphView,
10
+ AreaPath,
11
+ Edge,
12
+ Effect,
13
+ EntryPoint,
14
+ NavigationEvidence
15
+ } from "../contracts/area-graph.ts";
16
+ import {
17
+ isReqProjectedAction,
18
+ toAreaGraphDocument,
19
+ withAreaGraphFlatViews
20
+ } from "../contracts/area-graph.ts";
21
+ import {
22
+ GAP_AUDIT_CONTRACT_VERSION,
23
+ type GapAuditArtifact,
24
+ type GapAuditCandidate,
25
+ type GapAuditCategory
26
+ } from "../contracts/gap-audit.ts";
27
+ import type {
28
+ RawFactDataByKind,
29
+ RawFactInput,
30
+ RawFactKind
31
+ } from "../contracts/raw-fact.ts";
32
+ import type { ReqFeature, ReqModelArtifact } from "../contracts/req-model.ts";
33
+ import type { SemanticLimitation } from "../contracts/semantic-completeness.ts";
34
+ import type { SourceFactsArtifact } from "../contracts/source-facts.ts";
35
+ import type {
36
+ ImportedUtgLink,
37
+ ImportedUtgNode,
38
+ ImportedUtgPath,
39
+ ImportedUtgTopology,
40
+ ImportedUtgWorkspace
41
+ } from "../contracts/utg.ts";
42
+ import { buildAreaGraph } from "../analysis/graph/index.ts";
43
+ import {
44
+ assembleReqProjection,
45
+ buildReqModel
46
+ } from "../analysis/req-model/index.ts";
47
+ import { SourceFactsBuilder } from "../analysis/source-facts/builder.ts";
48
+ import { createStableId } from "../core/stable-id.ts";
49
+ import type {
50
+ FinalizedInteractionAnalysis,
51
+ InteractionEffectDraft,
52
+ InteractionFinalizeDiagnostic
53
+ } from "../interaction-analysis/contracts.ts";
54
+ import {
55
+ buildInteractionRawFactPlan,
56
+ type KeyedRawFactPatch
57
+ } from "../interaction-analysis/raw-facts.ts";
58
+ import { validateAreaGraph } from "../validation/area-graph.ts";
59
+
60
+ export interface AssembleModelInput {
61
+ readonly requirementScope?: import("../requirement-scope.ts").ReqGenerationScope;
62
+ readonly caseId: string;
63
+ readonly analysisContext: AnalysisContext;
64
+ readonly utg: ImportedUtgWorkspace;
65
+ readonly interactions: FinalizedInteractionAnalysis;
66
+ readonly sourceAvailability?: {
67
+ readonly treeSitter: boolean;
68
+ readonly homeGraph: boolean;
69
+ };
70
+ /** Stable identifier used by gap-audit; defaults to the input fingerprint. */
71
+ readonly runId?: string;
72
+ }
73
+
74
+ export interface ModelAssemblyStatistics {
75
+ readonly areas: number;
76
+ readonly utgLinks: number;
77
+ readonly utgLinksWithEvidence: number;
78
+ readonly topologySeeds: number;
79
+ readonly sourceControls: number;
80
+ readonly visibleFeatures: number;
81
+ readonly canonicalPaths: number;
82
+ readonly unreachablePaths: number;
83
+ readonly unresolvedPathAreas: number;
84
+ readonly internalEdgesWithoutUtgEvidence: number;
85
+ }
86
+
87
+ export interface AssembledModelArtifacts {
88
+ readonly sourceFacts: SourceFactsArtifact;
89
+ readonly areaGraph: AreaGraphView;
90
+ readonly areaGraphArtifact: AreaGraphArtifact;
91
+ readonly reqModel: ReqModelArtifact;
92
+ readonly gapAudit: GapAuditArtifact;
93
+ readonly statistics: ModelAssemblyStatistics;
94
+ }
95
+
96
+ interface SourceInteractionEffect {
97
+ readonly areaRef: string;
98
+ readonly actionSemanticKey: string;
99
+ readonly effect: InteractionEffectDraft;
100
+ readonly callbackKey: string;
101
+ readonly effectKey: string;
102
+ readonly callbackFactRef: string;
103
+ readonly effectFactRef: string;
104
+ }
105
+
106
+ interface TopologySeed {
107
+ readonly link: ImportedUtgLink;
108
+ readonly callbackFactRef: string;
109
+ readonly effectFactRef: string;
110
+ }
111
+
112
+ interface UtgFactIndex {
113
+ readonly componentKeyByArea: ReadonlyMap<string, string>;
114
+ readonly componentFactByArea: ReadonlyMap<string, string>;
115
+ readonly titleFactByArea: ReadonlyMap<string, string>;
116
+ }
117
+
118
+ function stableId(
119
+ caseId: string,
120
+ namespace: string,
121
+ entityKind: string,
122
+ identity: string
123
+ ): string {
124
+ return createStableId({
125
+ namespace,
126
+ caseId,
127
+ entityKind,
128
+ identity: [{ kind: "semantic-key", value: identity }]
129
+ });
130
+ }
131
+
132
+ function compareId(left: { readonly id: string }, right: { readonly id: string }): number {
133
+ return left.id.localeCompare(right.id, "en");
134
+ }
135
+
136
+ function unique(values: readonly string[]): string[] {
137
+ return [...new Set(values)].sort((left, right) =>
138
+ left.localeCompare(right, "en")
139
+ );
140
+ }
141
+
142
+ function encoded(value: string): string {
143
+ return encodeURIComponent(value.normalize("NFC"));
144
+ }
145
+
146
+ function utgEvidence(index: number, anchor: string) {
147
+ return {
148
+ sourceKind: "generated" as const,
149
+ path: "utg/utg.json",
150
+ anchor,
151
+ range: { startLine: index + 1, endLine: index + 1 }
152
+ };
153
+ }
154
+
155
+ function componentType(node: ImportedUtgNode): RawFactDataByKind["component"]["componentType"] {
156
+ switch (node.kind) {
157
+ case "activity":
158
+ case "activity-content":
159
+ case "host-activity":
160
+ return "activity";
161
+ case "fragment":
162
+ return "fragment";
163
+ case "dialog":
164
+ return "dialog";
165
+ case "sheet":
166
+ case "sheet-screen":
167
+ return "bottom-sheet";
168
+ case "menu":
169
+ return "popup";
170
+ case "pager-page":
171
+ return "pager-page";
172
+ case "app-widget":
173
+ return "widget";
174
+ default:
175
+ // UTG nodes, including modes, variants, dynamic nodes and external
176
+ // screens, are authoritative Areas. compose-destination is the generic
177
+ // Area-capable source-fact type; the final Area.kind remains node.kind.
178
+ return "compose-destination";
179
+ }
180
+ }
181
+
182
+ function displayName(node: ImportedUtgNode): string {
183
+ for (const value of [node.label, node.name, node.fqn, node.id]) {
184
+ if (value?.trim()) return value.trim();
185
+ }
186
+ return node.id;
187
+ }
188
+
189
+ function addUtgNodeFacts(
190
+ builder: SourceFactsBuilder,
191
+ topology: ImportedUtgTopology,
192
+ applicationModule: string
193
+ ): UtgFactIndex {
194
+ const componentKeyByArea = new Map<string, string>();
195
+ const componentFactByArea = new Map<string, string>();
196
+ const titleFactByArea = new Map<string, string>();
197
+ topology.nodes.forEach((node, index) => {
198
+ const semanticKey = `utg-component:${encoded(node.id)}`;
199
+ const evidence = utgEvidence(index, `node:${node.id}`);
200
+ const componentFactRef = builder.addFact("component", {
201
+ identity: [{ kind: "component", value: node.id }],
202
+ confidence: node.confidence !== undefined && node.confidence < 0.7
203
+ ? "medium"
204
+ : "high",
205
+ support: [{ location: evidence, role: "frozen UTG Area" }],
206
+ data: {
207
+ componentType: componentType(node),
208
+ qualifiedName: node.fqn ?? node.name ?? `utg:${node.id}`,
209
+ applicationModule
210
+ }
211
+ });
212
+ const titleFactRef = builder.addFact("ui-property", {
213
+ identity: [
214
+ { kind: "component", value: node.id },
215
+ { kind: "semantic-key", value: "utg-display-name" }
216
+ ],
217
+ confidence: "high",
218
+ support: [{ location: evidence, role: "frozen UTG Area label" }],
219
+ data: {
220
+ ownerKey: componentFactRef,
221
+ property: "title",
222
+ value: displayName(node)
223
+ },
224
+ relatedFactRefs: [componentFactRef]
225
+ });
226
+ componentKeyByArea.set(node.id, semanticKey);
227
+ componentFactByArea.set(node.id, componentFactRef);
228
+ titleFactByArea.set(node.id, titleFactRef);
229
+ });
230
+ return { componentKeyByArea, componentFactByArea, titleFactByArea };
231
+ }
232
+
233
+ function addEntryFacts(
234
+ builder: SourceFactsBuilder,
235
+ topology: ImportedUtgTopology,
236
+ facts: UtgFactIndex
237
+ ): void {
238
+ topology.entryRootAreaRefs.forEach((root, index) => {
239
+ const componentRef = facts.componentFactByArea.get(root);
240
+ if (!componentRef) throw new Error(`UTG entry root has no Area: ${root}`);
241
+ builder.addFact("entry-point", {
242
+ identity: [
243
+ { kind: "entry", value: root },
244
+ { kind: "component", value: root }
245
+ ],
246
+ confidence: "high",
247
+ support: [{
248
+ location: utgEvidence(index, `entry-root:${root}`),
249
+ role: "frozen UTG entry root"
250
+ }],
251
+ data: {
252
+ entryKind: "launcher",
253
+ category: root === topology.rootAreaRef ? "normal" : "alternate",
254
+ componentKey: componentRef,
255
+ conditionKeys: [],
256
+ startupRole: "default"
257
+ },
258
+ relatedFactRefs: [componentRef]
259
+ });
260
+ });
261
+ }
262
+
263
+ function resolveRef(mapping: ReadonlyMap<string, string>, key: string): string {
264
+ const ref = mapping.get(key);
265
+ if (!ref) throw new Error(`Raw-fact plan references unknown key ${key}`);
266
+ return ref;
267
+ }
268
+
269
+ function resolveFactData<K extends RawFactKind>(
270
+ kind: K,
271
+ data: RawFactDataByKind[K],
272
+ mapping: ReadonlyMap<string, string>
273
+ ): RawFactDataByKind[K] {
274
+ switch (kind) {
275
+ case "component":
276
+ case "resource-value":
277
+ return data;
278
+ case "component-variant": {
279
+ const value = data as RawFactDataByKind["component-variant"];
280
+ return {
281
+ ...value,
282
+ componentKey: resolveRef(mapping, value.componentKey),
283
+ conditionKeys: value.conditionKeys.map((key) => resolveRef(mapping, key)),
284
+ entryCallbackKeys: value.entryCallbackKeys.map((key) => resolveRef(mapping, key)),
285
+ ...(value.visibleElementKeys
286
+ ? { visibleElementKeys: value.visibleElementKeys.map((key) => resolveRef(mapping, key)) }
287
+ : {})
288
+ } as unknown as RawFactDataByKind[K];
289
+ }
290
+ case "entry-point": {
291
+ const value = data as RawFactDataByKind["entry-point"];
292
+ return {
293
+ ...value,
294
+ componentKey: resolveRef(mapping, value.componentKey),
295
+ conditionKeys: value.conditionKeys.map((key) => resolveRef(mapping, key)),
296
+ ...(value.preconditionKeys
297
+ ? { preconditionKeys: value.preconditionKeys.map((key) => resolveRef(mapping, key)) }
298
+ : {}),
299
+ ...(value.parentEntryKey
300
+ ? { parentEntryKey: resolveRef(mapping, value.parentEntryKey) }
301
+ : {})
302
+ } as unknown as RawFactDataByKind[K];
303
+ }
304
+ case "ui-element":
305
+ case "ui-property":
306
+ case "callback":
307
+ case "condition": {
308
+ const value = data as RawFactDataByKind[
309
+ "ui-element" | "ui-property" | "callback" | "condition"
310
+ ];
311
+ return { ...value, ownerKey: resolveRef(mapping, value.ownerKey) } as RawFactDataByKind[K];
312
+ }
313
+ case "container-binding": {
314
+ const value = data as RawFactDataByKind["container-binding"];
315
+ return {
316
+ ...value,
317
+ hostKey: resolveRef(mapping, value.hostKey),
318
+ contentKeys: value.contentKeys.map((key) => resolveRef(mapping, key)) as unknown as
319
+ RawFactDataByKind["container-binding"]["contentKeys"],
320
+ ...(value.initialContentKey
321
+ ? { initialContentKey: resolveRef(mapping, value.initialContentKey) }
322
+ : {})
323
+ } as RawFactDataByKind[K];
324
+ }
325
+ case "interaction-binding": {
326
+ const value = data as RawFactDataByKind["interaction-binding"];
327
+ return {
328
+ ...value,
329
+ elementKey: resolveRef(mapping, value.elementKey),
330
+ callbackKey: resolveRef(mapping, value.callbackKey)
331
+ } as RawFactDataByKind[K];
332
+ }
333
+ case "callback-flow": {
334
+ const value = data as RawFactDataByKind["callback-flow"];
335
+ return {
336
+ ...value,
337
+ fromCallbackKey: resolveRef(mapping, value.fromCallbackKey),
338
+ toCallbackKey: resolveRef(mapping, value.toCallbackKey),
339
+ ...(value.conditionKeys
340
+ ? { conditionKeys: value.conditionKeys.map((key) => resolveRef(mapping, key)) }
341
+ : {})
342
+ } as RawFactDataByKind[K];
343
+ }
344
+ case "behavior-effect": {
345
+ const value = data as RawFactDataByKind["behavior-effect"];
346
+ return {
347
+ ...value,
348
+ callbackKey: resolveRef(mapping, value.callbackKey),
349
+ ...(value.targetKey ? { targetKey: resolveRef(mapping, value.targetKey) } : {}),
350
+ ...(value.conditionKeys
351
+ ? { conditionKeys: value.conditionKeys.map((key) => resolveRef(mapping, key)) }
352
+ : {})
353
+ } as RawFactDataByKind[K];
354
+ }
355
+ case "navigation-target": {
356
+ const value = data as RawFactDataByKind["navigation-target"];
357
+ return {
358
+ ...value,
359
+ effectKey: resolveRef(mapping, value.effectKey),
360
+ ...(value.targetKey ? { targetKey: resolveRef(mapping, value.targetKey) } : {})
361
+ } as RawFactDataByKind[K];
362
+ }
363
+ }
364
+ }
365
+
366
+ function addPlannedFact<K extends RawFactKind>(
367
+ builder: SourceFactsBuilder,
368
+ patch: { readonly semanticKey: string; readonly fact: RawFactInput<K> },
369
+ mapping: Map<string, string>
370
+ ): string {
371
+ const id = builder.addFact(patch.fact.kind, {
372
+ identity: patch.fact.identity,
373
+ confidence: patch.fact.confidence,
374
+ support: patch.fact.evidence.map((location) => ({
375
+ location,
376
+ role: "Tree-sitter/HomeGraph interaction evidence"
377
+ })) as [{
378
+ readonly location: RawFactInput<K>["evidence"][number];
379
+ readonly role: string;
380
+ }, ...{
381
+ readonly location: RawFactInput<K>["evidence"][number];
382
+ readonly role: string;
383
+ }[]],
384
+ data: resolveFactData(patch.fact.kind, patch.fact.data, mapping),
385
+ ...(patch.fact.relatedKeys
386
+ ? { relatedFactRefs: patch.fact.relatedKeys.map((key) => resolveRef(mapping, key)) }
387
+ : {})
388
+ });
389
+ mapping.set(patch.semanticKey, id);
390
+ return id;
391
+ }
392
+
393
+ function applyInteractionPlan(
394
+ builder: SourceFactsBuilder,
395
+ interactions: FinalizedInteractionAnalysis,
396
+ componentKeyByArea: ReadonlyMap<string, string>,
397
+ componentFactByArea: ReadonlyMap<string, string>
398
+ ): readonly SourceInteractionEffect[] {
399
+ const mapping = new Map<string, string>();
400
+ for (const [area, key] of componentKeyByArea) {
401
+ mapping.set(key, resolveRef(componentFactByArea, area));
402
+ }
403
+ const plan = buildInteractionRawFactPlan({
404
+ analysis: interactions,
405
+ componentKeyByArea
406
+ });
407
+ for (const patch of plan) {
408
+ addPlannedFact(
409
+ builder,
410
+ patch as KeyedRawFactPatch & { readonly fact: RawFactInput },
411
+ mapping
412
+ );
413
+ }
414
+ return interactions.controls.flatMap((control) =>
415
+ control.actions.flatMap((action) => {
416
+ const callbackKey = `interaction-callback:${encoded(control.areaRef)}:${encoded(action.semanticKey)}`;
417
+ const callbackFactRef = resolveRef(mapping, callbackKey);
418
+ return action.effects.map((effect): SourceInteractionEffect => {
419
+ const effectKey = `interaction-effect:${encoded(control.areaRef)}:` +
420
+ `${encoded(action.semanticKey)}:${encoded(effect.semanticKey)}`;
421
+ return {
422
+ areaRef: control.areaRef,
423
+ actionSemanticKey: action.semanticKey,
424
+ effect,
425
+ callbackKey,
426
+ effectKey,
427
+ callbackFactRef,
428
+ effectFactRef: resolveRef(mapping, effectKey)
429
+ };
430
+ });
431
+ })
432
+ );
433
+ }
434
+
435
+ const UTG_CONTROL_ID_ARGUMENTS = new Set([
436
+ "controlid",
437
+ "resourceid",
438
+ "triggerid",
439
+ "viewid",
440
+ "widgetid"
441
+ ]);
442
+
443
+ function normalizedControlIdentifier(value: string): string | undefined {
444
+ const text = value.trim();
445
+ for (const pattern of [
446
+ /^@\+?id\/([A-Za-z_][A-Za-z0-9_]*)$/u,
447
+ /(?:^|\.)R?\.id\.([A-Za-z_][A-Za-z0-9_]*)$/u,
448
+ /(?:^|\.)binding\.([A-Za-z_][A-Za-z0-9_]*)$/u,
449
+ /^([A-Za-z_][A-Za-z0-9_]*)$/u
450
+ ]) {
451
+ const match = pattern.exec(text);
452
+ if (match?.[1]) return match[1];
453
+ }
454
+ return undefined;
455
+ }
456
+
457
+ function controlIdentifiers(
458
+ control: FinalizedInteractionAnalysis["controls"][number]["control"]
459
+ ): ReadonlySet<string> {
460
+ const result = new Set<string>();
461
+ for (const value of [control.resourceId, control.symbol]) {
462
+ if (!value) continue;
463
+ const identifier = normalizedControlIdentifier(value);
464
+ if (identifier) result.add(identifier);
465
+ }
466
+ const sourceId = /#id:([A-Za-z_][A-Za-z0-9_]*)/u.exec(
467
+ control.semanticKey
468
+ )?.[1];
469
+ if (sourceId) result.add(sourceId);
470
+ return result;
471
+ }
472
+
473
+ function normalizedArgumentName(value: string): string {
474
+ return value.toLocaleLowerCase("en-US").replaceAll("_", "").replaceAll("-", "");
475
+ }
476
+
477
+ /**
478
+ * Returns structural Android control ids carried by a frozen UTG link.
479
+ * `label_key` is a control id only when the UTG producer explicitly says the
480
+ * label came from a view id. A code-name or text label remains presentation
481
+ * evidence and must not become an identity join.
482
+ */
483
+ export function linkControlIdentifiers(link: ImportedUtgLink): ReadonlySet<string> {
484
+ const result = new Set<string>();
485
+ const labelSource = Object.entries(link.args).find(([key]) =>
486
+ normalizedArgumentName(key) === "labelsource"
487
+ )?.[1];
488
+ const labelKeyIsViewId = typeof labelSource === "string" &&
489
+ normalizedArgumentName(labelSource) === "viewid";
490
+ for (const [key, value] of Object.entries(link.args)) {
491
+ const normalizedKey = normalizedArgumentName(key);
492
+ const isStructuralId = UTG_CONTROL_ID_ARGUMENTS.has(normalizedKey) ||
493
+ (normalizedKey === "labelkey" && labelKeyIsViewId);
494
+ if (!isStructuralId || typeof value !== "string") {
495
+ continue;
496
+ }
497
+ const identifier = normalizedControlIdentifier(value);
498
+ if (identifier) result.add(identifier);
499
+ }
500
+ return result;
501
+ }
502
+
503
+ function sameEvidenceRange(
504
+ left: InteractionEffectDraft,
505
+ right: InteractionEffectDraft
506
+ ): boolean {
507
+ const key = (location: InteractionEffectDraft["evidence"][number]): string =>
508
+ JSON.stringify([
509
+ location.path,
510
+ location.range.startLine,
511
+ location.range.endLine,
512
+ location.range.startColumn ?? 0,
513
+ location.range.endColumn ?? 0
514
+ ]);
515
+ const leftKeys = unique(left.evidence.map(key));
516
+ const rightKeys = unique(right.evidence.map(key));
517
+ return leftKeys.length === rightKeys.length &&
518
+ leftKeys.every((value, index) => value === rightKeys[index]);
519
+ }
520
+
521
+ /** True when source analysis has not already resolved a concrete target. */
522
+ export function hasNoResolvedInteractionTarget(effect: InteractionEffectDraft): boolean {
523
+ return effect.target === undefined || effect.target.kind === "unresolved";
524
+ }
525
+
526
+ function effectCanCorroborateUtgLink(
527
+ effect: InteractionEffectDraft,
528
+ expectedKind: "navigate-area" | "show-surface",
529
+ link: Pick<ImportedUtgLink, "targetAreaRef">
530
+ ): boolean {
531
+ if (effect.kind !== expectedKind || effect.utgEdgeRef !== undefined) return false;
532
+ if (hasNoResolvedInteractionTarget(effect)) return true;
533
+ return effect.target?.kind === "area" && effect.target.areaRef === link.targetAreaRef;
534
+ }
535
+
536
+ /** Expands one source navigation into the frozen conditional links
537
+ * of the same structural Control while keeping every Effect identity unique. */
538
+ export function bindInteractionEffectToUtgLinks(
539
+ effect: InteractionEffectDraft,
540
+ links: readonly Pick<ImportedUtgLink, "id" | "targetAreaRef">[],
541
+ evidence: InteractionEffectDraft["evidence"] = effect.evidence
542
+ ): readonly InteractionEffectDraft[] {
543
+ return links.map((link) => ({
544
+ ...effect,
545
+ semanticKey: links.length === 1
546
+ ? effect.semanticKey
547
+ : `${effect.semanticKey}#${link.id}`,
548
+ target: { kind: "area" as const, areaRef: link.targetAreaRef },
549
+ utgEdgeRef: link.id,
550
+ evidence
551
+ }));
552
+ }
553
+
554
+ function nonEmptySourceLocations(
555
+ values: readonly InteractionEffectDraft["evidence"][number][]
556
+ ): InteractionEffectDraft["evidence"] {
557
+ const byKey = new Map(values.map((location) => [JSON.stringify([
558
+ location.path,
559
+ location.range.startLine,
560
+ location.range.endLine,
561
+ location.range.startColumn ?? 0,
562
+ location.range.endColumn ?? 0,
563
+ location.anchor,
564
+ location.symbol ?? ""
565
+ ]), location]));
566
+ const result = [...byKey.values()].sort((left, right) =>
567
+ JSON.stringify(left).localeCompare(JSON.stringify(right), "en")
568
+ );
569
+ if (result.length === 0) {
570
+ throw new Error("An exact UTG trigger binding has no source evidence");
571
+ }
572
+ return [result[0] as InteractionEffectDraft["evidence"][number], ...result.slice(1)];
573
+ }
574
+
575
+ interface UtgTriggerSourceLocation {
576
+ readonly path: string;
577
+ readonly line: number;
578
+ }
579
+
580
+ /** Extracts the source call site carried by triggers such as
581
+ * `onClick@app/src/main/Foo.java:42`. The source path may itself contain a
582
+ * colon, so the final numeric segment is treated as the line number. */
583
+ export function utgTriggerSourceLocation(
584
+ link: Pick<ImportedUtgLink, "trigger">
585
+ ): UtgTriggerSourceLocation | undefined {
586
+ const separator = link.trigger.lastIndexOf("@");
587
+ if (separator < 0) return undefined;
588
+ const source = link.trigger.slice(separator + 1);
589
+ const match = /^(.+):(\d+)$/u.exec(source);
590
+ if (!match?.[1] || !match[2]) return undefined;
591
+ const line = Number.parseInt(match[2], 10);
592
+ return Number.isSafeInteger(line) && line > 0
593
+ ? { path: match[1].replaceAll("\\", "/"), line }
594
+ : undefined;
595
+ }
596
+
597
+ function actionCoversTriggerSource(
598
+ action: FinalizedInteractionAnalysis["controls"][number]["actions"][number],
599
+ source: UtgTriggerSourceLocation
600
+ ): boolean {
601
+ return action.evidence.some((location) =>
602
+ location.path.replaceAll("\\", "/") === source.path &&
603
+ location.range.startLine <= source.line &&
604
+ location.range.endLine >= source.line
605
+ );
606
+ }
607
+
608
+ function compatibleActivationTrigger(
609
+ source: FinalizedInteractionAnalysis["controls"][number]["actions"][number]["trigger"],
610
+ topology: RawFactDataByKind["interaction-binding"]["trigger"]
611
+ ): boolean {
612
+ if (source === topology) return true;
613
+ return (source === "select" && topology === "click") ||
614
+ (source === "click" && topology === "select");
615
+ }
616
+
617
+ function sourceBindingKey(
618
+ control: FinalizedInteractionAnalysis["controls"][number],
619
+ action: FinalizedInteractionAnalysis["controls"][number]["actions"][number]
620
+ ): string {
621
+ return `${control.control.semanticKey}\u0000${action.semanticKey}`;
622
+ }
623
+
624
+ /**
625
+ * Returns only unambiguous link-to-source Action matches. This is a second
626
+ * structural join for UTG producers that do not expose a view id: the frozen
627
+ * UTG call-site line must fall inside exactly one same-Area source Action that
628
+ * also contains an unresolved navigation Effect of the required kind.
629
+ */
630
+ function exactSourceActionBindings(
631
+ interactions: FinalizedInteractionAnalysis,
632
+ topology: ImportedUtgTopology,
633
+ nodeById: ReadonlyMap<string, ImportedUtgNode>
634
+ ): ReadonlyMap<string, string> {
635
+ const result = new Map<string, string>();
636
+ for (const link of topology.links) {
637
+ if (link.transitionClass !== "user") continue;
638
+ const source = utgTriggerSourceLocation(link);
639
+ if (!source) continue;
640
+ const expectedKind = isSurface(nodeById.get(link.targetAreaRef))
641
+ ? "show-surface" as const
642
+ : "navigate-area" as const;
643
+ const candidates = interactions.controls.flatMap((control) =>
644
+ control.areaRef !== link.sourceAreaRef
645
+ ? []
646
+ : control.actions.flatMap((action) =>
647
+ compatibleActivationTrigger(action.trigger, actionForLink(link)) &&
648
+ actionCoversTriggerSource(action, source) &&
649
+ action.effects.some((effect) =>
650
+ effectCanCorroborateUtgLink(effect, expectedKind, link)
651
+ )
652
+ ? [sourceBindingKey(control, action)]
653
+ : []
654
+ )
655
+ );
656
+ if (candidates.length === 1) {
657
+ result.set(link.id, candidates[0] as string);
658
+ }
659
+ }
660
+ return result;
661
+ }
662
+
663
+ function canonicalControlHint(
664
+ link: ImportedUtgLink,
665
+ topology: ImportedUtgTopology
666
+ ): string | undefined {
667
+ for (const path of topology.canonicalPaths) {
668
+ const step = path.steps.find((candidate) => candidate.linkRefs.includes(link.id));
669
+ if (!step) continue;
670
+ const values = step.labelSource?.trim().toLocaleLowerCase("en-US") === "code-name"
671
+ ? [step.nlHint, step.labelAlt]
672
+ : [step.nlHint, step.label, step.labelAlt];
673
+ for (const value of values) {
674
+ if (value?.trim()) return value.trim();
675
+ }
676
+ }
677
+ for (const key of ["nl_hint", "nlHint"] as const) {
678
+ const value = link.args[key];
679
+ if (typeof value === "string" && value.trim()) return value.trim();
680
+ }
681
+ return undefined;
682
+ }
683
+
684
+ function isViewListenerBinding(bindingApi: string): boolean {
685
+ return /^setOn[A-Za-z0-9_]*Listener$/u.test(bindingApi);
686
+ }
687
+
688
+ /**
689
+ * Some upstream UTG producers expose an exact Android control id even when
690
+ * source analysis cannot resolve the destination class expression. A unique
691
+ * same-Area id match is a deterministic join: bind that source Action to the
692
+ * frozen link so assembly does not also synthesize a topology-only Control.
693
+ * Labels are deliberately excluded from this relation.
694
+ */
695
+ export function bindExactUtgTriggerControls(
696
+ interactions: FinalizedInteractionAnalysis,
697
+ topology: ImportedUtgTopology
698
+ ): FinalizedInteractionAnalysis {
699
+ const nodeById = new Map(topology.nodes.map((node) => [node.id, node]));
700
+ const sourceActionByLink = exactSourceActionBindings(
701
+ interactions,
702
+ topology,
703
+ nodeById
704
+ );
705
+ return {
706
+ ...interactions,
707
+ controls: interactions.controls.map((controlPatch) => {
708
+ const identifiers = controlIdentifiers(controlPatch.control);
709
+ const actions = controlPatch.actions.map((action) => {
710
+ let effects: readonly InteractionEffectDraft[] = action.effects;
711
+ for (const expectedKind of ["navigate-area", "show-surface"] as const) {
712
+ const matchingLinks = topology.links.filter((link) => {
713
+ if (
714
+ link.transitionClass !== "user" ||
715
+ link.sourceAreaRef !== controlPatch.areaRef
716
+ ) return false;
717
+ const exactSourceAction = sourceActionByLink.get(link.id) ===
718
+ sourceBindingKey(controlPatch, action);
719
+ const exactControlId = action.trigger === actionForLink(link) &&
720
+ [...linkControlIdentifiers(link)].some((identifier) =>
721
+ identifiers.has(identifier)
722
+ );
723
+ return (exactSourceAction || exactControlId) &&
724
+ !effects.some((effect) => effect.utgEdgeRef === link.id) &&
725
+ (isSurface(nodeById.get(link.targetAreaRef))
726
+ ? "show-surface"
727
+ : "navigate-area") === expectedKind;
728
+ });
729
+ if (matchingLinks.length === 0) continue;
730
+ const resolvedLinkIds = new Set<string>();
731
+ const linksByResolvedEffect = new Map<
732
+ InteractionEffectDraft,
733
+ ImportedUtgLink[]
734
+ >();
735
+ for (const link of matchingLinks) {
736
+ const candidates = effects.filter((effect) =>
737
+ effect.kind === expectedKind && effect.utgEdgeRef === undefined &&
738
+ effect.target?.kind === "area" &&
739
+ effect.target.areaRef === link.targetAreaRef
740
+ );
741
+ if (candidates.length !== 1) continue;
742
+ const selected = candidates[0] as InteractionEffectDraft;
743
+ const links = linksByResolvedEffect.get(selected) ?? [];
744
+ links.push(link);
745
+ linksByResolvedEffect.set(selected, links);
746
+ resolvedLinkIds.add(link.id);
747
+ }
748
+ if (linksByResolvedEffect.size > 0) {
749
+ effects = effects.flatMap((effect) => {
750
+ const links = linksByResolvedEffect.get(effect);
751
+ return links
752
+ ? bindInteractionEffectToUtgLinks(effect, links, effect.evidence)
753
+ : [effect];
754
+ });
755
+ }
756
+ const remainingLinks = matchingLinks.filter((link) =>
757
+ !resolvedLinkIds.has(link.id)
758
+ );
759
+ if (remainingLinks.length === 0) continue;
760
+ const unresolvedCandidates = effects.filter((effect) =>
761
+ effect.kind === expectedKind && hasNoResolvedInteractionTarget(effect) &&
762
+ effect.utgEdgeRef === undefined
763
+ );
764
+ if (unresolvedCandidates.length !== 1) continue;
765
+ const selected = unresolvedCandidates[0] as InteractionEffectDraft;
766
+ const redundant = new Set(effects.flatMap((effect) =>
767
+ effect !== selected && hasNoResolvedInteractionTarget(effect) &&
768
+ effect.utgEdgeRef === undefined &&
769
+ (effect.kind === "navigate-area" || effect.kind === "show-surface") &&
770
+ sameEvidenceRange(effect, selected)
771
+ ? [effect.semanticKey]
772
+ : []
773
+ ));
774
+ const redundantEvidence = effects
775
+ .filter((effect) => redundant.has(effect.semanticKey))
776
+ .flatMap((effect) => effect.evidence);
777
+ const selectedEvidence = nonEmptySourceLocations([
778
+ ...selected.evidence,
779
+ ...redundantEvidence
780
+ ]);
781
+ effects = effects.flatMap((effect) => {
782
+ if (redundant.has(effect.semanticKey)) return [];
783
+ if (effect !== selected) return [effect];
784
+ return bindInteractionEffectToUtgLinks(
785
+ effect,
786
+ remainingLinks,
787
+ selectedEvidence
788
+ );
789
+ });
790
+ }
791
+ return {
792
+ ...action,
793
+ effects: effects as typeof action.effects
794
+ };
795
+ });
796
+ const sourceBoundLinks = topology.links.filter((link) =>
797
+ controlPatch.actions.some((action) =>
798
+ sourceActionByLink.get(link.id) === sourceBindingKey(controlPatch, action)
799
+ )
800
+ );
801
+ const sourceHints = unique(sourceBoundLinks.flatMap((link) => {
802
+ const hint = canonicalControlHint(link, topology);
803
+ return hint ? [hint] : [];
804
+ }));
805
+ const sourceHint = sourceHints.length === 1 ? sourceHints[0] : undefined;
806
+ const removeCallbackLiteral = sourceHint !== undefined &&
807
+ controlPatch.control.resourceId === undefined &&
808
+ controlPatch.actions.every((action) => isViewListenerBinding(action.bindingApi));
809
+ const control = sourceHint
810
+ ? {
811
+ ...controlPatch.control,
812
+ ...(removeCallbackLiteral ? { visibleText: undefined } : {}),
813
+ associatedLabel: sourceHint
814
+ }
815
+ : controlPatch.control;
816
+ return {
817
+ ...controlPatch,
818
+ control,
819
+ actions: [actions[0] as typeof actions[number], ...actions.slice(1)]
820
+ };
821
+ })
822
+ };
823
+ }
824
+
825
+ function actionForLink(link: ImportedUtgLink): RawFactDataByKind["interaction-binding"]["trigger"] {
826
+ const values = [link.args.action, link.args.gesture, link.trigger.split("@", 1)[0]];
827
+ for (const raw of values) {
828
+ if (typeof raw !== "string") continue;
829
+ const value = raw.toLocaleLowerCase("en-US").replaceAll("_", "-");
830
+ if (value === "double-tap" || value === "double-click") return "click";
831
+ if (value === "tap" || value === "onclick" || value === "click") return "click";
832
+ if (value === "longpress" || value === "long-click") return "long-press";
833
+ if (
834
+ value === "long-press" || value === "select" || value === "toggle" ||
835
+ value === "text-input" || value === "text-submit" || value === "back" ||
836
+ value === "swipe" || value === "drag"
837
+ ) return value;
838
+ }
839
+ return "click";
840
+ }
841
+
842
+ function controlName(link: ImportedUtgLink, topology: ImportedUtgTopology): string {
843
+ for (const path of topology.canonicalPaths) {
844
+ const step = path.steps.find((candidate) => candidate.linkRefs.includes(link.id));
845
+ // `code-name` is an upstream locator such as a widget or symbol name. It
846
+ // is useful evidence, but it is not proof of text visible to the user.
847
+ const pathLabels = step?.labelSource?.trim().toLocaleLowerCase("en-US") === "code-name"
848
+ ? [step.labelAlt, step.nlHint]
849
+ : [step?.label, step?.labelAlt, step?.nlHint];
850
+ for (const value of pathLabels) {
851
+ if (value?.trim()) return value.trim();
852
+ }
853
+ }
854
+ const widgetCodeName = Object.entries(link.args).some(([key, value]) =>
855
+ key.toLocaleLowerCase("en-US").replaceAll("_", "").replaceAll("-", "") ===
856
+ "labelkey" &&
857
+ typeof value === "string" && /^\s*widget:/iu.test(value)
858
+ );
859
+ const argumentKeys = widgetCodeName
860
+ ? ["label_alt", "labelAlt", "nl_hint", "nlHint", "text", "title"] as const
861
+ : [
862
+ "label",
863
+ "label_base",
864
+ "label_en",
865
+ "label_alt",
866
+ "labelAlt",
867
+ "nl_hint",
868
+ "nlHint",
869
+ "text",
870
+ "title"
871
+ ] as const;
872
+ for (const key of argumentKeys) {
873
+ const value = link.args[key];
874
+ if (typeof value === "string" && value.trim()) return value.trim();
875
+ }
876
+ const trigger = link.trigger.split("@", 1)[0]?.trim();
877
+ if (trigger) return trigger;
878
+ return `${link.mechanism}: ${link.targetAreaRef}`;
879
+ }
880
+
881
+ function isSurface(node: ImportedUtgNode | undefined): boolean {
882
+ return node !== undefined && /dialog|sheet|menu|popup|drawer|overlay/iu.test(node.kind);
883
+ }
884
+
885
+ function addGuardFact(
886
+ builder: SourceFactsBuilder,
887
+ link: ImportedUtgLink,
888
+ callbackFactRef: string,
889
+ linkIndex: number
890
+ ): string | undefined {
891
+ if (!link.guard) return undefined;
892
+ return builder.addFact("condition", {
893
+ identity: [
894
+ { kind: "component", value: link.sourceAreaRef },
895
+ { kind: "semantic-key", value: `utg-guard:${link.id}` }
896
+ ],
897
+ confidence: link.confidence < 0.7 ? "medium" : "high",
898
+ support: [{
899
+ location: utgEvidence(linkIndex, `link:${link.id}:guard`),
900
+ role: "frozen UTG transition guard"
901
+ }],
902
+ data: {
903
+ ownerKey: callbackFactRef,
904
+ expressionAnchor: link.guard.text,
905
+ plainLanguage: link.guard.text,
906
+ valueKind: /config|variant/iu.test(link.guard.kind)
907
+ ? "configuration"
908
+ : "runtime",
909
+ pathRequirement: "runtime-availability"
910
+ },
911
+ relatedFactRefs: [callbackFactRef]
912
+ });
913
+ }
914
+
915
+ function addTopologySeed(
916
+ builder: SourceFactsBuilder,
917
+ link: ImportedUtgLink,
918
+ linkIndex: number,
919
+ topology: ImportedUtgTopology,
920
+ facts: UtgFactIndex
921
+ ): TopologySeed {
922
+ const ownerRef = resolveRef(facts.componentFactByArea, link.sourceAreaRef);
923
+ const targetRef = resolveRef(facts.componentFactByArea, link.targetAreaRef);
924
+ const location = utgEvidence(linkIndex, `link:${link.id}`);
925
+ const uiRef = builder.addFact("ui-element", {
926
+ identity: [
927
+ { kind: "component", value: link.sourceAreaRef },
928
+ { kind: "control", value: `utg:${link.id}` }
929
+ ],
930
+ confidence: link.confidence < 0.7 ? "medium" : "high",
931
+ support: [{ location, role: "frozen UTG transition control" }],
932
+ data: {
933
+ ownerKey: ownerRef,
934
+ elementType: link.transitionClass === "user" ? "utg-control" : "utg-transition",
935
+ actionable: true,
936
+ associatedLabel: controlName(link, topology),
937
+ dynamicIdentity: link.id
938
+ },
939
+ relatedFactRefs: [ownerRef]
940
+ });
941
+ const callbackRef = builder.addFact("callback", {
942
+ identity: [
943
+ { kind: "component", value: link.sourceAreaRef },
944
+ { kind: "callback", value: `utg:${link.id}` }
945
+ ],
946
+ confidence: link.confidence < 0.7 ? "medium" : "high",
947
+ support: [{ location, role: "frozen UTG transition callback" }],
948
+ data: {
949
+ ownerKey: ownerRef,
950
+ callableSymbol: `utg:${link.mechanism}:${link.id}`,
951
+ callbackKind: "function"
952
+ },
953
+ relatedFactRefs: [ownerRef]
954
+ });
955
+ const bindingRef = builder.addFact("interaction-binding", {
956
+ identity: [
957
+ { kind: "control", value: `utg:${link.id}` },
958
+ { kind: "callback", value: `utg:${link.id}` }
959
+ ],
960
+ confidence: link.confidence < 0.7 ? "medium" : "high",
961
+ support: [{ location, role: "frozen UTG transition binding" }],
962
+ data: {
963
+ elementKey: uiRef,
964
+ callbackKey: callbackRef,
965
+ trigger: actionForLink(link),
966
+ bindingApi: `utg:${link.mechanism}`
967
+ },
968
+ relatedFactRefs: [uiRef, callbackRef]
969
+ });
970
+ const guardRef = addGuardFact(builder, link, callbackRef, linkIndex);
971
+ const targetNode = topology.nodes.find((node) => node.id === link.targetAreaRef);
972
+ const effectRef = builder.addFact("behavior-effect", {
973
+ identity: [
974
+ { kind: "callback", value: `utg:${link.id}` },
975
+ { kind: "semantic-key", value: `transition:${link.id}` }
976
+ ],
977
+ confidence: link.confidence < 0.7 ? "medium" : "high",
978
+ support: [{ location, role: "frozen UTG transition effect" }],
979
+ data: {
980
+ callbackKey: callbackRef,
981
+ effectKind: isSurface(targetNode) ? "show-surface" : "navigate-area",
982
+ targetKey: targetRef,
983
+ transitionMode: link.transitionClass === "user" ? "user" : "startup-auto",
984
+ conditionKeys: guardRef ? [guardRef] : []
985
+ },
986
+ relatedFactRefs: [callbackRef, targetRef, ...(guardRef ? [guardRef] : [])]
987
+ });
988
+ builder.addFact("navigation-target", {
989
+ identity: [
990
+ { kind: "semantic-key", value: `transition:${link.id}` },
991
+ { kind: "component", value: link.targetAreaRef }
992
+ ],
993
+ confidence: link.confidence < 0.7 ? "medium" : "high",
994
+ support: [{ location, role: "frozen UTG transition target" }],
995
+ data: {
996
+ effectKey: effectRef,
997
+ targetKind: "component",
998
+ targetKey: targetRef
999
+ },
1000
+ relatedFactRefs: [effectRef, targetRef]
1001
+ });
1002
+ void bindingRef;
1003
+ return { link, callbackFactRef: callbackRef, effectFactRef: effectRef };
1004
+ }
1005
+
1006
+ function addCoveredLinkGuards(
1007
+ builder: SourceFactsBuilder,
1008
+ topology: ImportedUtgTopology,
1009
+ effectsByLink: ReadonlyMap<string, readonly SourceInteractionEffect[]>
1010
+ ): void {
1011
+ topology.links.forEach((link, index) => {
1012
+ const covered = effectsByLink.get(link.id) ?? [];
1013
+ if (covered.length === 0 || !link.guard) return;
1014
+ const guardRef = addGuardFact(
1015
+ builder,
1016
+ link,
1017
+ covered[0].callbackFactRef,
1018
+ index
1019
+ );
1020
+ if (!guardRef) return;
1021
+ for (const item of covered) {
1022
+ const fact = builder.fact(item.effectFactRef);
1023
+ if (fact?.kind !== "behavior-effect") {
1024
+ throw new Error(`Missing source behavior effect ${item.effectFactRef}`);
1025
+ }
1026
+ builder.mergeFactData("behavior-effect", item.effectFactRef, {
1027
+ conditionKeys: unique([...(fact.data.conditionKeys ?? []), guardRef])
1028
+ });
1029
+ }
1030
+ });
1031
+ }
1032
+
1033
+ function navigationEvidence(link: ImportedUtgLink): NavigationEvidence {
1034
+ return {
1035
+ source: "utg",
1036
+ utgEdgeId: link.id,
1037
+ mechanism: link.mechanism,
1038
+ trigger: link.trigger,
1039
+ ...(link.guard ? { guard: link.guard } : {}),
1040
+ confidence: link.confidence
1041
+ };
1042
+ }
1043
+
1044
+ function upstreamNonGestureAction(
1045
+ topology: ImportedUtgTopology,
1046
+ link: ImportedUtgLink
1047
+ ): string | undefined {
1048
+ for (const path of topology.canonicalPaths) {
1049
+ const step = path.steps.find((candidate) =>
1050
+ candidate.linkRefs.includes(link.id) && candidate.nonGesture === true
1051
+ );
1052
+ if (step) return step.action;
1053
+ }
1054
+ return link.transitionClass === "user"
1055
+ ? undefined
1056
+ : typeof link.args.action === "string"
1057
+ ? link.args.action
1058
+ : undefined;
1059
+ }
1060
+
1061
+ /**
1062
+ * The limitations that still leave the Model incomplete.
1063
+ *
1064
+ * `INTERACTION_CROSS_AREA_DUPLICATE_ANCHOR` records a decision the pipeline
1065
+ * already made: one Area keeps the end-to-end Feature for a project-global
1066
+ * anchor and every non-owner copy is excluded from the ReqModel. It is worth
1067
+ * reporting — it says where a control was described twice — but nothing is left
1068
+ * open for a caller to resolve, so it cannot be the reason a run whose every
1069
+ * Area was reviewed is refused by Render and the SPEC publication. An
1070
+ * UNRESOLVED duplicate (`INTERACTION_CROSS_AREA_DUPLICATE_UNRESOLVED`, no
1071
+ * dialog/transient owner to break the tie, both copies retained) IS open.
1072
+ */
1073
+ export function openSemanticLimitations(
1074
+ limitations: readonly SemanticLimitation[]
1075
+ ): readonly SemanticLimitation[] {
1076
+ return limitations.filter((item) =>
1077
+ item.code !== "INTERACTION_CROSS_AREA_DUPLICATE_ANCHOR"
1078
+ );
1079
+ }
1080
+
1081
+ function semanticLimitations(
1082
+ caseId: string,
1083
+ interactions: FinalizedInteractionAnalysis,
1084
+ pathGapAreaRefs: readonly string[]
1085
+ ): SemanticLimitation[] { const result: SemanticLimitation[] = [];
1086
+ const add = (
1087
+ code: string,
1088
+ message: string,
1089
+ critical: boolean,
1090
+ candidateRefs: readonly string[]
1091
+ ) => result.push({
1092
+ id: stableId(caseId, "limitation", code, candidateRefs.join("|") || code),
1093
+ code,
1094
+ message,
1095
+ critical,
1096
+ candidateRefs: unique(candidateRefs),
1097
+ supportRefs: []
1098
+ });
1099
+ if (interactions.failedShardIds.length > 0) {
1100
+ add(
1101
+ "INTERACTION_SHARD_FAILED",
1102
+ `${interactions.failedShardIds.length} interaction shard(s) failed; successful shards were retained.`,
1103
+ false,
1104
+ interactions.failedShardIds
1105
+ );
1106
+ }
1107
+ if (interactions.unresolved.length > 0) {
1108
+ add(
1109
+ "INTERACTION_CANDIDATE_UNRESOLVED",
1110
+ `${interactions.unresolved.length} interaction candidate(s) remain unresolved.`,
1111
+ false,
1112
+ interactions.unresolved.map((item) => item.candidateKey)
1113
+ );
1114
+ }
1115
+ if (interactions.incompleteAreaRefs.length > 0) {
1116
+ add(
1117
+ "INTERACTION_AREA_INCOMPLETE",
1118
+ `${interactions.incompleteAreaRefs.length} frozen UTG Area(s) have incomplete interaction coverage.`,
1119
+ false,
1120
+ interactions.incompleteAreaRefs
1121
+ );
1122
+ }
1123
+ const unknownEffects = interactions.controls.flatMap((control) =>
1124
+ control.actions.flatMap((action) =>
1125
+ action.effects.flatMap((effect) => effect.kind === "unknown"
1126
+ ? [{ effect, candidateRefs: action.candidateRefs }]
1127
+ : [])
1128
+ )
1129
+ );
1130
+ if (unknownEffects.length > 0) {
1131
+ add(
1132
+ "INTERACTION_EFFECT_UNRESOLVED",
1133
+ `${unknownEffects.length} retained interaction effect(s) have an unknown semantic result.`,
1134
+ false,
1135
+ unknownEffects.flatMap((item) => item.candidateRefs)
1136
+ );
1137
+ }
1138
+ if (interactions.utgNavConflicts > 0) {
1139
+ add(
1140
+ "UTG_NAV_CONFLICT",
1141
+ `${interactions.utgNavConflicts} source-backed navigation interaction(s) have no matching frozen UTG link; their existing-Area target is retained as a semantic Edge, while canonical breadcrumbs remain unchanged.`,
1142
+ false,
1143
+ interactions.diagnostics.flatMap((item) =>
1144
+ item.code === "UTG_NAV_CONFLICT" && item.candidateKey ? [item.candidateKey] : []
1145
+ )
1146
+ );
1147
+ }
1148
+ const duplicateAnchorDiagnostics = interactions.diagnostics.filter((item) =>
1149
+ item.code === "CROSS_AREA_DUPLICATE_ANCHOR" && item.suggestedOwnerAreaRef !== undefined
1150
+ );
1151
+ if (duplicateAnchorDiagnostics.length > 0) {
1152
+ const demotedCount = interactions.excludedDuplicateControls.length;
1153
+ add(
1154
+ "INTERACTION_CROSS_AREA_DUPLICATE_ANCHOR",
1155
+ `${crossAreaAffectedControlCount(duplicateAnchorDiagnostics)} Control(s) claimed the same project-global identity anchor as a Control in another Area; ${demotedCount} non-owner copy/copies were excluded from the ReqModel automatically (the dialog/transient owner Area retains the end-to-end Feature).`,
1156
+ false,
1157
+ involvedCandidateRefs(interactions, duplicateAnchorDiagnostics)
1158
+ );
1159
+ }
1160
+ const unresolvedDuplicateDiagnostics = interactions.diagnostics.filter((item) =>
1161
+ item.code === "CROSS_AREA_DUPLICATE_ANCHOR" && item.suggestedOwnerAreaRef === undefined
1162
+ );
1163
+ if (unresolvedDuplicateDiagnostics.length > 0) {
1164
+ // Ambiguous members (no dialog/transient owner to break the tie): nothing
1165
+ // was demoted, both copies are retained. That is an OPEN gap — reporting it
1166
+ // as decided would let a two-Features-for-one-control run through as
1167
+ // `complete`.
1168
+ add(
1169
+ "INTERACTION_CROSS_AREA_DUPLICATE_UNRESOLVED",
1170
+ `${crossAreaAffectedControlCount(unresolvedDuplicateDiagnostics)} Control(s) claimed the same project-global identity anchor as a Control in another Area with no dialog/transient owner to break the tie; both copies are retained. Decide the owning Area (or exclude one deliberately) and re-run the affected Areas.`,
1171
+ false,
1172
+ involvedCandidateRefs(interactions, unresolvedDuplicateDiagnostics)
1173
+ );
1174
+ }
1175
+ const anchorCollisionDiagnostics = interactions.diagnostics.filter((item) =>
1176
+ item.code === "CROSS_AREA_ANCHOR_COLLISION"
1177
+ );
1178
+ if (anchorCollisionDiagnostics.length > 0) {
1179
+ add(
1180
+ "INTERACTION_CROSS_AREA_ANCHOR_COLLISION",
1181
+ `${crossAreaAffectedControlCount(anchorCollisionDiagnostics)} retained Control(s) share an instance-scoped identity anchor with a Control in another Area; confirm whether they are distinct instances of a shared layout before treating them as duplicates.`,
1182
+ false,
1183
+ involvedCandidateRefs(interactions, anchorCollisionDiagnostics)
1184
+ );
1185
+ }
1186
+ if (pathGapAreaRefs.length > 0) {
1187
+ add(
1188
+ "UTG_BREADCRUMB_UNAVAILABLE",
1189
+ `${pathGapAreaRefs.length} UTG Area(s) have no compilable upstream breadcrumb.`,
1190
+ false,
1191
+ pathGapAreaRefs
1192
+ );
1193
+ }
1194
+ return result.sort(compareId);
1195
+ }
1196
+
1197
+ function crossAreaAffectedControlCount(
1198
+ diagnostics: readonly InteractionFinalizeDiagnostic[]
1199
+ ): number {
1200
+ return new Set(
1201
+ diagnostics
1202
+ .map((item) => item.controlRef)
1203
+ .filter((controlRef): controlRef is string => Boolean(controlRef))
1204
+ ).size;
1205
+ }
1206
+
1207
+ function involvedCandidateRefs(
1208
+ interactions: FinalizedInteractionAnalysis,
1209
+ diagnostics: readonly InteractionFinalizeDiagnostic[]
1210
+ ): readonly string[] {
1211
+ const demotedByControlRef = new Map(
1212
+ interactions.excludedDuplicateControls.map((item) => [item.controlRef, item])
1213
+ );
1214
+ return diagnostics.flatMap((item) => {
1215
+ if (!item.controlRef) return [];
1216
+ const control = interactions.controls.find((candidate) =>
1217
+ candidate.areaRef === item.areaRef &&
1218
+ candidate.control.semanticKey === item.controlRef
1219
+ );
1220
+ if (control) return control.actions.flatMap((action) => action.candidateRefs);
1221
+ // The Control was demoted as a duplicate; fall back to its audit record.
1222
+ return demotedByControlRef.get(item.controlRef)?.candidateKeys ?? [];
1223
+ });
1224
+ }
1225
+
1226
+ function exactAreaMapping(
1227
+ base: AreaGraphView,
1228
+ topology: ImportedUtgTopology,
1229
+ facts: UtgFactIndex
1230
+ ): ReadonlyMap<string, string> {
1231
+ const result = new Map<string, string>();
1232
+ for (const node of topology.nodes) {
1233
+ const componentRef = resolveRef(facts.componentFactByArea, node.id);
1234
+ const matches = base.areas.filter((area) => area.sourceFactRefs.includes(componentRef));
1235
+ if (matches.length !== 1) {
1236
+ throw new Error(
1237
+ `Frozen UTG node ${node.id} maps to ${matches.length} Areas instead of exactly one`
1238
+ );
1239
+ }
1240
+ result.set(node.id, matches[0].id);
1241
+ }
1242
+ if (new Set(result.values()).size !== topology.nodes.length ||
1243
+ base.areas.length !== topology.nodes.length) {
1244
+ throw new Error(
1245
+ `UTG Area conservation failed: nodes=${topology.nodes.length}, areas=${base.areas.length}`
1246
+ );
1247
+ }
1248
+ return result;
1249
+ }
1250
+
1251
+ function effectForFact(graph: AreaGraphView, factRef: string): Effect {
1252
+ const matches = graph.effects.filter((effect) => effect.sourceFactRefs.includes(factRef));
1253
+ if (matches.length !== 1) {
1254
+ throw new Error(`Source effect ${factRef} maps to ${matches.length} graph Effects`);
1255
+ }
1256
+ return matches[0];
1257
+ }
1258
+
1259
+ function synthesizedEdge(
1260
+ caseId: string,
1261
+ link: ImportedUtgLink,
1262
+ effect: Effect,
1263
+ graph: AreaGraphView,
1264
+ areaRefByUtg: ReadonlyMap<string, string>
1265
+ ): Edge {
1266
+ const action = graph.actions.find((item) => item.id === effect.actionRef);
1267
+ const control = action
1268
+ ? graph.controls.find((item) => item.id === action.controlRef)
1269
+ : undefined;
1270
+ if (!action || !control) {
1271
+ throw new Error(`Cannot materialize UTG link ${link.id}: missing action/control`);
1272
+ }
1273
+ const sourceAreaRef = resolveRef(areaRefByUtg, link.sourceAreaRef);
1274
+ const targetAreaRef = resolveRef(areaRefByUtg, link.targetAreaRef);
1275
+ if (control.areaRef !== sourceAreaRef) {
1276
+ throw new Error(`UTG link ${link.id} source does not match its semantic Control`);
1277
+ }
1278
+ return {
1279
+ id: stableId(caseId, "edge", "utg", `${link.id}:${action.id}`),
1280
+ sourceAreaRef,
1281
+ controlRef: control.id,
1282
+ actionRef: action.id,
1283
+ target: { kind: "area", ref: targetAreaRef },
1284
+ conditions: unique(effect.conditionAlternatives?.flatMap((item) => item.conditionRefs) ?? []),
1285
+ preconditions: action.preconditionRefs,
1286
+ sourceFactRefs: unique(effect.sourceFactRefs),
1287
+ navigationEvidence: [navigationEvidence(link)]
1288
+ };
1289
+ }
1290
+
1291
+ function entryPoints(
1292
+ caseId: string,
1293
+ topology: ImportedUtgTopology,
1294
+ areaRefByUtg: ReadonlyMap<string, string>,
1295
+ facts: UtgFactIndex,
1296
+ source: SourceFactsArtifact
1297
+ ): readonly EntryPoint[] {
1298
+ return topology.entryRootAreaRefs.map((root): EntryPoint => {
1299
+ const componentRef = resolveRef(facts.componentFactByArea, root);
1300
+ const entryFact = source.facts.find((fact) =>
1301
+ fact.kind === "entry-point" && fact.data.componentKey === componentRef
1302
+ );
1303
+ if (!entryFact) throw new Error(`Missing entry SourceFact for ${root}`);
1304
+ return {
1305
+ id: stableId(caseId, "entry", "utg", root),
1306
+ kind: "launcher",
1307
+ category: root === topology.rootAreaRef ? "normal" : "alternate",
1308
+ rootAreaRefs: [resolveRef(areaRefByUtg, root)],
1309
+ conditions: [],
1310
+ preconditions: [],
1311
+ startupRole: "default",
1312
+ sourceFactRefs: [entryFact.id]
1313
+ };
1314
+ }).sort(compareId);
1315
+ }
1316
+
1317
+ interface CompiledPaths {
1318
+ readonly paths: readonly AreaPath[];
1319
+ readonly canonicalPathByArea: ReadonlyMap<string, string>;
1320
+ readonly unresolved: readonly UnresolvedItem[];
1321
+ readonly gapAreaRefs: readonly string[];
1322
+ }
1323
+
1324
+ function compilePaths(
1325
+ caseId: string,
1326
+ topology: ImportedUtgTopology,
1327
+ areaRefByUtg: ReadonlyMap<string, string>,
1328
+ entryByUtg: ReadonlyMap<string, string>,
1329
+ edgeByUtgLink: ReadonlyMap<string, Edge>
1330
+ ): CompiledPaths {
1331
+ const paths: AreaPath[] = [];
1332
+ const canonicalPathByArea = new Map<string, string>();
1333
+ const unresolved: UnresolvedItem[] = [];
1334
+ const gapAreaRefs = new Set<string>();
1335
+ const importedByTarget = new Map(
1336
+ topology.canonicalPaths.map((path) => [path.targetAreaRef, path])
1337
+ );
1338
+ const unreachable = new Set(topology.unreachableAreaRefs);
1339
+
1340
+ const markGap = (node: ImportedUtgNode, reason: string): void => {
1341
+ const areaRef = resolveRef(areaRefByUtg, node.id);
1342
+ const id = stableId(caseId, "unresolved", "utg-path", node.id);
1343
+ unresolved.push({
1344
+ id,
1345
+ ownerRef: areaRef,
1346
+ fieldPath: "canonicalPathRef",
1347
+ reasonCode: node.status === "dynamic-only"
1348
+ ? "UTG_DYNAMIC_BREADCRUMB_UNAVAILABLE"
1349
+ : "UTG_BREADCRUMB_UNAVAILABLE",
1350
+ message: reason,
1351
+ evidenceRefs: [],
1352
+ candidates: [],
1353
+ impact: ["area-path"]
1354
+ });
1355
+ gapAreaRefs.add(node.id);
1356
+ };
1357
+
1358
+ for (const node of topology.nodes) {
1359
+ const targetAreaRef = resolveRef(areaRefByUtg, node.id);
1360
+ if (unreachable.has(node.id)) {
1361
+ const id = stableId(caseId, "path", "utg-unreachable", node.id);
1362
+ paths.push({
1363
+ id,
1364
+ kind: "unreachable",
1365
+ reachability: "unreachable",
1366
+ targetAreaRef,
1367
+ preconditions: [],
1368
+ steps: [],
1369
+ selectionReasons: ["classified unreachable by upstream UTG click_paths.json"],
1370
+ unresolvedRefs: []
1371
+ });
1372
+ canonicalPathByArea.set(targetAreaRef, id);
1373
+ continue;
1374
+ }
1375
+ const imported = importedByTarget.get(node.id);
1376
+ if (!imported) {
1377
+ markGap(
1378
+ node,
1379
+ node.status === "dynamic-only"
1380
+ ? "The reconciled dynamic-only UTG Area has no static breadcrumb."
1381
+ : "The upstream UTG did not provide a canonical breadcrumb for this Area."
1382
+ );
1383
+ continue;
1384
+ }
1385
+ const launch = imported.steps[0];
1386
+ const root = imported.entryRootAreaRef ?? launch?.targetAreaRef ?? topology.rootAreaRef;
1387
+ const rootEntryRef = entryByUtg.get(root);
1388
+ if (!rootEntryRef) {
1389
+ markGap(node, `The upstream path uses unknown entry root ${root}.`);
1390
+ continue;
1391
+ }
1392
+ const selected: Edge[] = [];
1393
+ let failedReason: string | undefined;
1394
+ for (const [index, step] of imported.steps.entries()) {
1395
+ if (index === 0 && step.action === "launch") continue;
1396
+ const compatible = step.linkRefs.flatMap((ref) => {
1397
+ const edge = edgeByUtgLink.get(ref);
1398
+ return edge ? [{ ref, edge }] : [];
1399
+ }).sort((left, right) => left.ref.localeCompare(right.ref, "en"));
1400
+ const chosen = compatible[0];
1401
+ if (!chosen) {
1402
+ failedReason =
1403
+ `The upstream breadcrumb step ${index} (${step.sourceAreaRef ?? "?"} -> ${step.targetAreaRef}) has no frozen UTG Edge.`;
1404
+ break;
1405
+ }
1406
+ selected.push(chosen.edge);
1407
+ }
1408
+ if (failedReason) {
1409
+ markGap(node, failedReason);
1410
+ continue;
1411
+ }
1412
+ const preconditions = unique(selected.flatMap((edge) => [
1413
+ ...edge.conditions,
1414
+ ...edge.preconditions
1415
+ ]));
1416
+ const id = stableId(
1417
+ caseId,
1418
+ "path",
1419
+ "utg-canonical",
1420
+ `${node.id}:${selected.map((edge) => edge.id).join("|")}`
1421
+ );
1422
+ const containsNonGesture = imported.steps.some((step) => step.nonGesture === true);
1423
+ paths.push({
1424
+ id,
1425
+ kind: "canonical",
1426
+ reachability: preconditions.length > 0 ? "conditional" : "unconditional",
1427
+ targetAreaRef,
1428
+ rootEntryRef,
1429
+ preconditions,
1430
+ steps: selected.map((edge) => {
1431
+ if ("status" in edge.target || edge.target.kind !== "area") {
1432
+ throw new Error(`Canonical UTG Edge ${edge.id} is not an internal Area transition`);
1433
+ }
1434
+ return {
1435
+ edgeRef: edge.id,
1436
+ sourceAreaRef: edge.sourceAreaRef,
1437
+ controlRef: edge.controlRef,
1438
+ actionRef: edge.actionRef,
1439
+ targetAreaRef: edge.target.ref
1440
+ };
1441
+ }),
1442
+ selectionReasons: unique([
1443
+ "copied from upstream UTG click_paths.json",
1444
+ imported.pathText,
1445
+ ...(containsNonGesture ? ["contains an upstream non-gesture transition"] : [])
1446
+ ]),
1447
+ unresolvedRefs: []
1448
+ });
1449
+ canonicalPathByArea.set(targetAreaRef, id);
1450
+ }
1451
+ return {
1452
+ paths: paths.sort(compareId),
1453
+ canonicalPathByArea,
1454
+ unresolved: unresolved.sort(compareId),
1455
+ gapAreaRefs: [...gapAreaRefs].sort()
1456
+ };
1457
+ }
1458
+
1459
+ function filterTopologyOnlyFeatures(
1460
+ req: ReqModelArtifact,
1461
+ graph: AreaGraphView
1462
+ ): ReqModelArtifact {
1463
+ const effectById = new Map(graph.effects.map((effect) => [effect.id, effect]));
1464
+ const hiddenActions = new Set(graph.actions
1465
+ .filter((action) => !isReqProjectedAction(action, effectById))
1466
+ .map((action) => action.id));
1467
+ const filterFeature = (feature: ReqFeature): ReqFeature | undefined => {
1468
+ const interactions = feature.interactions?.filter((item) =>
1469
+ !hiddenActions.has(item.actionRef)
1470
+ );
1471
+ if (!interactions || interactions.length === 0) return undefined;
1472
+ const first = interactions[0];
1473
+ return {
1474
+ ...feature,
1475
+ interactions,
1476
+ trigger: first.trigger,
1477
+ conditions: first.conditions,
1478
+ effects: first.effects,
1479
+ ...(first.target ? { target: first.target } : { target: undefined })
1480
+ };
1481
+ };
1482
+ return {
1483
+ ...req,
1484
+ areas: req.areas.map((area) => ({
1485
+ ...area,
1486
+ features: area.features.flatMap((feature) => {
1487
+ const filtered = filterFeature(feature);
1488
+ return filtered ? [filtered] : [];
1489
+ })
1490
+ }))
1491
+ };
1492
+ }
1493
+
1494
+ function category(
1495
+ id: GapAuditCategory["id"],
1496
+ label: string,
1497
+ candidates: readonly GapAuditCandidate[],
1498
+ expectedFactKinds: GapAuditCategory["expectedFactKinds"]
1499
+ ): GapAuditCategory {
1500
+ const recognized = candidates.filter((item) => item.status === "recognized").length;
1501
+ const unresolved = candidates.filter((item) => item.status === "unresolved").length;
1502
+ const excludedWithReason = candidates.filter(
1503
+ (item) => item.status === "excluded-with-reason"
1504
+ ).length;
1505
+ const limited = candidates.filter((item) => item.status === "limited").length;
1506
+ return {
1507
+ id,
1508
+ label,
1509
+ assessment: unresolved > 0 ? "partially-assessed" : "assessed",
1510
+ observed: candidates.length,
1511
+ normalized: recognized,
1512
+ possibleGap: unresolved,
1513
+ unassessed: 0,
1514
+ recognized,
1515
+ unresolved,
1516
+ excludedWithReason,
1517
+ limited,
1518
+ expectedFactKinds,
1519
+ candidates
1520
+ };
1521
+ }
1522
+
1523
+ function buildGapAudit(
1524
+ input: AssembleModelInput,
1525
+ source: SourceFactsArtifact,
1526
+ graph: AreaGraphView,
1527
+ effects: readonly SourceInteractionEffect[],
1528
+ limitations: readonly SemanticLimitation[],
1529
+ pathGapAreaRefs: readonly string[]
1530
+ ): GapAuditArtifact {
1531
+ const { topology } = input.utg;
1532
+ const areaByAnchor = new Map(graph.areas.flatMap((area) =>
1533
+ (area.navigationAnchors ?? []).map((anchor) => [anchor, area] as const)
1534
+ ));
1535
+ const edgeByLink = new Map<string, Edge[]>();
1536
+ for (const edge of graph.edges) {
1537
+ for (const evidence of edge.navigationEvidence ?? []) {
1538
+ const values = edgeByLink.get(evidence.utgEdgeId) ?? [];
1539
+ values.push(edge);
1540
+ edgeByLink.set(evidence.utgEdgeId, values);
1541
+ }
1542
+ }
1543
+ const componentByArea = new Map(topology.nodes.map((node) => {
1544
+ const area = areaByAnchor.get(node.id);
1545
+ const component = area?.sourceFactRefs.find((ref) =>
1546
+ source.facts.some((fact) => fact.id === ref && fact.kind === "component")
1547
+ );
1548
+ return [node.id, component] as const;
1549
+ }));
1550
+ const areaCandidates: GapAuditCandidate[] = topology.nodes.map((node) => ({
1551
+ id: `utg-area:${node.id}`,
1552
+ category: "utg-areas",
1553
+ source: "utg",
1554
+ semanticKey: node.id,
1555
+ rawRecordRef: node.id,
1556
+ expectedFactKinds: ["component"],
1557
+ normalizedFactRefs: unique([
1558
+ ...(componentByArea.get(node.id) ? [componentByArea.get(node.id) as string] : []),
1559
+ ...(areaByAnchor.get(node.id) ? [areaByAnchor.get(node.id)!.id] : [])
1560
+ ]),
1561
+ status: "recognized",
1562
+ critical: true,
1563
+ outcome: "normalized"
1564
+ }));
1565
+ const linkCandidates: GapAuditCandidate[] = topology.links.map((link) => ({
1566
+ id: `utg-link:${link.id}`,
1567
+ category: "utg-links",
1568
+ source: "utg",
1569
+ semanticKey: link.id,
1570
+ rawRecordRef: link.id,
1571
+ expectedFactKinds: ["behavior-effect", "navigation-target"],
1572
+ normalizedFactRefs: unique((edgeByLink.get(link.id) ?? []).flatMap((edge) => [
1573
+ edge.id,
1574
+ ...edge.sourceFactRefs
1575
+ ])),
1576
+ status: "recognized",
1577
+ critical: true,
1578
+ outcome: "normalized"
1579
+ }));
1580
+
1581
+ const retainedCandidateRefs = unique(input.interactions.controls.flatMap((control) =>
1582
+ control.actions.flatMap((action) => action.candidateRefs)
1583
+ ));
1584
+ const unresolvedByKey = new Map(
1585
+ input.interactions.unresolved.map((item) => [item.candidateKey, item])
1586
+ );
1587
+ const discoveryRefs = retainedCandidateRefs.filter((ref) =>
1588
+ ref.startsWith("agent-discovery:")
1589
+ );
1590
+ const originalRetained = retainedCandidateRefs.filter((ref) =>
1591
+ !ref.startsWith("agent-discovery:")
1592
+ );
1593
+ const interactionCandidates: GapAuditCandidate[] = [
1594
+ ...originalRetained.map((ref): GapAuditCandidate => ({
1595
+ id: `interaction:${ref}`,
1596
+ category: "interaction-candidates",
1597
+ source: "tree-sitter",
1598
+ semanticKey: ref,
1599
+ expectedFactKinds: ["ui-element", "callback", "interaction-binding", "behavior-effect"],
1600
+ normalizedFactRefs: unique(effects.flatMap((item) =>
1601
+ item.effectFactRef.includes(ref) ? [item.effectFactRef] : []
1602
+ )),
1603
+ status: "recognized",
1604
+ critical: true,
1605
+ outcome: "normalized"
1606
+ })),
1607
+ ...input.interactions.unresolved
1608
+ .filter((item) => !originalRetained.includes(item.candidateKey))
1609
+ .map((item): GapAuditCandidate => ({
1610
+ id: `interaction:${item.candidateKey}`,
1611
+ category: "interaction-candidates",
1612
+ source: "agent",
1613
+ semanticKey: item.candidateKey,
1614
+ expectedFactKinds: ["ui-element", "callback", "interaction-binding", "behavior-effect"],
1615
+ normalizedFactRefs: [],
1616
+ status: "unresolved",
1617
+ critical: true,
1618
+ reason: item.message,
1619
+ outcome: "possible-gap"
1620
+ }))
1621
+ ];
1622
+ for (const candidateKey of input.interactions.scopeExcludedCandidateKeys ?? []) {
1623
+ interactionCandidates.push({
1624
+ id: `interaction:${candidateKey}`,
1625
+ category: "interaction-candidates",
1626
+ source: "agent",
1627
+ semanticKey: candidateKey,
1628
+ expectedFactKinds: ["ui-element", "interaction-binding", "behavior-effect"],
1629
+ normalizedFactRefs: [],
1630
+ status: "excluded-with-reason",
1631
+ critical: false,
1632
+ reason: "scope-excluded: not generated in this run; not a claim that the source behavior is absent.",
1633
+ outcome: "normalized"
1634
+ });
1635
+ }
1636
+ const originalCount = interactionCandidates.length;
1637
+ const missingOriginal = Math.max(
1638
+ 0,
1639
+ input.interactions.conservation.candidateTotal - originalCount
1640
+ );
1641
+ const demotedDuplicateCount =
1642
+ input.interactions.conservation.demotedDuplicate ?? 0;
1643
+ for (let index = 0; index < missingOriginal; index += 1) {
1644
+ const demoted = index < demotedDuplicateCount;
1645
+ const excluded = !demoted && index < demotedDuplicateCount + input.interactions.conservation.excluded;
1646
+ interactionCandidates.push({
1647
+ id: `interaction:conservation-slot:${index + 1}`,
1648
+ category: "interaction-candidates",
1649
+ source: "agent",
1650
+ semanticKey: `conservation-slot:${index + 1}`,
1651
+ expectedFactKinds: ["ui-element", "callback", "interaction-binding", "behavior-effect"],
1652
+ normalizedFactRefs: [],
1653
+ status: demoted || excluded ? "excluded-with-reason" : "limited",
1654
+ critical: !(demoted || excluded),
1655
+ reason: demoted
1656
+ ? "Demoted as a cross-Area duplicate anchor; the suggested-owner Area retains the end-to-end Feature."
1657
+ : excluded
1658
+ ? "Agent deliberately excluded the candidate; the finalizer retains only the conservation count."
1659
+ : "The finalizer retains this disposition in aggregate conservation counts.",
1660
+ outcome: "normalized"
1661
+ });
1662
+ }
1663
+ for (const ref of discoveryRefs) {
1664
+ interactionCandidates.push({
1665
+ id: `interaction:${ref}`,
1666
+ category: "interaction-candidates",
1667
+ source: "agent",
1668
+ semanticKey: ref,
1669
+ expectedFactKinds: ["ui-element", "callback", "interaction-binding", "behavior-effect"],
1670
+ normalizedFactRefs: [],
1671
+ status: "recognized",
1672
+ critical: true,
1673
+ outcome: "normalized"
1674
+ });
1675
+ }
1676
+ void unresolvedByKey;
1677
+ const incomplete = new Set(input.interactions.incompleteAreaRefs);
1678
+ const pathGaps = new Set(pathGapAreaRefs);
1679
+ const coverageCandidates: GapAuditCandidate[] = topology.nodes.map((node) => {
1680
+ const scopeExcluded = input.interactions.scopeExcludedAreaRefs?.includes(node.id) ?? false;
1681
+ const interactionIncomplete = incomplete.has(node.id);
1682
+ const pathLimited = pathGaps.has(node.id);
1683
+ return {
1684
+ id: `interaction-area:${node.id}`,
1685
+ category: "interaction-area-coverage",
1686
+ source: "agent",
1687
+ semanticKey: node.id,
1688
+ expectedFactKinds: ["ui-element", "interaction-binding", "behavior-effect"],
1689
+ normalizedFactRefs: areaByAnchor.get(node.id)?.controlRefs ?? [],
1690
+ status: scopeExcluded ? "excluded-with-reason" : interactionIncomplete ? "unresolved" : pathLimited ? "limited" : "recognized",
1691
+ critical: interactionIncomplete,
1692
+ ...(scopeExcluded
1693
+ ? { reason: "scope-excluded: this frozen UTG Area was not selected for deep analysis." }
1694
+ : interactionIncomplete
1695
+ ? { reason: "Agent interaction coverage is incomplete for this frozen UTG Area." }
1696
+ : pathLimited
1697
+ ? { reason: "Interaction coverage completed, but the upstream UTG breadcrumb is unavailable." }
1698
+ : {}),
1699
+ outcome: interactionIncomplete ? "possible-gap" : "normalized"
1700
+ } satisfies GapAuditCandidate;
1701
+ });
1702
+ const categories = [
1703
+ category("utg-areas", "Frozen UTG Areas", areaCandidates, ["component"]),
1704
+ category("utg-links", "Frozen UTG links", linkCandidates, ["behavior-effect", "navigation-target"]),
1705
+ category(
1706
+ "interaction-candidates",
1707
+ "Tree-sitter/HomeGraph/Agent interaction candidates",
1708
+ interactionCandidates,
1709
+ ["ui-element", "callback", "interaction-binding", "behavior-effect"]
1710
+ ),
1711
+ category(
1712
+ "interaction-area-coverage",
1713
+ "Per-Area interaction coverage",
1714
+ coverageCandidates,
1715
+ ["ui-element", "interaction-binding", "behavior-effect"]
1716
+ )
1717
+ ];
1718
+ const summary = categories.reduce((sum, item) => ({
1719
+ observed: sum.observed + item.observed,
1720
+ normalized: sum.normalized + item.normalized,
1721
+ possibleGap: sum.possibleGap + item.possibleGap,
1722
+ unassessed: sum.unassessed + item.unassessed,
1723
+ recognized: sum.recognized + item.recognized,
1724
+ unresolved: sum.unresolved + item.unresolved,
1725
+ excludedWithReason: sum.excludedWithReason + item.excludedWithReason,
1726
+ limited: sum.limited + item.limited
1727
+ }), {
1728
+ observed: 0,
1729
+ normalized: 0,
1730
+ possibleGap: 0,
1731
+ unassessed: 0,
1732
+ recognized: 0,
1733
+ unresolved: 0,
1734
+ excludedWithReason: 0,
1735
+ limited: 0
1736
+ });
1737
+ const semanticCompleteness = openSemanticLimitations(limitations).length > 0
1738
+ ? "incomplete-known" as const
1739
+ : "complete" as const;
1740
+ return {
1741
+ contractVersion: GAP_AUDIT_CONTRACT_VERSION,
1742
+ artifactKind: "gap-audit",
1743
+ runId: input.runId ?? input.interactions.inputFingerprint,
1744
+ caseId: input.caseId,
1745
+ target: input.analysisContext,
1746
+ sourceAvailability: {
1747
+ sourceFacts: true,
1748
+ utg: true,
1749
+ treeSitter: input.sourceAvailability?.treeSitter ?? true,
1750
+ homeGraph: input.sourceAvailability?.homeGraph ?? true,
1751
+ agentShards: true
1752
+ },
1753
+ categories,
1754
+ summary,
1755
+ semanticCompleteness,
1756
+ semanticLimitations: limitations,
1757
+ limitations: limitations.map((item) => `${item.code}: ${item.message}`)
1758
+ };
1759
+ }
1760
+
1761
+ /**
1762
+ * Deterministically combines the frozen upstream UTG with finalized source
1763
+ * interactions. It never discovers an Area. A source-proven transition may
1764
+ * add an internal semantic Edge to an existing Area even when frozen UTG has
1765
+ * no matching link; canonical paths remain compiled from UTG topology only.
1766
+ */
1767
+ export function assembleModel(input: AssembleModelInput): AssembledModelArtifacts {
1768
+ if (input.caseId !== input.interactions.caseId) {
1769
+ throw new Error("Model inputs use different case IDs");
1770
+ }
1771
+ const { topology } = input.utg;
1772
+ const builder = new SourceFactsBuilder(input.caseId, input.analysisContext);
1773
+ const utgFacts = addUtgNodeFacts(
1774
+ builder,
1775
+ topology,
1776
+ input.analysisContext.applicationModule
1777
+ );
1778
+ addEntryFacts(builder, topology, utgFacts);
1779
+ const boundInteractions = bindExactUtgTriggerControls(
1780
+ input.interactions,
1781
+ topology
1782
+ );
1783
+ const sourceEffects = applyInteractionPlan(
1784
+ builder,
1785
+ boundInteractions,
1786
+ utgFacts.componentKeyByArea,
1787
+ utgFacts.componentFactByArea
1788
+ );
1789
+ const sourceEffectsByLink = new Map<string, SourceInteractionEffect[]>();
1790
+ for (const item of sourceEffects) {
1791
+ const edgeRef = item.effect.utgEdgeRef;
1792
+ if (!edgeRef) continue;
1793
+ if (!topology.links.some((link) => link.id === edgeRef)) {
1794
+ throw new Error(`Finalized interaction references unknown UTG link ${edgeRef}`);
1795
+ }
1796
+ const values = sourceEffectsByLink.get(edgeRef) ?? [];
1797
+ values.push(item);
1798
+ sourceEffectsByLink.set(edgeRef, values);
1799
+ }
1800
+ addCoveredLinkGuards(builder, topology, sourceEffectsByLink);
1801
+ const topologySeeds = topology.links.flatMap((link, index) =>
1802
+ sourceEffectsByLink.has(link.id)
1803
+ ? []
1804
+ : [addTopologySeed(builder, link, index, topology, utgFacts)]
1805
+ );
1806
+
1807
+ const preliminarySource = builder.finish();
1808
+ const baseGraph = buildAreaGraph(preliminarySource);
1809
+ const areaRefByUtg = exactAreaMapping(baseGraph, topology, utgFacts);
1810
+ const nodeById = new Map(topology.nodes.map((node) => [node.id, node]));
1811
+ const linkById = new Map(topology.links.map((link) => [link.id, link]));
1812
+ const edgeList = [...baseGraph.edges];
1813
+ const edgeByUtgLink = new Map<string, Edge>();
1814
+ const effectFactRefsByLink = new Map<string, string[]>(
1815
+ topologySeeds.map((seed) => [seed.link.id, [seed.effectFactRef]])
1816
+ );
1817
+ for (const [linkRef, effects] of sourceEffectsByLink) {
1818
+ effectFactRefsByLink.set(linkRef, effects.map((item) => item.effectFactRef));
1819
+ }
1820
+
1821
+ for (const link of topology.links) {
1822
+ const factRefs = effectFactRefsByLink.get(link.id) ?? [];
1823
+ if (factRefs.length === 0) {
1824
+ throw new Error(`UTG link ${link.id} has neither source coverage nor topology seed`);
1825
+ }
1826
+ const candidates: Edge[] = [];
1827
+ for (const factRef of factRefs) {
1828
+ const effect = effectForFact(baseGraph, factRef);
1829
+ if (link.transitionClass !== "user") {
1830
+ const effectIndex = baseGraph.effects.findIndex((item) => item.id === effect.id);
1831
+ if (effectIndex >= 0) {
1832
+ (baseGraph.effects as Effect[])[effectIndex] = {
1833
+ ...effect,
1834
+ transitionMode: "startup-auto"
1835
+ };
1836
+ }
1837
+ }
1838
+ const nonGestureAction = upstreamNonGestureAction(topology, link);
1839
+ if (nonGestureAction) {
1840
+ const actionIndex = baseGraph.actions.findIndex((item) =>
1841
+ item.id === effect.actionRef
1842
+ );
1843
+ const action = baseGraph.actions[actionIndex];
1844
+ if (action) {
1845
+ (baseGraph.actions as Action[])[actionIndex] = {
1846
+ ...action,
1847
+ trigger: nonGestureAction
1848
+ };
1849
+ }
1850
+ }
1851
+ const existing = edgeList.filter((edge) =>
1852
+ edge.sourceFactRefs.includes(factRef) &&
1853
+ edge.sourceAreaRef === resolveRef(areaRefByUtg, link.sourceAreaRef) &&
1854
+ !("status" in edge.target) && edge.target.kind === "area" &&
1855
+ edge.target.ref === resolveRef(areaRefByUtg, link.targetAreaRef)
1856
+ );
1857
+ if (existing.length === 0) {
1858
+ const created = synthesizedEdge(
1859
+ input.caseId,
1860
+ link,
1861
+ effect,
1862
+ baseGraph,
1863
+ areaRefByUtg
1864
+ );
1865
+ edgeList.push(created);
1866
+ candidates.push(created);
1867
+ } else {
1868
+ for (const edge of existing) {
1869
+ const index = edgeList.findIndex((item) => item.id === edge.id);
1870
+ const updated: Edge = {
1871
+ ...edge,
1872
+ navigationEvidence: [
1873
+ ...(edge.navigationEvidence ?? []),
1874
+ navigationEvidence(link)
1875
+ ]
1876
+ };
1877
+ edgeList[index] = updated;
1878
+ candidates.push(updated);
1879
+ }
1880
+ }
1881
+ }
1882
+ const selected = [...candidates].sort(compareId)[0];
1883
+ if (!selected) throw new Error(`UTG link ${link.id} did not produce an Edge`);
1884
+ edgeByUtgLink.set(link.id, selected);
1885
+ }
1886
+
1887
+ const conflictEffectRefs = new Set(sourceEffects.flatMap((item) =>
1888
+ item.effect.target?.kind === "unresolved" &&
1889
+ item.effect.target.reasonCode === "UTG_NAV_CONFLICT"
1890
+ ? [item.effectFactRef]
1891
+ : []
1892
+ ));
1893
+ const retainedEdges = edgeList.filter((edge) => {
1894
+ if (edge.sourceFactRefs.some((ref) => conflictEffectRefs.has(ref))) return false;
1895
+ return true;
1896
+ }).sort(compareId);
1897
+ for (const [linkId, selected] of edgeByUtgLink) {
1898
+ const retained = retainedEdges.find((edge) => edge.id === selected.id) ??
1899
+ retainedEdges.find((edge) => edge.navigationEvidence?.some((item) =>
1900
+ item.utgEdgeId === linkId
1901
+ ));
1902
+ if (!retained) throw new Error(`UTG link evidence was lost for ${linkId}`);
1903
+ edgeByUtgLink.set(linkId, retained);
1904
+ }
1905
+
1906
+ const entries = entryPoints(
1907
+ input.caseId,
1908
+ topology,
1909
+ areaRefByUtg,
1910
+ utgFacts,
1911
+ preliminarySource
1912
+ );
1913
+ const entryByUtg = new Map(topology.entryRootAreaRefs.map((root) => {
1914
+ const entry = entries.find((item) =>
1915
+ item.rootAreaRefs.includes(resolveRef(areaRefByUtg, root))
1916
+ );
1917
+ if (!entry) throw new Error(`Missing assembled entry for ${root}`);
1918
+ return [root, entry.id] as const;
1919
+ }));
1920
+ const compiledPaths = compilePaths(
1921
+ input.caseId,
1922
+ topology,
1923
+ areaRefByUtg,
1924
+ entryByUtg,
1925
+ edgeByUtgLink
1926
+ );
1927
+ const limitations = semanticLimitations(
1928
+ input.caseId,
1929
+ input.interactions,
1930
+ compiledPaths.gapAreaRefs
1931
+ );
1932
+ const semanticCompleteness = openSemanticLimitations(limitations).length > 0
1933
+ ? "incomplete-known" as const
1934
+ : "complete" as const;
1935
+ const sourceFacts: SourceFactsArtifact = {
1936
+ ...preliminarySource,
1937
+ semanticCompleteness,
1938
+ limitations
1939
+ };
1940
+ const unresolvedByArea = new Map(compiledPaths.unresolved.map((item) => [
1941
+ item.ownerRef,
1942
+ item.id
1943
+ ]));
1944
+ const areas: Area[] = topology.nodes.map((node): Area => {
1945
+ const areaRef = resolveRef(areaRefByUtg, node.id);
1946
+ const base = baseGraph.areas.find((item) => item.id === areaRef);
1947
+ if (!base) throw new Error(`Missing assembled Area for ${node.id}`);
1948
+ const { canonicalPathRef: _baseCanonicalPathRef, ...baseWithoutPath } = base;
1949
+ const componentRef = resolveRef(utgFacts.componentFactByArea, node.id);
1950
+ const titleRef = resolveRef(utgFacts.titleFactByArea, node.id);
1951
+ const pathRef = compiledPaths.canonicalPathByArea.get(areaRef);
1952
+ const pathGap = unresolvedByArea.get(areaRef);
1953
+ return {
1954
+ ...baseWithoutPath,
1955
+ identityAnchors: unique([...base.identityAnchors, node.id]),
1956
+ navigationAnchors: [node.id],
1957
+ kind: node.kind,
1958
+ name: {
1959
+ status: "resolved",
1960
+ value: displayName(node),
1961
+ confidence: "high",
1962
+ supportRefs: [componentRef, titleRef]
1963
+ },
1964
+ sourceFactRefs: unique([...base.sourceFactRefs, componentRef, titleRef]),
1965
+ ...(pathRef ? { canonicalPathRef: pathRef } : {}),
1966
+ unresolvedRefs: unique([...base.unresolvedRefs, ...(pathGap ? [pathGap] : [])])
1967
+ };
1968
+ }).sort(compareId);
1969
+ const selectedSourceEffectRefs = new Set(sourceEffects.map((item) => item.effectFactRef));
1970
+ const baseEffects = new Map(baseGraph.effects.map((effect) => [effect.id, effect]));
1971
+ const document: AreaGraphArtifact = {
1972
+ schemaVersion: "2.0.0",
1973
+ artifactKind: "area-graph",
1974
+ caseId: input.caseId,
1975
+ analysisContext: input.analysisContext,
1976
+ semanticCompleteness,
1977
+ limitations,
1978
+ areaControl: {
1979
+ areas,
1980
+ controls: [...baseGraph.controls].sort(compareId),
1981
+ externalEndpoints: [...baseGraph.externalEndpoints].sort(compareId),
1982
+ entryPoints: entries,
1983
+ excludedAreaCandidates: []
1984
+ },
1985
+ actionEffect: {
1986
+ actions: baseGraph.actions.map((action) => input.requirementScope &&
1987
+ !action.effectRefs.some((ref) => baseEffects.get(ref)?.sourceFactRefs.some((factRef) => selectedSourceEffectRefs.has(factRef)))
1988
+ ? { ...action, requirementScopeExcluded: true as const }
1989
+ : action).sort(compareId),
1990
+ effects: [...baseGraph.effects].sort(compareId),
1991
+ edges: retainedEdges,
1992
+ paths: compiledPaths.paths
1993
+ },
1994
+ unresolved: uniqueUnresolved([
1995
+ ...baseGraph.unresolved,
1996
+ ...compiledPaths.unresolved
1997
+ ])
1998
+ };
1999
+ const areaGraph = withAreaGraphFlatViews(document);
2000
+ const validation = validateAreaGraph(areaGraph);
2001
+ if (!validation.ok) {
2002
+ throw new Error(
2003
+ `Assembled AreaGraph is invalid: ${validation.issues.map((item) =>
2004
+ `${item.code}@${item.path}: ${item.message}`
2005
+ ).join(", ")}`
2006
+ );
2007
+ }
2008
+ const evidenceIds = new Set(retainedEdges.flatMap((edge) =>
2009
+ edge.navigationEvidence?.map((item) => item.utgEdgeId) ?? []
2010
+ ));
2011
+ const internalEdgesWithoutUtgEvidence = retainedEdges.filter((edge) =>
2012
+ !("status" in edge.target) &&
2013
+ edge.target.kind === "area" &&
2014
+ (edge.navigationEvidence?.length ?? 0) === 0
2015
+ ).length;
2016
+ // Conservation is directional: every frozen UTG link must remain evidenced.
2017
+ // Additional source-proven semantic edges are valid and counted separately.
2018
+ if (
2019
+ evidenceIds.size !== topology.links.length ||
2020
+ [...evidenceIds].some((id) => !linkById.has(id))
2021
+ ) {
2022
+ throw new Error(
2023
+ `UTG link evidence conservation failed: links=${topology.links.length}, evidence=${evidenceIds.size}`
2024
+ );
2025
+ }
2026
+ if (areas.some((area) => (area.navigationAnchors?.length ?? 0) !== 1)) {
2027
+ throw new Error("Every assembled Area must retain exactly one raw UTG node anchor");
2028
+ }
2029
+ const rawReqModel = buildReqModel(areaGraph, sourceFacts);
2030
+ const projectedReqModel = assembleReqProjection(
2031
+ filterTopologyOnlyFeatures(rawReqModel, areaGraph),
2032
+ areaGraph,
2033
+ sourceFacts
2034
+ );
2035
+ const reqModel: ReqModelArtifact = input.requirementScope ? {
2036
+ ...projectedReqModel,
2037
+ requirementScope: input.requirementScope,
2038
+ areas: projectedReqModel.areas.map((area) => {
2039
+ const utgNodeId = areaGraph.areas.find((item) => item.id === area.areaRef)?.navigationAnchors?.[0];
2040
+ if (!utgNodeId) throw new Error(`Scoped Area ${area.areaRef} has no frozen UTG node identity`);
2041
+ return {
2042
+ ...area,
2043
+ utgNodeId,
2044
+ features: input.requirementScope?.selectedNodeIds.includes(utgNodeId) ? area.features : []
2045
+ };
2046
+ })
2047
+ } : projectedReqModel;
2048
+ const gapAudit = buildGapAudit(
2049
+ input,
2050
+ sourceFacts,
2051
+ areaGraph,
2052
+ sourceEffects,
2053
+ limitations,
2054
+ compiledPaths.gapAreaRefs
2055
+ );
2056
+ return {
2057
+ sourceFacts,
2058
+ areaGraph,
2059
+ areaGraphArtifact: toAreaGraphDocument(areaGraph),
2060
+ reqModel,
2061
+ gapAudit,
2062
+ statistics: {
2063
+ areas: areas.length,
2064
+ utgLinks: topology.links.length,
2065
+ utgLinksWithEvidence: evidenceIds.size,
2066
+ topologySeeds: topologySeeds.length,
2067
+ sourceControls: input.interactions.controls.length,
2068
+ visibleFeatures: reqModel.areas.reduce((sum, area) => sum + area.features.length, 0),
2069
+ canonicalPaths: compiledPaths.paths.filter((path) => path.kind === "canonical").length,
2070
+ unreachablePaths: compiledPaths.paths.filter((path) => path.kind === "unreachable").length,
2071
+ unresolvedPathAreas: compiledPaths.gapAreaRefs.length,
2072
+ internalEdgesWithoutUtgEvidence
2073
+ }
2074
+ };
2075
+ }
2076
+
2077
+ function uniqueUnresolved(values: readonly UnresolvedItem[]): UnresolvedItem[] {
2078
+ return [...new Map(values.map((item) => [item.id, item])).values()].sort(compareId);
2079
+ }