@buaa_smat/hometrans 26.0.3 → 26.0.4
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.
- package/README.md +1 -1
- package/agents/code-reviewer.md +91 -21
- package/env-requirements.json +1 -1
- package/i18n/agents/code-reviewer.md +93 -21
- package/i18n/skills/a2h-app-migrate/SKILL.md +19 -11
- package/i18n/skills/a2h-app-migrate/references/feature-scope.md +121 -0
- package/i18n/skills/a2h-app-migrate/references/stage-map.md +2 -2
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +320 -73
- package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -5
- package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +79 -11
- package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +75 -4
- package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +12 -0
- package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +25 -10
- package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +35 -7
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +52 -0
- package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +26 -0
- package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +36 -0
- package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +71 -7
- package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +117 -0
- package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +7 -3
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +38 -2
- package/i18n/skills/a2h-arch-generate/SKILL.md +20 -17
- package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
- package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
- package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +25 -14
- package/i18n/skills/a2h-arch-generate/references/source-baseline.md +4 -4
- package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +3 -3
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +304 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -1
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +59 -2
- package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +52 -11
- package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +328 -38
- package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +245 -0
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +70 -21
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +5 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +6 -4
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +5 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +236 -11
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +8 -5
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +7 -4
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +31 -0
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +22 -6
- package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +3 -0
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +26 -4
- package/i18n/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +386 -16
- package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +19 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +134 -11
- package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +231 -5
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +82 -8
- package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +21 -7
- package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +48 -5
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +45 -11
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +60 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +63 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +224 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +133 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +5 -3
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +33 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +12 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +8 -0
- package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
- package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +11 -9
- package/i18n/skills/a2h-module-semantic-docs/SKILL.md +51 -13
- package/i18n/skills/a2h-page-specgen/SKILL.md +123 -20
- package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +1174 -0
- package/i18n/skills/a2h-page-specgen/references/body-language.md +11 -9
- package/i18n/skills/a2h-page-specgen/references/gates.md +119 -52
- package/i18n/skills/a2h-page-specgen/references/page-inventory.md +69 -22
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +274 -0
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +312 -0
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +113 -110
- package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
- package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
- package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +171 -62
- package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +314 -192
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +364 -76
- package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +216 -8
- package/i18n/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +116 -223
- package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +521 -13
- package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +12 -8
- package/i18n/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
- package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
- package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +483 -125
- package/i18n/skills/a2h-page-specgen/scripts/render.mjs +10 -33
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +288 -7
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +25 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +300 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +47 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +300 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +267 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +57 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +300 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +553 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +546 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +655 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1234 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +520 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1516 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +759 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +630 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +118 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +798 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +886 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +134 -163
- package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +40 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +206 -9
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +459 -188
- package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +89 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +862 -12
- package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +139 -5
- package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +378 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +69 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +267 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +111 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +10 -8
- package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +143 -51
- package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +166 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +13 -5
- package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +102 -7
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1308 -72
- package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +69 -44
- package/i18n/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +658 -120
- package/i18n/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +101 -65
- package/i18n/skills/a2h-resource-convert/SKILL.md +9 -1
- package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
- package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
- package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
- package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +67 -3
- package/i18n/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +69 -109
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +135 -37
- package/i18n/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +307 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +103 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +126 -23
- package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +71 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +24 -13
- package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +246 -0
- package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +170 -7
- package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
- package/i18n/skills/a2h-spec-generate/SKILL.md +2 -2
- package/i18n/skills/a2h-utg-explorer/SKILL.md +9 -3
- package/i18n/skills/a2h-utg-explorer/references/architecture.md +3 -0
- package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +74 -84
- package/i18n/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
- package/i18n/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +252 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +122 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +15 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +211 -61
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +724 -47
- package/i18n/skills/a2h-utg-static/SKILL.md +6 -2
- package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +82 -12
- package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +116 -5
- package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
- package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
- package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
- package/i18n/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
- package/i18n/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
- package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +50 -5
- package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
- package/i18n/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
- package/i18n/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
- package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +32 -4
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +17 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +113 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +181 -17
- package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +118 -19
- package/i18n/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
- package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +113 -70
- package/package.json +3 -6
- package/skills/a2h-app-migrate/SKILL.md +19 -11
- package/skills/a2h-app-migrate/references/feature-scope.md +121 -0
- package/skills/a2h-app-migrate/references/stage-map.md +2 -2
- package/skills/a2h-app-migrate/references/workflow.yaml +307 -74
- package/skills/a2h-app-migrate/scripts/android_index.mjs +35 -8
- package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +39 -1
- package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -5
- package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +144 -9
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +14 -1
- package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +46 -5
- package/skills/a2h-app-migrate/scripts/diagnose.mjs +162 -0
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +79 -11
- package/skills/a2h-app-migrate/scripts/feature_scope.mjs +347 -0
- package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +75 -4
- package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +17 -1
- package/skills/a2h-app-migrate/scripts/ledger.mjs +64 -6
- package/skills/a2h-app-migrate/scripts/migration_manifest.mjs +351 -0
- package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +9 -23
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +33 -9
- package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +33 -1
- package/skills/a2h-app-migrate/scripts/run_dir.mjs +27 -17
- package/skills/a2h-app-migrate/scripts/scope_model.mjs +255 -0
- package/skills/a2h-app-migrate/scripts/scope_report.mjs +128 -0
- package/skills/a2h-app-migrate/scripts/source_fp.mjs +120 -0
- package/skills/a2h-app-migrate/test/test_android_index.mjs +12 -0
- package/skills/a2h-app-migrate/test/test_env_requirements.mjs +25 -10
- package/skills/a2h-app-migrate/test/test_feature_scope.mjs +217 -0
- package/skills/a2h-app-migrate/test/test_finalize.mjs +35 -7
- package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +7 -7
- package/skills/a2h-app-migrate/test/test_incremental_acceptance.mjs +145 -0
- package/skills/a2h-app-migrate/test/test_incremental_phase2.mjs +223 -0
- package/skills/a2h-app-migrate/test/test_incremental_phase2_acceptance.mjs +157 -0
- package/skills/a2h-app-migrate/test/test_incremental_profile.mjs +84 -0
- package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +10 -0
- package/skills/a2h-app-migrate/test/test_json_io.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +39 -0
- package/skills/a2h-app-migrate/test/test_migration_manifest.mjs +225 -0
- package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +33 -0
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +52 -0
- package/skills/a2h-app-migrate/test/test_resume_summary.mjs +26 -0
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +36 -0
- package/skills/a2h-app-migrate/test/test_run_dir.mjs +71 -7
- package/skills/a2h-app-migrate/test/test_scope_model.mjs +172 -0
- package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +13 -5
- package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +117 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +7 -3
- package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +170 -3
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_ui_batch_capture_audit.mjs +106 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +12 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +38 -2
- package/skills/a2h-arch-generate/SKILL.md +20 -17
- package/skills/a2h-arch-generate/references/homegraph-workflow.md +10 -8
- package/skills/a2h-arch-generate/references/source-baseline.md +2 -2
- package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +34 -3
- package/skills/a2h-arch-generate/scripts/create_project.mjs +24 -1
- package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +29 -5
- package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +3 -3
- package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +17 -0
- package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +26 -0
- package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +4 -2
- package/skills/a2h-arkts-logic-coder/SKILL.md +146 -17
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -1
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +59 -2
- package/skills/a2h-arkts-logic-coder/references/spec-design.md +42 -11
- package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +328 -38
- package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +244 -0
- package/skills/a2h-batch-ui-align/SKILL.md +72 -22
- package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +16 -2
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +5 -0
- package/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
- package/skills/a2h-batch-ui-align/references/cards/resources.md +6 -4
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +5 -0
- package/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
- package/skills/a2h-batch-ui-align/references/checker-rules.md +236 -11
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +8 -5
- package/skills/a2h-batch-ui-align/references/host-dispatch.md +2 -0
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +7 -4
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
- 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 +30 -0
- package/skills/a2h-batch-ui-align/references/step3-capture.md +25 -6
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +3 -0
- package/skills/a2h-batch-ui-align/references/step5-convert.md +26 -4
- package/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +380 -16
- package/skills/a2h-batch-ui-align/scripts/capture_audit.mjs +474 -0
- package/skills/a2h-batch-ui-align/scripts/capture_fast.mjs +665 -0
- package/skills/a2h-batch-ui-align/scripts/capture_verify.mjs +552 -0
- package/skills/a2h-batch-ui-align/scripts/detach.mjs +5 -2
- package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +39 -5
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +19 -1
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +134 -11
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +213 -30
- package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
- package/skills/a2h-batch-ui-align/scripts/list_existing.mjs +141 -0
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +231 -5
- package/skills/a2h-batch-ui-align/scripts/page_gap.mjs +210 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +82 -8
- package/skills/a2h-batch-ui-align/scripts/progress_identity.mjs +208 -0
- package/skills/a2h-batch-ui-align/scripts/scroll_verdict.mjs +62 -0
- package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +21 -7
- package/skills/a2h-batch-ui-align/scripts/shell_requests.mjs +273 -0
- package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/core/baseline.ts +79 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +90 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +44 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +48 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +24 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +45 -11
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +60 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +63 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +24 -2
- package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +14 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_baseline.test.mjs +129 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_runtime2.test.mjs +697 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +298 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +224 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +41 -7
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +346 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme_runtime.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +126 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +1 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_audit.test.mjs +179 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_fast.test.mjs +56 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_gate.test.mjs +197 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_review_fixes.test.mjs +322 -0
- package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +19 -0
- package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +15 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/SearchMenuDialog.buggy.ets +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/meta.json +21 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/screenshot.png +0 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/view.xml +35 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pack_evidence.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +155 -1
- package/skills/a2h-batch-ui-align/scripts/tests/icon_coverage.test.mjs +314 -0
- package/skills/a2h-batch-ui-align/scripts/tests/list_existing.test.mjs +157 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +5 -3
- package/skills/a2h-batch-ui-align/scripts/tests/page_gap.test.mjs +115 -0
- package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +33 -2
- package/skills/a2h-batch-ui-align/scripts/tests/progress_identity.test.mjs +174 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +5 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_requests.test.mjs +158 -0
- package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +12 -0
- package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +8 -0
- package/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
- package/skills/a2h-dashboard-render/test/test_device_locale_dialogs.mjs +17 -0
- package/skills/a2h-module-semantic-docs/SKILL.md +51 -13
- package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +66 -11
- package/skills/a2h-module-semantic-docs/test/test_incremental_fingerprint.mjs +94 -0
- package/skills/a2h-page-specgen/SKILL.md +124 -20
- package/skills/a2h-page-specgen/references/behavior-ledger.md +1170 -0
- package/skills/a2h-page-specgen/references/body-language.md +11 -9
- package/skills/a2h-page-specgen/references/evidence.md +35 -0
- package/skills/a2h-page-specgen/references/execution-model.md +135 -26
- package/skills/a2h-page-specgen/references/footprint-and-grouping.md +20 -15
- package/skills/a2h-page-specgen/references/gates.md +120 -52
- package/skills/a2h-page-specgen/references/page-inventory.md +69 -22
- package/skills/a2h-page-specgen/references/scenario-authoring.md +272 -0
- package/skills/a2h-page-specgen/references/spec-example.md +312 -0
- package/skills/a2h-page-specgen/references/spec-template.md +112 -109
- package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
- package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
- package/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
- package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
- package/skills/a2h-page-specgen/scripts/dispatch.mjs +8 -5
- package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
- package/skills/a2h-page-specgen/scripts/facts-build.mjs +170 -61
- package/skills/a2h-page-specgen/scripts/finalize.mjs +466 -63
- package/skills/a2h-page-specgen/scripts/footprint.mjs +302 -180
- package/skills/a2h-page-specgen/scripts/gate.mjs +372 -82
- package/skills/a2h-page-specgen/scripts/interactions.mjs +215 -8
- package/skills/a2h-page-specgen/scripts/inventory.mjs +102 -0
- package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +116 -216
- package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +105 -13
- package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
- package/skills/a2h-page-specgen/scripts/lib/hg.mjs +520 -12
- package/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
- package/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
- package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +129 -6
- package/skills/a2h-page-specgen/scripts/lib/main-module.mjs +24 -0
- package/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
- package/skills/a2h-page-specgen/scripts/lib/prose.mjs +12 -8
- package/skills/a2h-page-specgen/scripts/lib/recovery-policy.mjs +28 -0
- package/skills/a2h-page-specgen/scripts/lib/scope.mjs +355 -0
- package/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
- package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +106 -0
- package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
- package/skills/a2h-page-specgen/scripts/prepare.mjs +470 -122
- package/skills/a2h-page-specgen/scripts/render.mjs +11 -34
- package/skills/a2h-page-specgen/scripts/report.mjs +339 -6
- package/skills/a2h-page-specgen/scripts/submission.mjs +253 -88
- package/skills/a2h-page-specgen/scripts/submit.mjs +12 -6
- package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +288 -7
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.java +15 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +26 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +298 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.java +36 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +43 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +298 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +265 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.java +47 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +54 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +298 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +515 -0
- package/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
- package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +543 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +652 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1231 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +494 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1513 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +758 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +623 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +116 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +795 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +883 -0
- package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +135 -137
- package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
- package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +40 -1
- package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +178 -9
- package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +19 -1
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.java +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.kt +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanelsKotlinForms.kt +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ChildContent.java +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ComposeLifecycle.kt +26 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleCallAndOverride.java +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleHooks.kt +31 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyLifecycleHooks.kt +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshOnResume.java +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshResultNoise.kt +36 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/SelectionView.java +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ShowPage.vue +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ThirdPartyLifecycle.kt +25 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/fragment_detail.xml +1 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +459 -188
- package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +89 -0
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +869 -13
- package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
- package/skills/a2h-page-specgen/scripts/test/helpers.mjs +139 -5
- package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +378 -0
- package/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
- package/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
- package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +69 -2
- package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +267 -2
- package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +111 -0
- package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +10 -8
- package/skills/a2h-page-specgen/scripts/test/ledger-lock.test.mjs +77 -0
- package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +1 -1
- package/skills/a2h-page-specgen/scripts/test/main-module.test.mjs +43 -0
- package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
- package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +143 -51
- package/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +42 -2
- package/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
- package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +171 -3
- package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +13 -5
- package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +365 -1
- package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +102 -7
- package/skills/a2h-page-specgen/scripts/test/recovery-policy.test.mjs +14 -0
- package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1308 -72
- package/skills/a2h-page-specgen/scripts/test/render.test.mjs +85 -42
- package/skills/a2h-page-specgen/scripts/test/report.test.mjs +296 -0
- package/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
- package/skills/a2h-page-specgen/scripts/test/scope.test.mjs +292 -0
- package/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
- package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +645 -115
- package/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
- package/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
- package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +101 -65
- package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +88 -74
- package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +30 -1
- package/skills/a2h-page-specgen/scripts/waker.mjs +79 -12
- package/skills/a2h-page-specgen/scripts/watchdog.mjs +18 -17
- package/skills/a2h-resource-convert/SKILL.md +9 -1
- package/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
- package/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
- package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
- package/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +67 -3
- package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +68 -0
- package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +45 -3
- package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +42 -5
- package/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
- package/skills/a2h-resource-convert/scripts/lottie_refs.ts +398 -0
- package/skills/a2h-resource-convert/scripts/merge_mapping.ts +316 -0
- package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +2 -1
- package/skills/a2h-resource-convert/scripts/tests/code_vector_guard.test.mjs +75 -0
- package/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
- package/skills/a2h-resource-convert/scripts/tests/lottie_incremental.test.mjs +178 -0
- package/skills/a2h-resource-convert/scripts/tests/merge_mapping.test.mjs +201 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +48 -72
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +123 -37
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +40 -8
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +5 -4
- package/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +229 -0
- package/skills/a2h-spec-design-pipeline/references/initialization.md +37 -5
- package/skills/a2h-spec-design-pipeline/references/merge-queue.md +126 -23
- package/skills/a2h-spec-design-pipeline/references/permission-index.json +206 -0
- package/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
- package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +7 -1
- package/skills/a2h-spec-design-pipeline/references/review-loop.md +46 -0
- package/skills/a2h-spec-design-pipeline/references/scripts.md +38 -14
- package/skills/a2h-spec-design-pipeline/references/shared-layer.md +127 -4
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +90 -24
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +65 -34
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +11 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +10 -2
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +47 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +31 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +698 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +96 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +103 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +124 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +138 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +106 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +113 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +705 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +1063 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +473 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/{HttpExtraDataEmptyStringCheck.js → platform/ExtraDataSubCheck.js} +27 -30
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +4 -2
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +3 -2
- package/skills/a2h-spec-design-pipeline/scripts/check_design_map.ts +108 -0
- package/skills/a2h-spec-design-pipeline/scripts/check_permissions.ts +420 -0
- package/skills/a2h-spec-design-pipeline/scripts/check_review_evidence.ts +45 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +55 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +138 -7
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +10 -13
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +21 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +63 -4
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +32 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +109 -13
- package/skills/a2h-spec-design-pipeline/scripts/ensure_index.ts +866 -0
- package/skills/a2h-spec-design-pipeline/scripts/fixtures/homecheck-stub.cjs +47 -0
- package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +12 -17
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +172 -7
- package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +36 -16
- package/skills/a2h-spec-design-pipeline/scripts/sync_permission_index.ts +340 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +281 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +690 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_check_design_map.ts +46 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_check_permissions.ts +201 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +27 -3
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +20 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +143 -13
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +168 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +139 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +25 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +92 -4
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +37 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index.ts +572 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index_real.ts +56 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +4 -5
- package/skills/a2h-spec-design-pipeline/scripts/test_homegraph_docs.ts +217 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_permission_index.ts +214 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +308 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +59 -8
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +44 -0
- package/skills/a2h-spec-generate/SKILL.md +2 -2
- package/skills/a2h-spec-generate/references/specs.schema.json +24 -11
- package/skills/a2h-spec-generate/scripts/ensure-index.mjs +1 -2
- package/skills/a2h-spec-generate/test/ensure-index.test.mjs +1 -2
- package/skills/a2h-utg-explorer/SKILL.md +9 -3
- package/skills/a2h-utg-explorer/references/architecture.md +3 -0
- package/skills/a2h-utg-explorer/scripts/audit.mjs +8 -2
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +56 -5
- package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +47 -2
- package/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
- package/skills/a2h-utg-explorer/scripts/plan.mjs +8 -0
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
- package/skills/a2h-utg-explorer/scripts/report.mjs +89 -0
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +67 -10
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +10 -2
- package/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
- package/skills/a2h-utg-explorer/scripts/tests/blank_wait.test.mjs +126 -0
- package/skills/a2h-utg-explorer/scripts/tests/default_override.test.mjs +109 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_locale_dialogs.test.mjs +29 -0
- package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +254 -0
- package/skills/a2h-utg-explorer/scripts/tests/foreground_spelling.test.mjs +155 -0
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +120 -0
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
- package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +122 -0
- package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +15 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +218 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +292 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_d_grounding.test.mjs +164 -0
- package/skills/a2h-utg-explorer/scripts/tests/replay_reroute.test.mjs +143 -0
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +6 -2
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle_follow.test.mjs +35 -0
- package/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +122 -4
- package/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +138 -4
- package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +22 -13
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +718 -42
- package/skills/a2h-utg-explorer/scripts/variant.mjs +57 -11
- package/skills/a2h-utg-static/SKILL.md +6 -2
- package/skills/a2h-utg-static/scripts/assemble.mjs +65 -0
- package/skills/a2h-utg-static/scripts/click_paths.mjs +116 -5
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +8 -1
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
- package/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
- package/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
- package/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
- package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +46 -1
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
- package/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
- package/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
- package/skills/a2h-utg-static/scripts/menu_nav.mjs +1 -1
- package/skills/a2h-utg-static/scripts/nl_hints.mjs +32 -4
- package/skills/a2h-utg-static/scripts/run_pipeline.mjs +86 -4
- package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +30 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +18 -0
- package/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
- package/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +114 -0
- package/skills/a2h-utg-static/scripts/tests/test_guard_kinds_locale.mjs +12 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +165 -1
- package/skills/a2h-utg-static/scripts/tests/test_library_activity.mjs +45 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_default_override.mjs +50 -0
- package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +21 -0
- package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_redirect_path_cost.mjs +136 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_route_jump.mjs +175 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +99 -0
- package/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
- package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +21 -0
- package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +112 -69
- package/skills/a2h-utg-static/scripts/vm_nav.mjs +9 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-cn.md +0 -55
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/http-extra-data-empty-string-en.md +0 -60
- package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +0 -948
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +0 -1014
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
// HomeGraph index lifecycle for a2h-spec-design-pipeline.
|
|
2
|
+
//
|
|
3
|
+
// node ensure_index.ts <repo> [--create] [--sync] [--no-rebuild]
|
|
4
|
+
// [--engine-mode off|auto|required]
|
|
5
|
+
// [--timeout-ms <n>] [--init-timeout-ms <n>] [--status-timeout-ms <n>] [--json]
|
|
6
|
+
//
|
|
7
|
+
// Pipeline events run --sync unconditionally: `homegraph status` reads git's
|
|
8
|
+
// uncommitted set, so after a pipeline commit it reports "up to date" while the
|
|
9
|
+
// index is behind HEAD. `status` only decides initialized/statistics.
|
|
10
|
+
//
|
|
11
|
+
// Only this script writes an index. It refuses linked worktrees, never deletes
|
|
12
|
+
// a local database, and never unlocks or kills a live writer (main-tree rule).
|
|
13
|
+
import { spawnSync } from 'node:child_process';
|
|
14
|
+
import {
|
|
15
|
+
appendFileSync, existsSync, lstatSync, readFileSync, realpathSync, renameSync, rmSync, statSync,
|
|
16
|
+
} from 'node:fs';
|
|
17
|
+
import * as path from 'node:path';
|
|
18
|
+
|
|
19
|
+
const USAGE = 'usage: node ensure_index.ts <repo> [--create] [--sync] [--no-rebuild] '
|
|
20
|
+
+ '[--engine-mode off|auto|required] [--timeout-ms <n>] [--init-timeout-ms <n>] '
|
|
21
|
+
+ '[--status-timeout-ms <n>] [--json]';
|
|
22
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
23
|
+
const DEFAULT_INIT_TIMEOUT_MS = 300_000;
|
|
24
|
+
const DEFAULT_STATUS_TIMEOUT_MS = 120_000;
|
|
25
|
+
const MAX_TIMEOUT_MS = 3_600_000;
|
|
26
|
+
const PROBE_TIMEOUT_MS = 30_000;
|
|
27
|
+
const MAX_ATTEMPTS = 3;
|
|
28
|
+
const LOCKED = /database is locked/i;
|
|
29
|
+
let INIT_TIMEOUT_MS = DEFAULT_INIT_TIMEOUT_MS;
|
|
30
|
+
|
|
31
|
+
type EngineMode = 'off' | 'auto' | 'required';
|
|
32
|
+
|
|
33
|
+
type Status = {
|
|
34
|
+
initialized?: boolean;
|
|
35
|
+
projectPath?: string;
|
|
36
|
+
indexPath?: string;
|
|
37
|
+
fileCount?: number;
|
|
38
|
+
lastIndexed?: string | null;
|
|
39
|
+
pendingChanges?: { added?: number; modified?: number; removed?: number };
|
|
40
|
+
worktreeMismatch?: unknown;
|
|
41
|
+
index?: { state?: string | null; builtWithVersion?: string | null; reindexRecommended?: boolean };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type RunResult = {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
out: string;
|
|
47
|
+
err: string;
|
|
48
|
+
code: number | null;
|
|
49
|
+
timeout: boolean;
|
|
50
|
+
missing: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type EmitPayload = {
|
|
54
|
+
ok: boolean;
|
|
55
|
+
repo: string | null;
|
|
56
|
+
action: 'none' | 'init' | 'sync' | 'index' | 'skip';
|
|
57
|
+
reason: string | null;
|
|
58
|
+
degraded: boolean;
|
|
59
|
+
initialized: boolean;
|
|
60
|
+
attempts: number;
|
|
61
|
+
reaped: number | null;
|
|
62
|
+
projectPath: string | null;
|
|
63
|
+
lastIndexed: string | null;
|
|
64
|
+
fileCount: number | null;
|
|
65
|
+
indexState: string | null;
|
|
66
|
+
builtWithVersion: string | null;
|
|
67
|
+
durationMs: number;
|
|
68
|
+
detail: string | null;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type Args = {
|
|
72
|
+
repo: string;
|
|
73
|
+
create: boolean;
|
|
74
|
+
sync: boolean;
|
|
75
|
+
rebuild: boolean;
|
|
76
|
+
engineMode: EngineMode;
|
|
77
|
+
timeoutMs: number;
|
|
78
|
+
initTimeoutMs: number;
|
|
79
|
+
statusTimeoutMs: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function realp(p: string): string {
|
|
83
|
+
try {
|
|
84
|
+
return realpathSync(path.resolve(p));
|
|
85
|
+
} catch {
|
|
86
|
+
return path.resolve(p);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Split a command line with double-quote grouping (`node "C:\a b\stub.mjs"`). */
|
|
91
|
+
function splitCommand(cmd: string): string[] {
|
|
92
|
+
const out: string[] = [];
|
|
93
|
+
const re = /"([^"]*)"|(\S+)/g;
|
|
94
|
+
let m: RegExpExecArray | null;
|
|
95
|
+
while ((m = re.exec(cmd)) !== null) out.push(m[1] ?? m[2]!);
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function engine(): string[] {
|
|
100
|
+
const raw = (process.env.HOMEGRAPH_BIN ?? '').trim();
|
|
101
|
+
if (!raw) return ['homegraph'];
|
|
102
|
+
// A bare path that exists is one token even when it contains spaces; the
|
|
103
|
+
// quote-grouped form stays available for real command lines.
|
|
104
|
+
if (!raw.includes('"') && existsSync(raw)) return [raw];
|
|
105
|
+
return splitCommand(raw);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Windows cannot exec an npm `.cmd` shim directly (and `homegraph` on PATH is
|
|
110
|
+
* exactly that). `.exe` runs directly; a `.js`/`.mjs` target runs through this
|
|
111
|
+
* node binary; anything else (bare name, `.cmd`, `.bat`) goes through cmd.exe
|
|
112
|
+
* with every token quoted, so paths with spaces survive.
|
|
113
|
+
*/
|
|
114
|
+
function commandFor(extra: string[]): { file: string; args: string[]; verbatim: boolean } {
|
|
115
|
+
const bin = engine();
|
|
116
|
+
const [head, ...rest] = bin;
|
|
117
|
+
const toks = [...rest, ...extra];
|
|
118
|
+
if (process.platform !== 'win32') return { file: head!, args: toks, verbatim: false };
|
|
119
|
+
const lower = head!.toLowerCase();
|
|
120
|
+
if (lower.endsWith('.exe')) return { file: head!, args: toks, verbatim: false };
|
|
121
|
+
if (/\.[cm]?js$/.test(lower)) return { file: process.execPath, args: [head!, ...toks], verbatim: false };
|
|
122
|
+
// cmd.exe /s strips the first and last quote of the whole command string, so
|
|
123
|
+
// the canonical shape is: /c ""prog" "arg1" "arg2"".
|
|
124
|
+
const quoted = `"${[head!, ...toks].map((tok) => `"${tok.replace(/"/g, '""')}"`).join(' ')}"`;
|
|
125
|
+
return { file: process.env.ComSpec || 'cmd.exe', args: ['/d', '/s', '/c', quoted], verbatim: true };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function run(args: string[], timeout: number): RunResult {
|
|
129
|
+
const cmd = commandFor(args);
|
|
130
|
+
const r = spawnSync(cmd.file, cmd.args, {
|
|
131
|
+
encoding: 'utf8', timeout, killSignal: 'SIGKILL', windowsHide: true,
|
|
132
|
+
windowsVerbatimArguments: cmd.verbatim,
|
|
133
|
+
});
|
|
134
|
+
const err = String(r.stderr ?? '').trim() || String(r.error?.message ?? '');
|
|
135
|
+
const code = typeof r.status === 'number' ? r.status : null;
|
|
136
|
+
const timedOut = r.error?.code === 'ETIMEDOUT' || r.signal === 'SIGKILL';
|
|
137
|
+
return {
|
|
138
|
+
ok: code === 0,
|
|
139
|
+
out: String(r.stdout ?? '').trim(),
|
|
140
|
+
err,
|
|
141
|
+
code,
|
|
142
|
+
timeout: timedOut,
|
|
143
|
+
missing: Boolean(r.error) && (r.error as NodeJS.ErrnoException).code === 'ENOENT',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function git(args: string[], cwd: string) {
|
|
148
|
+
const r = spawnSync('git', ['-C', cwd, '-c', 'core.quotepath=false', ...args],
|
|
149
|
+
{ encoding: 'utf8', timeout: 120_000, windowsHide: true });
|
|
150
|
+
return { ok: r.status === 0, out: String(r.stdout ?? '').trim(), err: String(r.stderr ?? '').trim() };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Engine output is full of ANSI color codes; never carry them into a wave log. */
|
|
154
|
+
function plain(text: string): string {
|
|
155
|
+
return text.replace(/\u001b\[[0-9;]*m/g, '').trim();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Keep both ends of a long engine message. The tail alone is often progress
|
|
160
|
+
* noise ("releaseScene: disposing ..."), which makes a recorded `detail`
|
|
161
|
+
* undiagnosable.
|
|
162
|
+
*/
|
|
163
|
+
function clip(text: string, max = 400): string {
|
|
164
|
+
if (text.length <= max) return text;
|
|
165
|
+
const half = Math.floor((max - 5) / 2);
|
|
166
|
+
return `${text.slice(0, half)} ... ${text.slice(-half)}`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Brace-balanced object spans, in order of appearance. Needed when the real
|
|
171
|
+
* status is pretty-printed and followed by another object (e.g. an `{"error"}`
|
|
172
|
+
* line): the whole text is not JSON and a single outermost span swallows both.
|
|
173
|
+
* One forward pass with a stack - linear in the output size, so a pathological
|
|
174
|
+
* payload cannot stall the pipeline.
|
|
175
|
+
*/
|
|
176
|
+
function* braceSpans(text: string): Generator<string> {
|
|
177
|
+
const spans: Array<{ start: number; value: string }> = [];
|
|
178
|
+
const open: number[] = [];
|
|
179
|
+
let inString = false;
|
|
180
|
+
let escaped = false;
|
|
181
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
182
|
+
const ch = text[i]!;
|
|
183
|
+
if (inString) {
|
|
184
|
+
if (escaped) escaped = false;
|
|
185
|
+
else if (ch === '\\') escaped = true;
|
|
186
|
+
else if (ch === '"') inString = false;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (ch === '"') inString = true;
|
|
190
|
+
else if (ch === '{') open.push(i);
|
|
191
|
+
else if (ch === '}') {
|
|
192
|
+
const start = open.pop();
|
|
193
|
+
if (start !== undefined) spans.push({ start, value: text.slice(start, i + 1) });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
spans.sort((a, b) => a.start - b.start);
|
|
197
|
+
for (const span of spans) yield span.value;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Parse `homegraph status --json` output. Tolerates a BOM, progress/warning
|
|
202
|
+
* lines, and pretty-printed JSON: whole text, then balanced object spans in
|
|
203
|
+
* order, then lines bottom-up. Only a real status object is accepted - a
|
|
204
|
+
* trailing `{"error":...}` object must never be mistaken for one (acting on it
|
|
205
|
+
* would rebuild a perfectly good index), and the FIRST valid object wins so a
|
|
206
|
+
* repeated status cannot flip the decision.
|
|
207
|
+
*/
|
|
208
|
+
function parseStatusText(text: string): Status | null {
|
|
209
|
+
const clean = text.replace(/^\uFEFF/, '');
|
|
210
|
+
const candidates: string[] = [clean.trim()];
|
|
211
|
+
for (const span of braceSpans(clean)) candidates.push(span);
|
|
212
|
+
const lines = clean.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
213
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) candidates.push(lines[i]!);
|
|
214
|
+
for (const candidate of candidates) {
|
|
215
|
+
if (!candidate) continue;
|
|
216
|
+
try {
|
|
217
|
+
const parsed: unknown = JSON.parse(candidate);
|
|
218
|
+
if (parsed && typeof parsed === 'object'
|
|
219
|
+
&& typeof (parsed as Status).initialized === 'boolean'
|
|
220
|
+
&& 'projectPath' in (parsed as Record<string, unknown>)) {
|
|
221
|
+
return parsed as Status;
|
|
222
|
+
}
|
|
223
|
+
} catch {
|
|
224
|
+
// try the next candidate
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
type StatusRead = {
|
|
231
|
+
status: Status | null;
|
|
232
|
+
missing: boolean;
|
|
233
|
+
timeout: boolean;
|
|
234
|
+
unreadable: boolean;
|
|
235
|
+
err: string;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
function readStatus(repo: string, statusTimeoutMs: number): StatusRead {
|
|
239
|
+
const r = run(['status', '--json', repo], statusTimeoutMs);
|
|
240
|
+
if (r.missing) return { status: null, missing: true, timeout: false, unreadable: false, err: r.err };
|
|
241
|
+
if (r.timeout) return { status: null, missing: false, timeout: true, unreadable: false, err: r.err };
|
|
242
|
+
const parsed = parseStatusText(r.out);
|
|
243
|
+
if (!parsed) {
|
|
244
|
+
return {
|
|
245
|
+
status: null, missing: false, timeout: false, unreadable: true,
|
|
246
|
+
err: plain(r.err || r.out).slice(-300),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return { status: parsed, missing: false, timeout: false, unreadable: false, err: '' };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* `status` with the ancestor trap removed. Without a local `homegraph.db` the
|
|
254
|
+
* engine resolves the READ command upward to the nearest initialized ancestor
|
|
255
|
+
* and scans that ancestor's whole project root, so the call can cost minutes and
|
|
256
|
+
* says nothing about this repo. There is also nothing to learn: no local db
|
|
257
|
+
* means no local index, which is exactly what `init` is for. Every status read
|
|
258
|
+
* in this file goes through here - including the post-failure and post-build
|
|
259
|
+
* checks, which can run while a failed build left no db behind.
|
|
260
|
+
*/
|
|
261
|
+
function probeStatus(repo: string, statusTimeoutMs: number): StatusRead {
|
|
262
|
+
if (!existsSync(path.join(repo, '.homegraph', 'homegraph.db'))) {
|
|
263
|
+
// Shaped like a readable engine answer so the callers' "initialized:false"
|
|
264
|
+
// branches (init / index_incomplete) keep working without a spawn.
|
|
265
|
+
return { status: { initialized: false }, missing: false, timeout: false, unreadable: false, err: '' };
|
|
266
|
+
}
|
|
267
|
+
return readStatus(repo, statusTimeoutMs);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** True when the resolved index lives in this very repo. */
|
|
271
|
+
function isLocal(status: Status | null, repo: string): boolean {
|
|
272
|
+
if (!status?.initialized) return false;
|
|
273
|
+
if (status.worktreeMismatch) return false;
|
|
274
|
+
if (!status.projectPath) return false;
|
|
275
|
+
if (realp(status.projectPath) !== realp(repo)) return false;
|
|
276
|
+
if (status.indexPath) {
|
|
277
|
+
return realp(status.indexPath) === realp(path.join(repo, '.homegraph'));
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* A killed build leaves `initialized:true` with content that never finalized,
|
|
284
|
+
* and `init` will not rebuild it - so a timed-out build that wrote every row
|
|
285
|
+
* would otherwise be advertised as usable. The engine persists `index_state`
|
|
286
|
+
* when a full build starts and clears it only on success, so `"indexing"` means
|
|
287
|
+
* "a run was killed mid-index", and `"failed"` means it reported failure;
|
|
288
|
+
* neither can be trusted. `"partial"` finished but dropped files: the rows it
|
|
289
|
+
* has are coherent, so it stays usable (a rebuild would drop the same files
|
|
290
|
+
* again at full cost). A missing/null state is a pre-marker engine or index:
|
|
291
|
+
* fall back to the content check rather than forcing a rebuild every run.
|
|
292
|
+
*/
|
|
293
|
+
function isUsable(status: Status | null): boolean {
|
|
294
|
+
if (!status?.lastIndexed) return false;
|
|
295
|
+
if (Number(status.fileCount ?? 0) <= 0) return false;
|
|
296
|
+
const state = status.index?.state ?? null;
|
|
297
|
+
if (state === null) return true;
|
|
298
|
+
return state === 'complete' || state === 'partial';
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** The engine records its own PID here before it starts writing (FileLock). */
|
|
302
|
+
function lockPath(repo: string): string {
|
|
303
|
+
return path.join(repo, '.homegraph', 'homegraph.lock');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** The engine's own FileLock.STALE_TIMEOUT_MS: older locks are never trusted. */
|
|
307
|
+
const LOCK_FRESH_MS = 120_000;
|
|
308
|
+
|
|
309
|
+
type LockInfo = { pid: number; ageMs: number; fresh: boolean };
|
|
310
|
+
|
|
311
|
+
function readLock(repo: string): LockInfo | null {
|
|
312
|
+
const file = lockPath(repo);
|
|
313
|
+
try {
|
|
314
|
+
const pid = Number.parseInt(readFileSync(file, 'utf8').trim(), 10);
|
|
315
|
+
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
316
|
+
const ageMs = Date.now() - statSync(file).mtimeMs;
|
|
317
|
+
return { pid, ageMs, fresh: ageMs >= 0 && ageMs < LOCK_FRESH_MS };
|
|
318
|
+
} catch {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function pidAlive(pid: number): boolean {
|
|
324
|
+
// A lock naming this very process is live: never unlock your own writer.
|
|
325
|
+
if (pid === process.pid) return true;
|
|
326
|
+
try {
|
|
327
|
+
process.kill(pid, 0);
|
|
328
|
+
return true;
|
|
329
|
+
} catch {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Never delete a lock acquired after the decision was made: re-read it immediately
|
|
336
|
+
* before `unlock` and skip when the PID changed (a new holder owns it now).
|
|
337
|
+
*/
|
|
338
|
+
function unlockIfSame(repo: string, pid: number): void {
|
|
339
|
+
const current = readLock(repo);
|
|
340
|
+
if (current?.pid !== pid) return;
|
|
341
|
+
run(['unlock', repo], 30_000);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Linked worktrees keep their git dir under the common dir; the main checkout does not. */
|
|
345
|
+
function isLinkedWorktree(repo: string): boolean {
|
|
346
|
+
const gitDir = git(['rev-parse', '--absolute-git-dir'], repo);
|
|
347
|
+
const commonDir = git(['rev-parse', '--git-common-dir'], repo);
|
|
348
|
+
if (!gitDir.ok || !commonDir.ok) return false;
|
|
349
|
+
const commonAbs = realp(path.isAbsolute(commonDir.out)
|
|
350
|
+
? commonDir.out : path.resolve(repo, commonDir.out));
|
|
351
|
+
return realp(gitDir.out) !== commonAbs;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function emit(payload: Partial<EmitPayload>, code: number): number {
|
|
355
|
+
const base: EmitPayload = {
|
|
356
|
+
ok: false, repo: null, action: 'skip', reason: null, degraded: false,
|
|
357
|
+
initialized: false, attempts: 0, reaped: null, projectPath: null, lastIndexed: null,
|
|
358
|
+
fileCount: null, indexState: null, builtWithVersion: null,
|
|
359
|
+
durationMs: 0, detail: null,
|
|
360
|
+
};
|
|
361
|
+
// Reporting-only `initialized` (design §4.2): the local db exists AND the status
|
|
362
|
+
// snapshot resolved to this repo. A call that never read status cannot claim it.
|
|
363
|
+
const dbPath = payload.repo ? path.join(payload.repo, '.homegraph', 'homegraph.db') : null;
|
|
364
|
+
const initialized = Boolean(
|
|
365
|
+
payload.repo && payload.projectPath && dbPath && existsSync(dbPath)
|
|
366
|
+
&& realp(payload.projectPath) === realp(payload.repo),
|
|
367
|
+
);
|
|
368
|
+
console.log(JSON.stringify({ ...base, initialized, ...payload }));
|
|
369
|
+
return code;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function statusFields(status: Status | null) {
|
|
373
|
+
return {
|
|
374
|
+
projectPath: status?.projectPath ?? null,
|
|
375
|
+
lastIndexed: status?.lastIndexed ?? null,
|
|
376
|
+
fileCount: typeof status?.fileCount === 'number' ? status.fileCount : null,
|
|
377
|
+
indexState: status?.index?.state ?? null,
|
|
378
|
+
builtWithVersion: status?.index?.builtWithVersion ?? null,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function ensureIgnored(repo: string): boolean {
|
|
383
|
+
const ignoreFile = path.join(repo, '.gitignore');
|
|
384
|
+
if (!existsSync(ignoreFile)) return true;
|
|
385
|
+
// Idempotent: a plain-text check must come first. `git check-ignore` fails in a
|
|
386
|
+
// non-git tree (Android is not required to be a git checkout), and appending on
|
|
387
|
+
// every run would grow the file without bound.
|
|
388
|
+
const hasRule = (text: string) => text.split(/\r?\n/)
|
|
389
|
+
.some((line) => /^\/?\.homegraph\/?$/.test(line.trim()));
|
|
390
|
+
try {
|
|
391
|
+
if (hasRule(readFileSync(ignoreFile, 'utf8'))) return true;
|
|
392
|
+
} catch { return false; }
|
|
393
|
+
if (git(['check-ignore', '-q', '--no-index', '.homegraph/'], repo).ok) return true;
|
|
394
|
+
try {
|
|
395
|
+
const cur = readFileSync(ignoreFile, 'utf8');
|
|
396
|
+
const eol = cur.includes('\r\n') ? '\r\n' : '\n';
|
|
397
|
+
const lead = cur.length > 0 && !cur.endsWith('\n') ? eol : '';
|
|
398
|
+
appendFileSync(ignoreFile, `${lead}.homegraph/${eol}`);
|
|
399
|
+
return true;
|
|
400
|
+
} catch {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function trackedIndexFiles(repo: string): { ok: boolean; files: string[] } {
|
|
406
|
+
// <ANDROID> is not required to be a git checkout (I2 only requires <HMOS> to
|
|
407
|
+
// be one). A non-git path has no tracked files and no ignore rule to enforce.
|
|
408
|
+
const isRepo = git(['rev-parse', '--is-inside-work-tree'], repo);
|
|
409
|
+
if (!isRepo.ok) return { ok: true, files: [] };
|
|
410
|
+
const listed = git(['ls-files', '--', ':(icase).homegraph'], repo);
|
|
411
|
+
if (!listed.ok) return { ok: false, files: [] };
|
|
412
|
+
const files = listed.out.split('\n').map((l) => l.trim()).filter(Boolean)
|
|
413
|
+
.map((f) => f.split('\\').join('/'))
|
|
414
|
+
.filter((f) => f.toLowerCase() !== '.homegraph/.gitignore');
|
|
415
|
+
return { ok: true, files };
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function versionOf(text: string): string | null {
|
|
419
|
+
const m = text.match(/(\d+\.\d+\.\d+)/);
|
|
420
|
+
return m ? m[1]! : null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function quarantineDb(repo: string): string | null {
|
|
424
|
+
const dir = path.join(repo, '.homegraph');
|
|
425
|
+
const db = path.join(dir, 'homegraph.db');
|
|
426
|
+
try {
|
|
427
|
+
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
428
|
+
const dest = path.join(dir, `homegraph.corrupt-${ts}.db`);
|
|
429
|
+
renameSync(db, dest);
|
|
430
|
+
// A crash can leave the WAL/SHM sidecars behind; move them with the db (same
|
|
431
|
+
// timestamp) so a fresh `init` never runs next to a stale journal.
|
|
432
|
+
for (const suffix of ['-wal', '-shm']) {
|
|
433
|
+
const sidecar = path.join(dir, `homegraph.db${suffix}`);
|
|
434
|
+
if (existsSync(sidecar)) renameSync(sidecar, path.join(dir, `homegraph.corrupt-${ts}.db${suffix}`));
|
|
435
|
+
}
|
|
436
|
+
return dest;
|
|
437
|
+
} catch {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function parseArgs(argv: string[]): Args {
|
|
443
|
+
const positionals: string[] = [];
|
|
444
|
+
let create = false;
|
|
445
|
+
let sync = false;
|
|
446
|
+
let rebuild = true;
|
|
447
|
+
let engineMode = (process.env.ENGINE_MODE ?? 'auto').trim().toLowerCase() as EngineMode;
|
|
448
|
+
let timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
449
|
+
let initTimeoutMs = DEFAULT_INIT_TIMEOUT_MS;
|
|
450
|
+
let statusTimeoutMs = DEFAULT_STATUS_TIMEOUT_MS;
|
|
451
|
+
const num = (value: string | undefined, flag: string): number => {
|
|
452
|
+
const n = Number(value);
|
|
453
|
+
if (!Number.isFinite(n) || n <= 0 || n > MAX_TIMEOUT_MS) {
|
|
454
|
+
throw new Error(`${flag} expects a positive millisecond value <= ${MAX_TIMEOUT_MS}`);
|
|
455
|
+
}
|
|
456
|
+
return n;
|
|
457
|
+
};
|
|
458
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
459
|
+
const a = argv[i]!;
|
|
460
|
+
if (a === '--create') create = true;
|
|
461
|
+
else if (a === '--sync') sync = true;
|
|
462
|
+
else if (a === '--no-rebuild') rebuild = false;
|
|
463
|
+
else if (a === '--json') { /* JSON is always the output format */ }
|
|
464
|
+
else if (a === '--engine-mode') engineMode = String(argv[++i] ?? '').trim().toLowerCase() as EngineMode;
|
|
465
|
+
else if (a.startsWith('--engine-mode=')) engineMode = a.slice('--engine-mode='.length).trim().toLowerCase() as EngineMode;
|
|
466
|
+
else if (a === '--timeout-ms') timeoutMs = num(argv[++i], '--timeout-ms');
|
|
467
|
+
else if (a.startsWith('--timeout-ms=')) timeoutMs = num(a.slice('--timeout-ms='.length), '--timeout-ms');
|
|
468
|
+
else if (a === '--init-timeout-ms') initTimeoutMs = num(argv[++i], '--init-timeout-ms');
|
|
469
|
+
else if (a.startsWith('--init-timeout-ms=')) initTimeoutMs = num(a.slice('--init-timeout-ms='.length), '--init-timeout-ms');
|
|
470
|
+
else if (a === '--status-timeout-ms') statusTimeoutMs = num(argv[++i], '--status-timeout-ms');
|
|
471
|
+
else if (a.startsWith('--status-timeout-ms=')) statusTimeoutMs = num(a.slice('--status-timeout-ms='.length), '--status-timeout-ms');
|
|
472
|
+
else if (a.startsWith('-')) throw new Error(`unknown option: ${a}`);
|
|
473
|
+
else positionals.push(a);
|
|
474
|
+
}
|
|
475
|
+
if (positionals.length !== 1) throw new Error('expected exactly one <repo>');
|
|
476
|
+
if (engineMode !== 'off' && engineMode !== 'auto' && engineMode !== 'required') {
|
|
477
|
+
throw new Error(`--engine-mode must be off|auto|required (got "${engineMode}")`);
|
|
478
|
+
}
|
|
479
|
+
return { repo: positionals[0]!, create, sync, rebuild, engineMode, timeoutMs, initTimeoutMs, statusTimeoutMs };
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
type Mutation = { last: RunResult | null; attempts: number; reaped: number | null; blockedPid: number | null };
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Read-only lock verdict. `ensure_index.ts` only runs on the main checkout and the
|
|
486
|
+
* design forbids killing a live writer there (§4.4), so a live holder is ALWAYS
|
|
487
|
+
* `lock_busy` - never kill or unlock. Only a dead/absent holder is unlocked.
|
|
488
|
+
*/
|
|
489
|
+
type LockDecision = { kind: 'none' | 'dead' | 'live'; pid: number | null };
|
|
490
|
+
|
|
491
|
+
function lockHolderDecision(repo: string): LockDecision {
|
|
492
|
+
const lock = readLock(repo);
|
|
493
|
+
if (lock === null) return { kind: 'none', pid: null };
|
|
494
|
+
if (!pidAlive(lock.pid)) return { kind: 'dead', pid: lock.pid };
|
|
495
|
+
return { kind: 'live', pid: lock.pid };
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function runMutation(args: string[], repo: string, timeoutMs: number): Mutation {
|
|
499
|
+
let last: RunResult | null = null;
|
|
500
|
+
let attempts = 0;
|
|
501
|
+
const reaped: number | null = null;
|
|
502
|
+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) {
|
|
503
|
+
attempts = attempt;
|
|
504
|
+
last = run(args, timeoutMs);
|
|
505
|
+
if (last.ok) break;
|
|
506
|
+
if (last.timeout) {
|
|
507
|
+
// Main-tree rule: never kill a writer whose ownership cannot be proven.
|
|
508
|
+
// A timed-out attempt leaves its lock behind: the next call sees a live
|
|
509
|
+
// holder (`lock_busy`) or a dead one (unlock then retry).
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
if (!LOCKED.test(`${last.out}\n${last.err}`)) break;
|
|
513
|
+
const holder = lockHolderDecision(repo);
|
|
514
|
+
if (holder.kind === 'live') return { last, attempts, reaped, blockedPid: holder.pid };
|
|
515
|
+
if (holder.kind === 'dead' && holder.pid !== null) unlockIfSame(repo, holder.pid);
|
|
516
|
+
}
|
|
517
|
+
return { last, attempts, reaped, blockedPid: null };
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function main(argv: string[]): number {
|
|
521
|
+
let parsed: Args;
|
|
522
|
+
try { parsed = parseArgs(argv); }
|
|
523
|
+
catch (e) {
|
|
524
|
+
console.error(`[ERROR] ${(e as Error).message}\n${USAGE}`);
|
|
525
|
+
return 2;
|
|
526
|
+
}
|
|
527
|
+
const { create, sync, rebuild, engineMode, timeoutMs, initTimeoutMs, statusTimeoutMs } = parsed;
|
|
528
|
+
INIT_TIMEOUT_MS = initTimeoutMs;
|
|
529
|
+
const started = Date.now();
|
|
530
|
+
const repo = realp(parsed.repo);
|
|
531
|
+
|
|
532
|
+
if (!existsSync(repo) || !statSync(repo).isDirectory()) {
|
|
533
|
+
return emit({ ok: false, repo, reason: 'repo_missing', durationMs: Date.now() - started }, 1);
|
|
534
|
+
}
|
|
535
|
+
// `off` is checked before ANY git read or filesystem write: this mode must not
|
|
536
|
+
// spawn an engine or touch `.gitignore`. Explicit paths are used literally, so a
|
|
537
|
+
// monorepo subdirectory (a normal <ANDROID> layout) is indexed where it stands.
|
|
538
|
+
if (engineMode === 'off') {
|
|
539
|
+
return emit({
|
|
540
|
+
ok: true, repo, action: 'skip', reason: 'engine_off', degraded: false,
|
|
541
|
+
durationMs: Date.now() - started, detail: 'ENGINE_MODE=off: no engine command may run',
|
|
542
|
+
}, 0);
|
|
543
|
+
}
|
|
544
|
+
if (isLinkedWorktree(repo)) {
|
|
545
|
+
return emit({
|
|
546
|
+
ok: false, repo, reason: 'not_main_checkout', durationMs: Date.now() - started,
|
|
547
|
+
detail: 'the pipeline index belongs to the main checkout; worktrees are read-only consumers',
|
|
548
|
+
}, 1);
|
|
549
|
+
}
|
|
550
|
+
const indexDir = path.join(repo, '.homegraph');
|
|
551
|
+
try {
|
|
552
|
+
if (lstatSync(indexDir).isSymbolicLink()) {
|
|
553
|
+
return emit({
|
|
554
|
+
ok: false, repo, reason: 'homegraph_linked', durationMs: Date.now() - started,
|
|
555
|
+
detail: '.homegraph/ is a symlink/junction to another tree; remove the link and re-run',
|
|
556
|
+
}, 1);
|
|
557
|
+
}
|
|
558
|
+
} catch { /* no .homegraph yet, init will create it */ }
|
|
559
|
+
|
|
560
|
+
const bin = engine();
|
|
561
|
+
const probe = run(['--version'], PROBE_TIMEOUT_MS);
|
|
562
|
+
if (!probe.ok) {
|
|
563
|
+
return emit({
|
|
564
|
+
ok: false, repo, reason: 'engine_missing', durationMs: Date.now() - started,
|
|
565
|
+
detail: plain(`${bin.join(' ')} --version failed: ${probe.err || probe.out}`).slice(-200),
|
|
566
|
+
}, 1);
|
|
567
|
+
}
|
|
568
|
+
const engineVersion = versionOf(probe.out);
|
|
569
|
+
const dbExists = existsSync(path.join(repo, '.homegraph', 'homegraph.db'));
|
|
570
|
+
if (!dbExists && !create) {
|
|
571
|
+
// No write is possible, so do NOT touch `.gitignore` here either.
|
|
572
|
+
return emit({
|
|
573
|
+
ok: false, repo, reason: 'not_initialized', durationMs: Date.now() - started,
|
|
574
|
+
detail: 'no local .homegraph/homegraph.db; pass --create to initialize it',
|
|
575
|
+
}, 1);
|
|
576
|
+
}
|
|
577
|
+
// The tracked-index gate runs before any write, so a refused run never dirties
|
|
578
|
+
// the main tree's `.gitignore`; the ignore rule is only appended once the gate
|
|
579
|
+
// passed and a write is actually possible.
|
|
580
|
+
const tracked = trackedIndexFiles(repo);
|
|
581
|
+
if (!tracked.ok || tracked.files.length > 0) {
|
|
582
|
+
return emit({
|
|
583
|
+
ok: false, repo, reason: 'homegraph_tracked', durationMs: Date.now() - started,
|
|
584
|
+
detail: tracked.files.length
|
|
585
|
+
? `.homegraph/ has tracked files (${tracked.files.slice(0, 5).join(', ')}); untrack them (git rm --cached) and re-run`
|
|
586
|
+
: 'could not verify that .homegraph/ is untracked; refusing to write',
|
|
587
|
+
}, 1);
|
|
588
|
+
}
|
|
589
|
+
if (!ensureIgnored(repo)) {
|
|
590
|
+
return emit({
|
|
591
|
+
ok: false, repo, reason: 'homegraph_tracked', durationMs: Date.now() - started,
|
|
592
|
+
detail: '.gitignore exists but could not be updated with .homegraph/; add it manually and re-run',
|
|
593
|
+
}, 1);
|
|
594
|
+
}
|
|
595
|
+
if (!dbExists) {
|
|
596
|
+
return initThen(repo, sync, rebuild, timeoutMs, initTimeoutMs, statusTimeoutMs, started);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const first = probeStatus(repo, statusTimeoutMs);
|
|
600
|
+
// Only spawn ENOENT proves the engine is missing. A present engine whose status
|
|
601
|
+
// fails (including a generic "No such file or directory") leaves an unreadable
|
|
602
|
+
// snapshot, which the rebuild path can recover - do not report `engine_missing`.
|
|
603
|
+
if (first.missing) {
|
|
604
|
+
return emit({
|
|
605
|
+
ok: false, repo, reason: 'engine_missing', durationMs: Date.now() - started,
|
|
606
|
+
detail: `cannot execute: ${bin.join(' ')}`,
|
|
607
|
+
}, 1);
|
|
608
|
+
}
|
|
609
|
+
if (first.timeout) {
|
|
610
|
+
return emit({
|
|
611
|
+
ok: false, repo, reason: 'status_timeout', degraded: true,
|
|
612
|
+
...statusFields(null), durationMs: Date.now() - started,
|
|
613
|
+
detail: `status exceeded ${statusTimeoutMs} ms; the snapshot is left untouched and unverified`,
|
|
614
|
+
}, 1);
|
|
615
|
+
}
|
|
616
|
+
if (first.unreadable) {
|
|
617
|
+
return rebuildThen(repo, 'index', 'status_unreadable', first, timeoutMs,
|
|
618
|
+
statusTimeoutMs, started, 'homegraph status --json did not return JSON');
|
|
619
|
+
}
|
|
620
|
+
if (first.status?.initialized === false) {
|
|
621
|
+
return rebuildThen(repo, 'index', 'index_incomplete', first, timeoutMs,
|
|
622
|
+
statusTimeoutMs, started, 'a local db exists but the engine does not report it initialized');
|
|
623
|
+
}
|
|
624
|
+
if (!isLocal(first.status, repo)) {
|
|
625
|
+
return emit({
|
|
626
|
+
ok: false, repo, reason: 'index_not_local', degraded: true,
|
|
627
|
+
...statusFields(first.status), durationMs: Date.now() - started,
|
|
628
|
+
detail: `the resolved index is ${first.status?.projectPath ?? 'another tree'}, not this repo`,
|
|
629
|
+
}, 1);
|
|
630
|
+
}
|
|
631
|
+
if (!isUsable(first.status)) {
|
|
632
|
+
return rebuildThen(repo, 'index', 'index_incomplete', first, timeoutMs,
|
|
633
|
+
statusTimeoutMs, started, 'the local index is partial, indexing, or empty');
|
|
634
|
+
}
|
|
635
|
+
if (engineVersion && first.status?.index?.builtWithVersion
|
|
636
|
+
&& versionOf(first.status.index.builtWithVersion) !== engineVersion) {
|
|
637
|
+
return rebuildThen(repo, 'index', 'version_mismatch', first, timeoutMs,
|
|
638
|
+
statusTimeoutMs, started,
|
|
639
|
+
`index built with ${first.status.index.builtWithVersion}, engine is ${engineVersion}`);
|
|
640
|
+
}
|
|
641
|
+
if (!sync) {
|
|
642
|
+
return emit({
|
|
643
|
+
ok: true, repo, action: 'none', ...statusFields(first.status),
|
|
644
|
+
durationMs: Date.now() - started,
|
|
645
|
+
}, 0);
|
|
646
|
+
}
|
|
647
|
+
return syncThen(repo, first, rebuild, timeoutMs, statusTimeoutMs, started);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function initThen(
|
|
651
|
+
repo: string, sync: boolean, rebuild: boolean,
|
|
652
|
+
timeoutMs: number, initTimeoutMs: number, statusTimeoutMs: number, started: number,
|
|
653
|
+
): number {
|
|
654
|
+
const init = runMutation(['init', repo], repo, initTimeoutMs);
|
|
655
|
+
if (init.blockedPid !== null) {
|
|
656
|
+
return emit({
|
|
657
|
+
ok: false, repo, action: 'init', reason: 'lock_busy', degraded: true,
|
|
658
|
+
attempts: init.attempts, reaped: init.reaped, durationMs: Date.now() - started,
|
|
659
|
+
detail: `engine lock is held by live PID ${init.blockedPid} ; a live writer is never killed or unlocked on the main tree`,
|
|
660
|
+
}, 1);
|
|
661
|
+
}
|
|
662
|
+
if (!init.last?.ok) {
|
|
663
|
+
// The engine can report an error AFTER the rows are complete. Re-read the
|
|
664
|
+
// snapshot and accept a complete index instead of rebuilding it next time.
|
|
665
|
+
const after = probeStatus(repo, statusTimeoutMs);
|
|
666
|
+
if (!after.unreadable && !after.timeout && isLocal(after.status, repo) && isUsable(after.status)) {
|
|
667
|
+
return emit({
|
|
668
|
+
ok: true, repo, action: 'init', ...statusFields(after.status),
|
|
669
|
+
attempts: init.attempts, reaped: init.reaped, durationMs: Date.now() - started,
|
|
670
|
+
detail: 'init reported an error but the index is complete',
|
|
671
|
+
}, 0);
|
|
672
|
+
}
|
|
673
|
+
return emit({
|
|
674
|
+
ok: false, repo, action: 'init',
|
|
675
|
+
reason: init.last?.timeout ? 'timeout' : 'init_failed', degraded: true,
|
|
676
|
+
attempts: init.attempts, reaped: init.reaped, durationMs: Date.now() - started,
|
|
677
|
+
detail: clip(plain(init.last?.err || init.last?.out || '')) || null,
|
|
678
|
+
}, 1);
|
|
679
|
+
}
|
|
680
|
+
const built = probeStatus(repo, statusTimeoutMs);
|
|
681
|
+
if (!built.unreadable && !built.timeout && isLocal(built.status, repo) && isUsable(built.status)) {
|
|
682
|
+
if (!sync) {
|
|
683
|
+
return emit({
|
|
684
|
+
ok: true, repo, action: 'init', ...statusFields(built.status),
|
|
685
|
+
attempts: init.attempts, reaped: init.reaped, durationMs: Date.now() - started,
|
|
686
|
+
}, 0);
|
|
687
|
+
}
|
|
688
|
+
return syncThen(repo, built, rebuild, timeoutMs, statusTimeoutMs, started, init.attempts, init.reaped);
|
|
689
|
+
}
|
|
690
|
+
return rebuildThen(repo, 'index', 'index_incomplete', built, timeoutMs,
|
|
691
|
+
statusTimeoutMs, started, 'init finished but the index is not usable', init.attempts, init.reaped);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function syncThen(
|
|
695
|
+
repo: string, before: StatusRead, rebuild: boolean,
|
|
696
|
+
timeoutMs: number, statusTimeoutMs: number, started: number,
|
|
697
|
+
priorAttempts = 0, priorReaped: number | null = null,
|
|
698
|
+
): number {
|
|
699
|
+
// No `--quiet`: the lock error text is what `runMutation`'s retry path keys on.
|
|
700
|
+
const sync = runMutation(['sync', repo], repo, timeoutMs);
|
|
701
|
+
const attempts = priorAttempts + sync.attempts;
|
|
702
|
+
const reaped = sync.reaped ?? priorReaped;
|
|
703
|
+
|
|
704
|
+
if (sync.blockedPid !== null) {
|
|
705
|
+
return emit({
|
|
706
|
+
ok: false, repo, action: 'sync', reason: 'lock_busy', degraded: true,
|
|
707
|
+
attempts, reaped, ...statusFields(before.status), durationMs: Date.now() - started,
|
|
708
|
+
detail: `engine lock is held by live PID ${sync.blockedPid} ; a live writer is never killed or unlocked on the main tree`,
|
|
709
|
+
}, 1);
|
|
710
|
+
}
|
|
711
|
+
if (sync.last?.ok) {
|
|
712
|
+
const after = probeStatus(repo, statusTimeoutMs);
|
|
713
|
+
if (!after.unreadable && !after.timeout && isLocal(after.status, repo) && isUsable(after.status)) {
|
|
714
|
+
return emit({
|
|
715
|
+
ok: true, repo, action: 'sync', ...statusFields(after.status),
|
|
716
|
+
attempts, reaped, durationMs: Date.now() - started,
|
|
717
|
+
}, 0);
|
|
718
|
+
}
|
|
719
|
+
return emit({
|
|
720
|
+
ok: true, repo, action: 'sync', reason: 'sync_incomplete',
|
|
721
|
+
...statusFields(before.status), attempts, reaped, durationMs: Date.now() - started,
|
|
722
|
+
detail: 'sync exited 0 but the post-sync status could not confirm the snapshot',
|
|
723
|
+
}, 0);
|
|
724
|
+
}
|
|
725
|
+
if (sync.last?.timeout) {
|
|
726
|
+
const check = probeStatus(repo, statusTimeoutMs);
|
|
727
|
+
if (!check.unreadable && !check.timeout && isLocal(check.status, repo) && isUsable(check.status)) {
|
|
728
|
+
return emit({
|
|
729
|
+
ok: true, repo, action: 'sync', reason: 'sync_incomplete',
|
|
730
|
+
...statusFields(check.status), attempts, reaped, durationMs: Date.now() - started,
|
|
731
|
+
detail: `sync timed out after ${timeoutMs} ms; the previous index is still usable (refresh incomplete)`,
|
|
732
|
+
}, 0);
|
|
733
|
+
}
|
|
734
|
+
return emit({
|
|
735
|
+
ok: false, repo, action: 'sync', reason: 'timeout', degraded: true,
|
|
736
|
+
...statusFields(before.status), attempts, reaped, durationMs: Date.now() - started,
|
|
737
|
+
detail: `sync timed out after ${timeoutMs} ms and the previous snapshot is not verifiably usable`,
|
|
738
|
+
}, 1);
|
|
739
|
+
}
|
|
740
|
+
// The engine can error AFTER the refresh is complete: trust a usable snapshot
|
|
741
|
+
// instead of paying for a full rebuild (same rule as init/index).
|
|
742
|
+
const afterFail = probeStatus(repo, statusTimeoutMs);
|
|
743
|
+
if (!afterFail.unreadable && !afterFail.timeout
|
|
744
|
+
&& isLocal(afterFail.status, repo) && isUsable(afterFail.status)) {
|
|
745
|
+
return emit({
|
|
746
|
+
ok: true, repo, action: 'sync', reason: 'sync_incomplete',
|
|
747
|
+
...statusFields(afterFail.status), attempts, reaped, durationMs: Date.now() - started,
|
|
748
|
+
detail: 'sync reported an error but the snapshot is usable (refresh incomplete)',
|
|
749
|
+
}, 0);
|
|
750
|
+
}
|
|
751
|
+
if (!rebuild) {
|
|
752
|
+
return emit({
|
|
753
|
+
ok: false, repo, action: 'sync', reason: 'sync_failed', degraded: true,
|
|
754
|
+
...statusFields(before.status), attempts, reaped, durationMs: Date.now() - started,
|
|
755
|
+
detail: clip(plain(sync.last?.err || sync.last?.out || '')) || null,
|
|
756
|
+
}, 1);
|
|
757
|
+
}
|
|
758
|
+
const holder = lockHolderDecision(repo);
|
|
759
|
+
if (holder.kind === 'live') {
|
|
760
|
+
return emit({
|
|
761
|
+
ok: false, repo, action: 'sync', reason: 'lock_busy', degraded: true,
|
|
762
|
+
...statusFields(before.status), attempts, reaped,
|
|
763
|
+
durationMs: Date.now() - started,
|
|
764
|
+
detail: `engine lock is held by live PID ${holder.pid}; never killed or unlocked on the main tree`,
|
|
765
|
+
}, 1);
|
|
766
|
+
}
|
|
767
|
+
if (holder.kind === 'dead' && holder.pid !== null) unlockIfSame(repo, holder.pid);
|
|
768
|
+
return rebuildThen(repo, 'index', 'sync_failed', before, timeoutMs,
|
|
769
|
+
statusTimeoutMs, started, clip(plain(sync.last?.err || sync.last?.out || '')) || null,
|
|
770
|
+
attempts, reaped);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function rebuildThen(
|
|
774
|
+
repo: string, action: 'index', reason: string, before: StatusRead,
|
|
775
|
+
timeoutMs: number, statusTimeoutMs: number, started: number, detail: string | null,
|
|
776
|
+
priorAttempts = 0, priorReaped: number | null = null,
|
|
777
|
+
): number {
|
|
778
|
+
const index = runMutation(['index', '--inplace', repo], repo, timeoutMs);
|
|
779
|
+
const attempts = priorAttempts + index.attempts;
|
|
780
|
+
const reaped = index.reaped ?? priorReaped;
|
|
781
|
+
|
|
782
|
+
if (index.blockedPid !== null) {
|
|
783
|
+
return emit({
|
|
784
|
+
ok: false, repo, action, reason: 'lock_busy', degraded: true,
|
|
785
|
+
attempts, reaped, ...statusFields(before.status), durationMs: Date.now() - started,
|
|
786
|
+
detail: `engine lock is held by live PID ${index.blockedPid} ; a live writer is never killed or unlocked on the main tree`,
|
|
787
|
+
}, 1);
|
|
788
|
+
}
|
|
789
|
+
if (index.last?.ok) {
|
|
790
|
+
const after = probeStatus(repo, statusTimeoutMs);
|
|
791
|
+
if (!after.unreadable && !after.timeout && isLocal(after.status, repo) && isUsable(after.status)) {
|
|
792
|
+
return emit({
|
|
793
|
+
ok: true, repo, action, ...statusFields(after.status),
|
|
794
|
+
reason: reason === 'sync_failed' ? 'sync_failed' : null,
|
|
795
|
+
attempts, reaped, durationMs: Date.now() - started,
|
|
796
|
+
detail: reason === 'sync_failed' ? `rebuilt after sync failure: ${detail ?? ''}`.trim() : null,
|
|
797
|
+
}, 0);
|
|
798
|
+
}
|
|
799
|
+
return emit({
|
|
800
|
+
ok: false, repo, action, reason: 'index_incomplete', degraded: true,
|
|
801
|
+
...statusFields(after.status), attempts, reaped, durationMs: Date.now() - started,
|
|
802
|
+
detail: detail ?? 'index exited 0 but the snapshot is not usable',
|
|
803
|
+
}, 1);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// Same rule as `init`: an error exit can still leave a complete index behind.
|
|
807
|
+
const afterFail = probeStatus(repo, statusTimeoutMs);
|
|
808
|
+
if (!afterFail.unreadable && !afterFail.timeout
|
|
809
|
+
&& isLocal(afterFail.status, repo) && isUsable(afterFail.status)) {
|
|
810
|
+
return emit({
|
|
811
|
+
ok: true, repo, action, ...statusFields(afterFail.status),
|
|
812
|
+
reason: reason === 'sync_failed' ? 'sync_failed' : null,
|
|
813
|
+
attempts, reaped, durationMs: Date.now() - started,
|
|
814
|
+
detail: 'index reported an error but the index is complete',
|
|
815
|
+
}, 0);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// Quarantine on any non-timeout failure: a timeout proves nothing about the db
|
|
819
|
+
// (the build may still be writing), while a plain error with a db present is
|
|
820
|
+
// exactly the "corrupt or unusable" case the rename-and-init fallback exists for.
|
|
821
|
+
if (!index.last?.timeout) {
|
|
822
|
+
const holder = lockHolderDecision(repo);
|
|
823
|
+
if (holder.kind === 'live') {
|
|
824
|
+
return emit({
|
|
825
|
+
ok: false, repo, action, reason: 'lock_busy', degraded: true,
|
|
826
|
+
...statusFields(before.status), attempts, reaped, durationMs: Date.now() - started,
|
|
827
|
+
detail: `engine lock is held by live PID ${holder.pid}; refusing to quarantine or rebuild`,
|
|
828
|
+
}, 1);
|
|
829
|
+
}
|
|
830
|
+
if (holder.kind === 'dead' && holder.pid !== null) unlockIfSame(repo, holder.pid);
|
|
831
|
+
const moved = quarantineDb(repo);
|
|
832
|
+
if (moved !== null) {
|
|
833
|
+
const fresh = run(['init', repo], INIT_TIMEOUT_MS);
|
|
834
|
+
if (fresh.ok) {
|
|
835
|
+
const after = probeStatus(repo, statusTimeoutMs);
|
|
836
|
+
if (!after.unreadable && !after.timeout && isLocal(after.status, repo) && isUsable(after.status)) {
|
|
837
|
+
return emit({
|
|
838
|
+
ok: true, repo, action: 'init', ...statusFields(after.status),
|
|
839
|
+
reason: reason === 'sync_failed' ? 'sync_failed' : 'index_failed',
|
|
840
|
+
attempts: attempts + 1, reaped, durationMs: Date.now() - started,
|
|
841
|
+
detail: `quarantined corrupt index as ${moved}`,
|
|
842
|
+
}, 0);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
return emit({
|
|
849
|
+
ok: false, repo, action,
|
|
850
|
+
reason: reason === 'sync_failed' ? 'sync_failed' : 'index_failed', degraded: true,
|
|
851
|
+
...statusFields(before.status), attempts, reaped, durationMs: Date.now() - started,
|
|
852
|
+
detail: clip(detail || plain(index.last?.err || index.last?.out || '')) || null,
|
|
853
|
+
}, 1);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function cli(): number {
|
|
857
|
+
try { return main(process.argv.slice(2)); }
|
|
858
|
+
catch (e) {
|
|
859
|
+
return emit({
|
|
860
|
+
ok: false, action: 'skip', reason: 'internal_error',
|
|
861
|
+
detail: String((e as Error)?.message ?? e).slice(-300),
|
|
862
|
+
}, 1);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
process.exitCode = cli();
|