@buaa_smat/hometrans 26.0.0-devecocli.4 → 26.0.0

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 (715) hide show
  1. package/README.md +433 -0
  2. package/agents/build-fixer.md +1 -2
  3. package/agents/code-reviewer.md +31 -15
  4. package/agents/model-render-worker.md +9 -5
  5. package/dist/cli/config-store.js +128 -0
  6. package/dist/cli/config.js +48 -0
  7. package/dist/cli/editors.json +114 -0
  8. package/dist/cli/env-vars.js +127 -0
  9. package/dist/cli/index.js +73 -0
  10. package/dist/cli/init.js +2513 -0
  11. package/dist/cli/uninstall.js +406 -0
  12. package/dist/platform/compose.js +228 -0
  13. package/dist/platform/frontmatter.js +151 -0
  14. package/dist/platform/installer.js +417 -0
  15. package/dist/platform/registry.js +337 -0
  16. package/dist/platform/transform.js +363 -0
  17. package/dist/platform/types.js +9 -0
  18. package/dist/platform/validate.js +152 -0
  19. package/dist/utils/regex.js +7 -0
  20. package/env-requirements.json +511 -0
  21. package/package.json +240 -11
  22. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  23. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  24. package/resource/choose_editor.png +0 -0
  25. package/resource/convert_pipeline_process.svg +114 -0
  26. package/resource/project_architecture.svg +120 -0
  27. package/resource/set_environment.png +0 -0
  28. package/resource/set_multimodel.png +0 -0
  29. package/resource/set_sdk.png +0 -0
  30. package/resource/title_dark.png +0 -0
  31. package/skills/a2h-app-migrate/SKILL.md +17 -11
  32. package/skills/a2h-app-migrate/references/stage-map.md +22 -7
  33. package/skills/a2h-app-migrate/references/workflow.yaml +276 -209
  34. package/skills/a2h-app-migrate/scripts/android_index.mjs +34 -16
  35. package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +12 -12
  36. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +12 -12
  37. package/skills/a2h-app-migrate/scripts/check_signing.mjs +16 -16
  38. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +17 -16
  39. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +141 -62
  40. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +12 -12
  41. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +26 -26
  42. package/skills/a2h-app-migrate/scripts/cli_values.mjs +7 -7
  43. package/skills/a2h-app-migrate/scripts/ensure_utg_snapshot.mjs +144 -0
  44. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +474 -365
  45. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +115 -108
  46. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +5 -0
  47. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +54 -0
  48. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +6 -6
  49. package/skills/a2h-app-migrate/scripts/json_io.mjs +1 -1
  50. package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -15
  51. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +99 -99
  52. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +25 -25
  53. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +9 -9
  54. package/skills/a2h-app-migrate/scripts/run_dir.mjs +33 -33
  55. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +13 -11
  56. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +128 -80
  57. package/skills/a2h-app-migrate/scripts/write_resume_summary.mjs +349 -0
  58. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +21 -21
  59. package/skills/a2h-arch-generate/scripts/create_project.mjs +23 -23
  60. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +48 -40
  61. package/skills/a2h-arch-generate/scripts/generate_state.mjs +7 -7
  62. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +5 -0
  63. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +54 -0
  64. package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +10 -1
  65. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +41 -36
  66. package/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  67. package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1 -1
  68. package/skills/a2h-arch-generate/scripts/module_create/create.mjs +17 -17
  69. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +54 -50
  70. package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +42 -42
  71. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +69 -44
  72. package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +62 -17
  73. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +5 -4
  74. package/skills/a2h-arkts-logic-coder/SKILL.md +39 -8
  75. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  76. package/skills/a2h-arkts-logic-coder/references/code-generation.md +28 -17
  77. package/skills/{a2h-spec-design/SKILL.md → a2h-arkts-logic-coder/references/spec-design.md} +45 -78
  78. package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +1 -1
  79. package/skills/a2h-arkts-logic-coder/scripts/check_units.ts +448 -0
  80. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +5 -0
  81. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +54 -0
  82. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/inspect_spec_design_inputs.mjs +18 -12
  83. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/lib/py_compat.mjs +1 -1
  84. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/move_spec_technical_reference.mjs +10 -7
  85. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/resolve_module_design.mjs +13 -7
  86. package/skills/{a2h-spec-design/scripts → a2h-arkts-logic-coder/scripts/design}/validate_spec_design_output.mjs +57 -41
  87. package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +66 -323
  88. package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +66 -108
  89. package/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  90. package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +5 -18
  91. package/skills/a2h-batch-ui-align/SKILL.md +39 -39
  92. package/skills/a2h-batch-ui-align/references/cards/alignment.md +31 -0
  93. package/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  94. package/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  95. package/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  96. package/skills/a2h-batch-ui-align/references/cards/geometry.md +80 -0
  97. package/skills/a2h-batch-ui-align/references/cards/interaction.md +22 -0
  98. package/skills/a2h-batch-ui-align/references/cards/resources.md +83 -0
  99. package/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  100. package/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  101. package/skills/a2h-batch-ui-align/references/cards/widgets.md +38 -0
  102. package/skills/a2h-batch-ui-align/references/cards/window.md +29 -0
  103. package/skills/a2h-batch-ui-align/references/checker-rules.md +642 -0
  104. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +69 -260
  105. package/skills/a2h-batch-ui-align/references/host-dispatch.md +34 -0
  106. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +16 -4
  107. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +3 -1
  108. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +32 -1
  109. package/skills/a2h-batch-ui-align/references/source-only-tier.md +7 -1
  110. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +28 -0
  111. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +220 -0
  112. package/skills/a2h-batch-ui-align/references/step3-capture.md +11 -9
  113. package/skills/a2h-batch-ui-align/references/step4-prepare.md +13 -8
  114. package/skills/a2h-batch-ui-align/references/step5-convert.md +21 -18
  115. package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +44 -44
  116. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +237 -236
  117. package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +42 -3854
  118. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +34 -32
  119. package/skills/a2h-batch-ui-align/scripts/detach.mjs +1 -1
  120. package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +240 -0
  121. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +139 -33
  122. package/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  123. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +26 -25
  124. package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +1 -1
  125. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +159 -12
  126. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +145 -21
  127. package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +8 -8
  128. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +1 -1
  129. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +5 -0
  130. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +54 -0
  131. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +228 -0
  132. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +444 -266
  133. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +66 -32
  134. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +141 -57
  135. package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +410 -0
  136. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +80 -0
  137. package/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  138. package/skills/a2h-batch-ui-align/scripts/static_check/core/findings.ts +21 -0
  139. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +22 -0
  140. package/skills/a2h-batch-ui-align/scripts/static_check/core/meta.ts +34 -0
  141. package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +668 -0
  142. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +392 -0
  143. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +167 -0
  144. package/skills/a2h-batch-ui-align/scripts/static_check/package.json +3 -0
  145. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +101 -0
  146. package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +629 -0
  147. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  148. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +67 -0
  149. package/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  150. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  151. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  152. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +71 -0
  153. package/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  154. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +102 -0
  155. package/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  156. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  157. package/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  158. package/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  159. package/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  160. package/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  161. package/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  162. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  163. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +551 -0
  164. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  165. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +310 -0
  166. package/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  167. package/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  168. package/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  169. package/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  170. package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +80 -0
  171. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +64 -0
  172. package/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  173. package/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  174. package/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  175. package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +97 -0
  176. package/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  177. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -0
  178. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  179. package/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  180. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  181. package/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  182. package/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  183. package/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  184. package/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  185. package/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  186. package/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  187. package/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  188. package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  189. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +68 -0
  190. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +153 -0
  191. package/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +65 -65
  192. package/skills/a2h-coldstart-smoke-gate/SKILL.md +8 -6
  193. package/skills/a2h-dashboard-render/SKILL.md +15 -7
  194. package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +5 -35
  195. package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +4 -4
  196. package/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  197. package/skills/a2h-dashboard-render/scripts/check-registry.mjs +17 -17
  198. package/skills/a2h-dashboard-render/scripts/dashboard.css +3546 -0
  199. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +1021 -941
  200. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +104 -65
  201. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +5 -0
  202. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +54 -0
  203. package/skills/a2h-dashboard-render/scripts/page_capture.mjs +8 -8
  204. package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +67 -37
  205. package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +4 -4
  206. package/skills/a2h-fix-build-errors/SKILL.md +1 -2
  207. package/skills/a2h-resource-convert/SKILL.md +1 -3
  208. package/skills/a2h-resource-convert/references/step7-report-template.md +2 -2
  209. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +366 -361
  210. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +170 -170
  211. package/skills/a2h-resource-convert/scripts/app_identity.ts +162 -162
  212. package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +95 -95
  213. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +132 -132
  214. package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +220 -220
  215. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +5 -0
  216. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +54 -0
  217. package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +74 -74
  218. package/skills/a2h-spec-design-pipeline/SKILL.md +113 -63
  219. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +226 -56
  220. package/skills/a2h-spec-design-pipeline/references/execution-model.md +315 -62
  221. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +4 -2
  222. package/skills/a2h-spec-design-pipeline/references/initialization.md +12 -9
  223. package/skills/a2h-spec-design-pipeline/references/legacy-cleanup.md +18 -0
  224. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +109 -8
  225. package/skills/a2h-spec-design-pipeline/references/scripts.md +29 -16
  226. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +116 -8
  227. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +179 -0
  228. package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +33 -5
  229. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +36 -16
  230. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +93 -0
  231. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +915 -0
  232. package/skills/a2h-spec-design-pipeline/scripts/dispatch/ledger.mjs +234 -0
  233. package/skills/a2h-spec-design-pipeline/scripts/dispatch/plan.mjs +33 -0
  234. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +31 -0
  235. package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +94 -0
  236. package/skills/a2h-spec-design-pipeline/scripts/dispatch/state-mirror.mjs +55 -0
  237. package/skills/a2h-spec-design-pipeline/scripts/dispatch/timeouts.mjs +34 -0
  238. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +92 -0
  239. package/skills/a2h-spec-design-pipeline/scripts/dispatch/waker.mjs +60 -0
  240. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +89 -0
  241. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +551 -0
  242. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +267 -33
  243. package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +30 -10
  244. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +634 -0
  245. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +5 -0
  246. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +54 -0
  247. package/skills/a2h-spec-design-pipeline/scripts/lib/io.mjs +33 -0
  248. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +107 -19
  249. package/skills/a2h-spec-design-pipeline/scripts/stage_design_inputs.ts +79 -0
  250. package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +4 -4
  251. package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +121 -38
  252. package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +58 -11
  253. package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +31 -31
  254. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +564 -0
  255. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +339 -0
  256. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +161 -0
  257. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +1024 -0
  258. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_ledger.mjs +178 -0
  259. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_plan.mjs +60 -0
  260. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +58 -0
  261. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +91 -0
  262. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +60 -0
  263. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_waker.mjs +95 -0
  264. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_worktree.mjs +81 -0
  265. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +183 -2
  266. package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +29 -2
  267. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +294 -0
  268. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +70 -0
  269. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +157 -30
  270. package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +2 -2
  271. package/skills/a2h-spec-design-pipeline/scripts/test_stage_design_inputs.ts +72 -0
  272. package/skills/a2h-spec-generate/SKILL.md +34 -10
  273. package/skills/a2h-spec-generate/references/batch-mode.md +4 -1
  274. package/skills/a2h-spec-generate/references/fusion-task-contract.md +90 -21
  275. package/skills/a2h-spec-generate/references/recall-guide.md +1 -0
  276. package/skills/a2h-spec-generate/references/requirement-scope.md +1 -1
  277. package/skills/a2h-spec-generate/references/specs.schema.json +6 -0
  278. package/skills/a2h-spec-generate/references/worker-rules.md +2 -1
  279. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +305 -116
  280. package/skills/a2h-spec-generate/scripts/check_spec.ts +136 -114
  281. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +19 -4
  282. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +74 -14
  283. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +4 -2
  284. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +5 -0
  285. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +54 -0
  286. package/skills/a2h-spec-generate/scripts/parse_requirements.ts +65 -65
  287. package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +8 -2
  288. package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +8 -2
  289. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +80 -5
  290. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +670 -0
  291. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +37 -30
  292. package/skills/a2h-spec-generate/scripts/report.mjs +7 -3
  293. package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +26 -26
  294. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +2 -2
  295. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +2 -2
  296. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +4 -4
  297. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +6 -6
  298. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +3 -3
  299. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +23 -23
  300. package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +16 -16
  301. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +27 -26
  302. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +7 -4
  303. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +32 -31
  304. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +3 -2
  305. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +26 -20
  306. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +92 -69
  307. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +7 -3
  308. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +545 -0
  309. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +545 -0
  310. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +177 -2
  311. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +424 -29
  312. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +133 -7
  313. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +302 -103
  314. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/zip.ts +99 -0
  315. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +5 -0
  316. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +54 -0
  317. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +8 -0
  318. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +5 -1
  319. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +39 -33
  320. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +4 -3
  321. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +4 -0
  322. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +48 -6
  323. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +366 -5
  324. package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +102 -3
  325. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +81 -52
  326. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +21 -11
  327. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +2 -1
  328. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +13 -4
  329. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +2 -2
  330. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +2 -2
  331. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +4 -4
  332. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +6 -6
  333. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +3 -3
  334. package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +16 -16
  335. package/skills/a2h-utg-explorer/assets/final_viewer.html +21 -21
  336. package/skills/a2h-utg-explorer/references/architecture.md +7 -2
  337. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +108 -9
  338. package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +21 -3
  339. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +4 -1
  340. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +5 -0
  341. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +54 -0
  342. package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +229 -0
  343. package/skills/a2h-utg-explorer/scripts/plan.mjs +45 -2
  344. package/skills/a2h-utg-explorer/scripts/recover_b.mjs +2 -1
  345. package/skills/a2h-utg-explorer/scripts/report.mjs +38 -18
  346. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +9 -2
  347. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +179 -18
  348. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +21 -4
  349. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +449 -42
  350. package/skills/a2h-utg-static/SKILL.md +7 -0
  351. package/skills/a2h-utg-static/scripts/assemble.mjs +29 -2
  352. package/skills/a2h-utg-static/scripts/click_paths.mjs +42 -26
  353. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +4 -2
  354. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +5 -0
  355. package/skills/a2h-utg-static/scripts/i18n-term.mjs +54 -0
  356. package/skills/a2h-utg-static/scripts/manifest.mjs +91 -10
  357. package/skills/a2h-utg-static/scripts/nl_hints.mjs +68 -3
  358. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +2 -1
  359. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +374 -0
  360. package/skills/a2h-utg-static/scripts/static_prior.mjs +87 -33
  361. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +240 -8
  362. package/skills/a2h-utg-static/scripts/utg_html.mjs +51 -51
  363. package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +100 -100
  364. package/devecocli-plugin/common.ts +0 -2203
  365. package/devecocli-plugin/install.ts +0 -61
  366. package/devecocli-plugin/uninstall.ts +0 -26
  367. package/devecocli-plugin/update.ts +0 -66
  368. package/index.js +0 -1418
  369. package/plugin.jsonc +0 -12
  370. package/skills/a2h-app-migrate/test/test_android_index.mjs +0 -80
  371. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +0 -63
  372. package/skills/a2h-app-migrate/test/test_arch_done.mjs +0 -54
  373. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +0 -92
  374. package/skills/a2h-app-migrate/test/test_config_example.mjs +0 -42
  375. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +0 -93
  376. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +0 -544
  377. package/skills/a2h-app-migrate/test/test_finalize.mjs +0 -89
  378. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +0 -146
  379. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +0 -68
  380. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +0 -91
  381. package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -122
  382. package/skills/a2h-app-migrate/test/test_json_io.mjs +0 -32
  383. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +0 -109
  384. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +0 -53
  385. package/skills/a2h-app-migrate/test/test_parse_args.mjs +0 -69
  386. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +0 -93
  387. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +0 -144
  388. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +0 -100
  389. package/skills/a2h-app-migrate/test/test_run_dir.mjs +0 -315
  390. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +0 -133
  391. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +0 -133
  392. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +0 -158
  393. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +0 -181
  394. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +0 -76
  395. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +0 -53
  396. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +0 -226
  397. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +0 -83
  398. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +0 -39
  399. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +0 -168
  400. package/skills/a2h-app-migrate/test/test_validate_races.mjs +0 -50
  401. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +0 -11
  402. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +0 -12
  403. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +0 -8
  404. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +0 -17
  405. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +0 -3
  406. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +0 -1
  407. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +0 -8
  408. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +0 -14
  409. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +0 -7
  410. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +0 -1
  411. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +0 -3
  412. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +0 -7
  413. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +0 -1
  414. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +0 -3
  415. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +0 -7
  416. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +0 -1
  417. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +0 -3
  418. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +0 -1
  419. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +0 -1
  420. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +0 -7
  421. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +0 -9
  422. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +0 -7
  423. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +0 -10
  424. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +0 -6
  425. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +0 -16
  426. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +0 -5
  427. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +0 -548
  428. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +0 -1122
  429. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +0 -191
  430. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +0 -52
  431. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +0 -34
  432. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +0 -138
  433. package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +0 -224
  434. package/skills/a2h-batch-ui-align/flowchart.html +0 -271
  435. package/skills/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 -648
  436. package/skills/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 -2089
  437. package/skills/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 -1033
  438. package/skills/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 -1183
  439. package/skills/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 -576
  440. package/skills/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 -297
  441. package/skills/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 -395
  442. package/skills/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 -903
  443. package/skills/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 -106
  444. package/skills/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 -1178
  445. package/skills/a2h-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +0 -911
  446. package/skills/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 -355
  447. package/skills/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 -11
  448. package/skills/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 -206
  449. package/skills/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 -373
  450. package/skills/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 -158
  451. package/skills/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 -750
  452. package/skills/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 -1704
  453. package/skills/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 -1012
  454. package/skills/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 -164
  455. package/skills/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 -840
  456. package/skills/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 -856
  457. package/skills/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 -83
  458. package/skills/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 -294
  459. package/skills/a2h-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +0 -1407
  460. package/skills/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 -1220
  461. package/skills/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 -47
  462. package/skills/a2h-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +0 -133
  463. package/skills/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 -840
  464. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +0 -217
  465. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +0 -253
  466. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +0 -312
  467. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +0 -241
  468. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +0 -365
  469. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +0 -298
  470. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +0 -365
  471. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +0 -91
  472. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +0 -473
  473. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +0 -356
  474. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +0 -290
  475. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +0 -74
  476. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +0 -31
  477. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +0 -564
  478. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +0 -123
  479. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +0 -126
  480. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +0 -241
  481. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +0 -1451
  482. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +0 -215
  483. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +0 -95
  484. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +0 -115
  485. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +0 -170
  486. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +0 -102
  487. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +0 -244
  488. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +0 -166
  489. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +0 -49
  490. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +0 -219
  491. package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +0 -83
  492. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +0 -1
  493. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +0 -156
  494. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +0 -1
  495. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +0 -1
  496. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +0 -1
  497. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +0 -170
  498. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +0 -99
  499. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +0 -182
  500. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +0 -64
  501. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +0 -1172
  502. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +0 -251
  503. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +0 -81
  504. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +0 -115
  505. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +0 -303
  506. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +0 -147
  507. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +0 -444
  508. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +0 -187
  509. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +0 -351
  510. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +0 -495
  511. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +0 -157
  512. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +0 -388
  513. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +0 -182
  514. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +0 -206
  515. package/skills/a2h-spec-design/test/golden/inspect_happy.json +0 -20
  516. package/skills/a2h-spec-design/test/golden/move_design.md +0 -18
  517. package/skills/a2h-spec-design/test/golden/move_design_crlf.md +0 -18
  518. package/skills/a2h-spec-design/test/golden/move_spec.md +0 -7
  519. package/skills/a2h-spec-design/test/golden/resolve_cases.json +0 -36
  520. package/skills/a2h-spec-design/test/golden/validate_issue_file.md +0 -12
  521. package/skills/a2h-spec-design/test/golden/validate_issues.json +0 -57
  522. package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +0 -381
  523. package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +0 -944
  524. package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +0 -95
  525. package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +0 -218
  526. package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +0 -64
  527. package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +0 -452
  528. package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +0 -182
  529. package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +0 -289
  530. package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +0 -441
  531. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +0 -50
  532. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +0 -75
  533. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +0 -256
  534. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +0 -576
  535. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +0 -290
  536. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +0 -1323
  537. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +0 -574
  538. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +0 -339
  539. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +0 -831
  540. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +0 -548
  541. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +0 -117
  542. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +0 -396
  543. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +0 -175
  544. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +0 -298
  545. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +0 -1061
  546. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +0 -286
  547. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +0 -25
  548. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +0 -159
  549. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +0 -632
  550. package/skills/a2h-spec-generate/test/check-spec.test.ts +0 -200
  551. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +0 -538
  552. package/skills/a2h-spec-generate/test/detect-project.test.mjs +0 -37
  553. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +0 -45
  554. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +0 -147
  555. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +0 -3
  556. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +0 -3
  557. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +0 -3
  558. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +0 -9
  559. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +0 -8
  560. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +0 -9
  561. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +0 -1
  562. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +0 -6
  563. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +0 -4
  564. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +0 -1
  565. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +0 -33
  566. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +0 -1
  567. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +0 -23
  568. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +0 -3
  569. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +0 -8
  570. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +0 -1
  571. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +0 -54
  572. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +0 -157
  573. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +0 -282
  574. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +0 -593
  575. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +0 -66
  576. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +0 -45
  577. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +0 -243
  578. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +0 -104
  579. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +0 -223
  580. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +0 -88
  581. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +0 -187
  582. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +0 -130
  583. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +0 -136
  584. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +0 -135
  585. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +0 -16
  586. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +0 -251
  587. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +0 -42
  588. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +0 -162
  589. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +0 -193
  590. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +0 -204
  591. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +0 -355
  592. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +0 -240
  593. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +0 -212
  594. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +0 -173
  595. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +0 -280
  596. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +0 -213
  597. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +0 -345
  598. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +0 -453
  599. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +0 -131
  600. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +0 -229
  601. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +0 -336
  602. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +0 -102
  603. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +0 -92
  604. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +0 -119
  605. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +0 -346
  606. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +0 -112
  607. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +0 -63
  608. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +0 -24
  609. package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +0 -28
  610. package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +0 -108
  611. package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +0 -90
  612. package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +0 -61
  613. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +0 -1261
  614. package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +0 -90
  615. package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +0 -106
  616. package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +0 -58
  617. package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +0 -19
  618. package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +0 -30
  619. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +0 -103
  620. package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +0 -60
  621. package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +0 -111
  622. package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +0 -113
  623. package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +0 -117
  624. package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +0 -166
  625. package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +0 -112
  626. package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +0 -289
  627. package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +0 -71
  628. package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +0 -77
  629. package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +0 -99
  630. package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +0 -69
  631. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +0 -96
  632. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +0 -37
  633. package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +0 -42
  634. package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +0 -140
  635. package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +0 -111
  636. package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +0 -70
  637. package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +0 -69
  638. package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +0 -43
  639. package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +0 -67
  640. package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +0 -38
  641. package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +0 -85
  642. package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +0 -92
  643. package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +0 -55
  644. package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +0 -86
  645. package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +0 -119
  646. package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +0 -68
  647. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +0 -74
  648. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +0 -181
  649. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +0 -293
  650. package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +0 -118
  651. package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +0 -272
  652. package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +0 -51
  653. package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +0 -69
  654. package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +0 -187
  655. package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +0 -70
  656. package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +0 -67
  657. package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +0 -103
  658. package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +0 -79
  659. package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +0 -47
  660. package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +0 -40
  661. package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +0 -84
  662. package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +0 -68
  663. package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +0 -172
  664. package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +0 -33
  665. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +0 -44
  666. package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +0 -80
  667. package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +0 -35
  668. package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +0 -42
  669. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +0 -85
  670. package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +0 -57
  671. package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +0 -62
  672. package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +0 -72
  673. package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +0 -86
  674. package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +0 -78
  675. package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +0 -65
  676. package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +0 -172
  677. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +0 -107
  678. package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +0 -167
  679. package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +0 -117
  680. package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +0 -98
  681. package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +0 -87
  682. package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +0 -183
  683. package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +0 -48
  684. package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +0 -41
  685. package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +0 -126
  686. package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +0 -142
  687. package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +0 -135
  688. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +0 -66
  689. package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +0 -236
  690. package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +0 -85
  691. package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +0 -148
  692. package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +0 -63
  693. package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +0 -58
  694. package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +0 -41
  695. package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +0 -109
  696. package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +0 -68
  697. package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +0 -127
  698. package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +0 -130
  699. package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +0 -51
  700. package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +0 -81
  701. package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +0 -58
  702. package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +0 -68
  703. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +0 -91
  704. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +0 -110
  705. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +0 -89
  706. package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +0 -98
  707. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +0 -231
  708. package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +0 -104
  709. package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +0 -69
  710. package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +0 -346
  711. package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +0 -340
  712. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +0 -98
  713. package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +0 -92
  714. package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +0 -158
  715. package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +0 -65
@@ -1,944 +0,0 @@
1
- #!/usr/bin/env node
2
- // skills/a2h-spec-design-pipeline/scripts/inflight.mjs
3
- //
4
- // Background-subagent slot ledger for B1 chunk agents and B2 conflict resolvers — the
5
- // mechanical carrier for the dropped-notification defense (references/execution-model.md).
6
- // The pipeline state carries no per-dispatch timestamps, so in-flight drift cannot be
7
- // reconstructed from it after the fact: the live count and the liveness ladder must live
8
- // on disk, in the ledger's OWN file — <HMOS>/.hometrans/spec_pipeline_inflight.json — read
9
- // and written ONLY by this script (the orchestrator and every other script never touch it;
10
- // hand-editing necessarily produces phantom entries). Writes are temp+rename atomic.
11
- //
12
- // Semantics are adapted verbatim from a2h-spec-fastgen's slots.mjs (the proven model):
13
- // - `stale` NEVER declares an agent dead; a 30-minute checkpoint only asks for a liveness
14
- // probe. `ended` is confirmed by two observations ≥5 minutes apart, or --terminal with
15
- // durable evidence. No command here removes or re-dispatches on age alone.
16
- // - Every replace is generation-guarded: a retry is `add --after <current dispatchedAt>`
17
- // (never remove→add), and replacing a live/unknown unit additionally requires a matching
18
- // ok:false receipt. `remove` requires `--expect-dispatched-at` and writes a tombstone
19
- // BEFORE deleting, so a later add for the same unitId is bound to that tombstone.
20
- // - Terminal rows (orphaned / outcome / accepted) are audit records: they stay visible,
21
- // release the concurrency slot, and block barrierClear until accepted.
22
- // - Self-heal on `show` removes ONLY entries whose state-side completion is certain
23
- // (chunk done in state; resolver's group merged/done). A failed group never heals its
24
- // entries wholesale — the conservative direction is held-too-long, never released-early.
25
- //
26
- // CLI: node inflight.mjs <HMOS> configure --concurrency <n> [--at <iso>]
27
- // node inflight.mjs <HMOS> show [--no-heal]
28
- // node inflight.mjs <HMOS> add <unitId> --phase chunk|resolver --target <t> [--after <iso> --from-receipt <path>]
29
- // node inflight.mjs <HMOS> checked <unitId> --liveness alive|unknown|ended [--at <iso>] [--last-activity <iso> --source <text>] [--terminal]
30
- // node inflight.mjs <HMOS> orphan <unitId> [--reason <text>] [--at <iso>]
31
- // node inflight.mjs <HMOS> revive <unitId> --source <text> [--last-activity <iso>] [--at <iso>]
32
- // node inflight.mjs <HMOS> outcome <unitId> --outcome ended-incomplete|ended-failed [--reason <text>] [--at <iso>]
33
- // node inflight.mjs <HMOS> failure <unitId> --from-receipt <path> [--at <iso>]
34
- // node inflight.mjs <HMOS> accept <unitId> --reason <text> [--force --ack-agent-may-still-run] [--at <iso>]
35
- // node inflight.mjs <HMOS> remove <unitId> --expect-dispatched-at <iso> [--from-receipt <path> | --force --reason <text>]
36
- // node inflight.mjs <HMOS> clear
37
- //
38
- // <HMOS> is the HarmonyOS project root (a .hometrans directory itself is also accepted).
39
- //
40
- // Unit-id scheme (collision-proof by construction; the id IS "phase:target"):
41
- // chunk chunk:g<G>c<k> — group G's chunk k (k is 1-based, matching chunk_<k> dirs)
42
- // resolver resolver:g<G> — group G's B2 conflict resolver
43
- import { appendFileSync, existsSync, mkdirSync } from "node:fs";
44
- import { basename, dirname, join, resolve as resolvePath } from "node:path";
45
- import { isMainModule, loadPipelineState, readJsonFile, saveJsonAtomic } from "./lib/bgcli.mjs";
46
-
47
- const LEDGER_FILE = "spec_pipeline_inflight.json";
48
- const CONFIG_FILE = "ledger-config.json";
49
- const TOMBSTONE_FILE = "tombstones.json";
50
- const EVENTS_FILE = "liveness-events.jsonl";
51
- const STATE_FILE = "spec_pipeline_state.json";
52
- const PHASES = new Set(["chunk", "resolver"]);
53
- const LIVENESS = new Set(["unchecked", "alive", "unknown", "ended"]);
54
- const OUTCOMES = new Set(["ended-incomplete", "ended-failed"]);
55
- const CHECKPOINT_MS = 30 * 60 * 1000;
56
- const ORPHAN_GRACE_MS = 15 * 60 * 1000;
57
- const ENDED_GAP_MS = 5 * 60 * 1000;
58
- const ACTIVITY_FRESH_MS = 30 * 60 * 1000;
59
- const CLOCK_SKEW_MS = 60 * 1000;
60
- const NONTERMINAL = new Set(["unchecked", "alive", "unknown"]);
61
- const iso = (ms) => new Date(ms).toISOString();
62
- const parseIso = (value) => {
63
- const ms = Date.parse(String(value ?? ""));
64
- return Number.isFinite(ms) ? ms : null;
65
- };
66
- const isTerminalUnit = (unit) => unit?.acceptedAt != null || unit?.orphanedAt != null ||
67
- unit?.outcome != null || unit?.liveness === "ended";
68
- // Dispatch occupancy: an ended-but-unresolved unit still blocks the barrier and holds a
69
- // slot until recovery/outcome/accept; only accepted/orphaned/outcome release it.
70
- const isActiveUnit = (unit) => unit?.acceptedAt == null && unit?.orphanedAt == null && unit?.outcome == null;
71
-
72
- // ============================================================================================
73
- // Pure helpers (exposed for the unit tests and read-only importers — reconcile.mjs)
74
- // ============================================================================================
75
-
76
- /** A chunk unit id → { G, k } (k 1-based); null when malformed. */
77
- export function parseChunkTarget(target) {
78
- const match = /^g(\d+)c(\d+)$/u.exec(String(target ?? ""));
79
- return match === null ? null : { G: Number(match[1]), k: Number(match[2]) };
80
- }
81
-
82
- /** Any unit id → { phase, target }; null when malformed. This is the unitId syntax gate
83
- * shared by add and remove — only a syntactically valid id may report already-absent. */
84
- export function parseUnitId(unitId) {
85
- const id = String(unitId ?? "");
86
- const colon = id.indexOf(":");
87
- if (colon < 0) return null;
88
- const phase = id.slice(0, colon);
89
- const target = id.slice(colon + 1);
90
- if (phase === "chunk") return parseChunkTarget(target) === null ? null : { phase, target };
91
- if (phase === "resolver") return /^g\d+$/u.test(target) ? { phase, target } : null;
92
- return null;
93
- }
94
-
95
- /** The state record of group G. plan_groups.ts emits `groups` as an ARRAY in G order
96
- * (groups[0] is G1), so the lookup matches on the record's own `G` field — indexing by
97
- * String(G) reads the NEXT group's record. A G-keyed object is still accepted. */
98
- export function groupOf(state, G) {
99
- const groups = state?.groups;
100
- if (groups === null || typeof groups !== "object") return undefined;
101
- const n = Number(G);
102
- if (!Number.isInteger(n)) return undefined;
103
- if (Array.isArray(groups)) return groups.find((g) => g?.G === n);
104
- return groups[String(n)];
105
- }
106
-
107
- /** G of a parsed unit id's target (chunk g<G>c<k> or resolver g<G>); null when unparsable. */
108
- export function targetGroupId(parsed) {
109
- if (parsed === null) return null;
110
- if (parsed.phase === "chunk") return parseChunkTarget(parsed.target)?.G ?? null;
111
- return Number(parsed.target.slice(1));
112
- }
113
-
114
- /** add-time shape validation → error strings (empty array = valid). */
115
- export function validateAdd({ unitId, phase, target }) {
116
- const errors = [];
117
- if (!PHASES.has(String(phase ?? ""))) {
118
- errors.push(`unknown phase ${JSON.stringify(phase)} (chunk|resolver)`);
119
- }
120
- const parsed = parseUnitId(unitId);
121
- if (parsed === null) {
122
- errors.push(`malformed unitId ${JSON.stringify(unitId)} — chunk: chunk:g<G>c<k>; resolver: resolver:g<G>`);
123
- } else {
124
- if (parsed.phase !== phase) {
125
- errors.push(`unitId/phase mismatch: ${JSON.stringify(unitId)} is a ${parsed.phase} id, --phase says ${JSON.stringify(phase)}`);
126
- }
127
- if (parsed.target !== target) {
128
- errors.push(`unitId/target mismatch: ${JSON.stringify(unitId)} implies target ${JSON.stringify(parsed.target)}, --target says ${JSON.stringify(target)}`);
129
- }
130
- }
131
- return errors;
132
- }
133
-
134
- /** Read-side integrity of one STORED ledger entry — the same invariants validateAdd
135
- * enforces at add time, re-checked on every read because the file is agent-writable: a
136
- * hand-edited entry otherwise shows as a healthy in-flight unit the orchestrator waits on
137
- * forever. Invalid entries KEEP their slot (conservative: held-too-long, never
138
- * released-early) — they are surfaced for explicit removal, never repaired. */
139
- export function ledgerProblems(unitId, unit) {
140
- const problems = [];
141
- const phase = unit?.phase;
142
- if (!PHASES.has(String(phase ?? ""))) {
143
- problems.push(`unknown phase ${JSON.stringify(phase)} (chunk|resolver)`);
144
- }
145
- const parsed = parseUnitId(unitId);
146
- if (parsed === null) {
147
- problems.push(`unparsable unitId ${JSON.stringify(unitId)}`);
148
- } else {
149
- if (parsed.phase !== phase) {
150
- problems.push(`unitId/phase mismatch: ${JSON.stringify(unitId)} is a ${parsed.phase} id, the entry says ${JSON.stringify(phase)}`);
151
- }
152
- if (parsed.target !== unit?.target) {
153
- problems.push(`unitId/target mismatch: ${JSON.stringify(unitId)} implies target ${JSON.stringify(parsed.target)}, the entry says ${JSON.stringify(unit?.target)}`);
154
- }
155
- }
156
- if (!Number.isFinite(Date.parse(unit?.dispatchedAt ?? ""))) {
157
- problems.push("missing/unparsable dispatchedAt — inflight.mjs add always stamps it (hand-edited ledger?)");
158
- }
159
- // Lifecycle fields: absent/null is a legal old-or-terminal shape; only a present
160
- // value of the wrong type/value is invalid.
161
- if (unit?.liveness !== undefined && unit.liveness !== null && !LIVENESS.has(String(unit.liveness))) {
162
- problems.push(`invalid liveness ${JSON.stringify(unit.liveness)} (unchecked|alive|unknown|ended)`);
163
- }
164
- if (unit?.outcome !== undefined && unit.outcome !== null && !OUTCOMES.has(String(unit.outcome))) {
165
- problems.push(`invalid outcome ${JSON.stringify(unit.outcome)} (ended-incomplete|ended-failed)`);
166
- }
167
- for (const field of ["checkAfter", "orphanAfter", "checkedAt", "lastActivityAt", "lastEndedAt", "orphanedAt", "outcomeAt", "acceptedAt"]) {
168
- if (unit?.[field] !== undefined && unit[field] !== null && parseIso(unit[field]) === null) {
169
- problems.push(`${field} is not an ISO timestamp (got ${JSON.stringify(unit[field])})`);
170
- }
171
- }
172
- if (unit?.endedCount !== undefined && unit.endedCount !== null &&
173
- (!Number.isInteger(unit.endedCount) || unit.endedCount < 0)) {
174
- problems.push(`endedCount must be a non-negative integer (got ${JSON.stringify(unit.endedCount)})`);
175
- }
176
- if (unit?.retryCount !== undefined && unit.retryCount !== null &&
177
- (!Number.isInteger(unit.retryCount) || unit.retryCount < 0)) {
178
- problems.push(`retryCount must be a non-negative integer (got ${JSON.stringify(unit.retryCount)})`);
179
- }
180
- for (const field of ["acceptedFromOrphaned", "agentMayStillRun"]) {
181
- if (unit?.[field] !== undefined && unit[field] !== null && typeof unit[field] !== "boolean") {
182
- problems.push(`${field} must be boolean when present`);
183
- }
184
- }
185
- return problems;
186
- }
187
-
188
- /** In-flight age in whole minutes (null when the stamp is absent/unparsable — itself an
189
- * invalid-entry signal). Rendered by show so an overdue receipt is VISIBLE. */
190
- export function ageMinOf(unit, now = Date.now()) {
191
- const at = Date.parse(unit?.dispatchedAt ?? "");
192
- return Number.isFinite(at) ? Math.max(0, Math.floor((now - at) / 60000)) : null;
193
- }
194
-
195
- /**
196
- * State-side completion of one ledger entry (the show self-heal verdict).
197
- * chunk: the chunk is `done` in the pipeline state — and ONLY that (chunk k is 1-based:
198
- * c<k> maps to chunks[k-1]; group merged/done implies its chunks are done, so the chunk
199
- * mark alone is the certain signal). A failed group never heals its entries wholesale —
200
- * the failure stopped the group, it is not a terminal marker for the ledger row; the
201
- * disposal protocol removes it explicitly.
202
- * resolver: the group is `merged` or `done` (the merge landed / the group finalized).
203
- * Malformed entries stay: an unparsable id must keep occupying its slot (conservative).
204
- */
205
- export function isStale(unitId, unit, state) {
206
- // Terminal/audit rows are never self-healed: dropping them would silently lose the
207
- // coverage/ownership record the barrier and final report depend on.
208
- if (isTerminalUnit(unit)) return false;
209
- const parsed = parseUnitId(unitId);
210
- if (parsed === null) return false;
211
- const group = groupOf(state, targetGroupId(parsed));
212
- if (parsed.phase === "chunk") {
213
- const id = parseChunkTarget(parsed.target);
214
- if (id === null) return false;
215
- return group?.chunks?.[id.k - 1]?.status === "done";
216
- }
217
- return group?.status === "merged" || group?.status === "done";
218
- }
219
-
220
- /** Pure split of a units map into { kept, healed } — healed is the sorted stale-id list. */
221
- export function healLedger(units, state) {
222
- const kept = {};
223
- const healed = [];
224
- for (const unitId of Object.keys(units ?? {})) {
225
- if (isStale(unitId, units[unitId], state)) healed.push(unitId);
226
- else kept[unitId] = units[unitId];
227
- }
228
- return { kept, healed: healed.sort((l, r) => l.localeCompare(r, "en")) };
229
- }
230
-
231
- /** A unit id's state-side terminal verdict (the remove already-absent reporting). */
232
- export function stateVerdict(state, unitId) {
233
- const parsed = parseUnitId(unitId);
234
- if (parsed === null) return "no-terminal-state";
235
- const group = groupOf(state, targetGroupId(parsed));
236
- if (group !== null && typeof group === "object") {
237
- if (group.status === "failed") return "group-failed";
238
- if (parsed.phase === "resolver" && (group.status === "merged" || group.status === "done")) return "group-merged";
239
- if (parsed.phase === "chunk") {
240
- const id = parseChunkTarget(parsed.target);
241
- if (id !== null && group.chunks?.[id.k - 1]?.status === "done") return "chunk-done";
242
- }
243
- }
244
- return "no-terminal-state";
245
- }
246
-
247
- /**
248
- * Pure read of the ledger — the read-only surface shared by `show --no-heal` and
249
- * reconcile.mjs: reads the units, never heals, never persists. A missing ledger file is an
250
- * empty ledger (a wave before its first add); unreadable/malformed content throws — a
251
- * silent empty would under-count in-flight units.
252
- */
253
- export function readLedger(hometransDir) {
254
- const path = ledgerPath(hometransDir);
255
- if (!existsSync(path)) return { units: {} };
256
- let raw;
257
- try {
258
- raw = readJsonFile(path);
259
- } catch (error) {
260
- throw new Error(`unreadable ledger ${path}: ${error instanceof Error ? error.message : String(error)} — `
261
- + "repair it manually; deleting it would under-count in-flight units");
262
- }
263
- const units = raw?.units;
264
- if (typeof raw !== "object" || raw === null || Array.isArray(raw) ||
265
- typeof units !== "object" || units === null || Array.isArray(units)) {
266
- throw new Error(`malformed ledger ${path}: expected { units: { <unitId>: { phase, target, dispatchedAt, ... } } } — repair it manually`);
267
- }
268
- return raw;
269
- }
270
-
271
- // ============================================================================================
272
- // CLI
273
- // ============================================================================================
274
-
275
- function usage() {
276
- process.stderr.write([
277
- "Usage: node inflight.mjs <HMOS> configure --concurrency <n> [--at <iso>]",
278
- " node inflight.mjs <HMOS> show [--no-heal]",
279
- " node inflight.mjs <HMOS> add <unitId> --phase chunk|resolver --target <t> [--after <iso> --from-receipt <path>]",
280
- " node inflight.mjs <HMOS> checked <unitId> --liveness alive|unknown|ended [--at <iso>] [--last-activity <iso> --source <text>] [--terminal]",
281
- " node inflight.mjs <HMOS> orphan <unitId> [--reason <text>] [--at <iso>]",
282
- " node inflight.mjs <HMOS> revive <unitId> --source <text> [--last-activity <iso>] [--at <iso>]",
283
- " node inflight.mjs <HMOS> outcome <unitId> --outcome ended-incomplete|ended-failed [--reason <text>] [--at <iso>]",
284
- " node inflight.mjs <HMOS> failure <unitId> --from-receipt <path> [--at <iso>]",
285
- " node inflight.mjs <HMOS> accept <unitId> --reason <text> [--force --ack-agent-may-still-run] [--at <iso>]",
286
- " node inflight.mjs <HMOS> remove <unitId> --expect-dispatched-at <iso> [--from-receipt <path> | --force --reason <text>]",
287
- " node inflight.mjs <HMOS> clear",
288
- "",
289
- " configure persist dispatch concurrency at wave start = WAVE_WIDTH (required before add).",
290
- " show counts active/stale/unknown/ended/orphaned/outcome/accepted, barrierClear and free.",
291
- " add register BEFORE dispatching; replacing any existing unit requires --after and,",
292
- " for unchecked/alive/unknown/orphaned, a matching ok:false receipt.",
293
- " checked record liveness at a watchdog checkpoint; ended is confirmed only by two",
294
- " observations at least 5 minutes apart, or --terminal with durable evidence.",
295
- " orphan release the dispatch slot while retaining ownership/coverage.",
296
- " failure record ok:false without removing (the receipt file is the evidence).",
297
- " accept terminal audit for a unit with outcome or orphanedAt.",
298
- " remove receipt-bound; requires --expect-dispatched-at; tombstones prevent remove→add bypass.",
299
- ].join("\n") + "\n");
300
- process.exit(2);
301
- }
302
-
303
- function fail(message) {
304
- process.stderr.write(`ERROR: ${message}\n`);
305
- process.exit(1);
306
- }
307
-
308
- const VALUE_FLAGS = new Set(["--concurrency", "--phase", "--target",
309
- "--expect-dispatched-at", "--after", "--from-receipt", "--liveness", "--last-activity",
310
- "--source", "--at", "--reason", "--outcome"]);
311
- const BOOLEAN_FLAGS = new Set(["--no-heal", "--force", "--ack-agent-may-still-run", "--terminal"]);
312
-
313
- function parseArgs(argv) {
314
- const args = { positional: [], flags: {} };
315
- for (let i = 0; i < argv.length; i += 1) {
316
- const arg = argv[i];
317
- const eq = arg.indexOf("=");
318
- const name = eq >= 0 ? arg.slice(0, eq) : arg;
319
- if (name === "--help" || name === "-h") {
320
- args.help = true;
321
- } else if (VALUE_FLAGS.has(name)) {
322
- const value = eq >= 0 ? arg.slice(eq + 1) : argv[i + 1];
323
- if (value === undefined) usage();
324
- args.flags[name.slice(2)] = value;
325
- if (eq < 0) i += 1;
326
- } else if (BOOLEAN_FLAGS.has(name)) {
327
- if (eq >= 0) usage();
328
- args.flags[name.slice(2)] = true;
329
- } else if (name.startsWith("--")) {
330
- usage();
331
- } else {
332
- args.positional.push(arg);
333
- }
334
- }
335
- return args;
336
- }
337
-
338
- function resolveHometransDir(rootArg) {
339
- const root = resolvePath(rootArg);
340
- if (existsSync(join(root, STATE_FILE)) || existsSync(join(root, LEDGER_FILE)) ||
341
- basename(root) === ".hometrans") return root;
342
- return join(root, ".hometrans");
343
- }
344
-
345
- const ledgerPath = (dir) => join(dir, LEDGER_FILE);
346
-
347
- function loadLedger(dir) {
348
- try {
349
- return readLedger(dir); // the pure read — same loader as reconcile.mjs
350
- } catch (error) {
351
- fail(error instanceof Error ? error.message : String(error));
352
- }
353
- }
354
-
355
- const saveLedger = (dir, ledger) => saveJsonAtomic(ledgerPath(dir), ledger);
356
- const print = (obj) => process.stdout.write(JSON.stringify(obj, null, 2) + "\n");
357
- const configPath = (dir) => join(dir, CONFIG_FILE);
358
- const tombstonePath = (dir) => join(dir, TOMBSTONE_FILE);
359
- const eventsPath = (dir) => join(dir, EVENTS_FILE);
360
-
361
- function loadConfig(dir) {
362
- if (!existsSync(configPath(dir))) return null;
363
- let raw;
364
- try {
365
- raw = readJsonFile(configPath(dir));
366
- } catch (error) {
367
- fail(`unreadable ${CONFIG_FILE}: ${error instanceof Error ? error.message : String(error)} — repair it manually`);
368
- }
369
- if (typeof raw !== "object" || raw === null || Array.isArray(raw) ||
370
- !Number.isInteger(raw.concurrency) || raw.concurrency < 1) {
371
- fail(`malformed ${CONFIG_FILE}: expected { concurrency: <positive integer>, configuredAt } — repair it manually`);
372
- }
373
- return raw;
374
- }
375
-
376
- function loadTombstones(dir) {
377
- if (!existsSync(tombstonePath(dir))) return {};
378
- let raw;
379
- try {
380
- raw = readJsonFile(tombstonePath(dir));
381
- } catch (error) {
382
- fail(`unreadable ${TOMBSTONE_FILE}: ${error instanceof Error ? error.message : String(error)} — repair it manually; refusing to treat it as empty`);
383
- }
384
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
385
- fail(`malformed ${TOMBSTONE_FILE}: expected { <unitId>: { dispatchedAt, liveness, ... } } — repair it manually`);
386
- }
387
- return raw;
388
- }
389
-
390
- const saveTombstones = (dir, tombstones) => saveJsonAtomic(tombstonePath(dir), tombstones);
391
-
392
- function appendEvent(dir, event) {
393
- try {
394
- mkdirSync(dirname(eventsPath(dir)), { recursive: true });
395
- const { event: name, unitId = null, generation = null, detail, at, ...rest } = event;
396
- const record = {
397
- runId: basename(dirname(dir)),
398
- at: at ?? new Date().toISOString(),
399
- event: name,
400
- unitId,
401
- generation: generation ?? event.dispatchedAt ?? null,
402
- detail: detail ?? rest,
403
- };
404
- appendFileSync(eventsPath(dir), JSON.stringify(record) + "\n", "utf8");
405
- } catch {
406
- // The ledger is authoritative; the event log is supplementary evidence.
407
- }
408
- }
409
-
410
- function readReceiptFile(path) {
411
- if (typeof path !== "string" || path.length === 0) fail("--from-receipt <path> is required");
412
- let receipt;
413
- try {
414
- receipt = readJsonFile(path);
415
- } catch (error) {
416
- fail(`unreadable receipt ${path}: ${error instanceof Error ? error.message : String(error)}`);
417
- }
418
- if (typeof receipt !== "object" || receipt === null || Array.isArray(receipt)) {
419
- fail(`malformed receipt ${path}: expected a JSON object`);
420
- }
421
- return receipt;
422
- }
423
-
424
- function requireReceipt({ path, unitId, dispatchedAt, ok, label }) {
425
- const receipt = readReceiptFile(path);
426
- if (receipt.ok !== ok) {
427
- fail(`${label} receipt ${path} must have ok:${ok} (got ${JSON.stringify(receipt.ok)})`);
428
- }
429
- if (receipt.unitId !== unitId) {
430
- fail(`${label} receipt unitId ${JSON.stringify(receipt.unitId)} does not match ${JSON.stringify(unitId)}`);
431
- }
432
- if (receipt.dispatchedAt !== dispatchedAt) {
433
- fail(`${label} receipt dispatchedAt ${JSON.stringify(receipt.dispatchedAt)} does not match current ${JSON.stringify(dispatchedAt)}`);
434
- }
435
- return receipt;
436
- }
437
-
438
- function writeTombstone(dir, unitId, dispatchedAt, liveness, reason, retryCount = 0) {
439
- const tombstones = loadTombstones(dir);
440
- tombstones[unitId] = {
441
- dispatchedAt: dispatchedAt ?? null,
442
- liveness,
443
- retryCount: Number.isInteger(retryCount) ? retryCount : 0,
444
- removedAt: new Date().toISOString(),
445
- reason: reason ?? "",
446
- };
447
- saveTombstones(dir, tombstones);
448
- }
449
-
450
- function freshEntry({ phase, target, dispatchedAt }) {
451
- const at = parseIso(dispatchedAt);
452
- return {
453
- phase,
454
- target,
455
- dispatchedAt,
456
- checkAfter: iso(at + CHECKPOINT_MS),
457
- orphanAfter: iso(at + CHECKPOINT_MS + ORPHAN_GRACE_MS),
458
- liveness: "unchecked",
459
- checkedAt: null,
460
- lastActivityAt: null,
461
- livenessSource: null,
462
- endedCount: 0,
463
- lastEndedAt: null,
464
- orphanedAt: null,
465
- orphanReason: null,
466
- outcome: null,
467
- outcomeAt: null,
468
- outcomeReason: null,
469
- acceptedAt: null,
470
- acceptReason: null,
471
- acceptedFromOrphaned: false,
472
- agentMayStillRun: false,
473
- retryCount: 0,
474
- };
475
- }
476
-
477
- function requireConfig(dir) {
478
- const config = loadConfig(dir);
479
- if (config === null) fail("ledger not configured — run `inflight.mjs <HMOS> configure --concurrency <n>` before add");
480
- return config;
481
- }
482
-
483
- function activeCount(units) {
484
- return Object.values(units).filter(isActiveUnit).length;
485
- }
486
-
487
- function unitView(unitId, unit, now) {
488
- const view = { unitId, phase: unit?.phase, target: unit?.target };
489
- if (unit?.dispatchedAt !== undefined) view.dispatchedAt = unit.dispatchedAt;
490
- const ageMin = ageMinOf(unit, now);
491
- if (ageMin !== null) view.ageMin = ageMin;
492
- const checkedMs = parseIso(unit?.checkedAt);
493
- if (checkedMs !== null) view.sinceCheckMin = Math.max(0, Math.round((now - checkedMs) / 60000));
494
- for (const field of ["liveness", "checkedAt", "checkAfter", "orphanAfter", "lastActivityAt",
495
- "livenessSource", "endedCount", "lastEndedAt", "orphanedAt", "orphanReason",
496
- "outcome", "outcomeAt", "outcomeReason", "acceptedAt", "acceptReason",
497
- "acceptedFromOrphaned", "agentMayStillRun", "retryCount"]) {
498
- if (unit?.[field] !== undefined && unit[field] !== null) view[field] = unit[field];
499
- }
500
- return view;
501
- }
502
-
503
- function cmdShow(dir, noHeal) {
504
- const ledger = loadLedger(dir);
505
- let units = ledger.units;
506
- let healed = [];
507
- if (!noHeal) {
508
- const state = loadPipelineState(dir);
509
- ({ kept: units, healed } = healLedger(ledger.units, state));
510
- if (healed.length > 0) {
511
- for (const unitId of healed) {
512
- const stale = ledger.units[unitId];
513
- writeTombstone(dir, unitId, stale?.dispatchedAt ?? null, "ended", "show self-heal", stale?.retryCount ?? 0);
514
- appendEvent(dir, { event: "recovered-by-heal", unitId });
515
- }
516
- saveLedger(dir, { units });
517
- }
518
- }
519
- const now = Date.now();
520
- const entries = Object.entries(units);
521
- const isAccepted = ([, unit]) => unit?.acceptedAt != null;
522
- const isOrphaned = ([, unit]) => unit?.orphanedAt != null && unit?.outcome == null && !isAccepted([, unit]);
523
- const hasOutcome = ([, unit]) => unit?.outcome != null && !isAccepted([, unit]);
524
- const active = entries.filter(([, unit]) => isActiveUnit(unit)).length;
525
- const stale = entries.filter(([, unit]) => {
526
- if (!isActiveUnit(unit) || unit?.liveness === "ended") return false;
527
- const dispatchedMs = parseIso(unit?.dispatchedAt);
528
- const checkMs = parseIso(unit?.checkAfter) ??
529
- (Number.isFinite(dispatchedMs) ? dispatchedMs + CHECKPOINT_MS : now + CHECKPOINT_MS);
530
- return checkMs <= now;
531
- }).length;
532
- const unknown = entries.filter(([, unit]) => isActiveUnit(unit) && unit?.liveness === "unknown").length;
533
- const ended = entries.filter(([, unit]) => !isAccepted([, unit]) && unit?.liveness === "ended" &&
534
- unit?.orphanedAt == null && unit?.outcome == null).length;
535
- const orphaned = entries.filter(isOrphaned).length;
536
- const outcome = entries.filter(hasOutcome).length;
537
- const accepted = entries.filter(isAccepted).length;
538
- const unresolved = orphaned + outcome;
539
- const invalid = [];
540
- const view = entries
541
- .sort(([l], [r]) => l.localeCompare(r, "en"))
542
- .map(([unitId, unit]) => {
543
- const problems = ledgerProblems(unitId, unit);
544
- if (problems.length > 0) invalid.push({ unitId, problems });
545
- return unitView(unitId, unit, now);
546
- });
547
- const configuration = loadConfig(dir);
548
- const limit = configuration?.concurrency ?? null;
549
- const counts = {
550
- active,
551
- stale,
552
- unknown,
553
- ended,
554
- orphaned,
555
- outcome,
556
- accepted,
557
- unresolved,
558
- barrierClear: active === 0 && unresolved === 0,
559
- free: limit === null ? null : Math.max(0, limit - active),
560
- concurrency: limit,
561
- };
562
- if (configuration === null) counts.warning = "ledger not configured — run `inflight.mjs <HMOS> configure --concurrency <n>` before add";
563
- print({ ...counts, healed, invalid, units: view });
564
- }
565
-
566
- function cmdConfigure(dir, concurrency, at) {
567
- const raw = String(concurrency ?? "").trim();
568
- if (!/^\d+$/u.test(raw) || Number(raw) < 1) fail(`invalid --concurrency ${JSON.stringify(concurrency)} (positive integer required)`);
569
- const config = { concurrency: Number(raw), configuredAt: at ?? new Date().toISOString() };
570
- saveJsonAtomic(configPath(dir), config);
571
- appendEvent(dir, { event: "configure", concurrency: config.concurrency, at: config.configuredAt });
572
- print({ configured: true, ...config });
573
- }
574
-
575
- function cmdAdd(dir, { unitId, phase, target, after, fromReceipt, at }) {
576
- const errors = validateAdd({ unitId, phase, target });
577
- if (errors.length > 0) fail(errors.join("; "));
578
- const config = requireConfig(dir);
579
- const ledger = loadLedger(dir);
580
- const existing = ledger.units[unitId];
581
- const tombstones = existing === undefined ? loadTombstones(dir) : {};
582
- const tombstone = existing === undefined ? tombstones[unitId] : undefined;
583
-
584
- if (existing !== undefined || tombstone !== undefined) {
585
- const currentDispatchedAt = existing?.dispatchedAt ?? tombstone?.dispatchedAt;
586
- const hasGeneration = typeof currentDispatchedAt === "string" && parseIso(currentDispatchedAt) !== null;
587
- if (after === undefined) {
588
- fail(`unit ${unitId} already exists/removed; --after <current dispatchedAt> is required (no blind overwrite, no remove→add bypass)`);
589
- }
590
- if (hasGeneration && after !== currentDispatchedAt) {
591
- fail(`--after ${JSON.stringify(after)} does not match current ${JSON.stringify(currentDispatchedAt)} for ${unitId}`);
592
- }
593
- if (hasGeneration && at !== undefined && parseIso(at) !== null &&
594
- parseIso(at) <= parseIso(currentDispatchedAt)) {
595
- fail(`--at ${JSON.stringify(at)} must be later than the current generation ${JSON.stringify(currentDispatchedAt)}`);
596
- }
597
- if (existing?.acceptedAt != null) fail(`unit ${unitId} is accepted; it cannot be re-dispatched`);
598
- const liveness = existing?.liveness ?? tombstone?.liveness ?? "unchecked";
599
- if (NONTERMINAL.has(String(liveness)) || liveness === "orphaned") {
600
- if (fromReceipt === undefined) {
601
- fail(`unit ${unitId} is ${liveness}; --from-receipt <failure-receipt> is required before replacing it`);
602
- }
603
- }
604
- if (fromReceipt !== undefined) {
605
- if (!hasGeneration) fail(`unit ${unitId} has no valid dispatchedAt; a receipt cannot bind to this generation`);
606
- requireReceipt({ path: fromReceipt, unitId, dispatchedAt: currentDispatchedAt, ok: false, label: "add" });
607
- }
608
- } else if (fromReceipt !== undefined) {
609
- fail(`--from-receipt is only valid when replacing an existing/removed unit (${unitId} is new)`);
610
- }
611
-
612
- const activeAfter = activeCount(ledger.units) + (existing !== undefined && isActiveUnit(existing) ? 0 : 1);
613
- if (activeAfter > config.concurrency) {
614
- fail(`concurrency ${config.concurrency} reached (active would become ${activeAfter}); wait for a receipt before dispatching ${unitId}`);
615
- }
616
-
617
- const dispatchedAt = at ?? new Date().toISOString();
618
- if (parseIso(dispatchedAt) === null) fail(`invalid --at ${JSON.stringify(at)} (ISO timestamp required)`);
619
- const entry = freshEntry({ phase, target, dispatchedAt });
620
- // A receipt-bound retry is the one legitimate replacement: the retry budget lives in the
621
- // ledger (this script is the ledger's only writer; the pipeline state stays the
622
- // orchestrator's exclusive file). The budget must survive generation transitions, so it
623
- // rides the current entry OR the tombstone of the removed one — never the state file.
624
- const retryBase = existing !== undefined ? existing : tombstone;
625
- if (fromReceipt !== undefined) {
626
- entry.retryCount = (Number.isInteger(retryBase?.retryCount) ? retryBase.retryCount : 0) + 1;
627
- } else if (Number.isInteger(retryBase?.retryCount)) {
628
- entry.retryCount = retryBase.retryCount;
629
- }
630
- ledger.units[unitId] = entry;
631
- saveLedger(dir, ledger);
632
- appendEvent(dir, { event: "add", unitId, phase, dispatchedAt, reDispatch: existing !== undefined, active: activeCount(ledger.units) });
633
- print({ added: true, unitId, reDispatch: existing !== undefined, active: activeCount(ledger.units), dispatchedAt });
634
- }
635
-
636
- function cmdRemove(dir, unitId, expectDispatchedAt, { fromReceipt, force, reason } = {}) {
637
- const parsed = parseUnitId(unitId);
638
- if (parsed === null) {
639
- fail(`malformed unitId ${JSON.stringify(unitId)} — chunk: chunk:g<G>c<k>; resolver: resolver:g<G>`);
640
- }
641
- const state = loadPipelineState(dir);
642
- const ledger = loadLedger(dir);
643
- const unit = ledger.units[unitId];
644
- if (expectDispatchedAt === undefined) {
645
- fail(`remove ${unitId} requires --expect-dispatched-at <echoed dispatchedAt> (stale receipts must not delete a newer generation)`);
646
- }
647
- if (unit === undefined) {
648
- print({ removed: false, alreadyAbsent: true, unitId, stateVerdict: stateVerdict(state, unitId) });
649
- return;
650
- }
651
- const generationKnown = typeof unit.dispatchedAt === "string" && parseIso(unit.dispatchedAt) !== null;
652
- if (generationKnown && unit.dispatchedAt !== expectDispatchedAt) {
653
- print({ removed: false, staleReceipt: true, echoed: expectDispatchedAt, current: unit.dispatchedAt ?? null });
654
- return;
655
- }
656
- const liveness = unit.liveness ?? "unchecked";
657
- if (fromReceipt !== undefined) {
658
- if (!generationKnown) fail(`remove ${unitId}: a receipt cannot bind to an entry without a valid dispatchedAt; use --force --reason`);
659
- requireReceipt({ path: fromReceipt, unitId, dispatchedAt: unit.dispatchedAt, ok: true, label: "remove" });
660
- } else if (!generationKnown) {
661
- if (force !== true || typeof reason !== "string" || reason.trim() === "") {
662
- fail(`remove ${unitId} has no valid dispatchedAt; require --force --reason`);
663
- }
664
- } else {
665
- const knownLiveness = liveness === "unchecked" || liveness === "alive" || liveness === "ended" || liveness === "unknown";
666
- const terminal = knownLiveness && (liveness === "ended" || unit.outcome != null);
667
- if (unit.orphanedAt != null || unit.acceptedAt != null || !terminal) {
668
- if (force !== true || typeof reason !== "string" || reason.trim() === "") {
669
- fail(`remove ${unitId} is ${liveness}${unit.acceptedAt != null ? "/accepted" : ""}; require --force --reason (or a success --from-receipt)`);
670
- }
671
- }
672
- }
673
- let tombstoneLiveness = generationKnown ? liveness : "ended";
674
- if (fromReceipt !== undefined) tombstoneLiveness = "ended";
675
- else if ((unit.acceptedFromOrphaned === true || unit.agentMayStillRun === true) && unit.acceptedAt != null) tombstoneLiveness = "unknown";
676
- writeTombstone(dir, unitId, generationKnown ? unit.dispatchedAt : null, tombstoneLiveness,
677
- reason ?? (fromReceipt ? "success receipt" : "manual remove"), unit.retryCount ?? 0);
678
- delete ledger.units[unitId];
679
- saveLedger(dir, ledger);
680
- appendEvent(dir, { event: "remove", unitId, dispatchedAt: unit.dispatchedAt, liveness: tombstoneLiveness, reason: reason ?? null });
681
- print({ removed: true, unitId, active: activeCount(ledger.units) });
682
- }
683
-
684
- function cmdChecked(dir, unitId, { liveness, at, lastActivity, source, terminal } = {}) {
685
- const ledger = loadLedger(dir);
686
- const unit = ledger.units[unitId];
687
- if (unit === undefined) fail(`checked: unit ${unitId} is absent`);
688
- if (!["alive", "unknown", "ended"].includes(liveness)) fail(`invalid --liveness ${JSON.stringify(liveness)} (alive|unknown|ended)`);
689
- if (unit.acceptedAt != null || unit.orphanedAt != null || unit.outcome != null) {
690
- fail(`checked: ${unitId} is terminal (${unit.acceptedAt != null ? "accepted" : unit.orphanedAt != null ? "orphaned" : "outcome"})`);
691
- }
692
- if (unit.liveness === "ended") fail(`checked: ${unitId} is already ended; terminal cannot be resurrected`);
693
- const atMs = parseIso(at ?? new Date().toISOString());
694
- if (atMs === null) fail(`invalid --at ${JSON.stringify(at)}`);
695
- const atIso = iso(atMs);
696
-
697
- if (liveness === "alive") {
698
- if (typeof source !== "string" || source.trim() === "") fail("checked --liveness alive requires --source <evidence>");
699
- const activityMs = parseIso(lastActivity);
700
- if (activityMs === null) fail("checked --liveness alive requires --last-activity <iso>");
701
- const dispatchedMs = parseIso(unit.dispatchedAt);
702
- if (activityMs < dispatchedMs) fail("--last-activity is earlier than dispatchedAt");
703
- if (activityMs > atMs + CLOCK_SKEW_MS) fail("--last-activity is implausibly in the future");
704
- if (activityMs < atMs - ACTIVITY_FRESH_MS) fail("--last-activity is not fresh; use --liveness unknown");
705
- const clamped = Math.min(activityMs, atMs);
706
- unit.liveness = "alive";
707
- unit.checkedAt = atIso;
708
- unit.lastActivityAt = iso(clamped);
709
- unit.livenessSource = source;
710
- unit.endedCount = 0;
711
- unit.lastEndedAt = null;
712
- unit.checkAfter = iso(Math.max(atMs + ENDED_GAP_MS, clamped + CHECKPOINT_MS));
713
- unit.orphanAfter = iso(atMs + CHECKPOINT_MS + ORPHAN_GRACE_MS);
714
- } else if (liveness === "unknown") {
715
- unit.liveness = "unknown";
716
- unit.checkedAt = atIso;
717
- unit.endedCount = 0;
718
- unit.lastEndedAt = null;
719
- unit.checkAfter = iso(atMs + CHECKPOINT_MS);
720
- unit.orphanAfter = iso(atMs + CHECKPOINT_MS);
721
- } else {
722
- const previousEndedAt = parseIso(unit.lastEndedAt);
723
- const first = unit.endedCount !== 1 || previousEndedAt === null;
724
- if (first && terminal !== true) {
725
- unit.liveness = "unknown";
726
- unit.checkedAt = atIso;
727
- unit.endedCount = 1;
728
- unit.lastEndedAt = atIso;
729
- unit.checkAfter = iso(atMs + ENDED_GAP_MS);
730
- unit.orphanAfter = iso(atMs + CHECKPOINT_MS);
731
- } else {
732
- if (terminal !== true && previousEndedAt !== null && atMs - previousEndedAt < ENDED_GAP_MS) {
733
- fail(`checked ended: second observation must be at least 5 minutes after the first (or pass --terminal)`);
734
- }
735
- unit.liveness = "ended";
736
- unit.checkedAt = atIso;
737
- unit.endedCount = 2;
738
- unit.lastEndedAt = atIso;
739
- unit.checkAfter = null;
740
- unit.orphanAfter = null;
741
- }
742
- }
743
- saveLedger(dir, ledger);
744
- appendEvent(dir, { event: "checked", unitId, liveness: unit.liveness, at: atIso, source: source ?? null });
745
- print({ checked: true, unitId, liveness: unit.liveness, endedCount: unit.endedCount, checkAfter: unit.checkAfter });
746
- }
747
-
748
- function cmdOrphan(dir, unitId, reason, at) {
749
- const ledger = loadLedger(dir);
750
- const unit = ledger.units[unitId];
751
- if (unit === undefined) fail(`orphan: unit ${unitId} is absent`);
752
- if (unit.acceptedAt != null || unit.outcome != null || unit.orphanedAt != null || unit.liveness === "ended") {
753
- fail(`orphan: ${unitId} is already terminal`);
754
- }
755
- if (unit.liveness === "alive") fail(`orphan: ${unitId} is alive; verify unknown/ended before orphaning`);
756
- const atMs = parseIso(at ?? new Date().toISOString());
757
- if (atMs === null) fail(`invalid --at ${JSON.stringify(at)}`);
758
- unit.orphanedAt = iso(atMs);
759
- unit.orphanReason = reason ?? "";
760
- unit.checkedAt = iso(atMs);
761
- unit.checkAfter = null;
762
- unit.orphanAfter = null;
763
- saveLedger(dir, ledger);
764
- appendEvent(dir, { event: "orphan", unitId, at: unit.orphanedAt, reason: unit.orphanReason });
765
- print({ orphaned: true, unitId, active: activeCount(ledger.units), orphanedAt: unit.orphanedAt });
766
- }
767
-
768
- function cmdRevive(dir, unitId, source, at, lastActivity) {
769
- const ledger = loadLedger(dir);
770
- const unit = ledger.units[unitId];
771
- if (unit === undefined) fail(`revive: unit ${unitId} is absent`);
772
- if (unit.orphanedAt == null || unit.acceptedAt != null || unit.outcome != null) {
773
- fail(`revive: only an orphaned (not accepted/outcome) unit can be revived`);
774
- }
775
- if (typeof source !== "string" || source.trim() === "") fail("revive requires --source <evidence>");
776
- const atMs = parseIso(at ?? new Date().toISOString());
777
- if (atMs === null) fail(`invalid --at ${JSON.stringify(at)}`);
778
- const activityMs = parseIso(lastActivity ?? iso(atMs));
779
- if (activityMs === null) fail(`invalid --last-activity ${JSON.stringify(lastActivity)}`);
780
- if (activityMs > atMs + CLOCK_SKEW_MS) fail("--last-activity is implausibly in the future");
781
- if (activityMs < atMs - ACTIVITY_FRESH_MS) fail("--last-activity is not fresh");
782
- const clampedActivity = Math.min(activityMs, atMs);
783
- unit.orphanedAt = null;
784
- unit.orphanReason = null;
785
- unit.liveness = "alive";
786
- unit.livenessSource = source;
787
- unit.checkedAt = iso(atMs);
788
- unit.lastActivityAt = iso(clampedActivity);
789
- unit.endedCount = 0;
790
- unit.lastEndedAt = null;
791
- unit.checkAfter = iso(Math.max(atMs + ENDED_GAP_MS, clampedActivity + CHECKPOINT_MS));
792
- unit.orphanAfter = iso(atMs + CHECKPOINT_MS + ORPHAN_GRACE_MS);
793
- saveLedger(dir, ledger);
794
- appendEvent(dir, { event: "revive", unitId, at: unit.checkedAt, source });
795
- print({ revived: true, unitId, active: activeCount(ledger.units), checkAfter: unit.checkAfter });
796
- }
797
-
798
- function cmdOutcome(dir, unitId, outcome, reason, at) {
799
- const ledger = loadLedger(dir);
800
- const unit = ledger.units[unitId];
801
- if (unit === undefined) fail(`outcome: unit ${unitId} is absent`);
802
- if (unit.acceptedAt != null || unit.outcome != null) fail(`outcome: ${unitId} already has a terminal outcome`);
803
- if (unit.orphanedAt != null) fail(`outcome: ${unitId} is orphaned; accept or revive first`);
804
- if (unit.liveness !== "ended") fail(`outcome: ${unitId} must be confirmed ended first`);
805
- if (!OUTCOMES.has(String(outcome))) fail(`invalid --outcome ${JSON.stringify(outcome)} (ended-incomplete|ended-failed)`);
806
- const atMs = parseIso(at ?? new Date().toISOString());
807
- if (atMs === null) fail(`invalid --at ${JSON.stringify(at)}`);
808
- unit.outcome = outcome;
809
- unit.outcomeAt = iso(atMs);
810
- unit.outcomeReason = reason ?? "";
811
- unit.orphanedAt = null;
812
- unit.orphanReason = null;
813
- unit.liveness = "ended";
814
- unit.endedCount = 2;
815
- unit.checkAfter = null;
816
- unit.orphanAfter = null;
817
- saveLedger(dir, ledger);
818
- appendEvent(dir, { event: "outcome", unitId, outcome, at: unit.outcomeAt, reason: unit.outcomeReason });
819
- print({ outcome: true, unitId, value: outcome, active: activeCount(ledger.units) });
820
- }
821
-
822
- function cmdFailure(dir, unitId, fromReceipt, at) {
823
- const ledger = loadLedger(dir);
824
- const unit = ledger.units[unitId];
825
- if (unit === undefined) {
826
- print({ failure: true, unitId, removed: null, alreadyAbsent: true });
827
- return;
828
- }
829
- if (unit.acceptedAt != null) fail(`failure: ${unitId} is accepted`);
830
- const receipt = requireReceipt({ path: fromReceipt, unitId, dispatchedAt: unit.dispatchedAt, ok: false, label: "failure" });
831
- const atMs = parseIso(at ?? new Date().toISOString());
832
- if (atMs === null) fail(`invalid --at ${JSON.stringify(at)}`);
833
- unit.liveness = "ended";
834
- unit.endedCount = 2;
835
- unit.outcome = "ended-failed";
836
- unit.outcomeAt = iso(atMs);
837
- unit.outcomeReason = typeof receipt.note === "string" && receipt.note.trim() !== "" ? receipt.note : "failure receipt";
838
- unit.orphanedAt = null;
839
- unit.orphanReason = null;
840
- unit.checkAfter = null;
841
- unit.orphanAfter = null;
842
- saveLedger(dir, ledger);
843
- appendEvent(dir, { event: "failure", unitId, at: unit.outcomeAt });
844
- print({ failure: true, unitId, removed: null, outcome: "ended-failed" });
845
- }
846
-
847
- function cmdAccept(dir, unitId, reason, { force, ackAgentMayStillRun, at } = {}) {
848
- const ledger = loadLedger(dir);
849
- const unit = ledger.units[unitId];
850
- if (unit === undefined) fail(`accept: unit ${unitId} is absent`);
851
- if (unit.acceptedAt != null) fail(`accept: ${unitId} is already accepted`);
852
- const fromOrphan = unit.orphanedAt != null;
853
- if (unit.outcome == null && !fromOrphan) fail(`accept: ${unitId} has no outcome and is not orphaned`);
854
- if (typeof reason !== "string" || reason.trim() === "") fail("accept requires a non-empty --reason");
855
- if (fromOrphan && (force !== true || ackAgentMayStillRun !== true)) {
856
- fail(`accept ${unitId} is orphaned; require --force --ack-agent-may-still-run`);
857
- }
858
- const atMs = parseIso(at ?? new Date().toISOString());
859
- if (atMs === null) fail(`invalid --at ${JSON.stringify(at)}`);
860
- unit.acceptedAt = iso(atMs);
861
- unit.acceptReason = reason;
862
- unit.acceptedFromOrphaned = fromOrphan;
863
- unit.agentMayStillRun = fromOrphan;
864
- unit.orphanedAt = null;
865
- unit.orphanReason = null;
866
- saveLedger(dir, ledger);
867
- appendEvent(dir, { event: "accept", unitId, at: unit.acceptedAt, reason, agentMayStillRun: unit.agentMayStillRun });
868
- print({ accepted: true, unitId, acceptedAt: unit.acceptedAt, agentMayStillRun: unit.agentMayStillRun, active: activeCount(ledger.units) });
869
- }
870
-
871
- function cmdClear(dir) {
872
- if (!existsSync(ledgerPath(dir))) {
873
- if (existsSync(tombstonePath(dir))) saveTombstones(dir, {});
874
- print({ cleared: 0, active: 0 }); // no ledger yet / already empty — no stray file written
875
- return;
876
- }
877
- const ledger = loadLedger(dir);
878
- const cleared = Object.keys(ledger.units).length;
879
- saveLedger(dir, { units: {} });
880
- saveTombstones(dir, {});
881
- appendEvent(dir, { event: "clear", cleared });
882
- print({ cleared, active: 0 });
883
- }
884
-
885
- function main() {
886
- const args = parseArgs(process.argv.slice(2));
887
- if (args.help) usage();
888
- const [rootArg, command, unitIdArg] = args.positional;
889
- if (rootArg === undefined || command === undefined) usage();
890
- const dir = resolveHometransDir(rootArg);
891
- if (!existsSync(dir)) {
892
- fail(`no .hometrans directory under ${rootArg} (resolved to ${dir}) — the pipeline state root is missing`);
893
- }
894
- const twoPositional = new Set(["show", "clear", "configure"]);
895
- if (twoPositional.has(command)) {
896
- if (args.positional.length > 2) usage();
897
- } else if (["add", "remove", "checked", "orphan", "revive", "outcome", "failure", "accept"].includes(command)) {
898
- if (args.positional.length !== 3) usage();
899
- } else {
900
- usage();
901
- }
902
- if (args.flags["no-heal"] !== undefined && command !== "show") usage();
903
-
904
- if (command === "show") {
905
- if (args.flags.concurrency !== undefined) usage(); // one-off counts are gone; configure owns it
906
- cmdShow(dir, args.flags["no-heal"] === true);
907
- } else if (command === "configure") {
908
- if (args.flags.concurrency === undefined) usage();
909
- cmdConfigure(dir, args.flags.concurrency, args.flags.at);
910
- } else if (command === "add") {
911
- if (args.flags.phase === undefined || args.flags.target === undefined) usage();
912
- cmdAdd(dir, {
913
- unitId: unitIdArg, phase: args.flags.phase, target: args.flags.target,
914
- after: args.flags.after, fromReceipt: args.flags["from-receipt"], at: args.flags.at,
915
- });
916
- } else if (command === "checked") {
917
- cmdChecked(dir, unitIdArg, {
918
- liveness: args.flags.liveness, at: args.flags.at, lastActivity: args.flags["last-activity"],
919
- source: args.flags.source, terminal: args.flags.terminal === true,
920
- });
921
- } else if (command === "orphan") {
922
- cmdOrphan(dir, unitIdArg, args.flags.reason, args.flags.at);
923
- } else if (command === "revive") {
924
- cmdRevive(dir, unitIdArg, args.flags.source, args.flags.at, args.flags["last-activity"]);
925
- } else if (command === "outcome") {
926
- cmdOutcome(dir, unitIdArg, args.flags.outcome, args.flags.reason, args.flags.at);
927
- } else if (command === "failure") {
928
- cmdFailure(dir, unitIdArg, args.flags["from-receipt"], args.flags.at);
929
- } else if (command === "accept") {
930
- cmdAccept(dir, unitIdArg, args.flags.reason, {
931
- force: args.flags.force === true, ackAgentMayStillRun: args.flags["ack-agent-may-still-run"] === true,
932
- at: args.flags.at,
933
- });
934
- } else if (command === "remove") {
935
- cmdRemove(dir, unitIdArg, args.flags["expect-dispatched-at"], {
936
- fromReceipt: args.flags["from-receipt"], force: args.flags.force === true, reason: args.flags.reason,
937
- });
938
- } else {
939
- cmdClear(dir);
940
- }
941
- }
942
-
943
- const invokedAsScript = isMainModule(import.meta.url);
944
- if (invokedAsScript) main();