@buaa_smat/hometrans 0.1.20 → 26.0.0-devecocli.2

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 (981) hide show
  1. package/agents/build-fixer.md +406 -0
  2. package/agents/code-reviewer.md +461 -496
  3. package/agents/model-render-worker.md +34 -0
  4. package/agents/model-worker.md +23 -0
  5. package/agents/specgen-worker.md +18 -0
  6. package/commands/hometrans.md +17 -0
  7. package/devecocli-plugin/common.ts +2203 -0
  8. package/devecocli-plugin/install.ts +61 -0
  9. package/devecocli-plugin/uninstall.ts +26 -0
  10. package/devecocli-plugin/update.ts +66 -0
  11. package/index.js +1418 -0
  12. package/package.json +81 -64
  13. package/platforms/atomcode/agents/build-fixer.frontmatter.md +6 -0
  14. package/platforms/atomcode/agents/code-reviewer.frontmatter.md +6 -0
  15. package/platforms/atomcode/agents/model-render-worker.frontmatter.md +6 -0
  16. package/platforms/atomcode/agents/model-worker.frontmatter.md +6 -0
  17. package/platforms/atomcode/agents/specgen-worker.frontmatter.md +6 -0
  18. package/platforms/deveco/agents/build-fixer.frontmatter.md +5 -0
  19. package/platforms/deveco/agents/code-reviewer.frontmatter.md +5 -0
  20. package/platforms/deveco/agents/model-render-worker.frontmatter.md +5 -0
  21. package/platforms/deveco/agents/model-worker.frontmatter.md +5 -0
  22. package/platforms/deveco/agents/specgen-worker.frontmatter.md +5 -0
  23. package/platforms/opencode/agents/build-fixer.frontmatter.md +5 -0
  24. package/platforms/opencode/agents/code-reviewer.frontmatter.md +5 -0
  25. package/platforms/opencode/agents/model-render-worker.frontmatter.md +5 -0
  26. package/platforms/opencode/agents/model-worker.frontmatter.md +5 -0
  27. package/platforms/opencode/agents/specgen-worker.frontmatter.md +5 -0
  28. package/plugin.jsonc +12 -0
  29. package/skills/a2h-app-migrate/SKILL.md +181 -0
  30. package/skills/a2h-app-migrate/references/config.example.json +27 -0
  31. package/skills/a2h-app-migrate/references/specs.example.json +19 -0
  32. package/skills/a2h-app-migrate/references/stage-map.md +33 -0
  33. package/skills/a2h-app-migrate/references/workflow.yaml +1600 -0
  34. package/skills/a2h-app-migrate/scripts/android_index.mjs +109 -0
  35. package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +80 -0
  36. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +95 -0
  37. package/skills/a2h-app-migrate/scripts/check_signing.mjs +152 -0
  38. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
  39. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +277 -0
  40. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +77 -0
  41. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +147 -0
  42. package/skills/a2h-app-migrate/scripts/cli_values.mjs +32 -0
  43. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1388 -0
  44. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +651 -0
  45. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +53 -0
  46. package/skills/a2h-app-migrate/scripts/json_io.mjs +35 -0
  47. package/skills/a2h-app-migrate/scripts/ledger.mjs +104 -0
  48. package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +288 -0
  49. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +713 -0
  50. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +205 -0
  51. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +121 -0
  52. package/skills/a2h-app-migrate/scripts/run_dir.mjs +212 -0
  53. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +30 -0
  54. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +455 -0
  55. package/skills/a2h-app-migrate/test/test_android_index.mjs +80 -0
  56. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  57. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  58. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +92 -0
  59. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  60. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +93 -0
  61. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +505 -0
  62. package/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
  63. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  64. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  65. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +91 -0
  66. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  67. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  68. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +109 -0
  69. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +53 -0
  70. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  71. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +83 -0
  72. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +144 -0
  73. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
  74. package/skills/a2h-app-migrate/test/test_run_dir.mjs +315 -0
  75. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +133 -0
  76. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +133 -0
  77. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +158 -0
  78. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +181 -0
  79. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  80. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +53 -0
  81. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  82. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +39 -0
  83. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +168 -0
  84. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  85. package/skills/a2h-arch-generate/SKILL.md +375 -0
  86. package/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  87. package/skills/a2h-arch-generate/examples/simple-conversion-android.md +103 -0
  88. package/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  89. package/skills/a2h-arch-generate/examples/simple-conversion-uniapp.md +106 -0
  90. package/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  91. package/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  92. package/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  93. package/skills/a2h-arch-generate/references/clustering-guidance.md +33 -0
  94. package/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  95. package/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  96. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  97. package/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  98. package/skills/a2h-arch-generate/references/homegraph-workflow.md +120 -0
  99. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +45 -0
  100. package/skills/a2h-arch-generate/references/reconciliation-model.md +204 -0
  101. package/skills/a2h-arch-generate/references/scope-policy.md +28 -0
  102. package/skills/a2h-arch-generate/references/semantic-review.md +65 -0
  103. package/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  104. package/skills/a2h-arch-generate/references/source-ecosystems.md +54 -0
  105. package/skills/a2h-arch-generate/references/transformation-model.md +78 -0
  106. package/skills/a2h-arch-generate/scripts/check_module_staleness.mjs +284 -0
  107. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +260 -0
  108. package/skills/a2h-arch-generate/scripts/compute_processing_order.mjs +325 -0
  109. package/skills/a2h-arch-generate/scripts/create_project.mjs +149 -0
  110. package/skills/a2h-arch-generate/scripts/dump_core_facts.mjs +151 -0
  111. package/skills/a2h-arch-generate/scripts/extract_core_components.mjs +167 -0
  112. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +363 -0
  113. package/skills/a2h-arch-generate/scripts/generate_state.mjs +60 -0
  114. package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +326 -0
  115. package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +3739 -0
  116. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +800 -0
  117. package/skills/a2h-arch-generate/scripts/inspect_project.mjs +251 -0
  118. package/skills/a2h-arch-generate/scripts/inspect_uniapp_project.mjs +809 -0
  119. package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1454 -0
  120. package/skills/a2h-arch-generate/scripts/module_create/create.mjs +136 -0
  121. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +636 -0
  122. package/skills/a2h-arch-generate/scripts/module_create/hap/build-profile.json5 +33 -0
  123. package/skills/a2h-arch-generate/scripts/module_create/hap/hvigorfile.ts +6 -0
  124. package/skills/a2h-arch-generate/scripts/module_create/hap/obfuscation-rules.txt +23 -0
  125. package/skills/a2h-arch-generate/scripts/module_create/hap/oh-package.json5 +10 -0
  126. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/applicationability/ApplicationAbility.ets +43 -0
  127. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +23 -0
  128. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/module.json5 +26 -0
  129. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/color.json +8 -0
  130. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/float.json +8 -0
  131. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/string.json +16 -0
  132. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/background.png +0 -0
  133. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/foreground.png +0 -0
  134. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/layered_image.json +7 -0
  135. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/startIcon.png +0 -0
  136. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/profile/main_pages.json +5 -0
  137. package/skills/a2h-arch-generate/scripts/module_create/hap/src/mock/mock-config.json5 +2 -0
  138. package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/Ability.test.ets +35 -0
  139. package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/List.test.ets +5 -0
  140. package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/module.json5 +11 -0
  141. package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/List.test.ets +5 -0
  142. package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/LocalUnit.test.ets +33 -0
  143. package/skills/a2h-arch-generate/scripts/module_create/har/Index.ets +1 -0
  144. package/skills/a2h-arch-generate/scripts/module_create/har/build-profile.json5 +36 -0
  145. package/skills/a2h-arch-generate/scripts/module_create/har/hvigorfile.ts +6 -0
  146. package/skills/a2h-arch-generate/scripts/module_create/har/obfuscation-rules.txt +23 -0
  147. package/skills/a2h-arch-generate/scripts/module_create/har/oh-package.json5 +9 -0
  148. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +19 -0
  149. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/module.json5 +9 -0
  150. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/float.json +8 -0
  151. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/string.json +8 -0
  152. package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/Ability.test.ets +35 -0
  153. package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/List.test.ets +5 -0
  154. package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/module.json5 +11 -0
  155. package/skills/a2h-arch-generate/scripts/module_create/har/src/test/List.test.ets +5 -0
  156. package/skills/a2h-arch-generate/scripts/module_create/har/src/test/LocalUnit.test.ets +33 -0
  157. package/skills/a2h-arch-generate/scripts/module_create/hsp/Index.ets +1 -0
  158. package/skills/a2h-arch-generate/scripts/module_create/hsp/build-profile.json5 +36 -0
  159. package/skills/a2h-arch-generate/scripts/module_create/hsp/consumer-rules.txt +0 -0
  160. package/skills/a2h-arch-generate/scripts/module_create/hsp/hvigorfile.ts +6 -0
  161. package/skills/a2h-arch-generate/scripts/module_create/hsp/obfuscation-rules.txt +23 -0
  162. package/skills/a2h-arch-generate/scripts/module_create/hsp/oh-package.json5 +10 -0
  163. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +20 -0
  164. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/utils/Calc.ets +3 -0
  165. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/module.json5 +12 -0
  166. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/float.json +8 -0
  167. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/string.json +8 -0
  168. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/profile/main_pages.json +5 -0
  169. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/Ability.test.ets +35 -0
  170. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/List.test.ets +5 -0
  171. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/module.json5 +11 -0
  172. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/List.test.ets +5 -0
  173. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/LocalUnit.test.ets +33 -0
  174. package/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  175. package/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  176. package/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  177. package/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  178. package/skills/a2h-arch-generate/scripts/resolve_android_stores.mjs +529 -0
  179. package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +230 -0
  180. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  181. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  182. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  183. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  184. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  185. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  186. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  187. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  188. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  189. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  190. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  191. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  192. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  193. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  194. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  195. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  196. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  197. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  198. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  199. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  200. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  201. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  202. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  203. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  204. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  205. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  206. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  207. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1122 -0
  208. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +191 -0
  209. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  210. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  211. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
  212. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +829 -0
  213. package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +937 -0
  214. package/skills/a2h-arch-generate/scripts/validate_homegraph_artifacts.mjs +542 -0
  215. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +415 -0
  216. package/skills/a2h-arkts-logic-coder/SKILL.md +125 -0
  217. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +6 -0
  218. package/skills/a2h-arkts-logic-coder/references/code-generation.md +124 -0
  219. package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +224 -0
  220. package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +377 -0
  221. package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +443 -0
  222. package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +211 -0
  223. package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +81 -0
  224. package/skills/a2h-batch-ui-align/SKILL.md +309 -0
  225. package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +81 -0
  226. package/skills/a2h-batch-ui-align/flowchart.html +271 -0
  227. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/conversion-procedure.md +523 -661
  228. package/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
  229. package/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  230. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +8 -8
  231. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +3 -0
  232. package/skills/a2h-batch-ui-align/references/source-only-tier.md +32 -0
  233. package/skills/a2h-batch-ui-align/references/step3-capture.md +211 -0
  234. package/skills/a2h-batch-ui-align/references/step4-prepare.md +192 -0
  235. package/skills/a2h-batch-ui-align/references/step5-convert.md +202 -0
  236. package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +572 -0
  237. package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/scripts/android_parse_fast.ts +246 -39
  238. package/skills/a2h-batch-ui-align/scripts/answers_check.mjs +86 -0
  239. package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +2689 -0
  240. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1656 -0
  241. package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  242. package/skills/a2h-batch-ui-align/scripts/detach.mjs +258 -0
  243. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1524 -0
  244. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  245. package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +166 -0
  246. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1437 -0
  247. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1869 -0
  248. package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +696 -0
  249. package/skills/a2h-batch-ui-align/scripts/harmony_index.mjs +218 -0
  250. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +208 -0
  251. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1229 -0
  252. package/skills/a2h-batch-ui-align/scripts/occlusion.mjs +141 -0
  253. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1124 -0
  254. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +996 -0
  255. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +217 -0
  256. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +253 -0
  257. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  258. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +72 -0
  259. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +353 -0
  260. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +345 -0
  261. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +290 -0
  262. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +74 -0
  263. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +507 -0
  264. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  265. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  266. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +189 -0
  267. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1451 -0
  268. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  269. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  270. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  271. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +170 -0
  272. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  273. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +244 -0
  274. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +130 -0
  275. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  276. package/skills/a2h-coldstart-smoke-gate/SKILL.md +57 -0
  277. package/skills/a2h-dashboard-render/SKILL.md +65 -0
  278. package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +147 -0
  279. package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  280. package/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  281. package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +83 -0
  282. package/skills/a2h-dashboard-render/scripts/artifact_contract.mjs +138 -0
  283. package/skills/a2h-dashboard-render/scripts/check-registry.mjs +87 -0
  284. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +3215 -0
  285. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +2010 -0
  286. package/skills/a2h-dashboard-render/scripts/page_capture.mjs +828 -0
  287. package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +459 -0
  288. package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +13 -0
  289. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  290. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  291. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  292. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  293. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  294. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +170 -0
  295. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  296. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +182 -0
  297. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +64 -0
  298. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1172 -0
  299. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +251 -0
  300. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  301. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  302. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +303 -0
  303. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  304. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +444 -0
  305. package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/SKILL.md +305 -293
  306. package/skills/a2h-module-semantic-docs/SKILL.md +227 -0
  307. package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +168 -0
  308. package/skills/a2h-module-semantic-docs/scripts/lib/py_compat.mjs +688 -0
  309. package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +1021 -0
  310. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  311. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  312. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  313. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  314. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  315. package/skills/a2h-resource-convert/SKILL.md +369 -0
  316. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/code-vector-icon-rules.md +4 -4
  317. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/conversion-rules.md +16 -5
  318. package/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
  319. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/lottie-conversion-rules.md +17 -17
  320. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/resource-mapping-rules.md +15 -4
  321. package/skills/a2h-resource-convert/references/step3_5-dependency-filter.md +54 -0
  322. package/skills/a2h-resource-convert/references/step4-qualifiers-and-values.md +142 -0
  323. package/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
  324. package/skills/a2h-resource-convert/references/step5-reference-resolution.md +154 -0
  325. package/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  326. package/skills/{hmos-resources-convert → a2h-resource-convert}/references/xml-drawable-to-svg-rules.md +38 -0
  327. package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/a2h_resource_convert.ts +456 -90
  328. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +1072 -0
  329. package/skills/a2h-resource-convert/scripts/app_identity.ts +947 -0
  330. package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/code_vector_icons.ts +19 -3
  331. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +989 -0
  332. package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +1464 -0
  333. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  334. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  335. package/skills/a2h-spec-design/SKILL.md +336 -0
  336. package/skills/a2h-spec-design/scripts/inspect_spec_design_inputs.mjs +146 -0
  337. package/skills/a2h-spec-design/scripts/lib/py_compat.mjs +481 -0
  338. package/skills/a2h-spec-design/scripts/move_spec_technical_reference.mjs +159 -0
  339. package/skills/a2h-spec-design/scripts/resolve_module_design.mjs +102 -0
  340. package/skills/a2h-spec-design/scripts/validate_spec_design_output.mjs +285 -0
  341. package/skills/a2h-spec-design/test/golden/inspect_happy.json +20 -0
  342. package/skills/a2h-spec-design/test/golden/move_design.md +18 -0
  343. package/skills/a2h-spec-design/test/golden/move_design_crlf.md +18 -0
  344. package/skills/a2h-spec-design/test/golden/move_spec.md +7 -0
  345. package/skills/a2h-spec-design/test/golden/resolve_cases.json +36 -0
  346. package/skills/a2h-spec-design/test/golden/validate_issue_file.md +12 -0
  347. package/skills/a2h-spec-design/test/golden/validate_issues.json +57 -0
  348. package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +381 -0
  349. package/skills/a2h-spec-design-pipeline/SKILL.md +228 -0
  350. package/skills/a2h-spec-design-pipeline/package.json +4 -0
  351. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +63 -0
  352. package/skills/a2h-spec-design-pipeline/references/execution-model.md +69 -0
  353. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +24 -0
  354. package/skills/a2h-spec-design-pipeline/references/initialization.md +57 -0
  355. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +21 -0
  356. package/skills/a2h-spec-design-pipeline/references/scripts.md +27 -0
  357. package/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  358. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +21 -0
  359. package/skills/a2h-spec-design-pipeline/scripts/atomic_write.ts +42 -0
  360. package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +252 -0
  361. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +77 -0
  362. package/skills/a2h-spec-design-pipeline/scripts/deps_ready.ts +195 -0
  363. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +651 -0
  364. package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +124 -0
  365. package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +944 -0
  366. package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +95 -0
  367. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +502 -0
  368. package/skills/a2h-spec-design-pipeline/scripts/plan_waves.ts +475 -0
  369. package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +218 -0
  370. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +164 -0
  371. package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +44 -0
  372. package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +301 -0
  373. package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +64 -0
  374. package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +87 -0
  375. package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +265 -0
  376. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +675 -0
  377. package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +105 -0
  378. package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +452 -0
  379. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +375 -0
  380. package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +561 -0
  381. package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +182 -0
  382. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +138 -0
  383. package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +289 -0
  384. package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +441 -0
  385. package/skills/a2h-spec-generate/SKILL.md +285 -0
  386. package/skills/a2h-spec-generate/package.json +9 -0
  387. package/skills/a2h-spec-generate/references/batch-mode.md +151 -0
  388. package/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  389. package/skills/a2h-spec-generate/references/fusion-task-contract.md +114 -0
  390. package/skills/a2h-spec-generate/references/input-formats.md +27 -0
  391. package/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  392. package/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  393. package/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  394. package/skills/a2h-spec-generate/references/recall-guide.md +83 -0
  395. package/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  396. package/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  397. package/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  398. package/skills/a2h-spec-generate/references/review-checklist.md +21 -0
  399. package/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  400. package/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  401. package/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  402. package/skills/a2h-spec-generate/references/specs.schema.json +79 -0
  403. package/skills/a2h-spec-generate/references/synthesis-rules.md +143 -0
  404. package/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  405. package/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  406. package/skills/a2h-spec-generate/references/worker-rules.md +126 -0
  407. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +514 -0
  408. package/skills/a2h-spec-generate/scripts/check_spec.ts +361 -0
  409. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +470 -0
  410. package/skills/a2h-spec-generate/scripts/detect-project.mjs +271 -0
  411. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +188 -0
  412. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +150 -0
  413. package/skills/a2h-spec-generate/scripts/inspect-uniapp.mjs +733 -0
  414. package/skills/{hmos-spec-generate → a2h-spec-generate}/scripts/parse_requirements.ts +1 -1
  415. package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +307 -0
  416. package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +171 -0
  417. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +280 -0
  418. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +399 -0
  419. package/skills/a2h-spec-generate/scripts/report.mjs +132 -0
  420. package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +149 -0
  421. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +49 -0
  422. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +140 -0
  423. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +16 -0
  424. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +42 -0
  425. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-splitters.js +78 -0
  426. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-state.js +47 -0
  427. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +194 -0
  428. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-virtual-list.js +118 -0
  429. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.css +245 -0
  430. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +99 -0
  431. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +220 -0
  432. package/skills/a2h-spec-generate/scripts/reqgen/package-lock.json +47 -0
  433. package/skills/a2h-spec-generate/scripts/reqgen/package.json +23 -0
  434. package/skills/a2h-spec-generate/scripts/reqgen/src/agent-render/serve.ts +95 -0
  435. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/callback-call-sites.ts +82 -0
  436. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/area-ownership.ts +496 -0
  437. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  438. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/callback-flow.ts +386 -0
  439. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  440. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/index.ts +24 -0
  441. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/index.ts +22 -0
  442. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  443. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  444. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1270 -0
  445. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/index.ts +10 -0
  446. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/projection.ts +804 -0
  447. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/render-projection.ts +51 -0
  448. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/android-interaction-registry.ts +286 -0
  449. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/builder.ts +453 -0
  450. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/compose-api-registry.ts +526 -0
  451. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/index.ts +15 -0
  452. package/skills/a2h-spec-generate/scripts/reqgen/src/connector/index.ts +1 -0
  453. package/skills/a2h-spec-generate/scripts/reqgen/src/connector/utg-inbound.ts +763 -0
  454. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/area-graph.ts +383 -0
  455. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/artifact.ts +68 -0
  456. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/common.ts +88 -0
  457. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/diagnostic.ts +64 -0
  458. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/gap-audit.ts +113 -0
  459. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/index.ts +12 -0
  460. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/name-traceability.ts +108 -0
  461. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/raw-fact.ts +377 -0
  462. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/req-model.ts +238 -0
  463. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/run.ts +134 -0
  464. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/semantic-completeness.ts +35 -0
  465. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/source-facts.ts +48 -0
  466. package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/utg.ts +133 -0
  467. package/skills/a2h-spec-generate/scripts/reqgen/src/core/output-guard.ts +42 -0
  468. package/skills/a2h-spec-generate/scripts/reqgen/src/core/stable-id.ts +118 -0
  469. package/skills/a2h-spec-generate/scripts/reqgen/src/cross-area-tally-cli.ts +179 -0
  470. package/skills/a2h-spec-generate/scripts/reqgen/src/dashboard-cli.ts +188 -0
  471. package/skills/a2h-spec-generate/scripts/reqgen/src/dump/dump.ts +1184 -0
  472. package/skills/a2h-spec-generate/scripts/reqgen/src/dump/index.ts +1 -0
  473. package/skills/a2h-spec-generate/scripts/reqgen/src/dump-cli.ts +373 -0
  474. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1014 -0
  475. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +32 -0
  476. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +142 -0
  477. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +312 -0
  478. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +310 -0
  479. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +685 -0
  480. package/skills/a2h-spec-generate/scripts/reqgen/src/graph/paths.ts +575 -0
  481. package/skills/a2h-spec-generate/scripts/reqgen/src/homegraph-cli.ts +50 -0
  482. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/android-resource-resolver.ts +391 -0
  483. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/androidx-preference-contracts.ts +44 -0
  484. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +640 -0
  485. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/cross-area.ts +207 -0
  486. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/finalizer.ts +1297 -0
  487. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/identity.ts +186 -0
  488. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/index.ts +16 -0
  489. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/planner.ts +312 -0
  490. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/preference-enrichment.ts +793 -0
  491. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/raw-facts.ts +355 -0
  492. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/rules.ts +271 -0
  493. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/scanner.ts +666 -0
  494. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +365 -0
  495. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/stable-key.ts +144 -0
  496. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +301 -0
  497. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  498. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/uniapp-utg-adapter.ts +543 -0
  499. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/xml-adapter.ts +262 -0
  500. package/skills/a2h-spec-generate/scripts/reqgen/src/model/assemble.ts +2079 -0
  501. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +157 -0
  502. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +809 -0
  503. package/skills/a2h-spec-generate/scripts/reqgen/src/model/index.ts +17 -0
  504. package/skills/a2h-spec-generate/scripts/reqgen/src/model/io.ts +165 -0
  505. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +806 -0
  506. package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +360 -0
  507. package/skills/a2h-spec-generate/scripts/reqgen/src/model/seeds.ts +218 -0
  508. package/skills/a2h-spec-generate/scripts/reqgen/src/model/spec-bindings-sidecar.ts +240 -0
  509. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +359 -0
  510. package/skills/a2h-spec-generate/scripts/reqgen/src/model-cli.ts +500 -0
  511. package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/index.ts +7 -0
  512. package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/output.ts +307 -0
  513. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +172 -0
  514. package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/index.ts +1 -0
  515. package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/source-cov.ts +176 -0
  516. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  517. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/area-graph.ts +490 -0
  518. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/index.ts +23 -0
  519. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-model.ts +957 -0
  520. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +248 -0
  521. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/semantic-area-graph.ts +1600 -0
  522. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/types.ts +10 -0
  523. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/artifact-data.ts +201 -0
  524. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +74 -0
  525. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +180 -0
  526. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +18 -0
  527. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +55 -0
  528. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-splitters.ts +78 -0
  529. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-state.ts +66 -0
  530. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +232 -0
  531. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-virtual-list.ts +179 -0
  532. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +240 -0
  533. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/contracts.d.ts +86 -0
  534. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/index.ts +3 -0
  535. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/server.ts +239 -0
  536. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/source-project.ts +316 -0
  537. package/skills/a2h-spec-generate/scripts/reqgen/src/viz-cli.ts +200 -0
  538. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  539. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  540. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  541. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  542. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +290 -0
  543. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1323 -0
  544. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +574 -0
  545. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  546. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +831 -0
  547. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +548 -0
  548. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  549. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +396 -0
  550. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  551. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +298 -0
  552. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  553. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  554. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  555. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  556. package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.json +16 -0
  557. package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.viz-client.json +12 -0
  558. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +632 -0
  559. package/skills/a2h-spec-generate/test/check-spec.test.ts +200 -0
  560. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +538 -0
  561. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  562. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +45 -0
  563. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +147 -0
  564. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  565. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  566. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  567. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  568. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  569. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  570. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  571. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  572. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  573. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  574. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  575. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  576. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  577. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  578. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  579. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  580. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  581. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +157 -0
  582. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +282 -0
  583. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +593 -0
  584. package/skills/a2h-utg-explorer/SKILL.md +120 -0
  585. package/skills/a2h-utg-explorer/assets/final_viewer.html +64 -0
  586. package/skills/a2h-utg-explorer/assets/u2.LICENSE +21 -0
  587. package/skills/a2h-utg-explorer/assets/u2.NOTICE +25 -0
  588. package/skills/a2h-utg-explorer/assets/u2.jar +0 -0
  589. package/skills/a2h-utg-explorer/references/architecture.md +270 -0
  590. package/skills/a2h-utg-explorer/references/protocol.md +9 -0
  591. package/skills/a2h-utg-explorer/scripts/app_settings.mjs +143 -0
  592. package/skills/a2h-utg-explorer/scripts/audit.mjs +167 -0
  593. package/skills/a2h-utg-explorer/scripts/close_phases.mjs +66 -0
  594. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +749 -0
  595. package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +597 -0
  596. package/skills/a2h-utg-explorer/scripts/device_health.mjs +227 -0
  597. package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +276 -0
  598. package/skills/a2h-utg-explorer/scripts/evidence.mjs +108 -0
  599. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +376 -0
  600. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +89 -0
  601. package/skills/a2h-utg-explorer/scripts/plan.mjs +258 -0
  602. package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +170 -0
  603. package/skills/a2h-utg-explorer/scripts/recover.mjs +467 -0
  604. package/skills/a2h-utg-explorer/scripts/recover_b.mjs +542 -0
  605. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +302 -0
  606. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +203 -0
  607. package/skills/a2h-utg-explorer/scripts/report.mjs +143 -0
  608. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +831 -0
  609. package/skills/a2h-utg-explorer/scripts/run_device.mjs +137 -0
  610. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  611. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  612. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +207 -0
  613. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  614. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +223 -0
  615. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +88 -0
  616. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  617. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  618. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +136 -0
  619. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  620. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  621. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +251 -0
  622. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +42 -0
  623. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +162 -0
  624. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  625. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +204 -0
  626. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +355 -0
  627. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  628. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  629. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  630. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +207 -0
  631. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  632. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  633. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +453 -0
  634. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +131 -0
  635. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  636. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +321 -0
  637. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  638. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  639. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  640. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  641. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  642. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  643. package/skills/a2h-utg-explorer/scripts/utg_explorer/_device_io.mjs +244 -0
  644. package/skills/a2h-utg-explorer/scripts/utg_explorer/_py.mjs +2097 -0
  645. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +1213 -0
  646. package/skills/a2h-utg-explorer/scripts/utg_explorer/attest.mjs +63 -0
  647. package/skills/a2h-utg-explorer/scripts/utg_explorer/chain.mjs +63 -0
  648. package/skills/a2h-utg-explorer/scripts/utg_explorer/coverage.mjs +89 -0
  649. package/skills/a2h-utg-explorer/scripts/utg_explorer/device_lock.mjs +46 -0
  650. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1136 -0
  651. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +1513 -0
  652. package/skills/a2h-utg-explorer/scripts/variant.mjs +75 -0
  653. package/skills/a2h-utg-explorer/scripts/worklist_parts.mjs +122 -0
  654. package/skills/a2h-utg-static/SKILL.md +361 -0
  655. package/skills/a2h-utg-static/config.json +19 -0
  656. package/skills/a2h-utg-static/references/extractors.md +217 -0
  657. package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  658. package/skills/a2h-utg-static/references/view-interactions.md +215 -0
  659. package/skills/a2h-utg-static/scripts/_graph.mjs +361 -0
  660. package/skills/a2h-utg-static/scripts/_py.mjs +2177 -0
  661. package/skills/a2h-utg-static/scripts/_spawn.mjs +45 -0
  662. package/skills/a2h-utg-static/scripts/activity_nav.mjs +738 -0
  663. package/skills/a2h-utg-static/scripts/activity_widgets.mjs +254 -0
  664. package/skills/a2h-utg-static/scripts/adapter_nav.mjs +229 -0
  665. package/skills/a2h-utg-static/scripts/androidfragment_nav.mjs +208 -0
  666. package/skills/a2h-utg-static/scripts/assemble.mjs +2065 -0
  667. package/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  668. package/skills/a2h-utg-static/scripts/carry_answers.mjs +201 -0
  669. package/skills/a2h-utg-static/scripts/click_paths.mjs +594 -0
  670. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +172 -0
  671. package/skills/a2h-utg-static/scripts/compose_merge.mjs +263 -0
  672. package/skills/a2h-utg-static/scripts/compose_nav.mjs +1216 -0
  673. package/skills/a2h-utg-static/scripts/compose_navbar_nav.mjs +238 -0
  674. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +2760 -0
  675. package/skills/a2h-utg-static/scripts/compose_titles.mjs +365 -0
  676. package/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  677. package/skills/a2h-utg-static/scripts/dialog_listener_nav.mjs +237 -0
  678. package/skills/a2h-utg-static/scripts/dialogshow_nav.mjs +308 -0
  679. package/skills/a2h-utg-static/scripts/fragfactory_nav.mjs +170 -0
  680. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +1136 -0
  681. package/skills/a2h-utg-static/scripts/guard_subjects.mjs +162 -0
  682. package/skills/a2h-utg-static/scripts/hg_query.mjs +137 -0
  683. package/skills/a2h-utg-static/scripts/host_resolve.mjs +393 -0
  684. package/skills/a2h-utg-static/scripts/hybrid_bundle.mjs +165 -0
  685. package/skills/a2h-utg-static/scripts/hybrid_pages.mjs +713 -0
  686. package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
  687. package/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  688. package/skills/a2h-utg-static/scripts/io_utils.mjs +59 -0
  689. package/skills/a2h-utg-static/scripts/label_resolve.mjs +864 -0
  690. package/skills/a2h-utg-static/scripts/launch_extras.mjs +91 -0
  691. package/skills/a2h-utg-static/scripts/layout_resolve.mjs +148 -0
  692. package/skills/a2h-utg-static/scripts/manifest.mjs +483 -0
  693. package/skills/a2h-utg-static/scripts/measure/measure_corpus.mjs +297 -0
  694. package/skills/a2h-utg-static/scripts/measure/measure_guards.mjs +98 -0
  695. package/skills/a2h-utg-static/scripts/media_browse_nav.mjs +356 -0
  696. package/skills/a2h-utg-static/scripts/menu_nav.mjs +603 -0
  697. package/skills/a2h-utg-static/scripts/navactions_nav.mjs +255 -0
  698. package/skills/a2h-utg-static/scripts/nl_hints.mjs +453 -0
  699. package/skills/a2h-utg-static/scripts/orphan_overlay_nav.mjs +89 -0
  700. package/skills/a2h-utg-static/scripts/phase_plan.mjs +108 -0
  701. package/skills/a2h-utg-static/scripts/phase_planner.mjs +119 -0
  702. package/skills/a2h-utg-static/scripts/plaindialog_nav.mjs +411 -0
  703. package/skills/a2h-utg-static/scripts/preference_nav.mjs +761 -0
  704. package/skills/a2h-utg-static/scripts/preference_widgets.mjs +142 -0
  705. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  706. package/skills/a2h-utg-static/scripts/registry_nav.mjs +288 -0
  707. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +870 -0
  708. package/skills/a2h-utg-static/scripts/scope_utils.mjs +430 -0
  709. package/skills/a2h-utg-static/scripts/screen_merge.mjs +287 -0
  710. package/skills/a2h-utg-static/scripts/screen_nav.mjs +279 -0
  711. package/skills/a2h-utg-static/scripts/single_host_nav.mjs +291 -0
  712. package/skills/a2h-utg-static/scripts/starter_nav.mjs +198 -0
  713. package/skills/a2h-utg-static/scripts/state_guard.mjs +579 -0
  714. package/skills/a2h-utg-static/scripts/static_prior.mjs +904 -0
  715. package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
  716. package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
  717. package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
  718. package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
  719. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  720. package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +90 -0
  721. package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
  722. package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
  723. package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
  724. package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  725. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
  726. package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  727. package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  728. package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
  729. package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
  730. package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
  731. package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
  732. package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +267 -0
  733. package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
  734. package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
  735. package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
  736. package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
  737. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
  738. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
  739. package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  740. package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  741. package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
  742. package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
  743. package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
  744. package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
  745. package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
  746. package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
  747. package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
  748. package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
  749. package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
  750. package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
  751. package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +119 -0
  752. package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
  753. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  754. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  755. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
  756. package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  757. package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
  758. package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
  759. package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
  760. package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  761. package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  762. package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  763. package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
  764. package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
  765. package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
  766. package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
  767. package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
  768. package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
  769. package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  770. package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +33 -0
  771. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
  772. package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
  773. package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
  774. package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  775. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  776. package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
  777. package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  778. package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
  779. package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
  780. package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
  781. package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
  782. package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
  783. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
  784. package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
  785. package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
  786. package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
  787. package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
  788. package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
  789. package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  790. package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  791. package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
  792. package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
  793. package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
  794. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
  795. package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
  796. package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
  797. package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  798. package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
  799. package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
  800. package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
  801. package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
  802. package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
  803. package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
  804. package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  805. package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  806. package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
  807. package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +58 -0
  808. package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
  809. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
  810. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  811. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
  812. package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
  813. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
  814. package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
  815. package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
  816. package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
  817. package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +273 -0
  818. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
  819. package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
  820. package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
  821. package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
  822. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1119 -0
  823. package/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  824. package/skills/a2h-utg-static/scripts/utg_html.mjs +721 -0
  825. package/skills/a2h-utg-static/scripts/view_interactions.mjs +799 -0
  826. package/skills/a2h-utg-static/scripts/view_widgets.mjs +512 -0
  827. package/skills/a2h-utg-static/scripts/viewpage_nav.mjs +485 -0
  828. package/skills/a2h-utg-static/scripts/vm_nav.mjs +422 -0
  829. package/skills/a2h-utg-static/scripts/window_nav.mjs +240 -0
  830. package/skills/a2h-utg-static/scripts/worklist_parts.mjs +154 -0
  831. package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  832. package/skills/a2h-utg-static/tools/package.json +3 -0
  833. package/README.md +0 -445
  834. package/agents/logic-coder.md +0 -224
  835. package/agents/logic-context-builder.md +0 -212
  836. package/agents/scripts/hmos-precheck/backends/arkts.mjs +0 -567
  837. package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +0 -159
  838. package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +0 -398
  839. package/agents/scripts/hmos-precheck/backends/codelinter.mjs +0 -250
  840. package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +0 -321
  841. package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +0 -247
  842. package/agents/scripts/hmos-precheck/core/config.mjs +0 -184
  843. package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +0 -20
  844. package/agents/scripts/hmos-precheck/core/process_adapter.mjs +0 -47
  845. package/agents/scripts/hmos-precheck/core/project_catalog.mjs +0 -50
  846. package/agents/scripts/hmos-precheck/core/result_projection.mjs +0 -147
  847. package/agents/scripts/hmos-precheck/core/scope_plan.mjs +0 -131
  848. package/agents/scripts/hmos-precheck/core/sdk_context.mjs +0 -67
  849. package/agents/scripts/hmos-precheck/docs/architecture.md +0 -37
  850. package/agents/scripts/hmos-precheck/docs/performance-optimization.md +0 -28
  851. package/agents/scripts/hmos-precheck/docs/upstream-reference.json +0 -19
  852. package/agents/scripts/hmos-precheck/docs/validation.md +0 -50
  853. package/agents/scripts/hmos-precheck/index.mjs +0 -17
  854. package/agents/scripts/hmos-precheck/invocation.mjs +0 -231
  855. package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +0 -32
  856. package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +0 -64
  857. package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +0 -59
  858. package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +0 -54
  859. package/agents/scripts/platform_query.mjs +0 -626
  860. package/agents/scripts/platform_query.test.mjs +0 -422
  861. package/agents/self-test-fixer.md +0 -298
  862. package/agents/self-tester.md +0 -55
  863. package/agents/test-case-generation-generator.md +0 -317
  864. package/agents/test-case-generation-validator.md +0 -231
  865. package/dist/cli/config-store.js +0 -310
  866. package/dist/cli/config.js +0 -44
  867. package/dist/cli/env-vars.js +0 -127
  868. package/dist/cli/index.js +0 -56
  869. package/dist/cli/init.js +0 -1187
  870. package/dist/cli/uninstall.js +0 -427
  871. package/dist/utils/regex.js +0 -8
  872. package/env-requirements.json +0 -179
  873. package/resource/choose_editor.png +0 -0
  874. package/resource/convert_pipeline_process.svg +0 -103
  875. package/resource/project_architecture.svg +0 -122
  876. package/resource/set_environment.png +0 -0
  877. package/resource/set_multimodel.png +0 -0
  878. package/resource/set_sdk.png +0 -0
  879. package/resource/title_dark.png +0 -0
  880. package/skills/hmos-batch-ui-align/SKILL.md +0 -413
  881. package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +0 -1592
  882. package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +0 -752
  883. package/skills/hmos-convert-pipeline/SKILL.md +0 -486
  884. package/skills/hmos-incremental-ui-align/README.md +0 -251
  885. package/skills/hmos-incremental-ui-align/SKILL.md +0 -375
  886. package/skills/hmos-incremental-ui-align/diff_analysis.md +0 -53
  887. package/skills/hmos-incremental-ui-align/page_align.md +0 -62
  888. package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +0 -38
  889. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -648
  890. 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
  891. 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
  892. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -1183
  893. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +0 -576
  894. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +0 -297
  895. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +0 -395
  896. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -903
  897. 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
  898. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -1178
  899. 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
  900. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -355
  901. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +0 -11
  902. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +0 -206
  903. 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
  904. 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
  905. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +0 -750
  906. 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
  907. 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
  908. 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
  909. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +0 -840
  910. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -856
  911. 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
  912. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -294
  913. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -1220
  914. 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
  915. package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +0 -840
  916. package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +0 -74
  917. package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +0 -34
  918. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +0 -2533
  919. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +0 -555
  920. package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -117
  921. package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +0 -937
  922. package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +0 -343
  923. package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +0 -76
  924. package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +0 -977
  925. package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +0 -188
  926. package/skills/hmos-integration-test/README.md +0 -341
  927. package/skills/hmos-integration-test/SKILL.md +0 -464
  928. package/skills/hmos-integration-test/scripts/report-tool.ts +0 -791
  929. package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +0 -125
  930. package/skills/hmos-integration-test/scripts/self-test-runner.ts +0 -756
  931. package/skills/hmos-integration-test/scripts/testcases-tool.ts +0 -239
  932. package/skills/hmos-resources-convert/SKILL.md +0 -891
  933. package/skills/hmos-spec-generate/SKILL.md +0 -404
  934. package/skills/hmos-test-case-generation/README.md +0 -241
  935. package/skills/hmos-test-case-generation/SKILL.md +0 -324
  936. package/skills/hmos-test-case-generation/references/contract.md +0 -315
  937. package/skills/hmos-test-case-generation/references/review-notes-template.md +0 -84
  938. package/skills/hmos-test-case-generation/references/ui-elements-schema.md +0 -142
  939. package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +0 -550
  940. package/skills/hmos-test-case-generation/tools/validate.ts +0 -1312
  941. package/tools/bfs-crawl/README.md +0 -73
  942. package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +0 -1662
  943. /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} +0 -0
  944. /package/{README.en.md → skills/a2h-arch-generate/scripts/module_create/har/consumer-rules.txt} +0 -0
  945. /package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -0
  946. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  947. /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" +0 -0
  948. /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" +0 -0
  949. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  950. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  951. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  952. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  953. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  954. /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" +0 -0
  955. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  956. /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" +0 -0
  957. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  958. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  959. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  960. /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" +0 -0
  961. /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" +0 -0
  962. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  963. /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" +0 -0
  964. /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" +0 -0
  965. /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" +0 -0
  966. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  967. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  968. /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" +0 -0
  969. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  970. /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" +0 -0
  971. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  972. /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" +0 -0
  973. /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" +0 -0
  974. /package/skills/{hmos-batch-ui-align → 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" +0 -0
  975. /package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/arkts-strict-patterns.md +0 -0
  976. /package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/known-patterns.md +0 -0
  977. /package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/rdb-entity-pattern.md +0 -0
  978. /package/skills/{hmos-resources-convert → a2h-resource-convert}/references/dependency-analysis-rules.md +0 -0
  979. /package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/svg_fidelity_check.ts +0 -0
  980. /package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.txt +0 -0
  981. /package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.xlsx +0 -0
@@ -0,0 +1,2760 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * compose_overlay.mjs — port of compose_overlay.py: detect NON-NAVIGATION UI states (overlays +
4
+ * data-state variants) for the UTG.
5
+ *
6
+ * compose_overlay.mjs <project_path> [--strings <values-zh/strings.xml>]
7
+ *
8
+ * Conventions:
9
+ * - file_text: Map<path, text> or plain object; screen2route: Map or object; overlay_names: Set/Map/object.
10
+ * - Tuples are arrays; tuple-keyed dicts (call_sites, callers_by_decl, ...) are Maps keyed by tupleKey().
11
+ * - resolveSource/resolveSources(file_rel, fn_name, screen2route, overlay_names, [call_index,
12
+ * gated_slot_ids, pager_page_ids, mode_gated_fns,] {kwargs}) — kwargs object uses the Python
13
+ * names (call_index, gated_slot_ids, pager_page_ids, mode_gated_fns, partial_tiers, return_path);
14
+ * buildResolverTiers() returns that object's three tier keys (spread it in).
15
+ * - Name-keyed results that are Python dicts are Maps (scanPagerPageNames, scanModeGatedNames,
16
+ * topLevelFunNames, buildImportIndex, _buildFlagLabels, _pagerTopLevelBranches ...).
17
+ * - Offsets are UTF-16 indices (equal to Python's unless the source holds astral chars).
18
+ * Determinism: Python str-sets iterated here become first-occurrence-ordered Sets:
19
+ * scanModeGatedNames flag set -> pyStrSetOrder (CPython order, compose_overlay.py:498-503),
20
+ * buildCallIndex per-file name set (setdefault winners — same file, so same result),
21
+ * _paramBoundIdents vals (used only when it has 1 member), _cbParamProviders (membership).
22
+ *
23
+ * Exports:
24
+ * CallIndex DECL_AMBIGUOUS DECL_IMPORTED DECL_SAME_FILE DECL_SAME_PACKAGE DECL_UNIQUE
25
+ * DECL_UNIQUE_VISIBLE DECL_UNRESOLVED DEF_RE DIALOG_PRIMS EMPTY_STATE_CALL_RE FUN_RE HERE
26
+ * MAIN_ACTIVITY MENU_PRIMS PAGER_RE SHEET_PRIMS VARIANT_GUARD _ACTIVITY_CLASS_RE _AMBIG_HOPS
27
+ * _ARM_SPLIT_RE _CALLBACK_PARAM_DECL _CALL_RE _CB_PROVIDER_MAX_HOPS _COMPOSABLE_PARAM_RE
28
+ * _DEVICE_ENV_APIS _DEVICE_ENV_WORD_RE _DP_LITERAL_RE _EXPANDABLE_PROOF_RE
29
+ * _FRAGMENT_ADAPTER_RE _FRAGMENT_CLASS_RE _GATED_CALL_RE _HOIST_MAX_HOPS _IDENT_CH _IDENT_RE
30
+ * _IF_HEAD_RE _IMPORT_RE _INITIAL_PAGE_KW_RE _LEAF_UI_PRIMS _LOCAL_CURRENT_ASSIGN_RE
31
+ * _M3_BREAKPOINTS_DP _MODE_ENTER_RE_TMPL _MODE_FLAG_DECL_RE _MODE_INTERACTIVE_RE
32
+ * _NAMED_ARG_RE _NULLABLE_CB_PARAM_RE _ON_PREFIX_RE _OPEN_TRIGGER_RE _ORIENTATION_CMP_RE
33
+ * _PAGER_BRANCH_HEAD_RE _PAGER_FIRST_CALL_RE _PAGER_STATE_ARG_RE _PAGER_STRUCTURAL_PRIMS
34
+ * _PAGER_WHEN_RE _PRIVATE_RE _ROUTE_CONST_RE _ROUTE_FILES _SEMANTIC_PARAMS _START_DEST_RE
35
+ * _STATE_DECL_RES _TIER_KEYS _TIER_LINTED _TOP_LEVEL_CALL_HEAD_RE _VIS_LOOKBEHIND
36
+ * _WHEN_ARROW_RE _WHEN_HEAD_RE _activityOwnerOfFile _armBounds _braceDepthAt
37
+ * _buildCalleeIndex _buildExpandableStateIndex _buildFlagLabels _cbParamProviders
38
+ * _deadStateFlags _declIsPrivate _declParams _enclosingCallbackParam
39
+ * _enclosingIfConditionsNames _enclosingWhenGroup _extractBalancedGenerous _fileInPackage
40
+ * _filterSourcesByCbParam _findExpandTrigger _findGatedContainer _findPrim
41
+ * _findRememberPagerState _flagLabelFor _funBodyRange _inferPagerInitialPage _innermostFnAt
42
+ * _isConfirmedExpandable _lintTiers _modeWrap _nullableCbGates _nullableCbParamsOf
43
+ * _pagerTopLevelBranches _paramBoundIdents _paramsEnd _passedArg _resolveHoistedGesture
44
+ * _resolveHoistedLabel _resolveIdentAcrossFiles _routePart _samePackageDir _sameSourceFile
45
+ * _semanticParams _sheetTopLevelCalls _skipString _splitTopLevelArgs
46
+ * _unwrapStructuralWrappers _variantOf ambiguousHops asCallIndex branchConditionAt
47
+ * buildCallIndex buildFunDeclIndex buildFunIndex buildImportIndex buildResolverTiers
48
+ * callSiteTitle classifyConditionKind classifyShared dupCalleeNames enclosingFn
49
+ * enclosingRenderConditions inferKind inferSurface lineOf main modeFlagIsInteractive
50
+ * modeNodeId norm ownBody readTextSmart rel relNorm rendersOwnOverlay resetAmbiguousHops
51
+ * resolveCalleeDecl resolveSource resolveSources routeNameIsLocal scanModeGatedNames
52
+ * scanPagerPageNames screenNameIsAmbiguous screenRouteMap setRouteFiles topLevelFunNames
53
+ */
54
+ import * as fs from 'node:fs';
55
+ import * as path from 'node:path';
56
+ import { pathToFileURL, fileURLToPath } from 'node:url';
57
+ import {
58
+ pyRe, reEscape, reFindall, pyStrip, pyLstrip, pyRstrip, pySplit, sortedBy, pyEq, pyRepr,
59
+ jsonLoads, jsonDumps, splitlines, pyPrintErr, subprocessRun, decodeReplace, pyInt, asFloat,
60
+ tupleKey, keysOf, dset, get, ArgumentParser, cpLen, cpSlice, pyStr, reprTuple, IS_WIN, pExists, SP, W,
61
+ pyStrSetOrder, pySetIter,
62
+ } from './_py.mjs';
63
+ import {
64
+ loadStrings, loadProjectStrings, nearestLabel, clickableLabel, enclosingGesture,
65
+ overlayIdentityText, templateFragments, _isTemplate, _LABEL_MAX, isCommentedOut,
66
+ } from './label_resolve.mjs';
67
+ import { readTextSmart } from './io_utils.mjs';
68
+ import * as _spawn from './_spawn.mjs';
69
+ import { _finditer, _searchIn } from './scope_utils.mjs';
70
+ import { _osWalk } from './layout_resolve.mjs';
71
+ import { inNestedNavGraph } from './compose_nav.mjs';
72
+
73
+ export { readTextSmart };
74
+
75
+ const S = String.raw;
76
+
77
+ // ---- small Python-compat helpers (module private) ------------------------ //
78
+ /** compiled pattern cache for dynamically built Python patterns. */
79
+ const _DYN = new Map();
80
+ function rx(p, flags = '') {
81
+ const k = flags + '\u0000' + p;
82
+ let r = _DYN.get(k);
83
+ if (!r) { r = pyRe(p, flags.includes('d') ? flags : flags + 'd'); _DYN.set(k, r); }
84
+ return r;
85
+ }
86
+ /** Python pattern -> RegExp with match indices ('d'), for m.start(g)/m.end(g). */
87
+ function P(p, flags = '') { return pyRe(p, flags + 'd'); }
88
+ /** rx.match(s, pos) (anchored at pos, sees chars before pos like CPython). */
89
+ function matchAt(re, s, pos = 0) {
90
+ const y = new RegExp(re.source, re.flags.replace(/[gy]/g, '') + 'y');
91
+ y.lastIndex = pos;
92
+ return y.exec(s);
93
+ }
94
+ /** rx.search(s). */
95
+ function search(re, s) { return _searchIn(re, s, 0, null); }
96
+ /** rx.finditer(s). */
97
+ function finditer(re, s, pos = 0, endpos = null) { return _finditer(re, s, pos, endpos); }
98
+ const mStart = (m, g = 0) => (g === 0 ? m.index : m.indices[g][0]);
99
+ const mEnd = (m, g = 0) => (g === 0 ? m.index + m[0].length : m.indices[g][1]);
100
+ /** str.rfind(sub, 0, end). */
101
+ function rfind(s, sub, start, end) {
102
+ if (end === undefined) { end = s.length; }
103
+ if (end < 0) { end = Math.max(0, s.length + end); }
104
+ if (end - sub.length < start) { return -1; }
105
+ const i = s.lastIndexOf(sub, end - sub.length);
106
+ return i >= start ? i : -1;
107
+ }
108
+ /** str.count(sub, start, end) for a single char. */
109
+ function countCh(s, ch, start = 0, end = s.length) {
110
+ let n = 0;
111
+ for (let i = Math.max(0, start); i < Math.min(end, s.length); i++) { if (s[i] === ch) { n++; } }
112
+ return n;
113
+ }
114
+ /** Python str.isupper() for a one-char string (cased char, all uppercase). */
115
+ function isUpperCh(c) { return !!c && c !== c.toLowerCase() && c === c.toUpperCase(); }
116
+ /** Python str.isupper(). */
117
+ function isUpper(s) {
118
+ let cased = false;
119
+ for (const c of s) {
120
+ if (c !== c.toLowerCase() || c !== c.toUpperCase()) { cased = true; if (c !== c.toUpperCase()) { return false; } }
121
+ }
122
+ return cased;
123
+ }
124
+ /** null-prototype dict. */
125
+ const dict = () => Object.create(null);
126
+ /** dict.setdefault(k, v). */
127
+ function setdefault(d, k, v) {
128
+ if (d instanceof Map) { if (!d.has(k)) { d.set(k, v); } return d.get(k); }
129
+ if (!Object.hasOwn(d, k)) { dset(d, k, v); }
130
+ return d[k];
131
+ }
132
+ /** file_text items: plain object or Map -> [[path, text]] in insertion order. */
133
+ function ftItems(ft) {
134
+ if (ft instanceof Map) { return [...ft]; }
135
+ return keysOf(ft).map((k) => [k, ft[k]]);
136
+ }
137
+ function ftGet(ft, k, dflt = undefined) {
138
+ if (ft instanceof Map) { return ft.has(k) ? ft.get(k) : dflt; }
139
+ return ft && Object.hasOwn(ft, k) ? ft[k] : dflt;
140
+ }
141
+ function ftHas(ft, k) { return ft instanceof Map ? ft.has(k) : !!ft && Object.hasOwn(ft, k); }
142
+ function ftValues(ft) { return ftItems(ft).map((x) => x[1]); }
143
+ function ftKeys(ft) { return ftItems(ft).map((x) => x[0]); }
144
+ function ftLen(ft) { return ft instanceof Map ? ft.size : ft ? keysOf(ft).length : 0; }
145
+ /** sorted(file_text.items()) (unique str keys -> by key). */
146
+ function ftSorted(ft) { return sortedBy(ftItems(ft), (x) => x[0]); }
147
+ /** generic d.get(k) for dict-like (Map / object). */
148
+ function dg(d, k, dflt = null) {
149
+ if (d === null || d === undefined) { return dflt; }
150
+ if (d instanceof Map) { return d.has(k) ? d.get(k) : dflt; }
151
+ return Object.hasOwn(d, k) ? d[k] : dflt;
152
+ }
153
+ function dh(d, k) { return d instanceof Map ? d.has(k) : d instanceof Set ? d.has(k) : !!d && Object.hasOwn(d, k); }
154
+ function dkeys(d) { return d instanceof Map || d instanceof Set ? [...d.keys()] : keysOf(d); }
155
+ function dlen(d) { return d instanceof Map || d instanceof Set ? d.size : keysOf(d).length; }
156
+ /** Python truthiness for a str/None/container. */
157
+ const T = (v) => !(v === null || v === undefined || v === false || v === '' || v === 0 ||
158
+ (Array.isArray(v) && !v.length) || ((v instanceof Map || v instanceof Set) && !v.size) ||
159
+ (typeof v === 'object' && !(v instanceof Map) && !(v instanceof Set) && !Array.isArray(v) && !keysOf(v).length));
160
+
161
+ // ---- what counts as an overlay definition, and its kind ------------------- //
162
+ export const HERE = path.dirname(fileURLToPath(import.meta.url));
163
+ export const DEF_RE = P(S`@Composable\s+(?:private\s+|internal\s+|public\s+)?fun\s+` +
164
+ S`([A-Z]\w*(?:Dialog|Popup))\s*\(`);
165
+ export const FUN_RE = P(S`(@Composable\s+)?(?:private\s+|internal\s+|public\s+|inline\s+)*` +
166
+ S`fun\s+(?:[A-Za-z_][\w<>,\s]*\.)?([A-Za-z_]\w*)\s*\(`);
167
+
168
+ export const SHEET_PRIMS = ['FullScreenColumnDialog', 'FullScreenWithCloseDialog',
169
+ 'FullScreenDialog', 'BottomSheetDialog'];
170
+ export const DIALOG_PRIMS = ['BasicDialog', 'YesDialog', 'YesNoDialog', 'InputDialog',
171
+ 'TextDialog', 'DialogColumn', 'Dialog('];
172
+ export const MENU_PRIMS = ['PopupMenu('];
173
+
174
+ export const _IDENT_CH = new Set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.');
175
+
176
+ export function _findPrim(body, prim) {
177
+ let start = 0;
178
+ for (;;) {
179
+ const i = body.indexOf(prim, start);
180
+ if (i < 0) { return -1; }
181
+ if (i === 0 || !_IDENT_CH.has(body[i - 1])) { return i; }
182
+ start = i + 1;
183
+ }
184
+ }
185
+
186
+ export function _paramsEnd(text, openParen) {
187
+ let depth = 0; let j = openParen; const n = text.length;
188
+ while (j < n) {
189
+ const c = text[j];
190
+ if (c === '"') {
191
+ if (text.startsWith('"""', j)) {
192
+ const k = text.indexOf('"""', j + 3);
193
+ j = k >= 0 ? k + 3 : n;
194
+ continue;
195
+ }
196
+ j += 1;
197
+ while (j < n) {
198
+ if (text[j] === '\\') { j += 2; continue; }
199
+ if (text[j] === '"') { j += 1; break; }
200
+ j += 1;
201
+ }
202
+ continue;
203
+ }
204
+ if (c === '(') { depth += 1; } else if (c === ')') {
205
+ depth -= 1;
206
+ if (depth === 0) { return j + 1; }
207
+ }
208
+ j += 1;
209
+ }
210
+ return openParen;
211
+ }
212
+
213
+ export function ownBody(text, declEnd, cap = 4000) {
214
+ if (cap !== null && typeof cap === 'object') { cap = cap.cap ?? 4000; }
215
+ let searchFrom = declEnd ? _paramsEnd(text, declEnd - 1) : declEnd;
216
+ if (searchFrom <= declEnd) { searchFrom = declEnd; }
217
+ const i = text.indexOf('{', searchFrom);
218
+ if (i < 0) { return text.slice(declEnd, declEnd + cap); }
219
+ let depth = 0; let j = i; const end = Math.min(text.length, i + cap);
220
+ while (j < end) {
221
+ const c = text[j];
222
+ if (c === '"') {
223
+ if (text.startsWith('"""', j)) {
224
+ const k = text.indexOf('"""', j + 3);
225
+ j = k >= 0 ? k + 3 : end;
226
+ continue;
227
+ }
228
+ j += 1;
229
+ while (j < end) {
230
+ if (text[j] === '\\') { j += 2; continue; }
231
+ if (text[j] === '"') { j += 1; break; }
232
+ j += 1;
233
+ }
234
+ continue;
235
+ }
236
+ if (c === "'") {
237
+ j += text.slice(j + 1, j + 2) !== '\\' ? 2 : 3;
238
+ if (text.slice(j, j + 1) === "'") { j += 1; }
239
+ continue;
240
+ }
241
+ if (c === '{') { depth += 1; } else if (c === '}') {
242
+ depth -= 1;
243
+ if (depth === 0) { return text.slice(i + 1, j); }
244
+ }
245
+ j += 1;
246
+ }
247
+ return text.slice(i + 1, end);
248
+ }
249
+
250
+ export function rendersOwnOverlay(body, overlays) {
251
+ for (const p of [...SHEET_PRIMS, ...DIALOG_PRIMS, ...MENU_PRIMS]) {
252
+ let i = _findPrim(body, p);
253
+ while (i >= 0) {
254
+ const head = body.slice(0, i + p.length);
255
+ let tok = '';
256
+ let k = head.length - p.length;
257
+ while (k > 0 && _IDENT_CH.has(head[k - 1]) && head[k - 1] !== '.') {
258
+ k -= 1;
259
+ tok = head[k] + tok;
260
+ }
261
+ const called = pyRstrip(tok + p, '(');
262
+ const meta = dg(overlays, called, null);
263
+ if (meta === null) { return true; }
264
+ if (search(_COMPOSABLE_PARAM_RE, dg(meta, 'params') || '')) { return true; }
265
+ const nxt = _findPrim(body.slice(i + 1), p);
266
+ i = nxt >= 0 ? i + 1 + nxt : -1;
267
+ }
268
+ }
269
+ return false;
270
+ }
271
+
272
+ // ---- pager pages ----------------------------------------------------------- //
273
+ export const PAGER_RE = P(S`\b(Horizontal|Vertical)Pager\s*(\()`);
274
+ export const _PAGER_WHEN_RE = P(S`\bwhen\s*\(\s*(\w+)\s*\)\s*\{`);
275
+ export const _PAGER_BRANCH_HEAD_RE = P(S`(?<!\w)(\d+)\s*->`);
276
+ export const _PAGER_FIRST_CALL_RE = P(S`\b([A-Z]\w+)\s*[({]`);
277
+ export const _PAGER_STATE_ARG_RE = P(S`\bstate\s*=\s*([A-Za-z_][\w.!]*)`);
278
+ export const _INITIAL_PAGE_KW_RE = P(S`initialPage\s*=\s*(\d+)`);
279
+ export const _FRAGMENT_ADAPTER_RE = P(S`\bcreateFragment\s*\(\s*\w+\s*:\s*Int\s*\)\s*:\s*Fragment\b`);
280
+ export const _PAGER_STRUCTURAL_PRIMS = new Set([
281
+ 'Box', 'BoxWithConstraints', 'Column', 'Row', 'LazyColumn', 'LazyRow',
282
+ 'Spacer', 'Surface', 'Card', 'ConstraintLayout', 'AnimatedVisibility',
283
+ 'AnimatedContent', 'CompositionLocalProvider', 'HorizontalPager',
284
+ 'VerticalPager', 'Crossfade', 'SubcomposeLayout', 'Layout',
285
+ ]);
286
+
287
+ export const _GATED_CALL_RE = P(S`\b([A-Z]\w+)\s*(\()`);
288
+ export const _NAMED_ARG_RE = P(S`^\s*([A-Za-z_]\w*)\s*=(?!=)\s*`);
289
+ export const _ON_PREFIX_RE = P(S`^on[A-Z]`);
290
+ export const _IDENT_RE = P(S`^\s*([A-Za-z_]\w*(?:\.\w+)*)\s*$`);
291
+ export const _EXPANDABLE_PROOF_RE = P(S`\b(\w+)\.(expand|show|open|collapse)\s*\(`);
292
+ export const _OPEN_TRIGGER_RE = P(S`\b(\w+)\.(expand|show|open)\s*\(`);
293
+
294
+ export const _START_DEST_RE = P(S`\bstartDestination\s*=\s*([A-Za-z_][\w.]*)`);
295
+ export const _ROUTE_CONST_RE = P(S`\bScreenRoute\.(\w+)`);
296
+ export const _LOCAL_CURRENT_ASSIGN_RE = P(S`\b(?:val|var)\s+(\w+)\s*=\s*(Local\w+)\.current\b`);
297
+ export const _TOP_LEVEL_CALL_HEAD_RE = P(S`\b([A-Z]\w+)\s*\(`);
298
+ export const _LEAF_UI_PRIMS = new Set([
299
+ 'Text', 'Icon', 'Image', 'Divider', 'HorizontalDivider', 'VerticalDivider',
300
+ 'Button', 'IconButton', 'TextButton', 'OutlinedButton',
301
+ 'FilledTonalButton', 'ElevatedButton', 'Checkbox', 'Switch', 'RadioButton',
302
+ 'Slider', 'ProgressIndicator', 'CircularProgressIndicator',
303
+ 'LinearProgressIndicator', 'AsyncImage', 'Chip', 'AssistChip', 'FilterChip',
304
+ ]);
305
+
306
+ const _WRAP_HEAD = P(S`([A-Za-z_]\w+)\s*(\()`);
307
+ const _BRACE_AFTER = P(S`\s*\{`);
308
+
309
+ export function _unwrapStructuralWrappers(body, maxDepth = 5) {
310
+ let cur = body;
311
+ for (let it = 0; it < maxDepth; it++) {
312
+ const stripped = pyLstrip(cur);
313
+ const m = matchAt(_WRAP_HEAD, stripped, 0);
314
+ if (!m || !_PAGER_STRUCTURAL_PRIMS.has(m[1])) { break; }
315
+ const lead = cur.length - stripped.length;
316
+ const parenStart = lead + mStart(m, 2);
317
+ const args = _extractBalancedGenerous(cur, parenStart);
318
+ if (args === null) { break; }
319
+ const callEnd = parenStart + 1 + args.length + 1;
320
+ const after = cur.slice(callEnd, callEnd + 40);
321
+ const bm = matchAt(_BRACE_AFTER, after, 0);
322
+ if (!bm) { break; }
323
+ const braceStart = callEnd + mEnd(bm) - 1;
324
+ const inner = _extractBalancedGenerous(cur, braceStart, '{', '}');
325
+ if (inner === null) { break; }
326
+ const tail = cur.slice(braceStart + 1 + inner.length + 1);
327
+ if (pyStrip(tail)) { break; }
328
+ cur = inner;
329
+ }
330
+ return cur;
331
+ }
332
+
333
+ export function _sheetTopLevelCalls(body) {
334
+ const calls = [];
335
+ let depth = 0;
336
+ let i = 0; const n = body.length;
337
+ while (i < n) {
338
+ if (depth === 0) {
339
+ const m = matchAt(_TOP_LEVEL_CALL_HEAD_RE, body, i);
340
+ if (m) {
341
+ const parenStart = mEnd(m) - 1;
342
+ const args = _extractBalancedGenerous(body, parenStart);
343
+ if (args === null) {
344
+ calls.push(m[1]);
345
+ i = mEnd(m);
346
+ continue;
347
+ }
348
+ let end = parenStart + 1 + args.length + 1;
349
+ const after = body.slice(end, end + 40);
350
+ const tm = matchAt(_BRACE_AFTER, after, 0);
351
+ if (tm) {
352
+ const braceStart = end + mEnd(tm) - 1;
353
+ const inner = _extractBalancedGenerous(body, braceStart, '{', '}');
354
+ if (inner !== null) { end = braceStart + 1 + inner.length + 1; }
355
+ }
356
+ calls.push(m[1]);
357
+ i = end;
358
+ continue;
359
+ }
360
+ }
361
+ const c = body[i];
362
+ if (c === '{' || c === '(') { depth += 1; } else if (c === '}' || c === ')') { depth -= 1; }
363
+ i += 1;
364
+ }
365
+ return calls;
366
+ }
367
+
368
+ export function _extractBalancedGenerous(text, start, openCh = '(', closeCh = ')', cap = 20000) {
369
+ if (start >= text.length || text[start] !== openCh) { return null; }
370
+ let depth = 0;
371
+ const end = Math.min(start + cap, text.length);
372
+ for (let i = start; i < end; i++) {
373
+ const c = text[i];
374
+ if (c === openCh) { depth += 1; } else if (c === closeCh) {
375
+ depth -= 1;
376
+ if (depth === 0) { return text.slice(start + 1, i); }
377
+ }
378
+ }
379
+ return null;
380
+ }
381
+
382
+ export const _MODE_FLAG_DECL_RE = P(
383
+ S`var\s+(\w*[Mm]ode)\s+by\s+remember\s*(?:\([^)]*\))?\s*\{\s*` +
384
+ S`mutableStateOf(?:<[^>]*>)?\(\s*false`);
385
+ export const _MODE_ENTER_RE_TMPL = S`\b{f}\s*=\s*true\b`;
386
+ export const _MODE_INTERACTIVE_RE = P(S`\bonClick\s*=|\.clickable\s*[({]|` +
387
+ S`\bonCheckedChange\s*=|\bon[A-Z]\w*Click\b`);
388
+ const _COMPONENT_CALL_RE = P(S`\b([A-Z]\w+)\s*[({]`);
389
+ const _CALL_PAREN_RE = P(S`\b([A-Z]\w+)\s*\(`);
390
+
391
+ export function modeFlagIsInteractive(text, flag) {
392
+ const enter = rx(_MODE_ENTER_RE_TMPL.replace('{f}', reEscape(flag)));
393
+ if (!finditer(enter, text).some((m) => !isCommentedOut(text, m.index))) { return false; }
394
+ for (const im of finditer(rx(S`\bif\s*\(\s*` + reEscape(flag) + S`\s*\)\s*\{`), text)) {
395
+ const body = _extractBalancedGenerous(text, mEnd(im) - 1, '{', '}');
396
+ if (!body) { continue; }
397
+ if (search(_MODE_INTERACTIVE_RE, body)) { return true; }
398
+ for (const cm of finditer(_COMPONENT_CALL_RE, body)) {
399
+ const nm = cm[1];
400
+ if (!_LEAF_UI_PRIMS.has(nm) && !_PAGER_STRUCTURAL_PRIMS.has(nm)) { return true; }
401
+ }
402
+ }
403
+ return false;
404
+ }
405
+
406
+ /** {composable name: mode flag} (Map, insertion order). Flag sets iterate in first-occurrence
407
+ * order (Python: str set, hash order) — matters only when one name is gated by two flags. */
408
+ export function scanModeGatedNames(fileText) {
409
+ const gated = new Map(); const ungated = new Set();
410
+ for (const text of ftValues(fileText)) {
411
+ // Python str-set comprehensions, iterated in CPython order (compose_overlay.py:498-503).
412
+ let flags = pyStrSetOrder(finditer(_MODE_FLAG_DECL_RE, text)
413
+ .filter((m) => !isCommentedOut(text, m.index)).map((m) => m[1]));
414
+ flags = pyStrSetOrder(flags.filter((f) => modeFlagIsInteractive(text, f)));
415
+ if (!flags.length) { continue; }
416
+ for (const flag of flags) {
417
+ for (const im of finditer(rx(S`\bif\s*\(\s*` + reEscape(flag) + S`\s*\)\s*\{`), text)) {
418
+ const body = _extractBalancedGenerous(text, mEnd(im) - 1, '{', '}');
419
+ if (body === null) { continue; }
420
+ for (const cm of finditer(_CALL_PAREN_RE, body)) {
421
+ const name = cm[1];
422
+ if (!_PAGER_STRUCTURAL_PRIMS.has(name) && !_LEAF_UI_PRIMS.has(name)) { setdefault(gated, name, flag); }
423
+ }
424
+ }
425
+ }
426
+ }
427
+ for (const text of ftValues(fileText)) {
428
+ for (const name of [...gated.keys()]) {
429
+ for (const cm of finditer(rx(S`\b` + reEscape(name) + S`\s*\(`), text)) {
430
+ if (isCommentedOut(text, cm.index)) { continue; }
431
+ const lo = Math.max(0, rfind(text, '\n', 0, cm.index));
432
+ if (search(rx(S`\bfun\s+(?:[\w.]+\.)?` + reEscape(name) + S`\s*\(`), text.slice(lo, mEnd(cm)))) { continue; }
433
+ const blk = _enclosingIfConditionsNames(text, cm.index);
434
+ if (!blk.has(gated.get(name))) { ungated.add(name); }
435
+ }
436
+ }
437
+ }
438
+ for (const name of ungated) { gated.delete(name); }
439
+ return gated;
440
+ }
441
+
442
+ const _IF_COND_RE = P(S`\bif\s*\(\s*([^)]{1,120}?)\s*\)\s*\{`);
443
+ const _WORD_RE = P(S`\w+`);
444
+
445
+ export function _enclosingIfConditionsNames(text, pos) {
446
+ const out = new Set();
447
+ for (const im of finditer(_IF_COND_RE, text)) {
448
+ const body = _extractBalancedGenerous(text, mEnd(im) - 1, '{', '}');
449
+ if (body === null) { continue; }
450
+ const start = mEnd(im) - 1;
451
+ if (start < pos && pos < start + 1 + body.length + 1) {
452
+ for (const w of reFindall(_WORD_RE, im[1])) { out.add(w); }
453
+ }
454
+ }
455
+ return out;
456
+ }
457
+
458
+ /** {composable name: "pager:<name>"} (Map). */
459
+ export function scanPagerPageNames(fileText) {
460
+ const out = new Map();
461
+ for (const text of ftValues(fileText)) {
462
+ for (const pm of finditer(PAGER_RE, text)) {
463
+ const parenStart = mStart(pm, 2);
464
+ const args = _extractBalancedGenerous(text, parenStart);
465
+ if (args === null) { continue; }
466
+ const callEnd = parenStart + 1 + args.length;
467
+ const bodyStart = text.indexOf('{', callEnd);
468
+ if (bodyStart === -1 || bodyStart > callEnd + 40) { continue; }
469
+ const body = _extractBalancedGenerous(text, bodyStart, '{', '}');
470
+ if (body === null) { continue; }
471
+ const wm = search(_PAGER_WHEN_RE, body);
472
+ if (!wm) { continue; }
473
+ const whenBody = _extractBalancedGenerous(body, mEnd(wm) - 1, '{', '}');
474
+ if (whenBody === null) { continue; }
475
+ for (const [, at] of _pagerTopLevelBranches(whenBody)) {
476
+ const cm = search(_PAGER_FIRST_CALL_RE, whenBody.slice(at, at + 300));
477
+ if (!cm || _PAGER_STRUCTURAL_PRIMS.has(cm[1])) { continue; }
478
+ setdefault(out, cm[1], 'pager:' + cm[1]);
479
+ }
480
+ }
481
+ }
482
+ return out;
483
+ }
484
+
485
+ /** Map<branch_index:int, pos after '->'> (insertion order like the Python dict). */
486
+ export function _pagerTopLevelBranches(body) {
487
+ const branches = new Map();
488
+ let depth = 0;
489
+ let i = 0; const n = body.length;
490
+ while (i < n) {
491
+ const c = body[i];
492
+ if (c === '{' || c === '(') { depth += 1; i += 1; continue; }
493
+ if (c === '}' || c === ')') { depth -= 1; i += 1; continue; }
494
+ if (depth === 0) {
495
+ const m = matchAt(_PAGER_BRANCH_HEAD_RE, body, i);
496
+ if (m) {
497
+ branches.set(Number(pyInt(m[1])), mEnd(m));
498
+ i = mEnd(m);
499
+ continue;
500
+ }
501
+ }
502
+ i += 1;
503
+ }
504
+ return branches;
505
+ }
506
+
507
+ /** [initial_page, true] or null. */
508
+ export function _findRememberPagerState(ident, text) {
509
+ const dm = search(rx(reEscape(ident) + S`\s*=\s*rememberPagerState\s*([({])`), text);
510
+ if (!dm) { return null; }
511
+ if (dm[1] === '{') { return [0, true]; }
512
+ const declArgs = _extractBalancedGenerous(text, mEnd(dm) - 1);
513
+ if (declArgs === null) { return null; }
514
+ const im = search(_INITIAL_PAGE_KW_RE, declArgs);
515
+ return im ? [Number(pyInt(im[1])), true] : [0, true];
516
+ }
517
+
518
+ export function _inferPagerInitialPage(text, pagerCallStart, fileText = null) {
519
+ if (fileText !== null && typeof fileText === 'object' && Object.hasOwn(fileText, 'file_text') && !(fileText instanceof Map)) {
520
+ fileText = fileText.file_text;
521
+ }
522
+ const argsWindow = text.slice(pagerCallStart, Math.min(text.length, pagerCallStart + 4000));
523
+ const sm = search(_PAGER_STATE_ARG_RE, argsWindow);
524
+ if (!sm) { return [0, false]; }
525
+ const raw = pyRstrip(sm[1], '!');
526
+ const parts = raw.split('.');
527
+ const ident = pyStrip(parts[parts.length - 1]);
528
+ const hit = _findRememberPagerState(ident, text);
529
+ if (hit !== null) { return hit; }
530
+ if (!fileText || !ftLen(fileText)) { return [0, false]; }
531
+ for (const argName of _paramBoundIdents(ident, text, pagerCallStart, fileText)) {
532
+ const h2 = _resolveIdentAcrossFiles(argName, text, fileText);
533
+ if (h2 !== null) { return h2; }
534
+ }
535
+ const h3 = _resolveIdentAcrossFiles(ident, text, fileText);
536
+ return h3 !== null ? h3 : [0, false];
537
+ }
538
+
539
+ export function _resolveIdentAcrossFiles(ident, text, fileText) {
540
+ const found = [];
541
+ for (const [, t] of ftSorted(fileText)) {
542
+ const h = _findRememberPagerState(ident, t);
543
+ if (h !== null) { found.push(h); }
544
+ }
545
+ if (found.length === 1) { return found[0]; }
546
+ if (found.length && found.every((f) => f[0] === found[0][0] && f[1] === found[0][1])) { return found[0]; }
547
+ return null;
548
+ }
549
+
550
+ const _PARAM_NAME_RE = P(S`\s*(?:val\s+|var\s+)?([A-Za-z_]\w*)\s*:`);
551
+
552
+ export function _paramBoundIdents(param, text, pagerCallStart, fileText) {
553
+ const funs = buildFunIndex(text);
554
+ const host = enclosingFn(funs, pagerCallStart);
555
+ if (!host) { return []; }
556
+ const decl = search(rx(S`\bfun\s+` + reEscape(host) + S`\s*\(`), text);
557
+ if (!decl) { return []; }
558
+ const plist = _extractBalancedGenerous(text, mEnd(decl) - 1);
559
+ if (plist === null) { return []; }
560
+ const names = [];
561
+ for (const [nm, val] of _splitTopLevelArgs(plist)) {
562
+ const m = matchAt(_PARAM_NAME_RE, nm || val || '', 0);
563
+ if (m) { names.push(m[1]); }
564
+ }
565
+ if (!names.includes(param)) { return []; }
566
+ const pIdx = names.indexOf(param);
567
+ const vals = new Set();
568
+ const callRe = rx(S`\b` + reEscape(host) + S`\s*\(`);
569
+ const declRe = rx(S`\bfun\s+` + reEscape(host) + S`\s*$`);
570
+ for (const [, t] of ftSorted(fileText)) {
571
+ for (const cm of finditer(callRe, t)) {
572
+ if (search(declRe, t.slice(0, mEnd(cm) - 1))) { continue; }
573
+ const args = _extractBalancedGenerous(t, mEnd(cm) - 1);
574
+ if (args === null) { continue; }
575
+ const parts = _splitTopLevelArgs(args);
576
+ let picked = null;
577
+ for (const [nm, val] of parts) {
578
+ if (nm && pyStrip(nm) === param) { picked = val; break; }
579
+ }
580
+ if (picked === null && parts.length > pIdx && !parts[pIdx][0]) { picked = parts[pIdx][1]; }
581
+ if (picked) {
582
+ const segs = pyRstrip(pyStrip(picked), '!').split('.');
583
+ vals.add(pyStrip(segs[segs.length - 1]));
584
+ }
585
+ }
586
+ }
587
+ return vals.size === 1 ? [...vals] : [];
588
+ }
589
+
590
+ /** [[name_or_null, value_text], ...] */
591
+ export function _splitTopLevelArgs(argtext) {
592
+ const segs = []; let depth = 0; let start = 0; const n = argtext.length;
593
+ for (let i = 0; i < n; i++) {
594
+ const c = argtext[i];
595
+ if (c === '(' || c === '[' || c === '{') { depth += 1; } else if (c === ')' || c === ']' || c === '}') { depth -= 1; }
596
+ else if (c === ',' && depth === 0) { segs.push(argtext.slice(start, i)); start = i + 1; }
597
+ }
598
+ segs.push(argtext.slice(start));
599
+ const out = [];
600
+ for (const seg of segs) {
601
+ const m = matchAt(_NAMED_ARG_RE, seg, 0);
602
+ out.push(m ? [m[1], seg.slice(mEnd(m))] : [null, seg]);
603
+ }
604
+ return out;
605
+ }
606
+
607
+ /** [state_ident, [slot names]] or [null, []]. */
608
+ export function _findGatedContainer(argtext) {
609
+ const args = _splitTopLevelArgs(argtext);
610
+ let stateIdent = null;
611
+ for (const [name, val] of args) {
612
+ if (name && name.toLowerCase() === 'state') {
613
+ const m = matchAt(_IDENT_RE, val, 0);
614
+ if (m) { stateIdent = m[1]; }
615
+ }
616
+ }
617
+ if (!stateIdent) { return [null, []]; }
618
+ const slots = args.filter(([name, val]) => name && !matchAt(_ON_PREFIX_RE, name, 0) &&
619
+ name.toLowerCase() !== 'state' && pyLstrip(val).startsWith('{')).map((a) => a[0]);
620
+ return [stateIdent, slots];
621
+ }
622
+
623
+ /** [sameFileExpandable Map<path, Set>, perFileLocalDerived Map<path, Map>, localsWithExpandConsumer Set] */
624
+ export function _buildExpandableStateIndex(fileText) {
625
+ const sameFile = new Map(); const perFile = new Map();
626
+ for (const [p, text] of ftItems(fileText)) {
627
+ sameFile.set(p, new Set(finditer(_EXPANDABLE_PROOF_RE, text).map((m) => m[1])));
628
+ perFile.set(p, new Map(reFindall(_LOCAL_CURRENT_ASSIGN_RE, text).map((t) => [t[0], t[1]])));
629
+ }
630
+ const consumers = new Set();
631
+ for (const [p, derived] of perFile) {
632
+ const expandable = sameFile.get(p);
633
+ for (const [ident, localName] of derived) { if (expandable.has(ident)) { consumers.add(localName); } }
634
+ }
635
+ return [sameFile, perFile, consumers];
636
+ }
637
+
638
+ export function _isConfirmedExpandable(p, stateIdent, expandableIndex) {
639
+ const [sameFile, perFile, consumers] = expandableIndex;
640
+ if ((sameFile.get(p) ?? new Set()).has(stateIdent)) { return true; }
641
+ const localName = (perFile.get(p) ?? new Map()).get(stateIdent);
642
+ return !!localName && consumers.has(localName);
643
+ }
644
+
645
+ /** [path, pos] or [null, null]. */
646
+ export function _findExpandTrigger(p, stateIdent, fileText, expandableIndex) {
647
+ const text = ftGet(fileText, p);
648
+ for (const m of finditer(_OPEN_TRIGGER_RE, text)) { if (m[1] === stateIdent) { return [p, m.index]; } }
649
+ const [, perFile, consumers] = expandableIndex;
650
+ const localName = (perFile.get(p) ?? new Map()).get(stateIdent);
651
+ if (!localName || !consumers.has(localName)) { return [null, null]; }
652
+ for (const [otherPath, derived] of perFile) {
653
+ for (const [ident, ln] of derived) {
654
+ if (ln !== localName) { continue; }
655
+ const otherText = ftGet(fileText, otherPath);
656
+ for (const m of finditer(_OPEN_TRIGGER_RE, otherText)) { if (m[1] === ident) { return [otherPath, m.index]; } }
657
+ }
658
+ }
659
+ return [null, null];
660
+ }
661
+
662
+ export const MAIN_ACTIVITY = 'activity:MainActivity';
663
+ export const EMPTY_STATE_CALL_RE = P(S`\b(Empty\w*Box|Empty\w*State|NoneBox|NoData\w*|NoItems\w*|EmptyView)\s*\(`);
664
+ export const VARIANT_GUARD = { empty: 'no data found', populated: 'content populated' };
665
+
666
+ export function norm(p) { return String(p).replace(/\\/g, '/'); }
667
+
668
+ export function rel(p, project) {
669
+ const q = norm(p);
670
+ const pr = pyRstrip(norm(project), '/');
671
+ return q.startsWith(pr) ? q.slice(pr.length + 1) : q;
672
+ }
673
+
674
+ export function lineOf(text, pos) { return countCh(text, '\n', 0, pos) + 1; }
675
+
676
+ /** Reuse compose_nav to get {ScreenName: ROUTE_KEY} (Map); with want_files also Map<name, Set<file>>. */
677
+ export function screenRouteMap(project, wantFiles = false) {
678
+ if (wantFiles !== null && typeof wantFiles === 'object') { wantFiles = !!wantFiles.want_files; }
679
+ const r = subprocessRun(_spawn.stageArgv('compose_nav', project));
680
+ const stdout = decodeReplace(r.stdout).replace(/\r\n?/g, '\n');
681
+ const m = new Map(); const files = new Map();
682
+ for (const ln of splitlines(stdout)) {
683
+ let d;
684
+ try { d = jsonLoads(ln); } catch (e) { if (e && e.name === 'JSONDecodeError') { continue; } throw e; }
685
+ if (get(d, 'type') === 'route') {
686
+ m.set(d.screen, d.route_key);
687
+ if (T(get(d, 'file'))) {
688
+ setdefault(files, d.screen, new Set()).add(pyStr(d.file).replace(/\\/g, '/'));
689
+ }
690
+ }
691
+ }
692
+ return wantFiles ? [m, files] : m;
693
+ }
694
+
695
+ export const _SEMANTIC_PARAMS = ['title', 'content', 'text', 'message', 'label', 'subtitle'];
696
+ export const _COMPOSABLE_PARAM_RE = P(S`@Composable`);
697
+
698
+ export function _declParams(text, parenPos) {
699
+ let depth = 0;
700
+ for (let j = parenPos; j < Math.min(text.length, parenPos + 8000); j++) {
701
+ if (text[j] === '(') { depth += 1; } else if (text[j] === ')') {
702
+ depth -= 1;
703
+ if (depth === 0) { return text.slice(parenPos + 1, j); }
704
+ }
705
+ }
706
+ return '';
707
+ }
708
+
709
+ export function _semanticParams(params) {
710
+ return _SEMANTIC_PARAMS.filter((p) => search(rx(S`(?:^|[(,\s])` + p + S`\s*:`), params));
711
+ }
712
+
713
+ /** [value, key] (either may be null). */
714
+ export function callSiteTitle(text, callPos, strings) {
715
+ const paren = text.indexOf('(', callPos);
716
+ if (paren < 0) { return [null, null]; }
717
+ const args = _extractBalancedGenerous(text, paren);
718
+ if (!args) { return [null, null]; }
719
+ let fallback = null;
720
+ for (const p of _SEMANTIC_PARAMS) {
721
+ let m = search(rx(p + S`\s*=\s*(?:\w+(?:\.\w+)*\.)?` +
722
+ S`(?:stringResource|getString)\(\s*(?:id\s*=\s*)?` +
723
+ S`R\.string\.(\w+)\s*(?=[),])`, 's'), args);
724
+ if (m) {
725
+ const key = m[1];
726
+ const val = dg(strings, key, null);
727
+ let cand;
728
+ if (val && !_isTemplate(val)) { cand = val; } else {
729
+ const frags = val ? templateFragments(val) : [];
730
+ cand = frags.length ? frags[0] : val;
731
+ }
732
+ if (cand) {
733
+ if (cpLen(cand) <= _LABEL_MAX) { return [cand, key]; }
734
+ fallback = fallback || [cand, key];
735
+ }
736
+ }
737
+ m = search(rx(p + S`\s*=\s*"([^"{}$]{1,40})"`, 's'), args);
738
+ if (m && pyStrip(m[1])) { return [m[1], null]; }
739
+ }
740
+ return fallback ? fallback : [null, null];
741
+ }
742
+
743
+ export function classifyShared(params, identity, callSiteFiles) {
744
+ if (T(identity)) { return 'page'; }
745
+ if (search(_COMPOSABLE_PARAM_RE, params || '')) { return 'shell'; }
746
+ if (_semanticParams(params || '').length && callSiteFiles >= 2) { return 'template'; }
747
+ return 'page';
748
+ }
749
+
750
+ export function inferKind(body) {
751
+ let first = null; let best = Infinity;
752
+ for (const p of [...SHEET_PRIMS, ...DIALOG_PRIMS, ...MENU_PRIMS]) {
753
+ const i = _findPrim(body, p);
754
+ if (i >= 0 && i < best) { best = i; first = p; }
755
+ }
756
+ if (first === null) { return 'dialog'; }
757
+ if (SHEET_PRIMS.includes(first)) { return 'sheet'; }
758
+ if (MENU_PRIMS.includes(first)) { return 'menu'; }
759
+ return 'dialog';
760
+ }
761
+
762
+ /** [[pos, name, is_composable], ...] */
763
+ export function buildFunIndex(text) {
764
+ return finditer(FUN_RE, text).map((m) => [m.index, m[2], m[1] !== undefined && m[1] !== '']);
765
+ }
766
+
767
+ export const _VIS_LOOKBEHIND = 64;
768
+ export const _PRIVATE_RE = P(S`\bprivate\b`);
769
+
770
+ export function _braceDepthAt(text, pos) {
771
+ let d = 0; let i = 0; const n = text.length;
772
+ while (i < pos && i < n) {
773
+ const c = text[i];
774
+ if (c === '"') {
775
+ if (text.startsWith('"""', i)) {
776
+ const j = text.indexOf('"""', i + 3);
777
+ i = j !== -1 ? j + 3 : n;
778
+ continue;
779
+ }
780
+ i += 1;
781
+ while (i < n && text[i] !== '"') { if (text[i] === '\\') { i += 1; } i += 1; }
782
+ i += 1;
783
+ continue;
784
+ }
785
+ if (c === "'") {
786
+ i += 1;
787
+ while (i < n && text[i] !== "'") { if (text[i] === '\\') { i += 1; } i += 1; }
788
+ i += 1;
789
+ continue;
790
+ }
791
+ if (c === '/' && i + 1 < n && text[i + 1] === '/') {
792
+ const j = text.indexOf('\n', i);
793
+ i = j !== -1 ? j + 1 : n;
794
+ continue;
795
+ }
796
+ if (c === '/' && i + 1 < n && text[i + 1] === '*') {
797
+ const j = text.indexOf('*/', i);
798
+ i = j !== -1 ? j + 2 : n;
799
+ continue;
800
+ }
801
+ if (c === '{') { d += 1; } else if (c === '}') { d -= 1; }
802
+ i += 1;
803
+ }
804
+ return d;
805
+ }
806
+
807
+ export function _declIsPrivate(text, declStart, nameEnd) {
808
+ const lo = Math.max(0, declStart - _VIS_LOOKBEHIND);
809
+ let head = text.slice(lo, nameEnd);
810
+ for (const sep of ['\n\n', ';', '}', '{']) {
811
+ const idx = head.lastIndexOf(sep);
812
+ if (idx !== -1) { head = head.slice(idx + sep.length); }
813
+ }
814
+ return !!search(_PRIVATE_RE, head);
815
+ }
816
+
817
+ /** [[pos, name, is_composable, is_private], ...] */
818
+ export function buildFunDeclIndex(text) {
819
+ return finditer(FUN_RE, text).map((m) => [m.index, m[2], m[1] !== undefined && m[1] !== '',
820
+ _declIsPrivate(text, m.index, mEnd(m))]);
821
+ }
822
+
823
+ /** Map<name, is_private> of top-level funs. */
824
+ export function topLevelFunNames(text) {
825
+ const out = new Map();
826
+ for (const [pos, name, , isPriv] of buildFunDeclIndex(text)) {
827
+ if (_braceDepthAt(text, pos) !== 0) { continue; }
828
+ out.set(name, !out.has(name) ? isPriv : (out.get(name) && isPriv));
829
+ }
830
+ return out;
831
+ }
832
+
833
+ export function enclosingFn(funs, pos) {
834
+ let comp = null; let plain = null;
835
+ for (const [start, nm, isComp] of funs) {
836
+ if (start <= pos) {
837
+ if (isComp) { comp = nm; }
838
+ plain = nm;
839
+ } else { break; }
840
+ }
841
+ return comp || plain;
842
+ }
843
+
844
+ export const _ACTIVITY_CLASS_RE = P(S`\bclass\s+([A-Za-z_]\w*)\s*:\s*(?:[\w.]+\.)?\w*Activity\b`);
845
+ export const _FRAGMENT_CLASS_RE = P(S`\bclass\s+([A-Za-z_]\w*)\s*:\s*(?:[\w.]+\.)?\w*Fragment\b`);
846
+ export const _CALL_RE = P(S`\b([A-Z]\w+)\s*[({]`);
847
+ const _LBRACE_RE = P(S`\{`);
848
+ const _EQ_RE = P(S`=`);
849
+
850
+ /** [body_start, body_end] or null. */
851
+ export function _funBodyRange(text, declStart) {
852
+ const parenStart = text.indexOf('(', declStart);
853
+ if (parenStart === -1) { return null; }
854
+ const args = _extractBalancedGenerous(text, parenStart);
855
+ if (args === null) { return null; }
856
+ const after = parenStart + 1 + args.length + 1;
857
+ const windowEnd = Math.min(text.length, after + 200);
858
+ const seg = text.slice(after, windowEnd);
859
+ const braceM = search(_LBRACE_RE, seg);
860
+ const eqM = search(_EQ_RE, seg);
861
+ if (!braceM || (eqM && eqM.index < braceM.index)) { return null; }
862
+ const braceStart = after + braceM.index;
863
+ const body = _extractBalancedGenerous(text, braceStart, '{', '}');
864
+ if (body === null) { return null; }
865
+ return [braceStart, braceStart + 1 + body.length + 1];
866
+ }
867
+
868
+ export function _innermostFnAt(ranges, pos) {
869
+ let bestName = null; let bestSpan = null;
870
+ for (const [start, end, name] of ranges) {
871
+ if (start <= pos && pos < end) {
872
+ const span = end - start;
873
+ if (bestSpan === null || span < bestSpan) { bestName = name; bestSpan = span; }
874
+ }
875
+ }
876
+ return bestName;
877
+ }
878
+
879
+ /**
880
+ * build_call_index()'s result (Python NamedTuple). Fields keep the Python names:
881
+ * screens Set, callee_to_callers Map<name, [caller]>, activity_owner_by_fn Map<name, id>,
882
+ * call_sites Map<tupleKey(callee, caller), [[path, pos]]>, fn_decls Map<name, [[file, priv]]>,
883
+ * callers_by_decl Map<tupleKey(name, decl_file), [caller]>, imports_by_file Map<path, Map>,
884
+ * activity_owner_by_file Map, decl_file_count Map<name, int>, fragment_owner_by_file Map.
885
+ * Iterable like the tuple (positional order).
886
+ */
887
+ export class CallIndex {
888
+ constructor(screens, calleeToCallers, activityOwnerByFn, callSites, fnDecls = new Map(),
889
+ callersByDecl = new Map(), opts = {}) {
890
+ this.screens = screens;
891
+ this.callee_to_callers = calleeToCallers;
892
+ this.activity_owner_by_fn = activityOwnerByFn;
893
+ this.call_sites = callSites;
894
+ this.fn_decls = fnDecls;
895
+ this.callers_by_decl = callersByDecl;
896
+ this.imports_by_file = opts.imports_by_file ?? new Map();
897
+ this.activity_owner_by_file = opts.activity_owner_by_file ?? new Map();
898
+ this.decl_file_count = opts.decl_file_count ?? new Map();
899
+ this.fragment_owner_by_file = opts.fragment_owner_by_file ?? new Map();
900
+ }
901
+ *[Symbol.iterator]() {
902
+ yield* [this.screens, this.callee_to_callers, this.activity_owner_by_fn, this.call_sites,
903
+ this.fn_decls, this.callers_by_decl, this.imports_by_file, this.activity_owner_by_file,
904
+ this.decl_file_count, this.fragment_owner_by_file];
905
+ }
906
+ }
907
+
908
+ export const DECL_SAME_FILE = 'same-file';
909
+ export const DECL_UNIQUE = 'unique';
910
+ export const DECL_UNIQUE_VISIBLE = 'unique-visible';
911
+ export const DECL_IMPORTED = 'imported';
912
+ export const DECL_SAME_PACKAGE = 'same-package';
913
+ export const DECL_AMBIGUOUS = 'ambiguous';
914
+ export const DECL_UNRESOLVED = 'unresolved';
915
+
916
+ /** refused hops: [[callee, why, from_file], ...] */
917
+ export const _AMBIG_HOPS = [];
918
+ /** Map<ScreenName, Set<file>> */
919
+ export const _ROUTE_FILES = new Map();
920
+
921
+ export function setRouteFiles(files) {
922
+ _ROUTE_FILES.clear();
923
+ if (files) {
924
+ for (const [k, v] of (files instanceof Map ? files : ftItems(files))) { _ROUTE_FILES.set(k, v); }
925
+ }
926
+ }
927
+
928
+ const _rfLen = (v) => (!v ? 0 : v instanceof Set || v instanceof Map ? v.size : v.length);
929
+
930
+ export function screenNameIsAmbiguous(screen, declFileCount = null) {
931
+ if (!screen || !declFileCount || !dlen(declFileCount)) { return false; }
932
+ const n = dg(declFileCount, screen, 0);
933
+ return n > Math.max(1, _rfLen(_ROUTE_FILES.get(screen)));
934
+ }
935
+
936
+ export function routeNameIsLocal(screen, fileRel, declFileCount = null) {
937
+ if (!screen) { return false; }
938
+ if (declFileCount !== null && dg(declFileCount, screen, 0) <= 1) { return true; }
939
+ const known = _ROUTE_FILES.get(screen);
940
+ if (!known || !_rfLen(known)) { return true; }
941
+ if (declFileCount !== null && dg(declFileCount, screen, 0) <= _rfLen(known)) { return true; }
942
+ if (!fileRel) { return true; }
943
+ const want = pyStr(fileRel).replace(/\\/g, '/');
944
+ const tail = (s) => { const i = s.lastIndexOf('/'); return i < 0 ? s : s.slice(i + 1); };
945
+ for (const k of known) {
946
+ if (k.endsWith(want) || want.endsWith(k)) { return true; }
947
+ if (tail(k) === tail(want)) { return true; }
948
+ }
949
+ return false;
950
+ }
951
+
952
+ export function resetAmbiguousHops() { _AMBIG_HOPS.length = 0; }
953
+
954
+ /** sorted(set(_AMBIG_HOPS)) */
955
+ export function ambiguousHops() {
956
+ const seen = new Map();
957
+ for (const h of _AMBIG_HOPS) { const k = tupleKey(...h); if (!seen.has(k)) { seen.set(k, h); } }
958
+ return sortedBy([...seen.values()], (x) => x);
959
+ }
960
+
961
+ const _keyParts = (k) => (typeof k === 'string' && k.startsWith('[') ? JSON.parse(k) : k);
962
+
963
+ export function dupCalleeNames(callIndex) {
964
+ const ci = asCallIndex(callIndex);
965
+ if (ci === null) { return []; }
966
+ const fnDecls = ci.fn_decls || new Map();
967
+ const reachable = new Set(dkeys(ci.callee_to_callers));
968
+ for (const k of dkeys(ci.callers_by_decl || new Map())) { reachable.add(_keyParts(k)[0]); }
969
+ const out = [];
970
+ for (const name of sortedBy([...reachable], (x) => x)) {
971
+ const files = new Set((dg(fnDecls, name, null) || []).map((x) => x[0]));
972
+ if (files.size > 1) { out.push(name); }
973
+ }
974
+ return out;
975
+ }
976
+
977
+ const _lstripDotSlash = (s) => s.replace(/^[./]+/, '');
978
+
979
+ export function _sameSourceFile(a, b) {
980
+ if (!a || !b) { return false; }
981
+ const na = _lstripDotSlash(norm(a)); const nb = _lstripDotSlash(norm(b));
982
+ if (na === nb) { return true; }
983
+ return na.endsWith('/' + nb) || nb.endsWith('/' + na);
984
+ }
985
+
986
+ // `^\s*import\s+([\w.]+)\s*$` with re.M: Python line anchors break only on "\n".
987
+ export const _IMPORT_RE = P('(?<![^\n])[' + SP + ']*' +
988
+ S`import\s+([\w.]+)` + '[' + SP + ']*(?![^\n])');
989
+
990
+ /** Map<simple_name, package>. */
991
+ export function buildImportIndex(text) {
992
+ const out = new Map();
993
+ for (const m of finditer(_IMPORT_RE, text)) {
994
+ const fqn = m[1];
995
+ if (!fqn.includes('.')) { continue; }
996
+ const i = fqn.lastIndexOf('.');
997
+ const pkg = fqn.slice(0, i); const simple = fqn.slice(i + 1);
998
+ if (simple && isUpperCh(simple[0])) { setdefault(out, simple, pkg); }
999
+ }
1000
+ return out;
1001
+ }
1002
+
1003
+ export function _fileInPackage(p, pkg) {
1004
+ return ('/' + _lstripDotSlash(norm(p))).includes('/' + pkg.replace(/\./g, '/') + '/');
1005
+ }
1006
+
1007
+ export function _samePackageDir(a, b) {
1008
+ if (!a || !b) { return false; }
1009
+ const dir = (s) => { const t = _lstripDotSlash(norm(s)); const i = t.lastIndexOf('/'); return i < 0 ? '' : t.slice(0, i); };
1010
+ const da = dir(a); const db = dir(b);
1011
+ if (!da || !db) { return false; }
1012
+ return da === db || da.endsWith('/' + db) || db.endsWith('/' + da);
1013
+ }
1014
+
1015
+ const _sortedUnique = (xs) => sortedBy([...new Set(xs)], (x) => x);
1016
+
1017
+ /** [decl_file | null, why]. */
1018
+ export function resolveCalleeDecl(name, fromFile, fnDecls, imports = null) {
1019
+ const decls = dg(fnDecls, name, null) || [];
1020
+ if (!decls.length) { return [null, DECL_UNRESOLVED]; }
1021
+ const files = _sortedUnique(decls.map((d) => d[0]));
1022
+ if (files.length === 1) { return [files[0], DECL_UNIQUE]; }
1023
+ if (fromFile !== null && fromFile !== undefined) {
1024
+ for (const f of files) { if (_sameSourceFile(f, fromFile)) { return [f, DECL_SAME_FILE]; } }
1025
+ }
1026
+ const pkg = dg(imports || new Map(), name, null);
1027
+ if (pkg) {
1028
+ const hit = _sortedUnique(decls.filter(([f, priv]) => !priv && _fileInPackage(f, pkg)).map((d) => d[0]));
1029
+ if (hit.length === 1) { return [hit[0], DECL_IMPORTED]; }
1030
+ }
1031
+ const visible = _sortedUnique(decls.filter((d) => !d[1]).map((d) => d[0]));
1032
+ if (visible.length > 1 && fromFile !== null && fromFile !== undefined) {
1033
+ const samePkg = _sortedUnique(visible.filter((f) => _samePackageDir(f, fromFile)));
1034
+ if (samePkg.length === 1) { return [samePkg[0], DECL_SAME_PACKAGE]; }
1035
+ }
1036
+ if (visible.length === 1) { return [visible[0], DECL_UNIQUE_VISIBLE]; }
1037
+ if (visible.length > 1) { return [null, DECL_AMBIGUOUS]; }
1038
+ return [null, DECL_UNRESOLVED];
1039
+ }
1040
+
1041
+ /** Coerce to CallIndex (accepts an array/iterable of 3+ positional parts). */
1042
+ export function asCallIndex(ci) {
1043
+ if (ci instanceof CallIndex) { return ci; }
1044
+ if (ci === null || ci === undefined) { return null; }
1045
+ const parts = [...ci];
1046
+ if (parts.length === 3) { return new CallIndex(parts[0], parts[1], parts[2], new Map()); }
1047
+ const [a, b, c, d, e, f, g, h, i, j] = parts;
1048
+ return new CallIndex(a, b, c, d, e ?? new Map(), f ?? new Map(), {
1049
+ imports_by_file: g, activity_owner_by_file: h, decl_file_count: i, fragment_owner_by_file: j,
1050
+ });
1051
+ }
1052
+
1053
+ /** The one Activity whose file holds every `caller -> callee` call site, else null. */
1054
+ export function _siteActivity(ci, callee, caller) {
1055
+ const sites = ci.call_sites ? (dg(ci.call_sites, tupleKey(callee, caller), null) || []) : [];
1056
+ if (!sites.length) { return null; }
1057
+ const owners = new Set(sites.map(([p]) => _activityOwnerOfFile(p, ci.activity_owner_by_file || new Map())));
1058
+ if (owners.size !== 1) { return null; }
1059
+ const [only] = owners;
1060
+ return only ?? null;
1061
+ }
1062
+
1063
+ export function _activityOwnerOfFile(fileRel, activityOwnerByFile) {
1064
+ if (!fileRel || !activityOwnerByFile || !dlen(activityOwnerByFile)) { return null; }
1065
+ const hit = dg(activityOwnerByFile, fileRel, null);
1066
+ if (hit !== null) { return hit; }
1067
+ const want = _lstripDotSlash(pyStr(fileRel).replace(/\\/g, '/'));
1068
+ for (const k of dkeys(activityOwnerByFile)) {
1069
+ const kk = pyStr(k).replace(/\\/g, '/');
1070
+ if (kk.endsWith('/' + want) || want.endsWith('/' + kk) || kk === want) { return dg(activityOwnerByFile, k); }
1071
+ }
1072
+ return null;
1073
+ }
1074
+
1075
+ /** Build the call index. known_activity_shorts: Set/array or null. Name Sets iterate in
1076
+ * first-declaration order (Python: str set) — only setdefault winners per name, which a
1077
+ * first-declaration order also decides deterministically (same file, same name). */
1078
+ export function buildCallIndex(fileText, screen2route, knownActivityShorts = null) {
1079
+ if (knownActivityShorts !== null && !(knownActivityShorts instanceof Set) && !Array.isArray(knownActivityShorts) &&
1080
+ typeof knownActivityShorts === 'object' && Object.hasOwn(knownActivityShorts, 'known_activity_shorts')) {
1081
+ knownActivityShorts = knownActivityShorts.known_activity_shorts;
1082
+ }
1083
+ const known = knownActivityShorts === null || knownActivityShorts === undefined ? null : new Set(knownActivityShorts);
1084
+ const screens = new Set(dkeys(screen2route));
1085
+ const fnOwner = new Map(); const fnDecls = new Map(); const importsByFile = new Map();
1086
+ const fnNamesByFile = new Map(); const activityOwnerByFn = new Map(); const activityOwnerByFile = new Map();
1087
+ const fragmentOwnerByFile = new Map(); const declFileCount = new Map(); const fileFunRanges = new Map();
1088
+ const paths = sortedBy(ftKeys(fileText), (x) => x);
1089
+ for (const p of paths) {
1090
+ const text = ftGet(fileText, p);
1091
+ const funs = buildFunDeclIndex(text);
1092
+ const names = new Set(funs.map((f) => f[1]));
1093
+ fnNamesByFile.set(p, names);
1094
+ for (const name of names) { setdefault(fnOwner, name, p); }
1095
+ for (const [name, isPriv] of topLevelFunNames(text)) { setdefault(fnDecls, name, []).push([p, isPriv]); }
1096
+ importsByFile.set(p, buildImportIndex(text));
1097
+ for (const name of names) { declFileCount.set(name, (declFileCount.get(name) ?? 0) + 1); }
1098
+ const am = search(_ACTIVITY_CLASS_RE, text);
1099
+ if (am && (known === null || known.has(am[1]))) {
1100
+ const activityId = 'activity:' + am[1];
1101
+ activityOwnerByFile.set(p, activityId);
1102
+ for (const name of names) { setdefault(activityOwnerByFn, name, activityId); }
1103
+ }
1104
+ const fm = search(_FRAGMENT_CLASS_RE, text);
1105
+ if (fm) { fragmentOwnerByFile.set(p, 'fragment:' + fm[1]); }
1106
+ const ranges = [];
1107
+ for (const [start, name] of funs) {
1108
+ const r = _funBodyRange(text, start);
1109
+ if (r !== null) { ranges.push([r[0], r[1], name]); }
1110
+ }
1111
+ fileFunRanges.set(p, ranges);
1112
+ }
1113
+ const calleeToCallers = new Map(); const seenPairs = new Set(); const callSites = new Map();
1114
+ const callersByDecl = new Map(); const seenDeclPairs = new Set();
1115
+ for (const p of paths) {
1116
+ const text = ftGet(fileText, p);
1117
+ const ranges = fileFunRanges.get(p);
1118
+ for (const cm of finditer(_CALL_RE, text)) {
1119
+ const callee = cm[1];
1120
+ if (!fnOwner.has(callee)) { continue; }
1121
+ const caller = _innermostFnAt(ranges, cm.index);
1122
+ if (!caller || caller === callee) { continue; }
1123
+ const pair = tupleKey(callee, caller);
1124
+ setdefault(callSites, pair, []).push([p, cm.index]);
1125
+ if (!seenPairs.has(pair)) {
1126
+ seenPairs.add(pair);
1127
+ setdefault(calleeToCallers, callee, []).push(caller);
1128
+ }
1129
+ const [declFile, why] = resolveCalleeDecl(callee, p, fnDecls, importsByFile.get(p) ?? null);
1130
+ if (declFile !== null) {
1131
+ const dkey = tupleKey(callee, declFile, caller);
1132
+ if (!seenDeclPairs.has(dkey)) {
1133
+ seenDeclPairs.add(dkey);
1134
+ setdefault(callersByDecl, tupleKey(callee, declFile), []).push(caller);
1135
+ }
1136
+ } else if (why === DECL_AMBIGUOUS) {
1137
+ _AMBIG_HOPS.push([callee, why, relNorm(p)]);
1138
+ }
1139
+ }
1140
+ }
1141
+ return new CallIndex(screens, calleeToCallers, activityOwnerByFn, callSites, fnDecls, callersByDecl, {
1142
+ imports_by_file: importsByFile, activity_owner_by_file: activityOwnerByFile,
1143
+ decl_file_count: declFileCount, fragment_owner_by_file: fragmentOwnerByFile,
1144
+ });
1145
+ }
1146
+
1147
+ export function relNorm(p) { return String(p).replace(/\\/g, '/'); }
1148
+
1149
+ export const _NULLABLE_CB_PARAM_RE = P(
1150
+ S`\b(on[A-Z]\w*)\s*:\s*\(\(?[^\n]*?\)?\s*->\s*\w[\w<>, ?]*\)?\s*\?` +
1151
+ S`\s*=\s*null`);
1152
+ const _IF_NOT_NULL_CB_RE = P(S`\bif\s*\(\s*(on[A-Z]\w*)\s*!=\s*null\s*\)\s*\{`);
1153
+
1154
+ export function _nullableCbGates(text, pos, funs) {
1155
+ const fn = enclosingFn(funs, pos);
1156
+ if (!fn) { return []; }
1157
+ const nullable = _nullableCbParamsOf(text, fn);
1158
+ if (!nullable.size) { return []; }
1159
+ const out = [];
1160
+ for (const im of finditer(_IF_NOT_NULL_CB_RE, text)) {
1161
+ if (!nullable.has(im[1])) { continue; }
1162
+ const body = _extractBalancedGenerous(text, mEnd(im) - 1, '{', '}');
1163
+ if (body === null) { continue; }
1164
+ const start = mEnd(im) - 1;
1165
+ if (start < pos && pos < start + 1 + body.length + 1) { out.push(im[1]); }
1166
+ }
1167
+ return out;
1168
+ }
1169
+
1170
+ export function _passedArg(text, callPos, param) {
1171
+ const openParen = text.indexOf('(', callPos);
1172
+ if (openParen === -1) { return null; }
1173
+ const args = _extractBalancedGenerous(text, openParen);
1174
+ if (args === null) { return null; }
1175
+ const m = search(rx(reEscape(param) + S`\s*=\s*([^,\n]+)`), args);
1176
+ if (!m) { return null; }
1177
+ const val = pyStrip(pyRstrip(pyStrip(m[1]), ','));
1178
+ return val === '' || val === 'null' ? null : val;
1179
+ }
1180
+
1181
+ /** Set of nullable `on*` callback params in fn's signature. */
1182
+ export function _nullableCbParamsOf(text, fn) {
1183
+ const dm = search(rx(S`\bfun\s+(?:[\w.]+\.)?` + reEscape(fn) + S`\s*\(`), text);
1184
+ if (!dm) { return new Set(); }
1185
+ const params = _extractBalancedGenerous(text, mEnd(dm) - 1);
1186
+ if (params === null) { return new Set(); }
1187
+ return new Set(finditer(_NULLABLE_CB_PARAM_RE, params).map((m) => m[1]));
1188
+ }
1189
+
1190
+ export const _CB_PROVIDER_MAX_HOPS = 4;
1191
+ const _WORD_FULL_RE = new RegExp('^' + W + '+$', 'u');
1192
+
1193
+ /** Set of provider composable names (first-found order; Python: set — only membership is used). */
1194
+ export function _cbParamProviders(param, fnName, fileText, project, _depth = 0, _seen = null) {
1195
+ if (_depth >= _CB_PROVIDER_MAX_HOPS) { return new Set(); }
1196
+ _seen = _seen || new Set();
1197
+ const key = tupleKey(param, fnName);
1198
+ if (_seen.has(key)) { return new Set(); }
1199
+ _seen = new Set([..._seen, key]);
1200
+ const out = new Set();
1201
+ const callRe = rx(S`\b` + reEscape(fnName) + S`\s*\(`);
1202
+ const declRe = rx(S`\bfun\s+(?:[\w.]+\.)?` + reEscape(fnName) + S`\s*\(`);
1203
+ for (const [, text] of ftItems(fileText)) {
1204
+ const funs = buildFunIndex(text);
1205
+ for (const cm of finditer(callRe, text)) {
1206
+ if (isCommentedOut(text, cm.index)) { continue; }
1207
+ const head = text.slice(Math.max(0, rfind(text, '\n', 0, cm.index)), mEnd(cm));
1208
+ if (search(declRe, head)) { continue; }
1209
+ const arg = _passedArg(text, cm.index, param);
1210
+ if (arg === null) { continue; }
1211
+ const owner = enclosingFn(funs, cm.index);
1212
+ if (!owner) { continue; }
1213
+ if (_WORD_FULL_RE.test(arg) && _nullableCbParamsOf(text, owner).has(arg)) {
1214
+ for (const x of _cbParamProviders(arg, owner, fileText, project, _depth + 1, _seen)) { out.add(x); }
1215
+ } else { out.add(owner); }
1216
+ }
1217
+ }
1218
+ return out;
1219
+ }
1220
+
1221
+ export function _routePart(sid) {
1222
+ if (sid.startsWith('compose-route:')) { return sid.slice('compose-route:'.length); }
1223
+ if (sid.includes('@') && !sid.startsWith('overlay:')) { return sid.slice(sid.lastIndexOf('@') + 1); }
1224
+ return sid;
1225
+ }
1226
+
1227
+ export function _filterSourcesByCbParam(sources, param, fnName, fileText, project,
1228
+ screen2route, overlayNames, callIndex, gatedSlotIds, pagerPageIds) {
1229
+ const providers = _cbParamProviders(param, fnName, fileText, project);
1230
+ if (!providers.size) { return sources; }
1231
+ const allowed = new Set();
1232
+ for (const p of providers) {
1233
+ if (dh(screen2route, p)) { allowed.add(dg(screen2route, p)); continue; }
1234
+ for (const [sid] of resolveSources(relNorm(''), p, screen2route, overlayNames, {
1235
+ call_index: callIndex, gated_slot_ids: gatedSlotIds, pager_page_ids: pagerPageIds, partial_tiers: true,
1236
+ })) { allowed.add(_routePart(sid)); }
1237
+ }
1238
+ if (!allowed.size) { return sources; }
1239
+ return sources.filter(([sid]) => allowed.has(_routePart(sid)));
1240
+ }
1241
+
1242
+ const _MODE_SUFFIX_RE = P(S`[Mm]ode$`);
1243
+ const _CAMEL_GAP_RE = P(S`(?<=[a-z0-9])(?=[A-Z])`);
1244
+
1245
+ export function modeNodeId(flag, route) {
1246
+ let slug = flag.replace(new RegExp(_MODE_SUFFIX_RE.source, 'gu'), '');
1247
+ slug = slug.replace(new RegExp(_CAMEL_GAP_RE.source, 'gu'), '_').toUpperCase() || 'MODE';
1248
+ return `mode:${slug}@${route}`;
1249
+ }
1250
+
1251
+ export function _modeWrap(sources, fnName, modeGatedFns) {
1252
+ if (!modeGatedFns || !dlen(modeGatedFns) || !fnName || !dh(modeGatedFns, fnName)) { return sources; }
1253
+ const out = [];
1254
+ for (const [sid, how] of sources) {
1255
+ if (sid.startsWith('mode:') || how === 'fallback') { out.push([sid, how]); continue; }
1256
+ out.push([modeNodeId(dg(modeGatedFns, fnName), _routePart(sid)), 'mode-gated']);
1257
+ }
1258
+ return out;
1259
+ }
1260
+
1261
+ export const _TIER_KEYS = ['gated_slot_ids', 'pager_page_ids', 'mode_gated_fns'];
1262
+
1263
+ /** {gated_slot_ids: Map, pager_page_ids: Map, mode_gated_fns: Map} — spread into the resolver opts. */
1264
+ export function buildResolverTiers(fileText, overlayRecords = null) {
1265
+ const tiers = {
1266
+ gated_slot_ids: new Map(),
1267
+ pager_page_ids: scanPagerPageNames(fileText),
1268
+ mode_gated_fns: scanModeGatedNames(fileText),
1269
+ };
1270
+ for (const d of (overlayRecords || [])) {
1271
+ if (get(d, 'type') !== 'node') { continue; }
1272
+ const nid = pyStr(get(d, 'id') || '');
1273
+ const kind = get(d, 'kind');
1274
+ if ((kind === 'sheet-screen' || kind === 'menu') && nid.includes(':')) {
1275
+ setdefault(tiers.gated_slot_ids, nid.slice(nid.indexOf(':') + 1), nid);
1276
+ }
1277
+ }
1278
+ return tiers;
1279
+ }
1280
+
1281
+ export const _TIER_LINTED = new Set();
1282
+
1283
+ export function _lintTiers(caller, gatedSlotIds, pagerPageIds, modeGatedFns, partialTiers) {
1284
+ if (partialTiers) { return; }
1285
+ if (gatedSlotIds != null || pagerPageIds != null || modeGatedFns != null) { return; }
1286
+ if (_TIER_LINTED.has(caller)) { return; }
1287
+ _TIER_LINTED.add(caller);
1288
+ pyPrintErr(`LINT: ${caller} called with no optional tiers — a pager page / ` +
1289
+ 'bottom-sheet / mode source will silently read as fallback or climb ' +
1290
+ 'to its host. Build them with build_resolver_tiers(), or pass ' +
1291
+ 'partial_tiers=True to say you meant it.');
1292
+ }
1293
+
1294
+ /** A kwargs object: plain `{...}` literal (not Map/Set/array/CallIndex/null-proto dict). */
1295
+ const _isKw = (v) => v !== null && typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype;
1296
+ /**
1297
+ * Resolver keyword args: a trailing kwargs object, optionally preceded by the Python-positional
1298
+ * (call_index, gated_slot_ids, pager_page_ids, mode_gated_fns).
1299
+ */
1300
+ function _resolverOpts(rest) {
1301
+ const names = ['call_index', 'gated_slot_ids', 'pager_page_ids', 'mode_gated_fns'];
1302
+ const o = {};
1303
+ const n = rest.length && _isKw(rest[rest.length - 1]) ? rest.length - 1 : rest.length;
1304
+ for (let i = 0; i < n && i < names.length; i++) { o[names[i]] = rest[i]; }
1305
+ if (n < rest.length) { Object.assign(o, rest[n]); }
1306
+ return o;
1307
+ }
1308
+ const _nz = (v) => (v === undefined ? null : v);
1309
+ const _truthyMap = (m) => !!m && dlen(m) > 0;
1310
+
1311
+ /** Map a call-site's enclosing fn to a UTG source node id -> [id, how] (or [id, how, chain]). */
1312
+ export function resolveSource(fileRel, fnName, screen2route, overlayNames, ...rest) {
1313
+ const o = _resolverOpts(rest);
1314
+ const callIndex = _nz(o.call_index); const gatedSlotIds = _nz(o.gated_slot_ids);
1315
+ const pagerPageIds = _nz(o.pager_page_ids); const modeGatedFns = _nz(o.mode_gated_fns);
1316
+ const partialTiers = !!o.partial_tiers; const returnPath = !!o.return_path;
1317
+ _lintTiers('resolve_source', gatedSlotIds, pagerPageIds, modeGatedFns, partialTiers);
1318
+ const _ret = (nodeId, how, chain = []) => (returnPath ? [nodeId, how, [...chain]] : [nodeId, how]);
1319
+ const _declFileCount = callIndex !== null ? (asCallIndex(callIndex).decl_file_count || new Map()) : new Map();
1320
+
1321
+ if (_truthyMap(modeGatedFns) && fnName && dh(modeGatedFns, fnName)) {
1322
+ const inner = resolveSource(fileRel, fnName, screen2route, overlayNames, {
1323
+ call_index: callIndex, gated_slot_ids: gatedSlotIds, pager_page_ids: pagerPageIds,
1324
+ partial_tiers: true, return_path: returnPath,
1325
+ });
1326
+ if (returnPath) {
1327
+ const wrapped = _modeWrap([[inner[0], inner[1]]], fnName, modeGatedFns)[0];
1328
+ return [wrapped[0], wrapped[1], inner[2]];
1329
+ }
1330
+ return _modeWrap([inner], fnName, modeGatedFns)[0];
1331
+ }
1332
+ if (fnName && dh(screen2route, fnName) && routeNameIsLocal(fnName, fileRel, _declFileCount)) {
1333
+ return _ret('compose-route:' + dg(screen2route, fnName), 'fn-screen');
1334
+ }
1335
+ if (fnName && overlayNames && dh(overlayNames, fnName)) { return _ret('overlay:' + fnName, 'fn-overlay'); }
1336
+ if (_truthyMap(gatedSlotIds) && fnName && dh(gatedSlotIds, fnName)) {
1337
+ return _ret(dg(gatedSlotIds, fnName), 'fn-gated-slot');
1338
+ }
1339
+ if (_truthyMap(pagerPageIds) && fnName && dh(pagerPageIds, fnName)) {
1340
+ return _ret(dg(pagerPageIds, fnName), 'fn-pager-page');
1341
+ }
1342
+ if (callIndex !== null && fnName) {
1343
+ const ci = asCallIndex(callIndex);
1344
+ const screens = ci.screens;
1345
+ const calleeToCallers = ci.callee_to_callers;
1346
+ const activityOwnerByFn = ci.activity_owner_by_fn;
1347
+ const activityOwnerByFile = ci.activity_owner_by_file || new Map();
1348
+ const fnDecls = ci.fn_decls || new Map();
1349
+ const callersByDecl = ci.callers_by_decl || new Map();
1350
+ const importsByFile = ci.imports_by_file || new Map();
1351
+ const importsFor = (p) => {
1352
+ if (!p || !dlen(importsByFile)) { return null; }
1353
+ const hit = dg(importsByFile, p, null);
1354
+ if (hit !== null) { return hit; }
1355
+ for (const k of dkeys(importsByFile)) { if (_sameSourceFile(k, p)) { return dg(importsByFile, k); } }
1356
+ return null;
1357
+ };
1358
+ const callersOf = (callee, fromFile) => {
1359
+ if (!dlen(fnDecls)) { return [dg(calleeToCallers, callee, null) || [], true]; }
1360
+ if (new Set((dg(fnDecls, callee, null) || []).map((x) => x[0])).size < 2) {
1361
+ return [dg(calleeToCallers, callee, null) || [], true];
1362
+ }
1363
+ const [declFile, why] = resolveCalleeDecl(callee, fromFile, fnDecls, importsFor(fromFile));
1364
+ if (declFile === null) {
1365
+ _AMBIG_HOPS.push([callee, why, relNorm(fromFile || '')]);
1366
+ return [dg(calleeToCallers, callee, null) || [], false];
1367
+ }
1368
+ return [dg(callersByDecl, tupleKey(callee, declFile), null) || [], true];
1369
+ };
1370
+ const fileOf = new Map([[fnName, fileRel]]);
1371
+ const declFileOf = (name) => {
1372
+ const f = fileOf.get(name);
1373
+ if (f !== undefined && f !== null) { return f; }
1374
+ const files = _sortedUnique((dg(fnDecls, name, null) || []).map((x) => x[0]));
1375
+ return files.length === 1 ? files[0] : null;
1376
+ };
1377
+ const own = _activityOwnerOfFile(fileRel, activityOwnerByFile);
1378
+ if (own) { return _ret(own, 'callgraph-activity'); }
1379
+ if (dh(activityOwnerByFn, fnName)) {
1380
+ if (dg(_declFileCount, fnName, 0) <= 1) { return _ret(dg(activityOwnerByFn, fnName), 'callgraph-activity'); }
1381
+ }
1382
+ const seen = new Set([fnName]);
1383
+ let frontier = [fnName];
1384
+ const parentOf = new Map();
1385
+ const chainTo = (callee) => {
1386
+ if (!returnPath) { return []; }
1387
+ const hops = []; let cur = callee;
1388
+ while (parentOf.has(cur)) { const prev = parentOf.get(cur); hops.push([prev, cur]); cur = prev; }
1389
+ hops.reverse();
1390
+ return hops;
1391
+ };
1392
+ const remember = (caller) => {
1393
+ if (!fileOf.has(caller)) {
1394
+ const cf = _sortedUnique((dg(fnDecls, caller, null) || []).map((x) => x[0]));
1395
+ if (cf.length === 1) { fileOf.set(caller, cf[0]); }
1396
+ }
1397
+ };
1398
+ let siteAct = null; // _siteActivity result, computed once per hop
1399
+ for (let it = 0; it < 6; it++) {
1400
+ const nxt = [];
1401
+ for (const callee of frontier) {
1402
+ const [callers, attributable] = callersOf(callee, declFileOf(callee));
1403
+ if (!attributable) {
1404
+ for (const caller of callers) {
1405
+ if (!seen.has(caller)) {
1406
+ seen.add(caller); parentOf.set(caller, callee); remember(caller); nxt.push(caller);
1407
+ }
1408
+ }
1409
+ continue;
1410
+ }
1411
+ const screenCallers = new Set(callers.filter((c) => dh(screens, c)));
1412
+ const ambiguous = screenCallers.size >= 2;
1413
+ for (const caller of callers) {
1414
+ const chain = [...chainTo(callee), [callee, caller]];
1415
+ if (dh(screens, caller) && !ambiguous && !screenNameIsAmbiguous(caller, _declFileCount)) {
1416
+ return _ret('compose-route:' + dg(screen2route, caller), 'callgraph', chain);
1417
+ } else if (_truthyMap(pagerPageIds) && dh(pagerPageIds, caller)) {
1418
+ return _ret(dg(pagerPageIds, caller), 'callgraph-pager-page', chain);
1419
+ } else if (_truthyMap(gatedSlotIds) && dh(gatedSlotIds, caller)) {
1420
+ return _ret(dg(gatedSlotIds, caller), 'callgraph-gated-slot', chain);
1421
+ } else if (overlayNames && dlen(overlayNames) && dh(overlayNames, caller)) {
1422
+ return _ret('overlay:' + caller, 'callgraph-overlay', chain);
1423
+ } else if (dh(activityOwnerByFn, caller) && dg(_declFileCount, caller, 0) <= 1) {
1424
+ return _ret(dg(activityOwnerByFn, caller), 'callgraph-activity', chain);
1425
+ } else if ((siteAct = _siteActivity(ci, callee, caller)) !== null) {
1426
+ // A lifecycle name declared in several classes (`onCreate` in the Activity and the
1427
+ // Application): the call sites themselves sit in one Activity's file.
1428
+ return _ret(siteAct, 'callgraph-activity', chain);
1429
+ } else if (!seen.has(caller)) {
1430
+ seen.add(caller); parentOf.set(caller, callee); remember(caller); nxt.push(caller);
1431
+ }
1432
+ }
1433
+ }
1434
+ frontier = nxt;
1435
+ if (!frontier.length) { break; }
1436
+ }
1437
+ }
1438
+ const fragOwn = callIndex !== null
1439
+ ? _activityOwnerOfFile(fileRel, asCallIndex(callIndex).fragment_owner_by_file || new Map()) : null;
1440
+ if (fragOwn) { return _ret(fragOwn, 'file-fragment'); }
1441
+ return _ret('screen:' + (fnName || 'UNKNOWN'), 'fallback');
1442
+ }
1443
+
1444
+ export const _IF_HEAD_RE = P(S`\bif\s*\(`);
1445
+ export const _WHEN_ARROW_RE = P(S`->`);
1446
+ const _wsJoin = (s) => pySplit(s).join(' ');
1447
+
1448
+ export function branchConditionAt(fnBody, constPos) {
1449
+ let bestCond = null; let bestSpan = null;
1450
+ for (const hm of finditer(_IF_HEAD_RE, fnBody)) {
1451
+ if (hm.index > constPos) { break; }
1452
+ const parenStart = mEnd(hm) - 1;
1453
+ const cond = _extractBalancedGenerous(fnBody, parenStart);
1454
+ if (cond === null) { continue; }
1455
+ const after = parenStart + 1 + cond.length + 1;
1456
+ const seg = fnBody.slice(after, after + 120);
1457
+ const bm = search(_LBRACE_RE, seg);
1458
+ let blkStart; let blkEnd;
1459
+ if (!bm) {
1460
+ const nl = fnBody.indexOf('\n', after);
1461
+ blkStart = after; blkEnd = nl !== -1 ? nl : fnBody.length;
1462
+ } else {
1463
+ const braceStart = after + bm.index;
1464
+ const body = _extractBalancedGenerous(fnBody, braceStart, '{', '}');
1465
+ if (body === null) { continue; }
1466
+ blkStart = braceStart; blkEnd = braceStart + 1 + body.length + 1;
1467
+ }
1468
+ if (blkStart <= constPos && constPos < blkEnd) {
1469
+ const span = blkEnd - blkStart;
1470
+ if (bestSpan === null || span < bestSpan) { bestSpan = span; bestCond = _wsJoin(cond); }
1471
+ }
1472
+ }
1473
+ return bestCond;
1474
+ }
1475
+
1476
+ export const _WHEN_HEAD_RE = P(S`\bwhen\s*(\(|\{)`);
1477
+ export const _ARM_SPLIT_RE = P(S`->`);
1478
+
1479
+ export function _skipString(s, i) {
1480
+ const n = s.length;
1481
+ let j = i + 1;
1482
+ while (j < n) {
1483
+ if (s[j] === '\\') { j += 2; continue; }
1484
+ if (s[j] === '"') { return j + 1; }
1485
+ j += 1;
1486
+ }
1487
+ return n;
1488
+ }
1489
+
1490
+ /** [[cond_text, arm_start, arm_end], ...] */
1491
+ export function _armBounds(whenBody) {
1492
+ const out = [];
1493
+ let i = 0; const n = whenBody.length;
1494
+ while (i < n) {
1495
+ let depth = 0; let j = i; let arrow = -1;
1496
+ while (j < n) {
1497
+ const c = whenBody[j];
1498
+ if (c === '"') { j = _skipString(whenBody, j); continue; }
1499
+ if (c === '{' || c === '(' || c === '[') { depth += 1; } else if (c === '}' || c === ')' || c === ']') { depth -= 1; }
1500
+ else if (depth === 0 && whenBody.startsWith('->', j)) { arrow = j; break; }
1501
+ j += 1;
1502
+ }
1503
+ if (arrow === -1) { break; }
1504
+ const cond = _wsJoin(whenBody.slice(i, arrow));
1505
+ let after = arrow + 2;
1506
+ while (after < n && ' \t\r\n'.includes(whenBody[after])) { after += 1; }
1507
+ let armEnd;
1508
+ if (after < n && whenBody[after] === '{') {
1509
+ const blk = _extractBalancedGenerous(whenBody, after, '{', '}');
1510
+ armEnd = blk === null ? n : after + 1 + blk.length + 1;
1511
+ } else {
1512
+ let d = 0; let k = after;
1513
+ while (k < n) {
1514
+ const c = whenBody[k];
1515
+ if (c === '"') { k = _skipString(whenBody, k); continue; }
1516
+ if (c === '{' || c === '(' || c === '[') { d += 1; } else if (c === '}' || c === ')' || c === ']') { d -= 1; }
1517
+ else if (c === '\n' && d <= 0) { break; }
1518
+ k += 1;
1519
+ }
1520
+ armEnd = k;
1521
+ }
1522
+ if (cond) { out.push([cond, after, armEnd]); }
1523
+ i = armEnd > after ? Math.max(armEnd, after) : after + 1;
1524
+ }
1525
+ return out;
1526
+ }
1527
+
1528
+ export const _DEVICE_ENV_APIS = {
1529
+ maxWidth: 'BoxWithConstraints', maxHeight: 'BoxWithConstraints',
1530
+ minWidth: 'BoxWithConstraints', minHeight: 'BoxWithConstraints',
1531
+ WindowSizeClass: 'WindowSizeClass',
1532
+ windowWidthSizeClass: 'WindowSizeClass',
1533
+ windowHeightSizeClass: 'WindowSizeClass',
1534
+ WindowWidthSizeClass: 'WindowSizeClass',
1535
+ WindowHeightSizeClass: 'WindowSizeClass',
1536
+ currentWindowAdaptiveInfo: 'WindowSizeClass',
1537
+ LocalConfiguration: 'Configuration',
1538
+ screenWidthDp: 'Configuration', screenHeightDp: 'Configuration',
1539
+ smallestScreenWidthDp: 'Configuration',
1540
+ ORIENTATION_LANDSCAPE: 'Configuration',
1541
+ ORIENTATION_PORTRAIT: 'Configuration',
1542
+ uiMode: 'Configuration', UI_MODE_TYPE_TELEVISION: 'Configuration',
1543
+ UI_MODE_TYPE_WATCH: 'Configuration', UI_MODE_TYPE_CAR: 'Configuration',
1544
+ isScreenRound: 'Configuration',
1545
+ };
1546
+ export const _DEVICE_ENV_WORD_RE = P(S`\b([A-Za-z_][A-Za-z0-9_]*)\b`);
1547
+ export const _M3_BREAKPOINTS_DP = [600, 840];
1548
+ export const _DP_LITERAL_RE = P(S`\b(\d{2,4})\s*\.\s*dp\b|\b(\d{2,4})\s*dp\b`, 'i');
1549
+ export const _ORIENTATION_CMP_RE = P(S`\bmax(Width|Height)\s*[><]=?\s*max(Width|Height)\b`);
1550
+ const _SCREEN_DP_CMP_RE = P(S`\b(?:screenWidthDp|screenHeightDp|` +
1551
+ S`smallestScreenWidthDp)\s*[><]=?\s*(\d{2,4})\b`);
1552
+ const _SIZE_CLASS_RE = P(S`\bWindow(?:Width|Height)SizeClass\s*\.\s*(\w+)`);
1553
+
1554
+ export function classifyConditionKind(condText) {
1555
+ if (!condText) { return null; }
1556
+ const apis = []; const dims = [];
1557
+ for (const wm of finditer(_DEVICE_ENV_WORD_RE, condText)) {
1558
+ const w = wm[1];
1559
+ const fam = Object.hasOwn(_DEVICE_ENV_APIS, w) ? _DEVICE_ENV_APIS[w] : null;
1560
+ if (fam) {
1561
+ if (!apis.includes(fam)) { apis.push(fam); }
1562
+ if (!dims.includes(w)) { dims.push(w); }
1563
+ }
1564
+ }
1565
+ if (!apis.length) { return null; }
1566
+ let thresholds = [];
1567
+ for (const dm of finditer(_DP_LITERAL_RE, condText)) { thresholds.push(Number(pyInt(dm[1] || dm[2]))); }
1568
+ for (const dm of finditer(_SCREEN_DP_CMP_RE, condText)) { thresholds.push(Number(pyInt(dm[1]))); }
1569
+ thresholds = [...new Set(thresholds)].sort((a, b) => a - b);
1570
+ const axesThresholded = [];
1571
+ for (const axis of ['maxWidth', 'maxHeight', 'minWidth', 'minHeight',
1572
+ 'screenWidthDp', 'screenHeightDp', 'smallestScreenWidthDp']) {
1573
+ if (!dims.includes(axis)) { continue; }
1574
+ if (search(rx(reEscape(axis) + S`\s*[><]=?\s*\d{2,4}\s*\.?\s*dp\b`, 'i'), condText) ||
1575
+ search(rx(reEscape(axis) + S`\s*[><]=?\s*\d{2,4}\b`), condText)) { axesThresholded.push(axis); }
1576
+ }
1577
+ const sizeClasses = reFindall(_SIZE_CLASS_RE, condText).map((v) => `WindowWidthSizeClass.${v}`);
1578
+ return {
1579
+ kind: 'device-env',
1580
+ apis,
1581
+ dims,
1582
+ thresholds_dp: thresholds,
1583
+ axes_thresholded: axesThresholded,
1584
+ size_classes: sizeClasses,
1585
+ thresholds_known: thresholds.length > 0 && thresholds.every((t) => _M3_BREAKPOINTS_DP.includes(t)),
1586
+ orientation_cmp: !!search(_ORIENTATION_CMP_RE, condText),
1587
+ };
1588
+ }
1589
+
1590
+ export function inferSurface(condText, env = null) {
1591
+ env = env || classifyConditionKind(condText);
1592
+ if (!env || get(env, 'kind') !== 'device-env') { return []; }
1593
+ const ths = get(env, 'thresholds_dp') || [];
1594
+ const dims = new Set(get(env, 'dims') || []);
1595
+ const gated = new Set(get(env, 'axes_thresholded') || []);
1596
+ const bothAxes = ['maxWidth', 'minWidth', 'screenWidthDp'].some((a) => gated.has(a)) &&
1597
+ ['maxHeight', 'minHeight', 'screenHeightDp'].some((a) => gated.has(a));
1598
+ if (get(env, 'thresholds_known') && bothAxes) { return ['tablet']; }
1599
+ if ((get(env, 'size_classes') || []).includes('WindowWidthSizeClass.Expanded')) { return ['tablet']; }
1600
+ if (get(env, 'thresholds_known') && dims.has('smallestScreenWidthDp')) { return ['tablet']; }
1601
+ if (get(env, 'orientation_cmp') && !ths.length) { return ['phone-landscape']; }
1602
+ if (dims.has('ORIENTATION_LANDSCAPE') && !ths.length) { return ['phone-landscape']; }
1603
+ if (dims.has('ORIENTATION_PORTRAIT') && !ths.length) { return ['phone-portrait']; }
1604
+ if (dims.has('UI_MODE_TYPE_CAR')) { return ['automotive']; }
1605
+ if (dims.has('UI_MODE_TYPE_TELEVISION')) { return ['tv']; }
1606
+ if (dims.has('UI_MODE_TYPE_WATCH') || dims.has('isScreenRound')) { return ['watch']; }
1607
+ return [];
1608
+ }
1609
+
1610
+ /** [when_head_pos, [arm_cond...], arm_index] or null. */
1611
+ export function _enclosingWhenGroup(text, pos) {
1612
+ let best = null;
1613
+ for (const wm of finditer(_WHEN_HEAD_RE, text)) {
1614
+ if (wm.index > pos) { break; }
1615
+ let braceStart;
1616
+ if (wm[1] === '(') {
1617
+ const subj = _extractBalancedGenerous(text, mEnd(wm) - 1);
1618
+ if (subj === null) { continue; }
1619
+ const after = mEnd(wm) - 1 + 1 + subj.length + 1;
1620
+ const bm = search(_LBRACE_RE, text.slice(after, after + 120));
1621
+ if (!bm) { continue; }
1622
+ braceStart = after + bm.index;
1623
+ } else { braceStart = mEnd(wm) - 1; }
1624
+ const body = _extractBalancedGenerous(text, braceStart, '{', '}');
1625
+ if (body === null) { continue; }
1626
+ const bodyStart = braceStart + 1;
1627
+ if (!(bodyStart <= pos && pos < bodyStart + body.length)) { continue; }
1628
+ const arms = _armBounds(body);
1629
+ if (!arms.length) { continue; }
1630
+ const relPos = pos - bodyStart;
1631
+ const idx = arms.findIndex(([, aS, aE]) => aS <= relPos && relPos < aE);
1632
+ if (idx < 0) { continue; }
1633
+ if (best === null || body.length < best[0]) { best = [body.length, wm.index, arms.map((a) => a[0]), idx]; }
1634
+ }
1635
+ return best === null ? null : [best[1], best[2], best[3]];
1636
+ }
1637
+
1638
+ export function _variantOf(fileRel, pos, text, climb, callIndex, fileText, project) {
1639
+ if (!climb || !climb.length || callIndex === null || callIndex === undefined) { return {}; }
1640
+ const conds = []; let group = null;
1641
+ const sites = asCallIndex(callIndex).call_sites;
1642
+ for (const [callee, caller] of climb) {
1643
+ for (const [spath, spos] of (dg(sites, tupleKey(callee, caller), null) || [])) {
1644
+ const stext = ftGet(fileText, spath, null);
1645
+ if (stext === null || stext === undefined) { continue; }
1646
+ const sr = rel(spath, project);
1647
+ for (const c of enclosingRenderConditions(stext, spos)) {
1648
+ const entry = { text: c.text, form: c.form, at: `${sr}:${lineOf(stext, spos)}` };
1649
+ if (!conds.some((e) => e.text === entry.text && e.form === entry.form && e.at === entry.at)) { conds.push(entry); }
1650
+ }
1651
+ if (group === null) {
1652
+ const g = _enclosingWhenGroup(stext, spos);
1653
+ if (g) {
1654
+ const [headPos, armConds, armIdx] = g;
1655
+ group = { id: `${sr}:${lineOf(stext, headPos)}`, arms: armConds.length, arm_index: armIdx, arm_conditions: armConds };
1656
+ }
1657
+ }
1658
+ }
1659
+ }
1660
+ if (!conds.length) { return {}; }
1661
+ const head = conds[0];
1662
+ const variantId = `${head.at}#${cpSlice(head.text, 0, 80)}`;
1663
+ let guard = null; let surface = [];
1664
+ for (const c of conds) {
1665
+ const env = classifyConditionKind(c.text);
1666
+ if (env) {
1667
+ const de = {};
1668
+ for (const k of keysOf(env)) { if (k !== 'kind') { de[k] = env[k]; } }
1669
+ guard = { text: `branch:${c.text}`, kind: 'device-env', device_env: de };
1670
+ surface = inferSurface(c.text, env);
1671
+ break;
1672
+ }
1673
+ }
1674
+ if (guard === null) {
1675
+ const sibs = (group || {}).arm_conditions || [];
1676
+ const others = sibs.filter((s) => s !== 'else');
1677
+ if (head.form === 'else' && others.length && others.every((s) => classifyConditionKind(s))) {
1678
+ guard = { text: 'branch:else', kind: 'device-env', device_env: { complement_of_arms: others.length } };
1679
+ } else {
1680
+ guard = { text: `branch:${head.text}`, kind: null };
1681
+ }
1682
+ }
1683
+ return { variant_id: variantId, conditions: conds, guard, surface, variant_group: group };
1684
+ }
1685
+
1686
+ export function enclosingRenderConditions(text, pos, limit = 12) {
1687
+ if (limit !== null && typeof limit === 'object') { limit = limit.limit ?? 12; }
1688
+ const conds = [];
1689
+ const ifHits = [];
1690
+ for (const hm of finditer(_IF_HEAD_RE, text)) {
1691
+ if (hm.index > pos) { break; }
1692
+ const parenStart = mEnd(hm) - 1;
1693
+ const cond = _extractBalancedGenerous(text, parenStart);
1694
+ if (cond === null) { continue; }
1695
+ const after = parenStart + 1 + cond.length + 1;
1696
+ const bm = search(_LBRACE_RE, text.slice(after, after + 120));
1697
+ let blk;
1698
+ if (!bm) {
1699
+ const nl = text.indexOf('\n', after);
1700
+ blk = [after, nl !== -1 ? nl : text.length];
1701
+ } else {
1702
+ const braceStart = after + bm.index;
1703
+ const body = _extractBalancedGenerous(text, braceStart, '{', '}');
1704
+ if (body === null) { continue; }
1705
+ blk = [braceStart, braceStart + 1 + body.length + 1];
1706
+ }
1707
+ if (blk[0] <= pos && pos < blk[1]) { ifHits.push([blk[1] - blk[0], _wsJoin(cond), 'if']); }
1708
+ }
1709
+ const whenHits = [];
1710
+ for (const wm of finditer(_WHEN_HEAD_RE, text)) {
1711
+ if (wm.index > pos) { break; }
1712
+ let subject = null; let braceStart;
1713
+ if (wm[1] === '(') {
1714
+ const subj = _extractBalancedGenerous(text, mEnd(wm) - 1);
1715
+ if (subj === null) { continue; }
1716
+ subject = _wsJoin(subj);
1717
+ const after = mEnd(wm) - 1 + 1 + subj.length + 1;
1718
+ const bm = search(_LBRACE_RE, text.slice(after, after + 120));
1719
+ if (!bm) { continue; }
1720
+ braceStart = after + bm.index;
1721
+ } else { braceStart = mEnd(wm) - 1; }
1722
+ const body = _extractBalancedGenerous(text, braceStart, '{', '}');
1723
+ if (body === null) { continue; }
1724
+ const bodyStart = braceStart + 1;
1725
+ if (!(bodyStart <= pos && pos < bodyStart + body.length)) { continue; }
1726
+ const r = pos - bodyStart;
1727
+ for (const [cond, aStart, aEnd] of _armBounds(body)) {
1728
+ if (aStart <= r && r < aEnd) {
1729
+ let form; let txt;
1730
+ if (subject !== null) {
1731
+ form = 'when-subject-arm';
1732
+ txt = cond !== 'else' ? `${subject} == ${cond}` : `else(${subject})`;
1733
+ } else if (cond === 'else') { form = 'else'; txt = 'else'; } else { form = 'when-arm'; txt = cond; }
1734
+ whenHits.push([aEnd - aStart, txt, form]);
1735
+ break;
1736
+ }
1737
+ }
1738
+ }
1739
+ for (const [, txt, form] of sortedBy([...ifHits, ...whenHits], (t) => t[0])) {
1740
+ if (txt && !conds.some((c) => c.text === txt)) { conds.push({ text: txt, form }); }
1741
+ if (conds.length >= limit) { break; }
1742
+ }
1743
+ return conds;
1744
+ }
1745
+
1746
+ /** Fan-out variant of resolveSource -> [[source_id, how], ...] ([] on fallback). */
1747
+ export function resolveSources(fileRel, fnName, screen2route, overlayNames, ...rest) {
1748
+ const o = _resolverOpts(rest);
1749
+ const callIndex = _nz(o.call_index); const gatedSlotIds = _nz(o.gated_slot_ids);
1750
+ const pagerPageIds = _nz(o.pager_page_ids); const modeGatedFns = _nz(o.mode_gated_fns);
1751
+ const partialTiers = !!o.partial_tiers;
1752
+ _lintTiers('resolve_sources', gatedSlotIds, pagerPageIds, modeGatedFns, partialTiers);
1753
+ const tiers = { call_index: callIndex, gated_slot_ids: gatedSlotIds, pager_page_ids: pagerPageIds, partial_tiers: true };
1754
+ if (_truthyMap(modeGatedFns) && fnName && dh(modeGatedFns, fnName)) {
1755
+ const inner = resolveSources(fileRel, fnName, screen2route, overlayNames, tiers);
1756
+ return _modeWrap(inner, fnName, modeGatedFns);
1757
+ }
1758
+ if (callIndex === null || !fnName) {
1759
+ const [sid, how] = resolveSource(fileRel, fnName, screen2route, overlayNames, tiers);
1760
+ return how === 'fallback' ? [] : [[sid, how]];
1761
+ }
1762
+ const ci = asCallIndex(callIndex);
1763
+ const dfc = ci.decl_file_count || new Map();
1764
+ if (dh(screen2route, fnName) && routeNameIsLocal(fnName, fileRel, dfc)) {
1765
+ return [['compose-route:' + dg(screen2route, fnName), 'fn-screen']];
1766
+ }
1767
+ if (dh(overlayNames, fnName)) { return [['overlay:' + fnName, 'fn-overlay']]; }
1768
+ if (_truthyMap(gatedSlotIds) && dh(gatedSlotIds, fnName)) { return [[dg(gatedSlotIds, fnName), 'fn-gated-slot']]; }
1769
+ if (_truthyMap(pagerPageIds) && dh(pagerPageIds, fnName)) { return [[dg(pagerPageIds, fnName), 'fn-pager-page']]; }
1770
+ const screens = ci.screens;
1771
+ const calleeToCallers = ci.callee_to_callers;
1772
+ const activityOwnerByFn = ci.activity_owner_by_fn;
1773
+ const fnDecls = ci.fn_decls || new Map();
1774
+ const callersByDecl = ci.callers_by_decl || new Map();
1775
+ const importsByFile = ci.imports_by_file || new Map();
1776
+ const importsFor = (p) => {
1777
+ if (!p || !dlen(importsByFile)) { return null; }
1778
+ const hit = dg(importsByFile, p, null);
1779
+ if (hit !== null) { return hit; }
1780
+ for (const k of dkeys(importsByFile)) { if (_sameSourceFile(k, p)) { return dg(importsByFile, k); } }
1781
+ return null;
1782
+ };
1783
+ const own = _activityOwnerOfFile(fileRel, ci.activity_owner_by_file || new Map());
1784
+ if (own) { return [[own, 'callgraph-activity']]; }
1785
+ if (dh(activityOwnerByFn, fnName)) {
1786
+ if (dg(dfc, fnName, 0) <= 1) { return [[dg(activityOwnerByFn, fnName), 'callgraph-activity']]; }
1787
+ }
1788
+ const files = new Map([[fnName, fileRel]]);
1789
+ const callersOf = (callee) => {
1790
+ if (!dlen(fnDecls)) { return [dg(calleeToCallers, callee, null) || [], true]; }
1791
+ if (new Set((dg(fnDecls, callee, null) || []).map((x) => x[0])).size < 2) {
1792
+ return [dg(calleeToCallers, callee, null) || [], true];
1793
+ }
1794
+ const from = files.has(callee) ? files.get(callee) : null;
1795
+ const [declFile, why] = resolveCalleeDecl(callee, from, fnDecls, importsFor(from));
1796
+ if (declFile === null) {
1797
+ _AMBIG_HOPS.push([callee, why, relNorm(from || '')]);
1798
+ return [dg(calleeToCallers, callee, null) || [], false];
1799
+ }
1800
+ return [dg(callersByDecl, tupleKey(callee, declFile), null) || [], true];
1801
+ };
1802
+ const noteDeclFile = (caller) => {
1803
+ if (files.has(caller)) { return; }
1804
+ const fs_ = _sortedUnique((dg(fnDecls, caller, null) || []).map((x) => x[0]));
1805
+ if (fs_.length === 1) { files.set(caller, fs_[0]); }
1806
+ };
1807
+ const seen = new Set([fnName]);
1808
+ let frontier = [fnName];
1809
+ let siteAct = null; // _siteActivity result, computed once per hop
1810
+ for (let it = 0; it < 6; it++) {
1811
+ const nxt = [];
1812
+ const levelOut = []; const levelEmitted = new Set(); const levelHosts = [];
1813
+ for (const callee of frontier) {
1814
+ const [callers, attributable] = callersOf(callee);
1815
+ if (!attributable) {
1816
+ for (const caller of callers) {
1817
+ if (!seen.has(caller)) { seen.add(caller); noteDeclFile(caller); nxt.push(caller); }
1818
+ }
1819
+ continue;
1820
+ }
1821
+ const ambName = new Set(callers.filter((c) => screenNameIsAmbiguous(c, dfc)));
1822
+ const screenCallers = callers.filter((c) => dh(screens, c) && !ambName.has(c));
1823
+ if (new Set(screenCallers).size >= 2) {
1824
+ for (const c of screenCallers) {
1825
+ const rid = 'compose-route:' + dg(screen2route, c);
1826
+ if (!levelEmitted.has(rid)) { levelEmitted.add(rid); levelOut.push([rid, 'callgraph-fanout']); }
1827
+ }
1828
+ continue;
1829
+ }
1830
+ for (const caller of callers) {
1831
+ let hit = null;
1832
+ if (dh(screens, caller) && !ambName.has(caller)) {
1833
+ hit = ['compose-route:' + dg(screen2route, caller), 'callgraph'];
1834
+ } else if (_truthyMap(pagerPageIds) && dh(pagerPageIds, caller)) {
1835
+ hit = [dg(pagerPageIds, caller), 'callgraph-pager-page'];
1836
+ } else if (_truthyMap(gatedSlotIds) && dh(gatedSlotIds, caller)) {
1837
+ hit = [dg(gatedSlotIds, caller), 'callgraph-gated-slot'];
1838
+ } else if (overlayNames && dlen(overlayNames) && dh(overlayNames, caller)) {
1839
+ hit = ['overlay:' + caller, 'callgraph-overlay'];
1840
+ } else if ((siteAct = _siteActivity(ci, callee, caller)) !== null) {
1841
+ levelHosts.push([siteAct, 'callgraph-activity']);
1842
+ continue;
1843
+ } else if (dh(activityOwnerByFn, caller)) {
1844
+ levelHosts.push([dg(activityOwnerByFn, caller), 'callgraph-activity']);
1845
+ continue;
1846
+ }
1847
+ if (hit !== null) {
1848
+ if (!levelEmitted.has(hit[0])) { levelEmitted.add(hit[0]); levelOut.push(hit); }
1849
+ } else if (!seen.has(caller)) { seen.add(caller); noteDeclFile(caller); nxt.push(caller); }
1850
+ }
1851
+ }
1852
+ if (levelOut.length) { return levelOut; }
1853
+ if (levelHosts.length) {
1854
+ const out = []; const emitted = new Set();
1855
+ for (const [sid, how] of levelHosts) { if (!emitted.has(sid)) { emitted.add(sid); out.push([sid, how]); } }
1856
+ return out;
1857
+ }
1858
+ frontier = nxt;
1859
+ if (!frontier.length) { break; }
1860
+ }
1861
+ const fragOwn = _activityOwnerOfFile(fileRel, ci.fragment_owner_by_file || new Map());
1862
+ if (fragOwn) { return [[fragOwn, 'file-fragment']]; }
1863
+ return [];
1864
+ }
1865
+
1866
+ export const _STATE_DECL_RES = [
1867
+ P(S`var\s+(\w+)\s+by\s+remember\s*(?:\([^)]*\))?\s*\{\s*` +
1868
+ S`mutableStateOf(?:<[^>]*>)?\(\s*(?:false|null)`),
1869
+ P(S`val\s+(\w+)\s*=\s*remember\s*(?:\([^)]*\))?\s*\{\s*` +
1870
+ S`mutableStateOf(?:<[^>]*>)?\(\s*(?:false|null)`),
1871
+ P(S`val\s*\(\s*(\w+)\s*,\s*(\w+)\s*\)\s*=\s*remember\s*` +
1872
+ S`(?:\([^)]*\))?\s*\{\s*mutableStateOf(?:<[^>]*>)?\(\s*(?:false|null)`),
1873
+ ];
1874
+
1875
+ /** Set of dead state flags (insertion order; Python: set — only membership-tested). */
1876
+ export function _deadStateFlags(text) {
1877
+ const dead = new Set();
1878
+ _STATE_DECL_RES.forEach((re, ri) => {
1879
+ for (const fm of finditer(re, text)) {
1880
+ if (isCommentedOut(text, fm.index)) { continue; }
1881
+ const flag = fm[1];
1882
+ const names = [flag];
1883
+ if (ri === 2 && fm[2] !== undefined) { names.push(fm[2]); }
1884
+ let live = 0; let commented = 0;
1885
+ for (const name of names) {
1886
+ const pat = name === flag ? reEscape(name) + S`(?:\.value)?\s*=\s*(?!=)\s*(\w+)` : reEscape(name) + S`\s*\(\s*(\w+)`;
1887
+ for (const tm of finditer(rx(pat), text)) {
1888
+ if (tm.index === mStart(fm, 1)) { continue; }
1889
+ if (tm[1] === 'false' || tm[1] === 'null') { continue; }
1890
+ if (isCommentedOut(text, tm.index)) { commented += 1; } else { live += 1; }
1891
+ }
1892
+ }
1893
+ if (commented && !live) { dead.add(flag); }
1894
+ }
1895
+ });
1896
+ return dead;
1897
+ }
1898
+
1899
+ export const _HOIST_MAX_HOPS = 3;
1900
+ export const _CALLBACK_PARAM_DECL = P(S`(\w+)\s*(?::\s*[^=]*?)?=\s*\{\s*$`);
1901
+ const _CALLEE_TAIL_RE = P(S`([A-Z]\w+)\s*$`);
1902
+
1903
+ /** Map<name, [[path, decl_start], ...]>. */
1904
+ export function _buildCalleeIndex(fileText) {
1905
+ const idx = new Map();
1906
+ for (const [p, text] of ftItems(fileText)) {
1907
+ for (const m of finditer(FUN_RE, text)) { setdefault(idx, m[2], []).push([p, m.index]); }
1908
+ }
1909
+ return idx;
1910
+ }
1911
+
1912
+ /**
1913
+ * [[overlayName, setterPos]]: the `flag = <non-false>` setters that sit in a callback lambda
1914
+ * passed to another overlay composable (one entry per overlay, its first setter). Only within
1915
+ * `range` ([start, end) of the composable holding the gated call), and only for a `flag` that
1916
+ * range declares as Compose state (`var flag by remember { mutableStateOf(false) }` and the
1917
+ * other `_STATE_DECL_RES` forms): a same-named local of another composable is another flag.
1918
+ */
1919
+ export function _overlayCallbackHosts(text, flag, self, overlayNames, range = null) {
1920
+ const [a, b] = range ?? [0, text.length];
1921
+ const scope = text.slice(a, b);
1922
+ const declared = _STATE_DECL_RES.some((re) => finditer(re, scope).some((m) => m[1] === flag));
1923
+ if (!declared) { return []; }
1924
+ const out = new Map();
1925
+ for (const tm of finditer(rx(S`\b` + reEscape(flag) + S`(?:\.value)?\s*=\s*(?!=)\s*(\w+)`), scope)) {
1926
+ const pos = a + tm.index;
1927
+ if (tm[1] === 'false' || tm[1] === 'null' || isCommentedOut(text, pos)) { continue; }
1928
+ const found = _enclosingCallbackParam(text, pos);
1929
+ const callee = found ? found[0] : null;
1930
+ if (callee && callee !== self && overlayNames.has(callee) && !out.has(callee)) { out.set(callee, pos); }
1931
+ }
1932
+ return [...out];
1933
+ }
1934
+
1935
+ /** [callee_name, param_name] or null. */
1936
+ export function _enclosingCallbackParam(text, pos) {
1937
+ let depth = 0; let brace = -1;
1938
+ let i = pos;
1939
+ while (i > 0) {
1940
+ i -= 1;
1941
+ const c = text[i];
1942
+ if (c === '}') { depth += 1; } else if (c === '{') {
1943
+ if (depth === 0) { brace = i; break; }
1944
+ depth -= 1;
1945
+ }
1946
+ }
1947
+ if (brace === -1) { return null; }
1948
+ const head = text.slice(Math.max(0, brace - 200), brace + 1);
1949
+ const pm = search(_CALLBACK_PARAM_DECL, head);
1950
+ if (!pm) { return null; }
1951
+ const param = pm[1];
1952
+ depth = 0; let j = brace; let paren = -1;
1953
+ while (j > 0) {
1954
+ j -= 1;
1955
+ const c = text[j];
1956
+ if (c === ')') { depth += 1; } else if (c === '(') {
1957
+ if (depth === 0) { paren = j; break; }
1958
+ depth -= 1;
1959
+ }
1960
+ }
1961
+ if (paren === -1) { return null; }
1962
+ const cm = search(_CALLEE_TAIL_RE, text.slice(Math.max(0, paren - 120), paren));
1963
+ if (!cm) { return null; }
1964
+ return [cm[1], param];
1965
+ }
1966
+
1967
+ const _invokeRe = (param) => rx(S`\b` + reEscape(param) + S`\s*(?:\?\.\s*invoke)?\s*\(`);
1968
+
1969
+ /** [key, label] or [null, null]. */
1970
+ export function _resolveHoistedLabel(text, pos, strings, fileText, calleeIndex, depth = 0) {
1971
+ if (depth >= _HOIST_MAX_HOPS) { return [null, null]; }
1972
+ const found = _enclosingCallbackParam(text, pos);
1973
+ if (!found) { return [null, null]; }
1974
+ const [callee, param] = found;
1975
+ const defs = dg(calleeIndex, callee, null) || [];
1976
+ if (defs.length !== 1) { return [null, null]; }
1977
+ const [dpath, dstart] = defs[0];
1978
+ const dtext = ftGet(fileText, dpath, null);
1979
+ if (dtext === null || dtext === undefined) { return [null, null]; }
1980
+ const rng = _funBodyRange(dtext, dstart);
1981
+ if (rng === null) { return [null, null]; }
1982
+ const [b0, b1] = rng;
1983
+ const body = dtext.slice(b0, b1);
1984
+ for (const im of finditer(_invokeRe(param), body)) {
1985
+ const ipos = b0 + im.index;
1986
+ const [lbl, key] = clickableLabel(dtext, ipos, strings);
1987
+ if (lbl && key !== 'widget:') { return [key || lbl, lbl]; }
1988
+ const [k, l] = _resolveHoistedLabel(dtext, ipos, strings, fileText, calleeIndex, depth + 1);
1989
+ if (l) { return [k, l]; }
1990
+ }
1991
+ return [null, null];
1992
+ }
1993
+
1994
+ export function _resolveHoistedGesture(text, pos, fileText, calleeIndex, depth = 0) {
1995
+ if (depth >= _HOIST_MAX_HOPS) { return null; }
1996
+ const found = _enclosingCallbackParam(text, pos);
1997
+ if (!found) { return null; }
1998
+ const [callee, param] = found;
1999
+ const defs = dg(calleeIndex, callee, null) || [];
2000
+ if (defs.length !== 1) { return null; }
2001
+ const [dpath, dstart] = defs[0];
2002
+ const dtext = ftGet(fileText, dpath, null);
2003
+ if (dtext === null || dtext === undefined) { return null; }
2004
+ const rng = _funBodyRange(dtext, dstart);
2005
+ if (rng === null) { return null; }
2006
+ const [b0, b1] = rng;
2007
+ const body = dtext.slice(b0, b1);
2008
+ for (const im of finditer(_invokeRe(param), body)) {
2009
+ const ipos = b0 + im.index;
2010
+ const g = enclosingGesture(dtext, ipos);
2011
+ if (g && g !== 'tap') { return g; }
2012
+ const deeper = _resolveHoistedGesture(dtext, ipos, fileText, calleeIndex, depth + 1);
2013
+ if (deeper) { return deeper; }
2014
+ }
2015
+ return null;
2016
+ }
2017
+
2018
+ const _SEALED_VARIANT_RE = P(S`\b[A-Z]\w*(?:\.\w+)*\.([A-Z]\w*)\s*[({]`);
2019
+
2020
+ /**
2021
+ * Map<token, [key, label, line]>; disagreeing openers under key "__multi__" as
2022
+ * Map<flag, [[pos, key, label, line], ...]>.
2023
+ */
2024
+ export function _buildFlagLabels(text, funs, strings, fileText = null, calleeIndex = null) {
2025
+ if (fileText !== null && _isKw(fileText)) { calleeIndex = fileText.callee_index ?? null; fileText = fileText.file_text ?? null; }
2026
+ const out = new Map();
2027
+ _STATE_DECL_RES.forEach((re, ri) => {
2028
+ for (const fm of finditer(re, text)) {
2029
+ const flag = fm[1];
2030
+ const setters = [];
2031
+ for (const tm of finditer(rx(reEscape(flag) + S`(?:\.value)?\s*=\s*(?!=)\s*(\w+)`), text)) {
2032
+ if (tm.index === mStart(fm, 1)) { continue; }
2033
+ if (tm[1] === 'false' || tm[1] === 'null') { continue; }
2034
+ if (isCommentedOut(text, tm.index)) { continue; }
2035
+ setters.push(tm.index);
2036
+ }
2037
+ if (ri === 2 && fm[2] !== undefined) {
2038
+ for (const tm of finditer(rx(reEscape(fm[2]) + S`\s*\(`), text)) {
2039
+ if (isCommentedOut(text, tm.index)) { continue; }
2040
+ setters.push(tm.index);
2041
+ }
2042
+ }
2043
+ const cands = [];
2044
+ for (const pos of setters) {
2045
+ let [lbl, key] = clickableLabel(text, pos, strings);
2046
+ if (key === 'widget:') { lbl = null; }
2047
+ if (!lbl && fileText !== null && calleeIndex !== null) {
2048
+ [key, lbl] = _resolveHoistedLabel(text, pos, strings, fileText, calleeIndex);
2049
+ }
2050
+ if (lbl) { cands.push([pos, key || lbl, lbl, lineOf(text, pos)]); }
2051
+ }
2052
+ if (!cands.length) { continue; }
2053
+ const keys = new Set(cands.map((c) => c[1]));
2054
+ if (keys.size === 1) {
2055
+ const [, key, lbl, ln] = cands[0];
2056
+ out.set(flag, [key, lbl, ln]);
2057
+ } else {
2058
+ setdefault(out, '__multi__', new Map()).set(flag, cands);
2059
+ }
2060
+ }
2061
+ });
2062
+ for (const vm of finditer(_SEALED_VARIANT_RE, text)) {
2063
+ const variant = vm[1];
2064
+ if (out.has(variant) || isCommentedOut(text, vm.index)) { continue; }
2065
+ let [lbl, key] = clickableLabel(text, vm.index, strings, { file_text: fileText });
2066
+ if (key === 'widget:') { lbl = null; }
2067
+ if (!lbl && fileText !== null && calleeIndex !== null) {
2068
+ [key, lbl] = _resolveHoistedLabel(text, vm.index, strings, fileText, calleeIndex);
2069
+ }
2070
+ if (lbl) { out.set(variant, [key || lbl, lbl, lineOf(text, vm.index)]); }
2071
+ }
2072
+ return out;
2073
+ }
2074
+
2075
+ /** [key, label, line] or [null, null, null]. */
2076
+ export function _flagLabelFor(flagLabel, flag, funs, renderPos, text) {
2077
+ if (dh(flagLabel, flag)) { return dg(flagLabel, flag); }
2078
+ const multi = dg(dg(flagLabel, '__multi__', null) || new Map(), flag, null);
2079
+ if (!multi || !multi.length) { return [null, null, null]; }
2080
+ const here = enclosingFn(funs, renderPos);
2081
+ const same = multi.filter((c) => enclosingFn(funs, c[0]) === here);
2082
+ if (same.length === 1) { const [, key, lbl, ln] = same[0]; return [key, lbl, ln]; }
2083
+ if (same.length) {
2084
+ const keys = new Set(same.map((c) => c[1]));
2085
+ if (keys.size === 1) { const [, key, lbl, ln] = same[0]; return [key, lbl, ln]; }
2086
+ }
2087
+ return [null, null, null];
2088
+ }
2089
+
2090
+ /** text.splitlines(True)[:n] total length (Python line boundaries). */
2091
+ function _offsetOfLine(text, lineNo) {
2092
+ // sum(len(l) for l in text.splitlines(True)[:lineNo-1]) — in UTF-16 units, consistent with JS offsets.
2093
+ const re = /\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/g;
2094
+ let off = 0; let k = 0;
2095
+ if (lineNo - 1 <= 0) { return 0; }
2096
+ let m;
2097
+ while ((m = re.exec(text)) !== null) {
2098
+ off = m.index + m[0].length; k += 1;
2099
+ if (k >= lineNo - 1) { return off; }
2100
+ }
2101
+ return text.length;
2102
+ }
2103
+
2104
+ const _argsOf = (pairs) => {
2105
+ const o = {};
2106
+ for (const [k, v] of pairs) { if (T(v)) { o[k] = v; } }
2107
+ return o;
2108
+ };
2109
+
2110
+ /** os.path.join(a, b) (no normalisation). */
2111
+ export function osJoin(a, b) {
2112
+ const sep = IS_WIN ? '\\' : '/';
2113
+ if (IS_WIN && /^[A-Za-z]:/.test(b)) { return b; }
2114
+ if (b.startsWith('/') || (IS_WIN && b.startsWith('\\'))) { return IS_WIN && /^[A-Za-z]:/.test(a) ? a.slice(0, 2) + b : b; }
2115
+ return a.endsWith('/') || a.endsWith(sep) || (IS_WIN && /^[A-Za-z]:$/.test(a)) ? a + b : a + sep + b;
2116
+ }
2117
+
2118
+ function _walkKt(project) {
2119
+ const out = [];
2120
+ const skip = new Set(['build', '.git', 'test', 'androidTest']);
2121
+ for (const [dp, dirs, files] of _osWalk(project)) {
2122
+ const keep = dirs.filter((d) => !skip.has(d));
2123
+ dirs.length = 0; dirs.push(...keep);
2124
+ for (const fn of files) { if (fn.endsWith('.kt')) { out.push(osJoin(dp, fn)); } }
2125
+ }
2126
+ return out;
2127
+ }
2128
+
2129
+ export function main(argv = process.argv.slice(2)) {
2130
+ const ap = new ArgumentParser({ prog: 'compose_overlay.mjs' });
2131
+ ap.add_argument('project');
2132
+ ap.add_argument('--strings', { default: null, help: 'values-zh/strings.xml for label resolution' });
2133
+ const args = ap.parse_args(argv);
2134
+ const project = args.project;
2135
+ const strings = loadProjectStrings(project);
2136
+ if (args.strings && pExists(args.strings)) {
2137
+ const extra = loadStrings(args.strings);
2138
+ for (const k of keysOf(extra)) { dset(strings, k, extra[k]); }
2139
+ }
2140
+ const [screen2route, routeFiles] = screenRouteMap(project, true);
2141
+ setRouteFiles(routeFiles);
2142
+ const s2rValues = new Set(screen2route.values());
2143
+
2144
+ // ---- pass 1: collect overlay definitions
2145
+ const ktFiles = _walkKt(project);
2146
+ const overlays = new Map();
2147
+ const fileText = new Map();
2148
+ for (const p of ktFiles) {
2149
+ const text = readTextSmart(p);
2150
+ fileText.set(p, text);
2151
+ const r = rel(p, project);
2152
+ for (const m of finditer(DEF_RE, text)) {
2153
+ const name = m[1];
2154
+ const body = ownBody(text, mEnd(m));
2155
+ overlays.set(name, {
2156
+ kind: inferKind(body), file: r, line: lineOf(text, m.index),
2157
+ identity: overlayIdentityText(body, strings), body, params: _declParams(text, mEnd(m) - 1),
2158
+ });
2159
+ }
2160
+ }
2161
+ const allNames = [...overlays.keys()];
2162
+ const gateDelegate = new Map();
2163
+ for (const [n, d] of overlays) {
2164
+ const body = d.body || '';
2165
+ if (rendersOwnOverlay(body, overlays)) { continue; }
2166
+ let first = null; let fpos = null;
2167
+ for (const cand of allNames) {
2168
+ if (cand === n) { continue; }
2169
+ const i = _findPrim(body, cand + '(');
2170
+ if (i >= 0 && (fpos === null || i < fpos)) { first = cand; fpos = i; }
2171
+ }
2172
+ if (first) { gateDelegate.set(n, first); }
2173
+ }
2174
+ for (const d of overlays.values()) { delete d.body; }
2175
+ const resolveGate = (name) => {
2176
+ const seen = new Set();
2177
+ while (gateDelegate.has(name) && !seen.has(name)) { seen.add(name); name = gateDelegate.get(name); }
2178
+ return name;
2179
+ };
2180
+ const overlayNames = new Set(overlays.keys());
2181
+ const callSiteFiles = new Map([...overlayNames].map((n) => [n, new Set()]));
2182
+ for (const [p, text] of fileText) {
2183
+ const r = rel(p, project);
2184
+ for (const name of overlayNames) {
2185
+ if (r === overlays.get(name).file) { continue; }
2186
+ if (search(rx(S`(?<![A-Za-z_.])` + reEscape(name) + S`\s*[({]`), text)) { callSiteFiles.get(name).add(r); }
2187
+ }
2188
+ }
2189
+ const sharedClass = new Map();
2190
+ for (const [name, meta] of overlays) {
2191
+ sharedClass.set(name, classifyShared(meta.params ?? '', meta.identity || [], (callSiteFiles.get(name) || new Set()).size));
2192
+ }
2193
+ const tmpl = sortedBy([...sharedClass].filter(([, c]) => c === 'template').map((x) => x[0]), (x) => x);
2194
+ const shell = sortedBy([...sharedClass].filter(([, c]) => c === 'shell').map((x) => x[0]), (x) => x);
2195
+ if (tmpl.length) { pyPrintErr(`[overlay] parameterized templates (instantiated per call site): ${tmpl.join(', ')}`); }
2196
+ if (shell.length) { pyPrintErr(`[overlay] layout shells (folded, no node emitted): ${shell.join(', ')}`); }
2197
+ // A gate cannot fold into a delegate that emits no node of its own (a shell, or a template that
2198
+ // only exists per call site): its edges would point at an id nobody declares. It keeps its node.
2199
+ const unfolded = [];
2200
+ for (const [g, dlg] of [...gateDelegate]) {
2201
+ const c = sharedClass.get(dlg) ?? 'page';
2202
+ if (c === 'shell' || c === 'template') { gateDelegate.delete(g); unfolded.push(g); }
2203
+ }
2204
+ if (gateDelegate.size) {
2205
+ pyPrintErr('[overlay] condition gates (folded into delegate, no node emitted): ' +
2206
+ sortedBy([...gateDelegate], (x) => x[0]).map(([k, v]) => `${k}->${v}`).join(', '));
2207
+ }
2208
+ if (unfolded.length) {
2209
+ pyPrintErr(`[overlay] gates kept as nodes (delegate is a shell/template): ${sortedBy(unfolded, (x) => x).join(', ')}`);
2210
+ }
2211
+ resetAmbiguousHops();
2212
+ const callIndex = buildCallIndex(fileText, screen2route);
2213
+ const calleeIndex = _buildCalleeIndex(fileText);
2214
+
2215
+ const nodes = []; let edges = [];
2216
+ for (const [name, meta] of sortedBy([...overlays], (x) => x[0])) {
2217
+ const cls = sharedClass.get(name) ?? 'page';
2218
+ if (cls === 'template' || cls === 'shell') { continue; }
2219
+ if (gateDelegate.has(name)) { continue; }
2220
+ const node = {
2221
+ type: 'node', id: 'overlay:' + name, kind: meta.kind, label: name,
2222
+ declared_at: `${meta.file}:${meta.line}`, status: 'static-only', provenance: 'static:overlay-scan',
2223
+ };
2224
+ if (T(meta.identity)) { node.expected = { title_any: [...meta.identity] }; }
2225
+ nodes.push(node);
2226
+ }
2227
+
2228
+ // ---- gated content slots
2229
+ const expandableIndex = _buildExpandableStateIndex(fileText);
2230
+ const gatedSlotMeta = new Map();
2231
+ /** [{m, argtext, stateIdent, slotNames, ...}] per confirmed gated container call, for both passes. */
2232
+ const gatedCalls = (p, text) => {
2233
+ const out = [];
2234
+ for (const m of finditer(_GATED_CALL_RE, text)) {
2235
+ const containerName = m[1];
2236
+ const parenStart = mStart(m, 2);
2237
+ const argtext = _extractBalancedGenerous(text, parenStart);
2238
+ if (argtext === null) { continue; }
2239
+ const [stateIdent, slotNames] = _findGatedContainer(argtext);
2240
+ if (!stateIdent || !slotNames.length) { continue; }
2241
+ if (!_isConfirmedExpandable(p, stateIdent, expandableIndex)) { continue; }
2242
+ const slots = [];
2243
+ for (const slotName of slotNames) {
2244
+ const argStart = argtext.indexOf(slotName);
2245
+ const eqPos = argtext.indexOf('=', argStart);
2246
+ const bracePos = argtext.indexOf('{', eqPos);
2247
+ if (bracePos === -1) { slots.push(null); continue; }
2248
+ const rawBody = _extractBalancedGenerous(argtext, bracePos, '{', '}');
2249
+ if (rawBody === null) { slots.push(null); continue; }
2250
+ const unwrapped = _unwrapStructuralWrappers(rawBody);
2251
+ const calls = _sheetTopLevelCalls(unwrapped).filter((c) => !_PAGER_STRUCTURAL_PRIMS.has(c) && !_LEAF_UI_PRIMS.has(c));
2252
+ slots.push(calls.length ? calls[0] : null);
2253
+ }
2254
+ out.push({ m, containerName, stateIdent, slots });
2255
+ }
2256
+ return out;
2257
+ };
2258
+ for (const [p, text] of fileText) {
2259
+ const r = rel(p, project);
2260
+ for (const g of gatedCalls(p, text)) {
2261
+ const kind = g.containerName.toLowerCase().includes('drawer') ? 'menu' : 'sheet-screen';
2262
+ for (const pageName of g.slots) {
2263
+ if (pageName === null) { continue; }
2264
+ setdefault(gatedSlotMeta, pageName, { file: r, line: lineOf(text, g.m.index), kind });
2265
+ }
2266
+ }
2267
+ }
2268
+ const pagerPageIds = scanPagerPageNames(fileText);
2269
+ const modeGatedFns = scanModeGatedNames(fileText);
2270
+ const modeIdsSeen = new Set();
2271
+ const gatedSlotIds = new Map();
2272
+ for (const [name, meta] of sortedBy([...gatedSlotMeta], (x) => x[0])) {
2273
+ const prefix = meta.kind === 'menu' ? 'overlay:' : 'sheet-screen:';
2274
+ gatedSlotIds.set(name, prefix + name);
2275
+ nodes.push({
2276
+ type: 'node', id: prefix + name, kind: meta.kind, label: name,
2277
+ declared_at: `${meta.file}:${meta.line}`, status: 'static-only', provenance: 'static:overlay-scan',
2278
+ });
2279
+ }
2280
+ const tiers = { call_index: callIndex, gated_slot_ids: gatedSlotIds, pager_page_ids: pagerPageIds, mode_gated_fns: modeGatedFns };
2281
+
2282
+ // ---- NavHost start destination
2283
+ for (const [p, text] of fileText) {
2284
+ const r = rel(p, project);
2285
+ for (const m of finditer(_START_DEST_RE, text)) {
2286
+ // A nested navigation(…) graph is entered through the edges into it (compose_nav).
2287
+ if (inNestedNavGraph(text, m.index)) { continue; }
2288
+ const ident = m[1];
2289
+ const line = lineOf(text, m.index);
2290
+ const direct = matchAt(_ROUTE_CONST_RE, ident, 0);
2291
+ const candCond = new Map();
2292
+ if (direct) { candCond.set(direct[1], null); } else if (s2rValues.has(ident)) { candCond.set(ident, null); } else {
2293
+ const declRe = rx(reEscape(ident) + S`\s*(?:by\s+remember\s*\{\s*mutableStateOf\(|=)\s*([A-Za-z_]\w*)\s*\(`);
2294
+ const dm = search(declRe, text);
2295
+ if (dm) {
2296
+ const fnName = dm[1];
2297
+ const fnDecl = search(rx(S`\bfun\s+` + reEscape(fnName) + S`\s*\(`), text);
2298
+ if (fnDecl) {
2299
+ const fnBodyStart = text.indexOf('{', mEnd(fnDecl));
2300
+ const fnBody = fnBodyStart < 0 ? _extractBalancedGenerous(text, text.length - 1, '{', '}')
2301
+ : _extractBalancedGenerous(text, fnBodyStart, '{', '}');
2302
+ if (fnBody) {
2303
+ for (const cm2 of finditer(_ROUTE_CONST_RE, fnBody)) {
2304
+ const rk = cm2[1];
2305
+ const cond = branchConditionAt(fnBody, cm2.index);
2306
+ if (!candCond.has(rk) || candCond.get(rk) === null) { candCond.set(rk, cond); }
2307
+ }
2308
+ }
2309
+ }
2310
+ }
2311
+ }
2312
+ for (const routeKey of sortedBy([...candCond.keys()], (x) => x)) {
2313
+ if (!s2rValues.has(routeKey)) { continue; }
2314
+ const routeNodeId = 'compose-route:' + routeKey;
2315
+ const fn = enclosingFn(buildFunIndex(text), m.index);
2316
+ const [source, how] = resolveSource(r, fn, screen2route, overlayNames, tiers);
2317
+ // No owning page: `screen:<fn>` would be a fabricated endpoint no extractor declares.
2318
+ if (how === 'fallback') { continue; }
2319
+ const cond = candCond.get(routeKey);
2320
+ let guard; let confidence;
2321
+ if (cond !== null) { guard = { text: cond, kind: null }; confidence = asFloat(0.25); } else {
2322
+ guard = null; confidence = asFloat(candCond.size === 1 ? 0.6 : 0.4);
2323
+ }
2324
+ edges.push({
2325
+ type: 'edge', source, target: routeNodeId, mechanism: 'compose-navigate',
2326
+ trigger: `startDestination@${r}:${line}`, guard, args: {}, provenance: 'static:llm',
2327
+ status: 'static-only', confidence,
2328
+ });
2329
+ }
2330
+ }
2331
+ }
2332
+
2333
+ for (const [p, text] of fileText) {
2334
+ for (const g of gatedCalls(p, text)) {
2335
+ for (const pageName of g.slots) {
2336
+ if (pageName === null) { continue; }
2337
+ const meta = gatedSlotMeta.get(pageName);
2338
+ if (!meta) { continue; }
2339
+ const prefix = meta.kind === 'menu' ? 'overlay:' : 'sheet-screen:';
2340
+ const tid = prefix + pageName;
2341
+ let [trigPath, trigPos] = _findExpandTrigger(p, g.stateIdent, fileText, expandableIndex);
2342
+ if (trigPath === null) { trigPath = p; trigPos = g.m.index; }
2343
+ const trigText = fileText.get(trigPath);
2344
+ const trigR = rel(trigPath, project);
2345
+ const trigFn = enclosingFn(buildFunIndex(trigText), trigPos);
2346
+ const [source, how] = resolveSource(trigR, trigFn, screen2route, overlayNames, tiers);
2347
+ if (source === tid) { continue; }
2348
+ const [label, labelKey] = clickableLabel(trigText, trigPos, strings, { file_text: fileText });
2349
+ const gesture = enclosingGesture(trigText, trigPos);
2350
+ edges.push({
2351
+ type: 'edge', source, target: tid, mechanism: 'open-overlay',
2352
+ trigger: `onClick@${trigR}:${lineOf(trigText, trigPos)}`, guard: null,
2353
+ args: _argsOf([['label', label], ['label_key', labelKey], ['gesture', gesture], ['source_resolved_by', how]]),
2354
+ provenance: 'static:overlay-scan', status: 'static-only', confidence: asFloat(0.8),
2355
+ });
2356
+ }
2357
+ }
2358
+ }
2359
+
2360
+ // ---- pass 2: call-sites of known overlays = open-overlay edges
2361
+ const hosted = new Set(); const instanceIds = new Set();
2362
+ const sortedOverlayNames = sortedBy([...overlayNames], (x) => x);
2363
+ const gateRe = P(S`if\s*\(\s*(\w+)(?:\.value)?\s*(?:!=\s*null\s*)?\)|` + S`\b(\w+)(?:\.value)?\s*\?\.\s*let\s*\{`);
2364
+ const armRe = P(S`(?:is\s+)?([A-Z]\w*(?:\.\w+)+)\s*->`);
2365
+ for (const [p, text] of fileText) {
2366
+ const r = rel(p, project);
2367
+ const funs = buildFunIndex(text);
2368
+ const flagLabel = _buildFlagLabels(text, funs, strings, fileText, calleeIndex);
2369
+ const deadFlags = _deadStateFlags(text);
2370
+ for (const name of sortedOverlayNames) {
2371
+ for (const cm of finditer(rx(S`\b` + reEscape(name) + S`\s*[({]`), text)) {
2372
+ const pos = cm.index;
2373
+ if (r === overlays.get(name).file && lineOf(text, pos) === overlays.get(name).line) { continue; }
2374
+ const fn = enclosingFn(funs, pos);
2375
+ if (fn === name) { continue; }
2376
+ let sources = resolveSources(r, fn, screen2route, overlayNames, tiers);
2377
+ const back = text.slice(Math.max(0, pos - 400), pos);
2378
+ let gates = reFindall(gateRe, back).map(([a, b]) => a || b);
2379
+ if (!gates.length) {
2380
+ const am = reFindall(armRe, back);
2381
+ gates = am.map((a) => a.split('.').pop()).slice(-1);
2382
+ }
2383
+ if (gates.length && deadFlags.has(gates[gates.length - 1])) { continue; }
2384
+ if (isCommentedOut(text, pos)) { continue; }
2385
+ let labelKey = null; let label = null;
2386
+ const callLine = lineOf(text, pos);
2387
+ let trigLine = callLine;
2388
+ if (gates.length) {
2389
+ const [k, l, ln] = _flagLabelFor(flagLabel, gates[gates.length - 1], funs, pos, text);
2390
+ if (k) { labelKey = k; label = l; trigLine = ln; }
2391
+ }
2392
+ if (!label) {
2393
+ let scanText = text;
2394
+ const openParen = text.indexOf('(', pos);
2395
+ const braceAt = text.indexOf('{', pos);
2396
+ if (openParen !== -1 && (braceAt === -1 || openParen < braceAt)) {
2397
+ const own = _extractBalancedGenerous(text, openParen);
2398
+ if (own) {
2399
+ const a = openParen + 1; const b = openParen + 1 + own.length;
2400
+ scanText = text.slice(0, a) + ' '.repeat(b - a) + text.slice(b);
2401
+ }
2402
+ }
2403
+ [labelKey, label] = nearestLabel(scanText, pos, strings);
2404
+ }
2405
+ // A gate flag set inside a callback handed to another overlay
2406
+ // (`DetailPopup(onQueryClick = { showQuery = true })`): that overlay opens this one too.
2407
+ const condM = /\bif\s*\(([^(){}]*)\)\s*\{[^{}]*$/.exec(back);
2408
+ const gateIdents = gates.length ? [gates[gates.length - 1]]
2409
+ : (condM ? [...new Set(condM[1].match(/\b[a-z]\w*\b/g) || [])] : []);
2410
+ let fnDecl = null;
2411
+ for (const [start, nm] of funs) { if (start <= pos && nm === fn) { fnDecl = start; } else if (start > pos) { break; } }
2412
+ const fnRange = fnDecl === null ? null : _funBodyRange(text, fnDecl);
2413
+ const viaOverlay = fnRange === null ? []
2414
+ : gateIdents.flatMap((f) => _overlayCallbackHosts(text, f, name, overlayNames, fnRange));
2415
+ const trigPosG = _offsetOfLine(text, trigLine);
2416
+ for (const gp of _nullableCbGates(text, trigPosG, funs)) {
2417
+ sources = _filterSourcesByCbParam(sources, gp, enclosingFn(funs, trigPosG), fileText,
2418
+ project, screen2route, overlayNames, callIndex, gatedSlotIds, pagerPageIds);
2419
+ }
2420
+ if (!sources.length) { continue; }
2421
+ const cls = sharedClass.get(name) ?? 'page';
2422
+ if (cls === 'shell') { continue; }
2423
+ let targetId;
2424
+ if (cls === 'template') {
2425
+ const [tval, tkey] = callSiteTitle(text, pos, strings);
2426
+ const instId = `overlay:${name}@${r}:${callLine}`;
2427
+ const labelTxt = tval || `${name} (${r}:${callLine})`;
2428
+ const inst = {
2429
+ type: 'node', id: instId, kind: overlays.get(name).kind, label: labelTxt,
2430
+ declared_at: `${r}:${callLine}`, status: 'static-only', provenance: 'static:overlay-scan',
2431
+ template_of: 'overlay:' + name,
2432
+ };
2433
+ if (tval) {
2434
+ inst.expected = { title_any: [tval] };
2435
+ if (tkey) { inst.title_key = tkey; }
2436
+ }
2437
+ if (!instanceIds.has(instId)) { instanceIds.add(instId); nodes.push(inst); }
2438
+ targetId = instId;
2439
+ } else { targetId = 'overlay:' + name; }
2440
+ let gestureH = enclosingGesture(text, trigPosG);
2441
+ if (gestureH === null || gestureH === 'tap') {
2442
+ gestureH = _resolveHoistedGesture(text, trigPosG, fileText, calleeIndex) || gestureH;
2443
+ }
2444
+ for (const [source, how] of sources) {
2445
+ const key = tupleKey(source, targetId);
2446
+ if (hosted.has(key)) { continue; }
2447
+ hosted.add(key);
2448
+ edges.push({
2449
+ type: 'edge', source, target: targetId, mechanism: 'open-overlay',
2450
+ trigger: `onClick@${r}:${trigLine}`, guard: null,
2451
+ args: _argsOf([['label', label], ['label_key', labelKey], ['gesture', gestureH], ['source_resolved_by', how]]),
2452
+ provenance: 'static:overlay-scan', status: 'static-only', confidence: asFloat(0.8),
2453
+ });
2454
+ }
2455
+ for (const [host, hpos] of viaOverlay) {
2456
+ const key = tupleKey('overlay:' + host, targetId);
2457
+ if (hosted.has(key)) { continue; }
2458
+ hosted.add(key);
2459
+ const [hk, hl] = _resolveHoistedLabel(text, hpos, strings, fileText, calleeIndex);
2460
+ edges.push({
2461
+ type: 'edge', source: 'overlay:' + host, target: targetId, mechanism: 'open-overlay',
2462
+ trigger: `onClick@${r}:${lineOf(text, hpos)}`, guard: null,
2463
+ args: _argsOf([['label', hl], ['label_key', hk], ['gesture', 'tap'], ['source_resolved_by', 'callback-of-overlay']]),
2464
+ provenance: 'static:overlay-scan', status: 'static-only', confidence: asFloat(0.7),
2465
+ });
2466
+ }
2467
+ }
2468
+ }
2469
+ }
2470
+
2471
+ // ---- multi-select mode
2472
+ const multipleChoice = dg(strings, 'multiple_choice', null);
2473
+ for (const [p, text] of fileText) {
2474
+ const r = rel(p, project);
2475
+ for (const mm of finditer(_MODE_FLAG_DECL_RE, text)) {
2476
+ if (isCommentedOut(text, mm.index)) { continue; }
2477
+ if (!modeFlagIsInteractive(text, mm[1])) { continue; }
2478
+ const ln = lineOf(text, mm.index);
2479
+ for (const [src] of resolveSources(r, enclosingFn(buildFunIndex(text), mm.index), screen2route, overlayNames, {
2480
+ call_index: callIndex, gated_slot_ids: gatedSlotIds, pager_page_ids: pagerPageIds, partial_tiers: true,
2481
+ })) {
2482
+ const mid = modeNodeId(mm[1], _routePart(src));
2483
+ if (!modeIdsSeen.has(mid)) {
2484
+ modeIdsSeen.add(mid);
2485
+ nodes.push({
2486
+ type: 'node', id: mid, kind: 'mode', label: multipleChoice || mm[1],
2487
+ declared_at: `${r}:${ln}`, status: 'static-only', provenance: 'static:overlay-scan',
2488
+ });
2489
+ }
2490
+ edges.push({
2491
+ type: 'edge', source: src, target: mid, mechanism: 'enter-mode', trigger: `onClick@${r}:${ln}`,
2492
+ guard: null, args: { label: multipleChoice }, provenance: 'static:overlay-scan',
2493
+ status: 'static-only', confidence: asFloat(0.85),
2494
+ });
2495
+ }
2496
+ }
2497
+ }
2498
+
2499
+ // ---- pager pages
2500
+ const pagerEdges = new Map();
2501
+ const pagerNodesSeen = new Set();
2502
+ const pagerSurfaces = new Map();
2503
+ const pagerDefaultReachable = new Set();
2504
+ const pagerBodyIndex = new Map();
2505
+ for (const [, t] of fileText) {
2506
+ for (const [s, nm] of buildFunIndex(t)) { setdefault(pagerBodyIndex, nm, [t, s]); }
2507
+ }
2508
+ const pagerIdentityCache = new Map();
2509
+ const pagerIdentity = (compName) => {
2510
+ if (pagerIdentityCache.has(compName)) { return pagerIdentityCache.get(compName); }
2511
+ const loc = pagerBodyIndex.get(compName);
2512
+ let toks = [];
2513
+ if (loc) {
2514
+ const [t, s] = loc;
2515
+ const rng = _funBodyRange(t, s);
2516
+ const body = rng ? t.slice(rng[0], rng[1]) : t.slice(s, s + 4000);
2517
+ toks = overlayIdentityText(body, strings);
2518
+ }
2519
+ pagerIdentityCache.set(compName, toks);
2520
+ return toks;
2521
+ };
2522
+ for (const [p, text] of fileText) {
2523
+ const r = rel(p, project);
2524
+ const funs = buildFunIndex(text);
2525
+ for (const pm of finditer(PAGER_RE, text)) {
2526
+ const directionWord = pm[1];
2527
+ const parenStart = mStart(pm, 2);
2528
+ const args = _extractBalancedGenerous(text, parenStart);
2529
+ if (args === null) { continue; }
2530
+ const callEnd = parenStart + 1 + args.length;
2531
+ const bodyStart = text.indexOf('{', callEnd);
2532
+ if (bodyStart === -1 || bodyStart > callEnd + 40) { continue; }
2533
+ const body = _extractBalancedGenerous(text, bodyStart, '{', '}');
2534
+ if (body === null) { continue; }
2535
+ const wm = search(_PAGER_WHEN_RE, body);
2536
+ if (!wm) { continue; }
2537
+ const whenBody = _extractBalancedGenerous(body, mEnd(wm) - 1, '{', '}');
2538
+ if (whenBody === null) { continue; }
2539
+ const branchPos = _pagerTopLevelBranches(whenBody);
2540
+ if (!branchPos.size) { continue; }
2541
+ const pagerPos = pm.index;
2542
+ const fn = enclosingFn(funs, pagerPos);
2543
+ const [source, how, climb] = resolveSource(r, fn, screen2route, overlayNames, {
2544
+ call_index: callIndex, gated_slot_ids: gatedSlotIds, partial_tiers: true, return_path: true,
2545
+ });
2546
+ const variant = _variantOf(r, pagerPos, text, climb, callIndex, fileText, project);
2547
+ const pagerLine = lineOf(text, pagerPos);
2548
+ const [initialPage, pageConfident] = _inferPagerInitialPage(text, pagerPos, fileText);
2549
+ for (const idx of [...branchPos.keys()].sort((a, b) => a - b)) {
2550
+ const seg = whenBody.slice(branchPos.get(idx), branchPos.get(idx) + 300);
2551
+ const cm = search(_PAGER_FIRST_CALL_RE, seg);
2552
+ if (!cm || _PAGER_STRUCTURAL_PRIMS.has(cm[1])) { continue; }
2553
+ const branchName = cm[1];
2554
+ const pid = 'pager:' + branchName;
2555
+ let swipeDir;
2556
+ if (idx === initialPage) { swipeDir = null; } else if (directionWord === 'Horizontal') {
2557
+ swipeDir = idx > initialPage ? 'swipe-left' : 'swipe-right';
2558
+ } else { swipeDir = idx > initialPage ? 'swipe-up' : 'swipe-down'; }
2559
+ const key = tupleKey(source, pid, get(variant, 'variant_id'));
2560
+ const existing = pagerEdges.get(key);
2561
+ if (existing !== undefined && existing[1] && !pageConfident) { continue; }
2562
+ if (!pagerNodesSeen.has(pid)) {
2563
+ pagerNodesSeen.add(pid);
2564
+ const pnode = {
2565
+ type: 'node', id: pid, kind: 'pager-page', label: branchName, declared_at: `${r}:${pagerLine}`,
2566
+ status: 'static-only', provenance: 'static:overlay-scan',
2567
+ };
2568
+ const toks = pagerIdentity(branchName);
2569
+ if (toks.length) { pnode.expected = { title_any: [...toks] }; }
2570
+ nodes.push(pnode);
2571
+ }
2572
+ const edge = {
2573
+ type: 'edge', source, target: pid, mechanism: 'pager-swipe', trigger: `pager@${r}:${pagerLine}`,
2574
+ guard: get(variant, 'guard'),
2575
+ args: { pager_index: idx, source_resolved_by: how, action: swipeDir || 'default', initial_page_confident: pageConfident },
2576
+ provenance: 'static:overlay-scan', status: 'static-only', confidence: asFloat(0.8),
2577
+ };
2578
+ if (T(get(variant, 'variant_group'))) { edge.args.variant_group = variant.variant_group; }
2579
+ if (T(get(variant, 'variant_id'))) { edge.args.variant_id = variant.variant_id; }
2580
+ if (T(get(variant, 'surface'))) {
2581
+ edge.args.surface = variant.surface;
2582
+ const ss = setdefault(pagerSurfaces, pid, new Set());
2583
+ for (const s of variant.surface) { ss.add(s); }
2584
+ }
2585
+ if (T(get(get(get(variant, 'guard') || {}, 'device_env') || {}, 'complement_of_arms'))) {
2586
+ pagerDefaultReachable.add(pid);
2587
+ }
2588
+ pagerEdges.set(key, [edge, pageConfident]);
2589
+ }
2590
+ }
2591
+ }
2592
+ for (const [e] of pagerEdges.values()) { edges.push(e); }
2593
+ for (const n of nodes) {
2594
+ if (get(n, 'kind') !== 'pager-page') { continue; }
2595
+ if (pagerSurfaces.has(n.id)) { n.surface = sortedBy([...pagerSurfaces.get(n.id)], (x) => x); }
2596
+ if (pagerDefaultReachable.has(n.id)) { n.surface_default_reachable = true; }
2597
+ }
2598
+
2599
+ // ---- View-system ViewPager2 + FragmentStateAdapter pages
2600
+ const fragEdges = new Map();
2601
+ const fragNodesSeen = new Set();
2602
+ for (const [p, text] of fileText) {
2603
+ const r = rel(p, project);
2604
+ const am = search(_ACTIVITY_CLASS_RE, text);
2605
+ if (!am) { continue; }
2606
+ const hostId = 'activity:' + am[1];
2607
+ for (const fm of finditer(_FRAGMENT_ADAPTER_RE, text)) {
2608
+ const bodyStart = text.indexOf('{', mEnd(fm));
2609
+ if (bodyStart === -1) { continue; }
2610
+ const body = _extractBalancedGenerous(text, bodyStart, '{', '}');
2611
+ if (body === null) { continue; }
2612
+ const wm = search(_PAGER_WHEN_RE, body);
2613
+ if (!wm) { continue; }
2614
+ const whenBody = _extractBalancedGenerous(body, mEnd(wm) - 1, '{', '}');
2615
+ if (whenBody === null) { continue; }
2616
+ const branchPos = _pagerTopLevelBranches(whenBody);
2617
+ if (!branchPos.size) { continue; }
2618
+ const fragLine = lineOf(text, fm.index);
2619
+ const idxs = [...branchPos.keys()].sort((a, b) => a - b);
2620
+ const initialPage = idxs[0];
2621
+ for (const idx of idxs) {
2622
+ const seg = whenBody.slice(branchPos.get(idx), branchPos.get(idx) + 300);
2623
+ const cm = search(_PAGER_FIRST_CALL_RE, seg);
2624
+ if (!cm || _PAGER_STRUCTURAL_PRIMS.has(cm[1])) { continue; }
2625
+ const fragName = cm[1];
2626
+ const pid = 'fragment:' + fragName;
2627
+ const swipeDir = idx === initialPage ? null : 'swipe-left';
2628
+ const key = tupleKey(hostId, pid);
2629
+ if (fragEdges.has(key)) { continue; }
2630
+ if (!fragNodesSeen.has(pid)) {
2631
+ fragNodesSeen.add(pid);
2632
+ const fnode = {
2633
+ type: 'node', id: pid, kind: 'pager-page', label: fragName, declared_at: `${r}:${fragLine}`,
2634
+ status: 'static-only', provenance: 'static:fragment-adapter',
2635
+ };
2636
+ const toks = pagerIdentity(fragName);
2637
+ if (toks.length) { fnode.expected = { title_any: [...toks] }; }
2638
+ nodes.push(fnode);
2639
+ }
2640
+ fragEdges.set(key, {
2641
+ type: 'edge', source: hostId, target: pid, mechanism: 'pager-swipe',
2642
+ trigger: `createFragment@${r}:${fragLine}`, guard: null,
2643
+ args: { pager_index: idx, source_resolved_by: 'activity-host', action: swipeDir || 'default', initial_page_confident: true },
2644
+ provenance: 'static:fragment-adapter', status: 'static-only', confidence: asFloat(0.8),
2645
+ });
2646
+ }
2647
+ }
2648
+ }
2649
+ for (const e of fragEdges.values()) { edges.push(e); }
2650
+
2651
+ // ---- data-state variants
2652
+ const emptyIdentity = [];
2653
+ const emptyFunRe = P(S`\bfun\s+(Empty\w*Box|Empty\w*State|NoneBox|` + S`NoData\w*|NoItems\w*|EmptyView)\s*\(`);
2654
+ for (const [, text] of fileText) {
2655
+ for (const m of finditer(emptyFunRe, text)) {
2656
+ const rng = _funBodyRange(text, m.index);
2657
+ if (!rng) { continue; }
2658
+ for (const tok of overlayIdentityText(text.slice(rng[0], rng[1]), strings)) {
2659
+ if (!emptyIdentity.includes(tok)) { emptyIdentity.push(tok); }
2660
+ }
2661
+ }
2662
+ }
2663
+ const variantRoutes = new Set();
2664
+ for (const [screen, route] of screen2route) {
2665
+ const funRe = rx(S`\bfun\s+` + reEscape(screen) + S`\s*\(`);
2666
+ for (const [, text] of fileText) {
2667
+ if (search(funRe, text) && search(EMPTY_STATE_CALL_RE, text)) { variantRoutes.add(route); break; }
2668
+ }
2669
+ }
2670
+ for (const route of sortedBy([...variantRoutes], (x) => x)) {
2671
+ const base = 'compose-route:' + route;
2672
+ for (const v of ['empty', 'populated']) {
2673
+ const vid = base + '#' + v;
2674
+ const nv = {
2675
+ type: 'node', id: vid, kind: 'compose-route-variant', label: `${route} (${v})`, label_synthetic: true,
2676
+ status: 'static-only', provenance: 'static:overlay-scan', variant_of: base, variant: v,
2677
+ };
2678
+ if (v === 'empty' && emptyIdentity.length) { nv.identity_text = [...emptyIdentity]; }
2679
+ nodes.push(nv);
2680
+ edges.push({
2681
+ type: 'edge', source: base, target: vid, mechanism: 'data-variant', trigger: 'render-branch',
2682
+ guard: Object.hasOwn(VARIANT_GUARD, v) ? VARIANT_GUARD[v] : v, args: { variant: v },
2683
+ provenance: 'static:overlay-scan', status: 'static-only', confidence: asFloat(0.9),
2684
+ });
2685
+ }
2686
+ }
2687
+
2688
+ if (gateDelegate.size) {
2689
+ const gateIds = new Set([...gateDelegate.keys()].map((g) => 'overlay:' + g));
2690
+ for (const e of edges) {
2691
+ for (const end of ['source', 'target']) {
2692
+ if (gateIds.has(get(e, end))) { e[end] = 'overlay:' + resolveGate(e[end].slice('overlay:'.length)); }
2693
+ }
2694
+ }
2695
+ const seenEdge = new Set(); const kept = [];
2696
+ for (const e of edges) {
2697
+ if (pyEq(get(e, 'source'), get(e, 'target'))) { continue; }
2698
+ const k = tupleKey(get(e, 'source'), get(e, 'target'), get(e, 'mechanism'), get(e, 'trigger'));
2699
+ if (seenEdge.has(k)) { continue; }
2700
+ seenEdge.add(k); kept.push(e);
2701
+ }
2702
+ edges = kept;
2703
+ }
2704
+
2705
+ let out = '';
2706
+ for (const x of [...nodes, ...edges]) { out += jsonDumps(x, { ensure_ascii: false }) + '\n'; }
2707
+ _writeStdout(out);
2708
+
2709
+ const kinds = {};
2710
+ for (const n of nodes) { dset(kinds, n.kind, (Object.hasOwn(kinds, n.kind) ? kinds[n.kind] : 0) + 1); }
2711
+ const ovEdges = edges.filter((e) => get(e, 'mechanism') === 'open-overlay');
2712
+ const labelled = ovEdges.filter((e) => T(get(get(e, 'args') || {}, 'label'))).length;
2713
+ const pgEdges = edges.filter((e) => get(e, 'mechanism') === 'pager-swipe');
2714
+ const devEnv = pgEdges.filter((e) => get(get(e, 'guard') || {}, 'kind') === 'device-env').length;
2715
+ const seenSt = new Map();
2716
+ for (const e of pgEdges) { const k = tupleKey(e.source, e.target); seenSt.set(k, (seenSt.get(k) ?? 0) + 1); }
2717
+ let pagerVariants = 0;
2718
+ for (const v of seenSt.values()) { if (v > 1) { pagerVariants += v - 1; } }
2719
+ const unconf = (e) => !T(get(get(e, 'args') || {}, 'initial_page_confident'));
2720
+ const pgUnconf = pgEdges.filter(unconf).length;
2721
+ const dups = dupCalleeNames(callIndex);
2722
+ const ambig = ambiguousHops();
2723
+ pyPrintErr(`[compose_overlay] overlays=${overlays.size} nodes=${nodes.length} ` +
2724
+ `edges=${edges.length} open_overlay=${ovEdges.length} ` +
2725
+ `labelled=${labelled} device_env=${devEnv} ` +
2726
+ `pager_variants=${pagerVariants} pager_unresolved=${pgUnconf} ` +
2727
+ `dup_callee_names=${dups.length} ambiguous_hops=${ambig.length} ` +
2728
+ `kinds=${pyRepr(kinds)}`);
2729
+ if (dups.length) {
2730
+ pyPrintErr(`# same-name composables in >1 file (resolved per call site by file scope/visibility): ${pyRepr(dups)}`);
2731
+ }
2732
+ if (ambig.length) {
2733
+ pyPrintErr('# call-graph hops REFUSED as ambiguous (2+ visible same-named ' +
2734
+ `declarations — no edge attributed): [${ambig.map(reprTuple).join(', ')}]`);
2735
+ }
2736
+ if (pgUnconf) {
2737
+ const un = sortedBy([...new Set(pgEdges.filter(unconf).map((e) => e.trigger))], (x) => x);
2738
+ pyPrintErr(`# pager initialPage UNRESOLVED at ${un.length} site(s) — swipe ` +
2739
+ 'directions there are a blind default of 0, verify against ' +
2740
+ `source: ${pyRepr(un)}`);
2741
+ }
2742
+ const targets = new Set(edges.map((e) => e.target));
2743
+ const orphan = nodes.filter((n) => n.id.startsWith('overlay:') && !targets.has(n.id)).map((n) => n.id);
2744
+ if (orphan.length) { pyPrintErr(`# orphan overlays (no show-site found, needs manual wiring): ${pyRepr(orphan)}`); }
2745
+ return 0;
2746
+ }
2747
+
2748
+ /** Write text to stdout in text mode ("\n" -> os.linesep), synchronously. */
2749
+ function _writeStdout(s) {
2750
+ if (!s) { return; }
2751
+ const buf = Buffer.from(IS_WIN ? s.replace(/\n/g, '\r\n') : s, 'utf8');
2752
+ let off = 0;
2753
+ while (off < buf.length) {
2754
+ try { off += fs.writeSync(1, buf, off, buf.length - off); } catch (e) { if (e.code === 'EAGAIN') { continue; } throw e; }
2755
+ }
2756
+ }
2757
+
2758
+ if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
2759
+ _spawn.guardMain(() => { main(); return null; });
2760
+ }