@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
|
@@ -1,948 +0,0 @@
|
|
|
1
|
-
// Worktree-local HomeGraph index for a2h-spec-design-pipeline (W0 + deps release).
|
|
2
|
-
//
|
|
3
|
-
// node ensure_wt_index.ts <hmos> <worktree> [--sync] [--timeout-ms <n>] [--status-timeout-ms <n>]
|
|
4
|
-
//
|
|
5
|
-
// Why this exists
|
|
6
|
-
// ---------------
|
|
7
|
-
// `git worktree add` materializes tracked files only. `.homegraph/` is
|
|
8
|
-
// gitignored (I3 - `git_baseline.ts`), so a fresh worktree has NO index, and
|
|
9
|
-
// HomeGraph's nearest-ancestor lookup cannot see the main checkout either: the
|
|
10
|
-
// pipeline's worktrees are siblings of <hmos> (<hmos>/../wt/<basename>/g<G>).
|
|
11
|
-
// A coder in the worktree therefore has no graph at all. Pointing it at <hmos>
|
|
12
|
-
// instead is NOT a substitute - results come from whatever branch main holds
|
|
13
|
-
// (other groups' merged code, none of this worktree's commits), and the CLI
|
|
14
|
-
// `explore`/`query`/`node` commands print NO mismatch warning (only `status`
|
|
15
|
-
// and the MCP tools surface it), so the wrong-tree answer arrives looking
|
|
16
|
-
// authoritative.
|
|
17
|
-
//
|
|
18
|
-
// This script builds each worktree its own index, synchronously, at the moment
|
|
19
|
-
// its worktree is created - W0 step 3 for `ready` members, the deps release
|
|
20
|
-
// sweep for `held` ones - and never writes <hmos>'s index (B4 owns that one).
|
|
21
|
-
//
|
|
22
|
-
// no local db, or a resolved index belonging to another tree -> init
|
|
23
|
-
// local index that is not usable (empty, corrupt, killed) -> index
|
|
24
|
-
// usable local index, no --sync -> none
|
|
25
|
-
// usable local index + --sync -> sync
|
|
26
|
-
// probe timed out on a local db, no --sync -> index
|
|
27
|
-
// probe timed out on a local db, --sync -> skip (timeout)
|
|
28
|
-
//
|
|
29
|
-
// The probe (`homegraph status --json`) is a READ command and the engine
|
|
30
|
-
// resolves it UPWARD: when the path holds no `.homegraph/homegraph.db`, it
|
|
31
|
-
// returns the nearest initialized ANCESTOR and computes that ancestor's
|
|
32
|
-
// `pendingChanges`, i.e. walks the ancestor's whole project root. On a real
|
|
33
|
-
// project an unrelated `<user>/Desktop/.homegraph` turned every fresh
|
|
34
|
-
// worktree's probe into a ~62k-file scan that blew the 120 s status budget and
|
|
35
|
-
// made the worktree degrade for no reason. `init`/`index`/`sync` are literal
|
|
36
|
-
// (the engine's resolveCliMutatingProjectRoot never looks up), so when there is
|
|
37
|
-
// no local db there is nothing to interrogate: the probe is skipped and `init`
|
|
38
|
-
// runs directly. That also removes the "unreadable status belongs to an
|
|
39
|
-
// ancestor, do not touch anything" dead end - a build is local and safe.
|
|
40
|
-
// The probe budget is `--status-timeout-ms` (default 120 s): it reads the whole
|
|
41
|
-
// index and its pendingChanges, so a large project may legitimately need more.
|
|
42
|
-
//
|
|
43
|
-
// "Usable" = local (projectPath is this worktree, no worktree mismatch) AND
|
|
44
|
-
// lastIndexed is set AND fileCount > 0 AND the engine marked the last build
|
|
45
|
-
// finished (`index.state` complete/partial). `index.state: "indexing"` is the
|
|
46
|
-
// engine's own "a run was killed mid-index" marker, so a timed-out build that
|
|
47
|
-
// wrote every row but never finalized must NOT be advertised - the next run
|
|
48
|
-
// rebuilds it with `index`. `homegraph init` does nothing when the directory
|
|
49
|
-
// already holds an index db, so a killed/corrupt leftover must be rebuilt with
|
|
50
|
-
// `homegraph index` (a `.homegraph/` that holds no db - e.g. only a tracked
|
|
51
|
-
// `.homegraph/.gitignore` - is still built by `init`). A corrupt db also makes
|
|
52
|
-
// `status --json` itself fail ("no such table: ..."), which is why an unreadable
|
|
53
|
-
// status with a local `.homegraph/` is treated as that same rebuild.
|
|
54
|
-
//
|
|
55
|
-
// `--sync` always syncs (no "pendingChanges" gate): `pendingChanges` only
|
|
56
|
-
// counts UNCOMMITTED working-tree edits, while this pipeline's worktree changes
|
|
57
|
-
// are commits and branch resets - the gate would make hop (b)'s refresh a no-op.
|
|
58
|
-
//
|
|
59
|
-
// init/index/sync retry up to twice on "database is locked". The engine keeps
|
|
60
|
-
// its own PID in `<worktree>/.homegraph/homegraph.lock`; a LIVE holder is
|
|
61
|
-
// killed before the retry, never `unlock`ed - the engine treats a lock older
|
|
62
|
-
// than 2 minutes as stale regardless of PID, so deleting a running writer's
|
|
63
|
-
// lock lets two engines write the same db. Only a lock whose PID is dead is
|
|
64
|
-
// cleared with `homegraph unlock`; a live holder we cannot POSITIVELY identify
|
|
65
|
-
// (fresh lock, homegraph + this worktree on its command line, not this process
|
|
66
|
-
// or one of its ancestors) is left alone and the run degrades with
|
|
67
|
-
// `lock_busy` - guessing there could kill the orchestrator's own session.
|
|
68
|
-
// After EVERY failed attempt the index is re-read first (synthesised as
|
|
69
|
-
// `initialized:false` when the attempt left no db - the engine is never asked
|
|
70
|
-
// without a local db): the store-worker error is often raised after the data is
|
|
71
|
-
// complete, so a complete index ends the retries immediately instead of paying
|
|
72
|
-
// for a second full build. A snapshot whose read TIMED OUT is never removed: a
|
|
73
|
-
// slow read proves nothing about the data (the fallback rebuild above may cost
|
|
74
|
-
// one --timeout-ms attempt), so the run reports `timeout` and leaves it.
|
|
75
|
-
// Reproduced on real-project inits on a busy machine, for both space and
|
|
76
|
-
// non-space paths; the exact cause is not established.
|
|
77
|
-
//
|
|
78
|
-
// Fail-soft by construction: exit 1 means "no usable local index", which the
|
|
79
|
-
// orchestrator records in the wave log and continues - the coder falls back to
|
|
80
|
-
// grep/read.
|
|
81
|
-
//
|
|
82
|
-
// Cleanup rules (learned the hard way):
|
|
83
|
-
// - NEVER call `homegraph uninit` here. When the worktree has no `.homegraph/`
|
|
84
|
-
// of its own, `uninit <worktree>` walks UP and deletes the nearest ancestor
|
|
85
|
-
// index (a parent workspace index is a supported HomeGraph layout), which
|
|
86
|
-
// would silently destroy a user's index from a worktree-scoped failure.
|
|
87
|
-
// - Only `<worktree>/.homegraph` is ever removed, directly, only after a build
|
|
88
|
-
// of our own that did not leave a usable index, and only when it is a real
|
|
89
|
-
// directory (never a link, never a plain file) that holds no tracked files
|
|
90
|
-
// (`.homegraph/.gitignore` is legitimately tracked in some repos).
|
|
91
|
-
// - A timed-out build is NOT deleted: the engine may still be writing. On
|
|
92
|
-
// Windows spawnSync kills only its direct child (the cmd.exe shim), not the
|
|
93
|
-
// shim's node child, so the writer recorded in `.homegraph/homegraph.lock`
|
|
94
|
-
// is reaped with `taskkill /T` (the PID must have appeared during THIS call,
|
|
95
|
-
// its lock must be < 2 minutes old, and its command line must name
|
|
96
|
-
// `homegraph` and THIS worktree - a recycled PID belongs to something else).
|
|
97
|
-
// The leftover index stays on disk but is no longer usable
|
|
98
|
-
// (`index.state: "indexing"`), so the next run's `index` rebuilds it. A
|
|
99
|
-
// timed-out first build or rebuild is therefore ALWAYS a failure (exit 1);
|
|
100
|
-
// only a timed-out `--sync` may succeed, and only because the previous,
|
|
101
|
-
// already-usable snapshot is intact (`reason:"sync_incomplete"`).
|
|
102
|
-
// - An engine that exits non-zero but still leaves a usable index is a
|
|
103
|
-
// SUCCESS: the store-worker error is observed after the data is complete.
|
|
104
|
-
//
|
|
105
|
-
// Gates (all cheap, all protect the campaign):
|
|
106
|
-
// - <worktree> must be a LINKED git worktree (git dir != common dir) - the
|
|
107
|
-
// main checkout is refused even when both arguments are not identical.
|
|
108
|
-
// - <worktree> must not be <hmos>.
|
|
109
|
-
// - `.homegraph/` must be a real directory in the worktree (a symlink or
|
|
110
|
-
// junction - including a DANGLING one, which `existsSync` reports as absent,
|
|
111
|
-
// so `lstat` is the test - is refused: the engine echoes the CLI path back
|
|
112
|
-
// as projectPath, so a link would silently present another tree's index as
|
|
113
|
-
// this worktree's and would be written through).
|
|
114
|
-
// - `.homegraph/` must be ignored in the worktree. An unignored index would
|
|
115
|
-
// dirty the tree and leak into coder commits (I3 commits the rule; a
|
|
116
|
-
// hand-edited .gitignore is the risk this catches; `homegraph_not_ignored`
|
|
117
|
-
// means "fix <HMOS>/.gitignore and re-run", the index stays unavailable).
|
|
118
|
-
// - nothing but HomeGraph's own `.homegraph/.gitignore` may be tracked there
|
|
119
|
-
// (a committed db would churn).
|
|
120
|
-
//
|
|
121
|
-
// Output: one JSON line on stdout for every non-usage outcome (success or
|
|
122
|
-
// degraded); usage errors go to stderr only.
|
|
123
|
-
// { "ok": true, "action": "init", "ms": 8314, "attempts": 1,
|
|
124
|
-
// "worktree": "...", "projectPath": "...", "fileCount": 217,
|
|
125
|
-
// "reason": null, "detail": null }
|
|
126
|
-
// { "ok": false, "action": "init", "reason": "timeout", "reaped": 4242,
|
|
127
|
-
// "detail": "...", ... } // reaped = engine PID killed, or null
|
|
128
|
-
// { "ok": false, "action": "skip", "reason": "engine_missing", "detail": "..." }
|
|
129
|
-
// Reasons: worktree_missing | not_a_worktree | not_a_linked_worktree |
|
|
130
|
-
// same_as_main | homegraph_not_ignored | homegraph_tracked |
|
|
131
|
-
// homegraph_linked | engine_missing | status_unreadable | timeout |
|
|
132
|
-
// lock_busy | init_failed | index_failed | sync_failed |
|
|
133
|
-
// index_incomplete | index_not_local | internal_error
|
|
134
|
-
// `reason: "sync_incomplete"` accompanies a SUCCESSFUL exit 0 whose refresh
|
|
135
|
-
// failed while the previous index is still usable (the snapshot is stale).
|
|
136
|
-
// Exit codes: 0 usable index (init / index / sync / none); 1 degraded (record
|
|
137
|
-
// and continue); 2 usage error.
|
|
138
|
-
// HOMEGRAPH_BIN overrides the engine command line (tests use a stub); it is
|
|
139
|
-
// split on whitespace with double-quote grouping.
|
|
140
|
-
// Zero dependencies - Node >= 22.18 (type stripping).
|
|
141
|
-
import { spawnSync } from 'node:child_process';
|
|
142
|
-
import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, rmSync, statSync } from 'node:fs';
|
|
143
|
-
import * as path from 'node:path';
|
|
144
|
-
|
|
145
|
-
const USAGE = 'usage: node ensure_wt_index.ts <hmos> <worktree> [--sync] [--timeout-ms <n>] [--status-timeout-ms <n>]';
|
|
146
|
-
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
147
|
-
const MAX_TIMEOUT_MS = 3_600_000;
|
|
148
|
-
// Bounds the status probe only (the build uses --timeout-ms). The probe reads
|
|
149
|
-
// the whole index and its pendingChanges, so a large project can legitimately
|
|
150
|
-
// need more than the default; --status-timeout-ms raises it.
|
|
151
|
-
const DEFAULT_STATUS_TIMEOUT_MS = 120_000;
|
|
152
|
-
const PROBE_TIMEOUT_MS = 30_000;
|
|
153
|
-
const MAX_ATTEMPTS = 3;
|
|
154
|
-
const LOCKED = /database is locked/i;
|
|
155
|
-
// cmd.exe's own wording when the shim is not on PATH (the direct-spawn case is
|
|
156
|
-
// RunResult.missing). Escapes keep this file pure ASCII.
|
|
157
|
-
const NOT_FOUND = /is not recognized|command not found|No such file or directory|\u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4/i;
|
|
158
|
-
|
|
159
|
-
type Status = {
|
|
160
|
-
initialized?: boolean;
|
|
161
|
-
projectPath?: string;
|
|
162
|
-
indexPath?: string;
|
|
163
|
-
fileCount?: number;
|
|
164
|
-
lastIndexed?: string | null;
|
|
165
|
-
pendingChanges?: { added?: number; modified?: number; removed?: number };
|
|
166
|
-
worktreeMismatch?: unknown;
|
|
167
|
-
index?: { state?: string | null; builtWithVersion?: string | null; reindexRecommended?: boolean };
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
type RunResult = {
|
|
171
|
-
ok: boolean;
|
|
172
|
-
out: string;
|
|
173
|
-
err: string;
|
|
174
|
-
code: number | null;
|
|
175
|
-
timeout: boolean;
|
|
176
|
-
missing: boolean;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
function realp(p: string): string {
|
|
180
|
-
try {
|
|
181
|
-
return realpathSync(path.resolve(p));
|
|
182
|
-
} catch {
|
|
183
|
-
return path.resolve(p);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/** Split a command line with double-quote grouping (`node "C:\a b\stub.mjs"`). */
|
|
188
|
-
function splitCommand(cmd: string): string[] {
|
|
189
|
-
const out: string[] = [];
|
|
190
|
-
const re = /"([^"]*)"|(\S+)/g;
|
|
191
|
-
let m: RegExpExecArray | null;
|
|
192
|
-
while ((m = re.exec(cmd)) !== null) out.push(m[1] ?? m[2]!);
|
|
193
|
-
return out;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function engine(): string[] {
|
|
197
|
-
const raw = (process.env.HOMEGRAPH_BIN ?? '').trim();
|
|
198
|
-
if (!raw) return ['homegraph'];
|
|
199
|
-
// A bare path that exists is one token even when it contains spaces; the
|
|
200
|
-
// quote-grouped form stays available for real command lines.
|
|
201
|
-
if (!raw.includes('"') && existsSync(raw)) return [raw];
|
|
202
|
-
return splitCommand(raw);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Windows cannot exec an npm `.cmd` shim directly (and `homegraph` on PATH is
|
|
207
|
-
* exactly that). `.exe` runs directly; a `.js`/`.mjs` target runs through this
|
|
208
|
-
* node binary; anything else (bare name, `.cmd`, `.bat`) goes through cmd.exe
|
|
209
|
-
* with every token quoted, so worktree paths with spaces survive.
|
|
210
|
-
*/
|
|
211
|
-
function commandFor(extra: string[]): { file: string; args: string[]; verbatim: boolean } {
|
|
212
|
-
const bin = engine();
|
|
213
|
-
const [head, ...rest] = bin;
|
|
214
|
-
const toks = [...rest, ...extra];
|
|
215
|
-
if (process.platform !== 'win32') return { file: head!, args: toks, verbatim: false };
|
|
216
|
-
const lower = head!.toLowerCase();
|
|
217
|
-
if (lower.endsWith('.exe')) return { file: head!, args: toks, verbatim: false };
|
|
218
|
-
if (/\.[cm]?js$/.test(lower)) return { file: process.execPath, args: [head!, ...toks], verbatim: false };
|
|
219
|
-
// cmd.exe /s strips the first and last quote of the whole command string, so
|
|
220
|
-
// the canonical shape is: /c ""prog" "arg1" "arg2"".
|
|
221
|
-
const quoted = `"${[head!, ...toks].map((tok) => `"${tok.replace(/"/g, '""')}"`).join(' ')}"`;
|
|
222
|
-
return { file: process.env.ComSpec || 'cmd.exe', args: ['/d', '/s', '/c', quoted], verbatim: true };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function run(args: string[], timeout: number): RunResult {
|
|
226
|
-
const cmd = commandFor(args);
|
|
227
|
-
const r = spawnSync(cmd.file, cmd.args, {
|
|
228
|
-
encoding: 'utf8', timeout, killSignal: 'SIGKILL', windowsHide: true,
|
|
229
|
-
windowsVerbatimArguments: cmd.verbatim,
|
|
230
|
-
});
|
|
231
|
-
const err = String(r.stderr ?? '').trim() || String(r.error?.message ?? '');
|
|
232
|
-
const code = typeof r.status === 'number' ? r.status : null;
|
|
233
|
-
const timedOut = r.error?.code === 'ETIMEDOUT' || r.signal === 'SIGKILL';
|
|
234
|
-
return {
|
|
235
|
-
ok: code === 0,
|
|
236
|
-
out: String(r.stdout ?? '').trim(),
|
|
237
|
-
err,
|
|
238
|
-
code,
|
|
239
|
-
timeout: timedOut,
|
|
240
|
-
missing: Boolean(r.error) && (r.error as NodeJS.ErrnoException).code === 'ENOENT',
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function git(args: string[], cwd: string) {
|
|
245
|
-
const r = spawnSync('git', ['-C', cwd, '-c', 'core.quotepath=false', ...args],
|
|
246
|
-
{ encoding: 'utf8', timeout: 120_000, windowsHide: true });
|
|
247
|
-
return { ok: r.status === 0, out: String(r.stdout ?? '').trim(), err: String(r.stderr ?? '').trim() };
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/** Engine output is full of ANSI color codes; never carry them into a wave log. */
|
|
251
|
-
function plain(text: string): string {
|
|
252
|
-
return text.replace(/\u001b\[[0-9;]*m/g, '').trim();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Keep both ends of a long engine message. The tail alone is often progress
|
|
257
|
-
* noise ("releaseScene: disposing ..."), which makes a recorded `detail`
|
|
258
|
-
* undiagnosable.
|
|
259
|
-
*/
|
|
260
|
-
function clip(text: string, max = 400): string {
|
|
261
|
-
if (text.length <= max) return text;
|
|
262
|
-
const half = Math.floor((max - 5) / 2);
|
|
263
|
-
return `${text.slice(0, half)} ... ${text.slice(-half)}`;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Brace-balanced object spans, in order of appearance. Needed when the real
|
|
268
|
-
* status is pretty-printed and followed by another object (e.g. an `{"error"}`
|
|
269
|
-
* line): the whole text is not JSON and a single outermost span swallows both.
|
|
270
|
-
* One forward pass with a stack - linear in the output size, so a pathological
|
|
271
|
-
* payload cannot stall W0.
|
|
272
|
-
*/
|
|
273
|
-
function* braceSpans(text: string): Generator<string> {
|
|
274
|
-
const spans: Array<{ start: number; value: string }> = [];
|
|
275
|
-
const open: number[] = [];
|
|
276
|
-
let inString = false;
|
|
277
|
-
let escaped = false;
|
|
278
|
-
for (let i = 0; i < text.length; i += 1) {
|
|
279
|
-
const ch = text[i]!;
|
|
280
|
-
if (inString) {
|
|
281
|
-
if (escaped) escaped = false;
|
|
282
|
-
else if (ch === '\\') escaped = true;
|
|
283
|
-
else if (ch === '"') inString = false;
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
if (ch === '"') inString = true;
|
|
287
|
-
else if (ch === '{') open.push(i);
|
|
288
|
-
else if (ch === '}') {
|
|
289
|
-
const start = open.pop();
|
|
290
|
-
if (start !== undefined) spans.push({ start, value: text.slice(start, i + 1) });
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
spans.sort((a, b) => a.start - b.start);
|
|
294
|
-
for (const span of spans) yield span.value;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Parse `homegraph status --json` output. Tolerates a BOM, progress/warning
|
|
299
|
-
* lines, and pretty-printed JSON: whole text, then balanced object spans in
|
|
300
|
-
* order, then lines bottom-up. Only a real status object is accepted - a
|
|
301
|
-
* trailing `{"error":...}` object must never be mistaken for one (acting on it
|
|
302
|
-
* would rebuild and then delete a perfectly good index), and the FIRST valid
|
|
303
|
-
* object wins so a repeated status cannot flip the decision.
|
|
304
|
-
*/
|
|
305
|
-
function parseStatusText(text: string): Status | null {
|
|
306
|
-
const clean = text.replace(/^\uFEFF/, '');
|
|
307
|
-
const candidates: string[] = [clean.trim()];
|
|
308
|
-
for (const span of braceSpans(clean)) candidates.push(span);
|
|
309
|
-
const lines = clean.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
310
|
-
for (let i = lines.length - 1; i >= 0; i -= 1) candidates.push(lines[i]!);
|
|
311
|
-
for (const candidate of candidates) {
|
|
312
|
-
if (!candidate) continue;
|
|
313
|
-
try {
|
|
314
|
-
const parsed: unknown = JSON.parse(candidate);
|
|
315
|
-
if (parsed && typeof parsed === 'object'
|
|
316
|
-
&& typeof (parsed as Status).initialized === 'boolean'
|
|
317
|
-
&& 'projectPath' in (parsed as Record<string, unknown>)) {
|
|
318
|
-
return parsed as Status;
|
|
319
|
-
}
|
|
320
|
-
} catch {
|
|
321
|
-
// try the next candidate
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
type StatusRead = {
|
|
328
|
-
status: Status | null;
|
|
329
|
-
missing: boolean;
|
|
330
|
-
timeout: boolean;
|
|
331
|
-
unreadable: boolean;
|
|
332
|
-
err: string;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
function readStatus(worktree: string, statusTimeoutMs: number): StatusRead {
|
|
336
|
-
const r = run(['status', '--json', worktree], statusTimeoutMs);
|
|
337
|
-
if (r.missing) return { status: null, missing: true, timeout: false, unreadable: false, err: r.err };
|
|
338
|
-
if (r.timeout) return { status: null, missing: false, timeout: true, unreadable: false, err: r.err };
|
|
339
|
-
const parsed = parseStatusText(r.out);
|
|
340
|
-
if (!parsed) {
|
|
341
|
-
return {
|
|
342
|
-
status: null, missing: false, timeout: false, unreadable: true,
|
|
343
|
-
err: plain(r.err || r.out).slice(-300),
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
return { status: parsed, missing: false, timeout: false, unreadable: false, err: '' };
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* `status` with the ancestor trap removed. Without a local `homegraph.db` the
|
|
351
|
-
* engine resolves the READ command upward to the nearest initialized ancestor
|
|
352
|
-
* and scans that ancestor's whole project root, so the call can cost minutes and
|
|
353
|
-
* says nothing about this worktree. There is also nothing to learn: no local db
|
|
354
|
-
* means no local index, which is exactly what `init` is for. Every status read
|
|
355
|
-
* in this file goes through here - including the post-failure and post-build
|
|
356
|
-
* checks, which can run while a failed build left no db behind.
|
|
357
|
-
*/
|
|
358
|
-
function probeStatus(worktree: string, statusTimeoutMs: number): StatusRead {
|
|
359
|
-
if (!existsSync(path.join(worktree, '.homegraph', 'homegraph.db'))) {
|
|
360
|
-
// Shaped like a readable engine answer so the callers' "initialized:false"
|
|
361
|
-
// branches (init / index_incomplete) keep working without a spawn.
|
|
362
|
-
return { status: { initialized: false }, missing: false, timeout: false, unreadable: false, err: '' };
|
|
363
|
-
}
|
|
364
|
-
return readStatus(worktree, statusTimeoutMs);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/** True when the resolved index lives in this very worktree. */
|
|
368
|
-
function isLocal(status: Status | null, worktree: string): boolean {
|
|
369
|
-
if (!status?.initialized) return false;
|
|
370
|
-
if (status.worktreeMismatch) return false;
|
|
371
|
-
if (!status.projectPath) return false;
|
|
372
|
-
if (realp(status.projectPath) !== realp(worktree)) return false;
|
|
373
|
-
if (status.indexPath) {
|
|
374
|
-
return realp(status.indexPath) === realp(path.join(worktree, '.homegraph'));
|
|
375
|
-
}
|
|
376
|
-
return true;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* A killed build leaves `initialized:true` with content that never finalized,
|
|
381
|
-
* and `init` will not rebuild it - so a timed-out build that wrote every row
|
|
382
|
-
* would otherwise be advertised as usable. The engine persists `index_state`
|
|
383
|
-
* when a full build starts and clears it only on success, so `"indexing"` means
|
|
384
|
-
* "a run was killed mid-index", and `"failed"` means it reported failure;
|
|
385
|
-
* neither can be trusted. `"partial"` finished but dropped files: the rows it
|
|
386
|
-
* has are coherent, so it stays usable (a rebuild would drop the same files
|
|
387
|
-
* again at full cost). A missing/null state is a pre-marker engine or index:
|
|
388
|
-
* fall back to the content check rather than forcing a rebuild every run.
|
|
389
|
-
*/
|
|
390
|
-
function isUsable(status: Status | null): boolean {
|
|
391
|
-
if (!status?.lastIndexed) return false;
|
|
392
|
-
if (Number(status.fileCount ?? 0) <= 0) return false;
|
|
393
|
-
const state = status.index?.state ?? null;
|
|
394
|
-
if (state === null) return true;
|
|
395
|
-
return state === 'complete' || state === 'partial';
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/** The engine records its own PID here before it starts writing (FileLock). */
|
|
399
|
-
function lockPath(worktree: string): string {
|
|
400
|
-
return path.join(worktree, '.homegraph', 'homegraph.lock');
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/** The engine's own FileLock.STALE_TIMEOUT_MS: older locks are never trusted. */
|
|
404
|
-
const LOCK_FRESH_MS = 120_000;
|
|
405
|
-
|
|
406
|
-
type LockInfo = { pid: number; ageMs: number; fresh: boolean };
|
|
407
|
-
|
|
408
|
-
function readLock(worktree: string): LockInfo | null {
|
|
409
|
-
const file = lockPath(worktree);
|
|
410
|
-
try {
|
|
411
|
-
const pid = Number.parseInt(readFileSync(file, 'utf8').trim(), 10);
|
|
412
|
-
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
413
|
-
const ageMs = Date.now() - statSync(file).mtimeMs;
|
|
414
|
-
return { pid, ageMs, fresh: ageMs >= 0 && ageMs < LOCK_FRESH_MS };
|
|
415
|
-
} catch {
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function readLockPid(worktree: string): number | null {
|
|
421
|
-
const lock = readLock(worktree);
|
|
422
|
-
return lock === null || lock.pid === process.pid ? null : lock.pid;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function pidAlive(pid: number): boolean {
|
|
426
|
-
if (pid === process.pid) return false;
|
|
427
|
-
try {
|
|
428
|
-
process.kill(pid, 0);
|
|
429
|
-
return true;
|
|
430
|
-
} catch {
|
|
431
|
-
return false;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/** Full command line of a PID, or null when it cannot be read. */
|
|
436
|
-
function processCommandLine(pid: number): string | null {
|
|
437
|
-
try {
|
|
438
|
-
if (process.platform === 'win32') {
|
|
439
|
-
const r = spawnSync('powershell', [
|
|
440
|
-
'-NoLogo', '-NoProfile', '-NonInteractive', '-Command',
|
|
441
|
-
`(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine`,
|
|
442
|
-
], { encoding: 'utf8', timeout: 20_000, windowsHide: true });
|
|
443
|
-
return r.status === 0 ? (String(r.stdout ?? '').trim() || null) : null;
|
|
444
|
-
}
|
|
445
|
-
if (process.platform === 'linux') {
|
|
446
|
-
return readFileSync(`/proc/${pid}/cmdline`, 'utf8').split('\0').join(' ').trim() || null;
|
|
447
|
-
}
|
|
448
|
-
const r = spawnSync('ps', ['-o', 'command=', '-p', String(pid)],
|
|
449
|
-
{ encoding: 'utf8', timeout: 20_000 });
|
|
450
|
-
return r.status === 0 ? (String(r.stdout ?? '').trim() || null) : null;
|
|
451
|
-
} catch {
|
|
452
|
-
return null;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/** Ancestors of this process: they must never be killed, whatever a lock says. */
|
|
457
|
-
let ancestorCache: Set<number> | null = null;
|
|
458
|
-
|
|
459
|
-
function ancestors(): Set<number> {
|
|
460
|
-
if (ancestorCache !== null) return ancestorCache;
|
|
461
|
-
const out = new Set<number>();
|
|
462
|
-
try {
|
|
463
|
-
if (process.platform === 'win32') {
|
|
464
|
-
const script = [
|
|
465
|
-
'$all = @{}',
|
|
466
|
-
'Get-CimInstance Win32_Process | ForEach-Object { $all[[int]$_.ProcessId] = [int]$_.ParentProcessId }',
|
|
467
|
-
`$x = ${process.pid}`,
|
|
468
|
-
'while ($all.ContainsKey($x)) { $x = $all[$x]; if ($x -gt 0) { $x } }',
|
|
469
|
-
].join('; ');
|
|
470
|
-
const r = spawnSync('powershell', ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', script],
|
|
471
|
-
{ encoding: 'utf8', timeout: 20_000, windowsHide: true });
|
|
472
|
-
for (const line of String(r.stdout ?? '').split(/\r?\n/)) {
|
|
473
|
-
const n = Number(line.trim());
|
|
474
|
-
if (Number.isFinite(n) && n > 0) out.add(n);
|
|
475
|
-
}
|
|
476
|
-
} else {
|
|
477
|
-
let pid = process.ppid;
|
|
478
|
-
for (let i = 0; i < 16 && pid > 1; i += 1) {
|
|
479
|
-
out.add(pid);
|
|
480
|
-
const r = spawnSync('ps', ['-o', 'ppid=', '-p', String(pid)],
|
|
481
|
-
{ encoding: 'utf8', timeout: 10_000 });
|
|
482
|
-
const n = Number(String(r.stdout ?? '').trim());
|
|
483
|
-
if (!Number.isFinite(n) || n <= 1) break;
|
|
484
|
-
pid = n;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
} catch {
|
|
488
|
-
// An unreadable process table means "cannot prove ownership" - callers
|
|
489
|
-
// then refuse to kill, which is the safe direction.
|
|
490
|
-
}
|
|
491
|
-
ancestorCache = out;
|
|
492
|
-
return out;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Positive identification of a lock owner. A PID read from a lock file proves
|
|
497
|
-
* nothing on its own: the writer may have exited and the OS may have recycled
|
|
498
|
-
* the number for any unrelated node process (including the agent session that
|
|
499
|
-
* spawned us). Kill only a LIVE process that is not us and not an ancestor and
|
|
500
|
-
* whose command line names homegraph AND this worktree.
|
|
501
|
-
*/
|
|
502
|
-
function isEngineFor(pid: number, worktree: string): boolean {
|
|
503
|
-
if (pid === process.pid || !pidAlive(pid) || ancestors().has(pid)) return false;
|
|
504
|
-
const cmd = processCommandLine(pid);
|
|
505
|
-
if (cmd === null) return false;
|
|
506
|
-
const haystack = cmd.replace(/\\/g, '/').toLowerCase();
|
|
507
|
-
const needle = worktree.replace(/\\/g, '/').toLowerCase();
|
|
508
|
-
return haystack.includes('homegraph') && haystack.includes(needle);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Kill a PID and its descendants. Windows is the case that matters: the engine
|
|
513
|
-
* runs as cmd.exe -> node shim -> node worker, and spawnSync's timeout kills
|
|
514
|
-
* only the cmd.exe it spawned, so the worker survives at ~1 CPU core and keeps
|
|
515
|
-
* the db/shm open. `taskkill /T` walks the tree.
|
|
516
|
-
*/
|
|
517
|
-
function killTree(pid: number, worktree: string): boolean {
|
|
518
|
-
if (!isEngineFor(pid, worktree)) return false;
|
|
519
|
-
try {
|
|
520
|
-
if (process.platform === 'win32') {
|
|
521
|
-
spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'],
|
|
522
|
-
{ encoding: 'utf8', timeout: 30_000, windowsHide: true });
|
|
523
|
-
} else {
|
|
524
|
-
process.kill(pid, 'SIGKILL');
|
|
525
|
-
}
|
|
526
|
-
} catch {
|
|
527
|
-
// Already gone, or not ours: the liveness check below is the verdict.
|
|
528
|
-
}
|
|
529
|
-
return !pidAlive(pid);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/** Drop the lock only when it still names the PID we just killed. */
|
|
533
|
-
function clearLock(worktree: string, pid: number): void {
|
|
534
|
-
if (readLockPid(worktree) !== pid) return;
|
|
535
|
-
try {
|
|
536
|
-
rmSync(lockPath(worktree), { force: true });
|
|
537
|
-
} catch {
|
|
538
|
-
// A live successor owns it now; the next run's stale-lock takeover handles it.
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* Reap the writer a timed-out call started. Only a PID that appeared during
|
|
544
|
-
* this call is killed, and only while its lock is still fresh: a lock that was
|
|
545
|
-
* already present belongs to an earlier run, which is the retry path's job.
|
|
546
|
-
*/
|
|
547
|
-
function reapWriter(worktree: string, before: number | null): number | null {
|
|
548
|
-
const lock = readLock(worktree);
|
|
549
|
-
if (lock === null || lock.pid === before || lock.pid === process.pid) return null;
|
|
550
|
-
if (!lock.fresh) return null;
|
|
551
|
-
if (!killTree(lock.pid, worktree)) return null;
|
|
552
|
-
clearLock(worktree, lock.pid);
|
|
553
|
-
return lock.pid;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
type HolderReap =
|
|
557
|
-
| { status: 'none' | 'dead' | 'killed'; pid: number | null }
|
|
558
|
-
| { status: 'unsafe'; pid: number };
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Decide what to do with the current lock before a retry. `unlock` deletes the
|
|
562
|
-
* lock file unconditionally, which is safe only when its owner is gone; a LIVE
|
|
563
|
-
* owner is killed only when it can be positively identified. Anything else is
|
|
564
|
-
* `unsafe`: the caller must NOT unlock (two engines on one db) and must not
|
|
565
|
-
* retry - it degrades instead.
|
|
566
|
-
*/
|
|
567
|
-
function reapLockHolder(worktree: string): HolderReap {
|
|
568
|
-
const lock = readLock(worktree);
|
|
569
|
-
if (lock === null) return { status: 'none', pid: null };
|
|
570
|
-
if (lock.pid === process.pid) return { status: 'unsafe', pid: lock.pid };
|
|
571
|
-
if (!pidAlive(lock.pid)) return { status: 'dead', pid: lock.pid };
|
|
572
|
-
if (!lock.fresh) return { status: 'unsafe', pid: lock.pid };
|
|
573
|
-
if (!killTree(lock.pid, worktree)) return { status: 'unsafe', pid: lock.pid };
|
|
574
|
-
clearLock(worktree, lock.pid);
|
|
575
|
-
return { status: 'killed', pid: lock.pid };
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
function emit(payload: Record<string, unknown>, code: number): number {
|
|
579
|
-
console.log(JSON.stringify(payload));
|
|
580
|
-
return code;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
/** Linked worktrees keep their git dir under the common dir; the main checkout does not. */
|
|
584
|
-
function isLinkedWorktree(worktree: string): boolean {
|
|
585
|
-
const gitDir = git(['rev-parse', '--absolute-git-dir'], worktree);
|
|
586
|
-
const commonDir = git(['rev-parse', '--git-common-dir'], worktree);
|
|
587
|
-
if (!gitDir.ok || !commonDir.ok) return false;
|
|
588
|
-
const commonAbs = realp(path.isAbsolute(commonDir.out)
|
|
589
|
-
? commonDir.out : path.resolve(worktree, commonDir.out));
|
|
590
|
-
return realp(gitDir.out) !== commonAbs;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Remove ONLY this worktree's own `.homegraph/` directory. Never a symlink or
|
|
595
|
-
* junction (that would unlink a shared layout the team may rely on), never a
|
|
596
|
-
* plain file, and never a directory that holds tracked files: `.homegraph/`
|
|
597
|
-
* .gitignore is legitimately tracked in repos that predate the ignore rule, and
|
|
598
|
-
* deleting it would dirty the worktree and carry the deletion into the coder's
|
|
599
|
-
* commit (the next run's `index` rebuilds without touching it). Never
|
|
600
|
-
* `homegraph uninit` either: without a local `.homegraph/` it resolves upward
|
|
601
|
-
* and deletes an ancestor workspace index.
|
|
602
|
-
*/
|
|
603
|
-
function removeLocalIndex(worktree: string, hasTracked: boolean): void {
|
|
604
|
-
if (hasTracked) return;
|
|
605
|
-
const target = path.join(worktree, '.homegraph');
|
|
606
|
-
try {
|
|
607
|
-
let st;
|
|
608
|
-
try {
|
|
609
|
-
st = lstatSync(target);
|
|
610
|
-
} catch {
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
if (st.isSymbolicLink() || !st.isDirectory()) return;
|
|
614
|
-
// A db this script does not know by name means an engine layout it cannot
|
|
615
|
-
// judge (`a2h-utg-static` already probes both homegraph.db and graph.db):
|
|
616
|
-
// "cannot verify", never "delete it".
|
|
617
|
-
let entries: string[];
|
|
618
|
-
try {
|
|
619
|
-
entries = readdirSync(target);
|
|
620
|
-
} catch {
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
if (entries.some((f) => f.toLowerCase() !== 'homegraph.db' && /\.db$/i.test(f))) return;
|
|
624
|
-
rmSync(target, { recursive: true, force: true });
|
|
625
|
-
} catch {
|
|
626
|
-
// A live writer may hold the files; the next run rebuilds anyway.
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
function parseArgs(argv: string[]) {
|
|
631
|
-
const positionals: string[] = [];
|
|
632
|
-
let sync = false;
|
|
633
|
-
let timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
634
|
-
let statusTimeoutMs = DEFAULT_STATUS_TIMEOUT_MS;
|
|
635
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
636
|
-
const a = argv[i]!;
|
|
637
|
-
if (a === '--sync') sync = true;
|
|
638
|
-
else if (a === '--timeout-ms') {
|
|
639
|
-
timeoutMs = Number(argv[++i]);
|
|
640
|
-
} else if (a.startsWith('--timeout-ms=')) {
|
|
641
|
-
timeoutMs = Number(a.slice('--timeout-ms='.length));
|
|
642
|
-
} else if (a === '--status-timeout-ms') {
|
|
643
|
-
statusTimeoutMs = Number(argv[++i]);
|
|
644
|
-
} else if (a.startsWith('--status-timeout-ms=')) {
|
|
645
|
-
statusTimeoutMs = Number(a.slice('--status-timeout-ms='.length));
|
|
646
|
-
} else if (a.startsWith('-')) {
|
|
647
|
-
throw new Error(`unknown option: ${a}`);
|
|
648
|
-
} else positionals.push(a);
|
|
649
|
-
}
|
|
650
|
-
return { positionals, sync, timeoutMs, statusTimeoutMs };
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
function main(argv: string[]): number {
|
|
654
|
-
let parsed: ReturnType<typeof parseArgs>;
|
|
655
|
-
try {
|
|
656
|
-
parsed = parseArgs(argv);
|
|
657
|
-
} catch (e) {
|
|
658
|
-
console.error(`[ERROR] ${(e as Error).message}\n${USAGE}`);
|
|
659
|
-
return 2;
|
|
660
|
-
}
|
|
661
|
-
const { positionals, sync, timeoutMs, statusTimeoutMs } = parsed;
|
|
662
|
-
if (positionals.length !== 2 || !Number.isFinite(timeoutMs)
|
|
663
|
-
|| timeoutMs <= 0 || timeoutMs > MAX_TIMEOUT_MS
|
|
664
|
-
|| !Number.isFinite(statusTimeoutMs)
|
|
665
|
-
|| statusTimeoutMs <= 0 || statusTimeoutMs > MAX_TIMEOUT_MS) {
|
|
666
|
-
console.error(USAGE);
|
|
667
|
-
return 2;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const hmos = realp(positionals[0]!);
|
|
671
|
-
const worktree = realp(positionals[1]!);
|
|
672
|
-
const started = Date.now();
|
|
673
|
-
|
|
674
|
-
if (worktree === hmos) {
|
|
675
|
-
return emit({ ok: false, action: 'skip', reason: 'same_as_main', worktree, ms: Date.now() - started }, 1);
|
|
676
|
-
}
|
|
677
|
-
if (!existsSync(worktree) || !statSync(worktree).isDirectory()) {
|
|
678
|
-
return emit({ ok: false, action: 'skip', reason: 'worktree_missing', worktree, ms: Date.now() - started }, 1);
|
|
679
|
-
}
|
|
680
|
-
const toplevel = git(['rev-parse', '--show-toplevel'], worktree);
|
|
681
|
-
if (!toplevel.ok || realp(toplevel.out) !== worktree) {
|
|
682
|
-
return emit({
|
|
683
|
-
ok: false, action: 'skip', reason: 'not_a_worktree', worktree,
|
|
684
|
-
detail: plain(toplevel.err || toplevel.out || 'not a git working tree'),
|
|
685
|
-
ms: Date.now() - started,
|
|
686
|
-
}, 1);
|
|
687
|
-
}
|
|
688
|
-
if (!isLinkedWorktree(worktree)) {
|
|
689
|
-
return emit({
|
|
690
|
-
ok: false, action: 'skip', reason: 'not_a_linked_worktree', worktree,
|
|
691
|
-
detail: 'this is the main checkout, not a linked worktree - the main index belongs to B4',
|
|
692
|
-
ms: Date.now() - started,
|
|
693
|
-
}, 1);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
// Trailing slash: `check-ignore` skips non-existent paths, but a directory
|
|
697
|
-
// pattern still matches when written with the separator. `--no-index` asks
|
|
698
|
-
// the patterns alone - without it a *partially tracked* directory answers 1
|
|
699
|
-
// even though the rule matches (observed on a project whose .homegraph was
|
|
700
|
-
// committed before the rule existed).
|
|
701
|
-
if (!git(['check-ignore', '-q', '--no-index', '.homegraph/'], worktree).ok) {
|
|
702
|
-
return emit({
|
|
703
|
-
ok: false, action: 'skip', reason: 'homegraph_not_ignored', worktree,
|
|
704
|
-
detail: '.homegraph/ is not gitignored in this worktree - add it to <HMOS>/.gitignore (the campaign baseline normally provides it) and re-run; no index is built meanwhile',
|
|
705
|
-
ms: Date.now() - started,
|
|
706
|
-
}, 1);
|
|
707
|
-
}
|
|
708
|
-
// HomeGraph's own `.homegraph/.gitignore` is legitimately tracked in some
|
|
709
|
-
// repos (committed before the ignore rule existed); the database files are
|
|
710
|
-
// what must stay out of git. Pathspec matching stays case-SENSITIVE on
|
|
711
|
-
// Windows git even though the ignore rule does not, so `:(icase)` is needed
|
|
712
|
-
// to see `.HomeGraph/...` - otherwise a case variant is treated as untracked
|
|
713
|
-
// and the failure cleanup deletes a tracked file.
|
|
714
|
-
const listed = git(['ls-files', '--', ':(icase).homegraph'], worktree);
|
|
715
|
-
const trackedFiles = listed.out
|
|
716
|
-
.split('\n').map((l) => l.trim()).filter(Boolean)
|
|
717
|
-
.map((f) => f.split('\\').join('/'));
|
|
718
|
-
const trackedIndex = trackedFiles.filter((f) => f.toLowerCase() !== '.homegraph/.gitignore');
|
|
719
|
-
// Removal is authorized only by PROOF that nothing under `.homegraph` is
|
|
720
|
-
// tracked: a failed listing, or any tracked entry at all, means "do not
|
|
721
|
-
// delete" (a corrupt leftover is rebuilt by the next run's `index` anyway).
|
|
722
|
-
const hasTrackedFiles = !listed.ok || trackedFiles.length > 0;
|
|
723
|
-
if (trackedIndex.length) {
|
|
724
|
-
return emit({
|
|
725
|
-
ok: false, action: 'skip', reason: 'homegraph_tracked', worktree,
|
|
726
|
-
detail: `.homegraph/ has tracked files in this worktree (${trackedIndex.slice(0, 5).join(', ')}) - untrack them (git rm --cached) and re-run; no index is built meanwhile`,
|
|
727
|
-
ms: Date.now() - started,
|
|
728
|
-
}, 1);
|
|
729
|
-
}
|
|
730
|
-
// A symlink/junction here redirects the "local" index to another tree (the
|
|
731
|
-
// engine echoes the CLI path back as projectPath, so it cannot be trusted to
|
|
732
|
-
// detect this) - building would write into that tree and the coder would read
|
|
733
|
-
// another branch's graph as its own. `lstat` is the only reliable test: it
|
|
734
|
-
// also sees a DANGLING link, which `existsSync` reports as absent (and which
|
|
735
|
-
// would otherwise fail `init` with ENOENT on every single run).
|
|
736
|
-
const localIndexPath = path.join(worktree, '.homegraph');
|
|
737
|
-
let localStat = null;
|
|
738
|
-
try {
|
|
739
|
-
localStat = lstatSync(localIndexPath);
|
|
740
|
-
} catch {
|
|
741
|
-
localStat = null;
|
|
742
|
-
}
|
|
743
|
-
if (localStat?.isSymbolicLink()) {
|
|
744
|
-
return emit({
|
|
745
|
-
ok: false, action: 'skip', reason: 'homegraph_linked', worktree,
|
|
746
|
-
detail: '.homegraph/ is a symlink/junction (possibly dangling) to another tree - remove the link and re-run; no index is built or deleted meanwhile',
|
|
747
|
-
ms: Date.now() - started,
|
|
748
|
-
}, 1);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
const bin = engine();
|
|
752
|
-
// Availability probe: `--version` is the one call whose failure is
|
|
753
|
-
// unambiguous, and cmd.exe's "not recognized" wording is localized (and
|
|
754
|
-
// mojibake once decoded as UTF-8), so message matching cannot decide this.
|
|
755
|
-
const probe = run(['--version'], PROBE_TIMEOUT_MS);
|
|
756
|
-
if (!probe.ok) {
|
|
757
|
-
return emit({
|
|
758
|
-
ok: false, action: 'skip', reason: 'engine_missing', worktree,
|
|
759
|
-
detail: plain(`${bin.join(' ')} --version failed: ${probe.err || probe.out}`).slice(-200),
|
|
760
|
-
ms: Date.now() - started,
|
|
761
|
-
}, 1);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
// No db -> no probe (see probeStatus): the engine's read commands resolve
|
|
765
|
-
// upward and would scan an ancestor's whole tree.
|
|
766
|
-
const first = probeStatus(worktree, statusTimeoutMs);
|
|
767
|
-
if (first.missing || NOT_FOUND.test(first.err)) {
|
|
768
|
-
return emit({
|
|
769
|
-
ok: false, action: 'skip', reason: 'engine_missing', worktree,
|
|
770
|
-
detail: `cannot execute: ${bin.join(' ')}`,
|
|
771
|
-
ms: Date.now() - started,
|
|
772
|
-
}, 1);
|
|
773
|
-
}
|
|
774
|
-
if (first.timeout && sync) {
|
|
775
|
-
// A local db exists but cannot be probed. A refresh must never throw away
|
|
776
|
-
// the previous snapshot on a slow read, so --sync keeps the documented
|
|
777
|
-
// degraded exit; a plain run rebuilds locally instead (below).
|
|
778
|
-
return emit({
|
|
779
|
-
ok: false, action: 'skip', reason: 'timeout', worktree,
|
|
780
|
-
detail: `status exceeded ${statusTimeoutMs} ms`,
|
|
781
|
-
ms: Date.now() - started,
|
|
782
|
-
}, 1);
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
const local = !first.timeout && !first.unreadable && isLocal(first.status, worktree);
|
|
786
|
-
const usable = local && isUsable(first.status);
|
|
787
|
-
// A timed-out probe means "present but unverifiable": rebuild it in place.
|
|
788
|
-
// `index` is literal, so this can never touch an ancestor index.
|
|
789
|
-
const action: 'none' | 'sync' | 'init' | 'index' = first.timeout || first.unreadable
|
|
790
|
-
? 'index'
|
|
791
|
-
: !local
|
|
792
|
-
? 'init'
|
|
793
|
-
: !usable
|
|
794
|
-
? 'index'
|
|
795
|
-
: (sync ? 'sync' : 'none');
|
|
796
|
-
|
|
797
|
-
if (action === 'none') {
|
|
798
|
-
return emit({
|
|
799
|
-
ok: true, action, ms: Date.now() - started, attempts: 0, worktree,
|
|
800
|
-
projectPath: first.status?.projectPath ?? worktree,
|
|
801
|
-
fileCount: first.status?.fileCount ?? null,
|
|
802
|
-
reason: null, detail: null,
|
|
803
|
-
}, 0);
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
const args = action === 'init'
|
|
807
|
-
? ['init', worktree]
|
|
808
|
-
: action === 'index'
|
|
809
|
-
? ['index', worktree]
|
|
810
|
-
: ['sync', '--quiet', worktree];
|
|
811
|
-
let attempts = 0;
|
|
812
|
-
let last: RunResult | null = null;
|
|
813
|
-
let accepted: Status | null = null;
|
|
814
|
-
let acceptedVia: 'error' | 'timeout' | null = null;
|
|
815
|
-
let reaped: number | null = null;
|
|
816
|
-
const lockBefore = readLockPid(worktree);
|
|
817
|
-
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) {
|
|
818
|
-
attempts = attempt;
|
|
819
|
-
last = run(args, timeoutMs);
|
|
820
|
-
if (last.ok) break;
|
|
821
|
-
// The store-worker often errors AFTER the data is complete: trust the
|
|
822
|
-
// index, not the exit code, and do not burn the remaining retries.
|
|
823
|
-
const check = probeStatus(worktree, statusTimeoutMs);
|
|
824
|
-
const usableNow = !check.unreadable && isLocal(check.status, worktree) && isUsable(check.status);
|
|
825
|
-
if (last.timeout) {
|
|
826
|
-
// spawnSync killed only its direct child (cmd.exe on Windows); the engine
|
|
827
|
-
// worker may still be running. Reap the PID this call started, then let
|
|
828
|
-
// the leftover index be rebuilt by the next run (`index.state` is not
|
|
829
|
-
// `complete`, so it is never advertised as usable).
|
|
830
|
-
const killed = reapWriter(worktree, lockBefore);
|
|
831
|
-
if (killed !== null) reaped = killed;
|
|
832
|
-
// A timed-out writer may still be running. Only a REFRESH is safe to
|
|
833
|
-
// accept (SQLite leaves the previous, already-usable snapshot in place);
|
|
834
|
-
// a timed-out first build or full rebuild must never be advertised.
|
|
835
|
-
if (action === 'sync' && usableNow) {
|
|
836
|
-
accepted = check.status;
|
|
837
|
-
acceptedVia = 'timeout';
|
|
838
|
-
}
|
|
839
|
-
break;
|
|
840
|
-
}
|
|
841
|
-
if (usableNow) {
|
|
842
|
-
accepted = check.status;
|
|
843
|
-
acceptedVia = 'error';
|
|
844
|
-
break;
|
|
845
|
-
}
|
|
846
|
-
if (!LOCKED.test(`${last.out}\n${last.err}`)) break;
|
|
847
|
-
// A live holder is killed only when positively identified (fresh lock,
|
|
848
|
-
// homegraph + this worktree on its command line); `unlock` deletes the lock
|
|
849
|
-
// of a running writer unconditionally, so it is reserved for a dead PID.
|
|
850
|
-
// Anything unproven degrades: guessing here could kill the caller's own
|
|
851
|
-
// session or start a second writer on the same db.
|
|
852
|
-
const holder = reapLockHolder(worktree);
|
|
853
|
-
if (holder.status === 'killed') {
|
|
854
|
-
reaped = holder.pid;
|
|
855
|
-
} else if (holder.status === 'none' || holder.status === 'dead') {
|
|
856
|
-
run(['unlock', worktree], 30_000);
|
|
857
|
-
} else {
|
|
858
|
-
return emit({
|
|
859
|
-
ok: false, action, reason: 'lock_busy', ms: Date.now() - started, attempts, worktree, reaped,
|
|
860
|
-
detail: `engine lock is held by live PID ${holder.pid} that cannot be positively identified as this worktree's builder; not unlocking it - re-run after that writer exits`,
|
|
861
|
-
}, 1);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
const detail = clip(plain(last?.err || last?.out || '')) || null;
|
|
865
|
-
|
|
866
|
-
if (accepted) {
|
|
867
|
-
return emit({
|
|
868
|
-
ok: true, action, ms: Date.now() - started, attempts, worktree, reaped,
|
|
869
|
-
projectPath: accepted.projectPath ?? worktree,
|
|
870
|
-
fileCount: accepted.fileCount ?? null,
|
|
871
|
-
// A failed refresh left the pre-refresh index in place: usable, but not
|
|
872
|
-
// the snapshot the caller asked for. Machine-readable so the wave log
|
|
873
|
-
// shows it (hop (b) records and continues).
|
|
874
|
-
reason: action === 'sync' ? 'sync_incomplete' : null,
|
|
875
|
-
detail: acceptedVia === 'timeout'
|
|
876
|
-
? `${args[0]} timed out after ${timeoutMs} ms; the previous index is still usable (refresh incomplete)`
|
|
877
|
-
: `build process reported an error but the index is complete: ${detail ?? ''}`.trim(),
|
|
878
|
-
}, 0);
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
if (!last || !last.ok) {
|
|
882
|
-
// A timed-out build's writer was reaped above; the leftover index stays on
|
|
883
|
-
// disk (never deleted: a writer may have died mid-write) and the next run's
|
|
884
|
-
// `index` rebuilds it, because its `index.state` is not `complete`. A probe
|
|
885
|
-
// that timed out never proved the previous snapshot unusable, so a failed
|
|
886
|
-
// fallback must not delete it either. Only our own failed build is removed,
|
|
887
|
-
// and only after the process has exited.
|
|
888
|
-
if (!last?.timeout && !first.timeout && action !== 'sync') {
|
|
889
|
-
removeLocalIndex(worktree, hasTrackedFiles);
|
|
890
|
-
}
|
|
891
|
-
const reason = last?.timeout ? 'timeout' : action === 'init' ? 'init_failed' : action === 'index' ? 'index_failed' : 'sync_failed';
|
|
892
|
-
return emit({
|
|
893
|
-
ok: false, action, reason, ms: Date.now() - started, attempts, worktree, reaped, detail,
|
|
894
|
-
}, 1);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
const after = probeStatus(worktree, statusTimeoutMs);
|
|
898
|
-
const afterLocal = !after.unreadable && isLocal(after.status, worktree);
|
|
899
|
-
const afterUsable = afterLocal && isUsable(after.status);
|
|
900
|
-
const elapsed = Date.now() - started;
|
|
901
|
-
if (!afterUsable) {
|
|
902
|
-
// Rebuilds we ran may be discarded; a failed sync's older index may not.
|
|
903
|
-
// A read that TIMED OUT proves nothing about the snapshot (a large index is
|
|
904
|
-
// simply slow), so it never authorises deletion either.
|
|
905
|
-
if (action !== 'sync' && !after.timeout) removeLocalIndex(worktree, hasTrackedFiles);
|
|
906
|
-
// A readable-but-uninitialized status is "nothing was built", not "another
|
|
907
|
-
// tree's index" - `isLocal` is false for both.
|
|
908
|
-
const reason = after.unreadable
|
|
909
|
-
? 'status_unreadable'
|
|
910
|
-
: after.timeout
|
|
911
|
-
? 'timeout'
|
|
912
|
-
: after.status?.initialized === false || afterLocal
|
|
913
|
-
? 'index_incomplete'
|
|
914
|
-
: 'index_not_local';
|
|
915
|
-
const why = reason === 'index_not_local'
|
|
916
|
-
? `the built index resolves to ${after.status?.projectPath ?? 'another tree'}, not this worktree`
|
|
917
|
-
: reason === 'status_unreadable'
|
|
918
|
-
? (clip(after.err, 300) || 'homegraph status --json did not return JSON')
|
|
919
|
-
: reason === 'timeout'
|
|
920
|
-
? `status exceeded ${statusTimeoutMs} ms after the build; the snapshot is left in place unverified (raise --status-timeout-ms if the index is large)`
|
|
921
|
-
: (detail ?? null);
|
|
922
|
-
return emit({
|
|
923
|
-
ok: false, action, reason, ms: elapsed, attempts, worktree, reaped,
|
|
924
|
-
projectPath: after.status?.projectPath ?? null,
|
|
925
|
-
fileCount: after.status?.fileCount ?? null,
|
|
926
|
-
detail: why,
|
|
927
|
-
}, 1);
|
|
928
|
-
}
|
|
929
|
-
return emit({
|
|
930
|
-
ok: true, action, ms: elapsed, attempts, worktree, reaped,
|
|
931
|
-
projectPath: after.status?.projectPath ?? worktree,
|
|
932
|
-
fileCount: after.status?.fileCount ?? null,
|
|
933
|
-
reason: null, detail: null,
|
|
934
|
-
}, 0);
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
function cli(): number {
|
|
938
|
-
try {
|
|
939
|
-
return main(process.argv.slice(2));
|
|
940
|
-
} catch (e) {
|
|
941
|
-
return emit({
|
|
942
|
-
ok: false, action: 'skip', reason: 'internal_error',
|
|
943
|
-
detail: String((e as Error)?.message ?? e).slice(-300),
|
|
944
|
-
}, 1);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
process.exitCode = cli();
|