@buaa_smat/hometrans 26.0.5 → 26.0.6
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 +249 -279
- package/agents/code-reviewer.md +1 -1
- package/dist/cli/editors.json +20 -0
- package/dist/platform/registry.js +1 -0
- package/dist/platform/validate.js +2 -1
- package/i18n/agents/code-reviewer.md +1 -1
- package/i18n/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/i18n/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
- package/i18n/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/i18n/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/skills/a2h-app-migrate/SKILL.md +32 -15
- package/i18n/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +148 -89
- package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
- package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +9 -3
- package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +14 -12
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
- package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
- package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
- package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
- package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
- package/i18n/skills/a2h-module-semantic-docs/SKILL.md +3 -2
- package/i18n/skills/a2h-page-specgen/SKILL.md +36 -5
- package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +89 -21
- package/i18n/skills/a2h-page-specgen/references/gates.md +33 -7
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +166 -32
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +8 -5
- package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +37 -1
- package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
- package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
- package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
- package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +19 -10
- package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +62 -3
- package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +116 -6
- package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
- package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +26 -14
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +216 -216
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +100 -15
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +155 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +75 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +124 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +106 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +12 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +11 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
- package/i18n/skills/a2h-resource-convert/SKILL.md +1 -1
- package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
- package/i18n/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +15 -12
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
- package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +5 -3
- package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
- package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
- package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
- package/i18n/skills/a2h-spec-generate/references/input-formats.md +1 -1
- package/i18n/skills/a2h-utg-explorer/SKILL.md +11 -5
- package/i18n/skills/a2h-utg-explorer/references/architecture.md +37 -19
- package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +48 -3
- package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
- package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +143 -14
- package/i18n/skills/a2h-utg-static/SKILL.md +3 -3
- package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
- package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
- package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
- package/package.json +2 -1
- package/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/codebuddy/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/model-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +2 -0
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +2 -0
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +2 -0
- package/platforms/deveco/agents/model-worker.frontmatter.md +2 -0
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +2 -0
- package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +2 -0
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +2 -0
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +2 -0
- package/platforms/opencode/agents/model-worker.frontmatter.md +2 -0
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +2 -0
- package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
- package/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/skills/a2h-app-migrate/SKILL.md +31 -14
- package/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/skills/a2h-app-migrate/references/workflow.yaml +152 -89
- package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +28 -11
- package/skills/a2h-app-migrate/scripts/dag_action_catalog.mjs +76 -0
- package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +60 -5
- package/skills/a2h-app-migrate/scripts/dag_runner.mjs +184 -4
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/ledger.mjs +2 -2
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -3
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
- package/skills/a2h-app-migrate/test/test_dag_blocked_guard.mjs +291 -0
- package/skills/a2h-app-migrate/test/test_dag_production.mjs +40 -0
- package/skills/a2h-app-migrate/test/test_dag_runner.mjs +4 -3
- package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +36 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +19 -6
- package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
- package/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
- package/skills/a2h-batch-ui-align/SKILL.md +14 -12
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
- package/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
- package/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
- package/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
- package/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
- package/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
- package/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
- package/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
- package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
- package/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
- package/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
- package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +6 -1
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
- package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +270 -0
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +134 -16
- package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +39 -8
- package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
- package/skills/a2h-batch-ui-align/scripts/module_placement.mjs +189 -0
- package/skills/a2h-batch-ui-align/scripts/overlay_effects.mjs +205 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +28 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +28 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_chrome_defaults.test.mjs +328 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_click_handler.test.mjs +127 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_compose_semantics.test.mjs +150 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +117 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +413 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +159 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_sheet_builder.test.mjs +192 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +4 -2
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_compose.test.mjs +106 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +15 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pass.test.mjs +150 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +125 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +56 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack_icon_leaf.test.mjs +143 -0
- package/skills/a2h-batch-ui-align/scripts/tests/module_placement.test.mjs +248 -0
- package/skills/a2h-batch-ui-align/scripts/tests/overlay_effects.test.mjs +214 -0
- package/skills/a2h-fix-build-errors/references/known-patterns.md +5 -5
- package/skills/a2h-module-semantic-docs/SKILL.md +3 -2
- package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +10 -0
- package/skills/a2h-module-semantic-docs/scripts/design_baseline.mjs +158 -0
- package/skills/a2h-module-semantic-docs/test/test_design_baseline.mjs +128 -0
- package/skills/a2h-page-specgen/SKILL.md +36 -5
- package/skills/a2h-page-specgen/references/behavior-ledger.md +88 -21
- package/skills/a2h-page-specgen/references/evidence.md +2 -1
- package/skills/a2h-page-specgen/references/execution-model.md +13 -5
- package/skills/a2h-page-specgen/references/gates.md +33 -7
- package/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
- package/skills/a2h-page-specgen/references/spec-example.md +166 -32
- package/skills/a2h-page-specgen/references/spec-template.md +8 -5
- package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +40 -2
- package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
- package/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
- package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +35 -2
- package/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
- package/skills/a2h-page-specgen/scripts/finalize.mjs +55 -2
- package/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
- package/skills/a2h-page-specgen/scripts/gate.mjs +20 -11
- package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +56 -3
- package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
- package/skills/a2h-page-specgen/scripts/lib/hg.mjs +114 -5
- package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +20 -3
- package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
- package/skills/a2h-page-specgen/scripts/prepare.mjs +25 -14
- package/skills/a2h-page-specgen/scripts/report.mjs +26 -5
- package/skills/a2h-page-specgen/scripts/submission.mjs +69 -2
- package/skills/a2h-page-specgen/scripts/submit.mjs +105 -4
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +224 -224
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +153 -3
- package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
- package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
- package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
- package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +82 -3
- package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +11 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +94 -1
- package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
- package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +14 -0
- package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +49 -1
- package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
- package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +12 -4
- package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
- package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
- package/skills/a2h-page-specgen/scripts/test/report.test.mjs +80 -1
- package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
- package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +23 -0
- package/skills/a2h-page-specgen/scripts/waker.mjs +8 -1
- package/skills/a2h-resource-convert/SKILL.md +1 -1
- package/skills/a2h-resource-convert/data/framework-strings/NOTICE +10 -0
- package/skills/a2h-resource-convert/data/framework-strings/manifest.json +90 -0
- package/skills/a2h-resource-convert/data/framework-strings/strings.json +382 -0
- package/skills/a2h-resource-convert/references/conversion-rules.md +7 -1
- package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
- package/skills/a2h-resource-convert/references/step5-reference-resolution.md +16 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
- package/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
- package/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +14 -11
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +3 -0
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -3
- package/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
- package/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/scripts.md +4 -3
- package/skills/a2h-spec-design-pipeline/references/shared-layer.md +24 -19
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +12 -5
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +27 -3
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +46 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +2511 -295
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +27 -72
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +39 -83
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +132 -101
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +158 -115
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +60 -93
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +73 -100
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-cn.md +52 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-en.md +59 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +57 -8
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +475 -18
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +472 -4
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/RoutePageSideEffectImportCheck.js +570 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/arkui/RouteParamCarrierSubCheck.js +1053 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/sql/SqlIdentifierAnalysis.js +427 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +7 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/settle.ts +785 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +286 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +166 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_docs_refresh_contract.ts +40 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +350 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_route_page_side_effect_import.ts +185 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_route_param_carrier.ts +341 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_settle.ts +593 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +92 -1
- package/skills/a2h-spec-design-pipeline/scripts/test_sql_identifier_analysis.ts +137 -0
- package/skills/a2h-spec-generate/references/input-formats.md +1 -1
- package/skills/a2h-utg-explorer/SKILL.md +11 -5
- package/skills/a2h-utg-explorer/references/architecture.md +37 -19
- package/skills/a2h-utg-explorer/scripts/audit.mjs +6 -2
- package/skills/a2h-utg-explorer/scripts/close_phases.mjs +8 -5
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +95 -19
- package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +192 -4
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
- package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/plan.mjs +16 -1
- package/skills/a2h-utg-explorer/scripts/predicates.mjs +270 -0
- package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +2 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +4 -3
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +4 -3
- package/skills/a2h-utg-explorer/scripts/report.mjs +32 -2
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +103 -36
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +3 -8
- package/skills/a2h-utg-explorer/scripts/schedule_states.mjs +189 -0
- package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +9 -0
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +11 -0
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +31 -2
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
- package/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +4 -1
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +6 -28
- package/skills/a2h-utg-explorer/scripts/tests/in_route_surface.test.mjs +125 -0
- package/skills/a2h-utg-explorer/scripts/tests/list_probe_target_wait.test.mjs +86 -0
- package/skills/a2h-utg-explorer/scripts/tests/multi_host.test.mjs +167 -0
- package/skills/a2h-utg-explorer/scripts/tests/nested_list.test.mjs +58 -0
- package/skills/a2h-utg-explorer/scripts/tests/overlay_opener.test.mjs +100 -0
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +8 -1
- package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +1 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +2 -31
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +56 -7
- package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +117 -6
- package/skills/a2h-utg-explorer/scripts/tests/state_inventory.test.mjs +414 -0
- package/skills/a2h-utg-explorer/scripts/tests/tree_unreliable.test.mjs +197 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +196 -30
- package/skills/a2h-utg-explorer/scripts/utg_explorer/hosts.mjs +146 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
- package/skills/a2h-utg-explorer/scripts/utg_explorer/states.mjs +286 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +197 -19
- package/skills/a2h-utg-static/SKILL.md +3 -3
- package/skills/a2h-utg-static/references/extractors.md +7 -0
- package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
- package/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +642 -22
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
- package/skills/a2h-utg-static/scripts/tests/test_in_route_surface.mjs +123 -0
- package/skills/a2h-utg-static/scripts/tests/test_overlay_host_effects.mjs +239 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_host_depths.mjs +48 -0
- package/skills/a2h-utg-static/scripts/utg_html.mjs +2 -0
- package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
- package/i18n/skills/a2h-app-migrate/references/specs.example.json +0 -19
- package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
- package/resource/convert_pipeline_process.svg +0 -114
- package/resource/project_architecture.svg +0 -120
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.png +0 -0
- package/skills/a2h-app-migrate/references/specs.example.json +0 -19
- package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
- package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract-calls.mjs — platform-neutral "contract-only calls" evidence.
|
|
3
|
+
*
|
|
4
|
+
* The SourceUnit snapshot is deliberately bounded to declaration composition.
|
|
5
|
+
* A call-only target is not composition evidence, but it can still carry an
|
|
6
|
+
* external contract: an HTTP client that builds the request, a UI adapter that
|
|
7
|
+
* renders a list, a persistence accessor. Dropping those silently is what let a
|
|
8
|
+
* page be "complete" without its request parameters.
|
|
9
|
+
*
|
|
10
|
+
* This module keeps one hop of `calls`/`instantiates` from the reviewed scope
|
|
11
|
+
* and classifies the target by *call-site and target-file signals*, never by a
|
|
12
|
+
* class-name guess alone. A wrapper (`WeatherClient` -> `OpenMeteoClient`) is
|
|
13
|
+
* followed one extra hop. Every target gets an explicit disposition:
|
|
14
|
+
* kept — contract evidence, written to evidence/contracts.json
|
|
15
|
+
* reviewed-scope — already a SourceUnit in this page's reviewed scope
|
|
16
|
+
* not-contract — no contract signal, with a reason
|
|
17
|
+
* contract-path — a wrapper that led to kept/deferred contract evidence
|
|
18
|
+
* deferred — unresolvable, unreadable, or a dead-end wrapper
|
|
19
|
+
* omitted — contract evidence beyond the per-page budget
|
|
20
|
+
*
|
|
21
|
+
* The caller must treat `deferred`/`omitted` as incomplete; nothing is silently
|
|
22
|
+
* dropped.
|
|
23
|
+
*/
|
|
24
|
+
import fs from "node:fs";
|
|
25
|
+
import path from "node:path";
|
|
26
|
+
import { canonicalSourcePath, stableDigest } from "./behavior-model.mjs";
|
|
27
|
+
import { stripJsComments, stripSourceComments } from "./lib/source-text.mjs";
|
|
28
|
+
|
|
29
|
+
export const CONTRACT_CALLS_SCHEMA_VERSION = 2;
|
|
30
|
+
export const DEFAULT_MAX_CONTRACT_TARGETS = 128;
|
|
31
|
+
const MAX_SOURCE_BYTES = 1_000_000;
|
|
32
|
+
|
|
33
|
+
const JVM = "jvm";
|
|
34
|
+
const UNIAPP = "uniapp";
|
|
35
|
+
const GENERIC = "generic";
|
|
36
|
+
|
|
37
|
+
const DEFER_HINT_RE = /(?:Client|Request)$/i;
|
|
38
|
+
const TRAVERSAL_PATH_RE = /(?:^|\/)(?:api|service|services|network|data|repository|repositories)(?:\/|$)/i;
|
|
39
|
+
const EXCLUDED_TARGET_RE = /(^|\/)(?:androidTest|test|tests|__tests__)\//i;
|
|
40
|
+
|
|
41
|
+
const RULES = [
|
|
42
|
+
// transport
|
|
43
|
+
{ kind: "transport", signal: "url", platforms: [JVM, UNIAPP, GENERIC], regex: /https?:\/\/[^\s"'`)]+/ },
|
|
44
|
+
{ kind: "transport", signal: "query-parameter", platforms: [JVM], regex: /\baddQueryParameter\s*\(/ },
|
|
45
|
+
{ kind: "transport", signal: "okhttp-builder", platforms: [JVM], regex: /\b(?:Request|HttpUrl)\.Builder\b/ },
|
|
46
|
+
{ kind: "transport", signal: "call-builder", platforms: [JVM], regex: /\bnewCall\s*\(/ },
|
|
47
|
+
{ kind: "transport", signal: "call-execution", platforms: [JVM], regex: /\.(?:execute|enqueue)\s*\(\s*\)/ },
|
|
48
|
+
{ kind: "transport", signal: "retrofit-annotation", platforms: [JVM], regex: /@(?:GET|POST|PUT|DELETE|PATCH|HTTP)\b/ },
|
|
49
|
+
{ kind: "transport", signal: "retrofit-parameter", platforms: [JVM], regex: /@(?:Query|QueryMap|Path|Body|Header|Field)\b/ },
|
|
50
|
+
{ kind: "transport", signal: "volley", platforms: [JVM], regex: /\b(?:Volley|JsonObjectRequest|StringRequest)\b/ },
|
|
51
|
+
{ kind: "transport", signal: "ktor", platforms: [JVM], regex: /\bHttpClient\b|\b\w*[Cc]lient\.(?:get|post|put|delete|request)\s*\(/ },
|
|
52
|
+
{ kind: "transport", signal: "http-url", platforms: [JVM], regex: /\b(?:HttpUrl\.parse|openConnection|XMLHttpRequest)\b/ },
|
|
53
|
+
{ kind: "transport", signal: "uniapp-request", platforms: [UNIAPP], regex: /\b(?:uni|wx|my|swan|tt|Taro)\.(?:request|uploadFile|downloadFile)\s*\(/ },
|
|
54
|
+
{ kind: "transport", signal: "axios", platforms: [UNIAPP], regex: /\baxios(?:\.(?:get|post|put|delete|request)|\s*\(|\.create\b)/ },
|
|
55
|
+
{ kind: "transport", signal: "fetch", platforms: [UNIAPP, GENERIC], regex: /\bfetch\s*\(/ },
|
|
56
|
+
{ kind: "transport", signal: "api-wrapper", platforms: [UNIAPP], regex: /\$api\.|\$http\./ },
|
|
57
|
+
{ kind: "transport", signal: "unicloud", platforms: [UNIAPP], regex: /\buniCloud\.callFunction\s*\(/ },
|
|
58
|
+
// ui construction
|
|
59
|
+
{ kind: "ui-construction", signal: "adapter-view-constructor", platforms: [JVM], regex: /\bnew\s+[A-Za-z_$][\w$]*(?:Adapter|View|Dialog)\b/ },
|
|
60
|
+
{ kind: "ui-construction", signal: "set-adapter", platforms: [JVM], regex: /\bsetAdapter\s*\(/ },
|
|
61
|
+
{ kind: "ui-construction", signal: "add-view", platforms: [JVM], regex: /\baddView\s*\(/ },
|
|
62
|
+
{ kind: "ui-construction", signal: "vue-component-import", platforms: [UNIAPP], regex: /\bimport\s+[A-Z][\w$]*\s+from\s+["'][^"']+\.vue["']/ },
|
|
63
|
+
// persistence
|
|
64
|
+
{ kind: "persistence", signal: "shared-preferences", platforms: [JVM], regex: /\bSharedPreferences\b/ },
|
|
65
|
+
{ kind: "persistence", signal: "data-store", platforms: [JVM], regex: /\bDataStore\b/ },
|
|
66
|
+
{ kind: "persistence", signal: "uniapp-storage", platforms: [UNIAPP], regex: /\buni\.(?:setStorage|getStorage|removeStorage)|(?:setStorageSync|getStorageSync)\s*\(/ },
|
|
67
|
+
{ kind: "persistence", signal: "web-storage", platforms: [UNIAPP], regex: /\b(?:localStorage|sessionStorage|plus\.storage)\./ },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const KIND_PRIORITY = new Map([
|
|
71
|
+
["transport", 0],
|
|
72
|
+
["persistence", 1],
|
|
73
|
+
["ui-construction", 2],
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
const STRONG_TRANSPORT_SIGNALS = new Set([
|
|
77
|
+
"query-parameter", "okhttp-builder", "call-builder", "retrofit-annotation",
|
|
78
|
+
"retrofit-parameter", "volley", "ktor", "http-url", "uniapp-request",
|
|
79
|
+
"axios", "fetch", "api-wrapper", "unicloud",
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
function cmp(a, b) {
|
|
83
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function normalizeLocator(value) {
|
|
87
|
+
const text = String(value ?? "").replace(/\\/g, "/").replace(/^\.\//, "");
|
|
88
|
+
return text === "" ? null : text;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function platformOf(locator) {
|
|
92
|
+
if (/\.(?:java|kt|kts)$/i.test(locator)) return JVM;
|
|
93
|
+
if (/\.(?:vue|nvue|uvue|js|jsx|mjs|cjs|ts|tsx)$/i.test(locator)) return UNIAPP;
|
|
94
|
+
return GENERIC;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function uniqueSorted(values) {
|
|
98
|
+
return [...new Set(values.filter(value => typeof value === "string" && value !== ""))].sort(cmp);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function matchAll(text, regex) {
|
|
102
|
+
const out = [];
|
|
103
|
+
regex.lastIndex = 0;
|
|
104
|
+
for (const match of text.matchAll(regex)) {
|
|
105
|
+
const value = match[1] !== undefined ? match[1] : match[0];
|
|
106
|
+
if (typeof value === "string" && value !== "") out.push(value);
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function vueScriptText(text) {
|
|
112
|
+
const scripts = [...text.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)]
|
|
113
|
+
.map(match => match[1]);
|
|
114
|
+
if (scripts.length > 0) return scripts.join("\n");
|
|
115
|
+
// A pure-template SFC has no executable contract; its markup and styles must
|
|
116
|
+
// not leak asset URLs into the transport inventory.
|
|
117
|
+
return /<template\b|<style\b/i.test(text) ? "" : text;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function vueTemplateText(text) {
|
|
121
|
+
const tag = /<\/?template\b[^>]*>/gi;
|
|
122
|
+
let depth = 0;
|
|
123
|
+
let start = -1;
|
|
124
|
+
let end = -1;
|
|
125
|
+
for (const match of text.matchAll(tag)) {
|
|
126
|
+
const closing = match[0].startsWith("</");
|
|
127
|
+
if (!closing) {
|
|
128
|
+
if (depth === 0) start = match.index + match[0].length;
|
|
129
|
+
depth += 1;
|
|
130
|
+
} else if (depth > 0) {
|
|
131
|
+
depth -= 1;
|
|
132
|
+
if (depth === 0) {
|
|
133
|
+
end = match.index;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (start === -1) return "";
|
|
139
|
+
return text.slice(start, end === -1 ? text.length : end);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function scanText(text, locator) {
|
|
143
|
+
if (platformOf(locator) === UNIAPP && /\.(?:vue|nvue|uvue)$/i.test(locator)) {
|
|
144
|
+
return stripJsComments(vueScriptText(text));
|
|
145
|
+
}
|
|
146
|
+
if (platformOf(locator) === UNIAPP) return stripJsComments(text);
|
|
147
|
+
return stripSourceComments(text);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Classify one target file by its content and call context.
|
|
152
|
+
* A class name alone never keeps a target; it only escalates an unclassified
|
|
153
|
+
* target to `deferred` (or a wrapper path) so the gap stays visible.
|
|
154
|
+
*/
|
|
155
|
+
export function classifyContractSignals(text, locator, targetSymbol = null) {
|
|
156
|
+
const platform = platformOf(locator);
|
|
157
|
+
const code = scanText(text, locator);
|
|
158
|
+
const kinds = new Set();
|
|
159
|
+
const signals = new Set();
|
|
160
|
+
for (const rule of RULES) {
|
|
161
|
+
if (!rule.platforms.includes(platform) && !(platform === GENERIC && rule.platforms.includes(GENERIC))) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (rule.regex.test(code)) {
|
|
165
|
+
kinds.add(rule.kind);
|
|
166
|
+
signals.add(rule.signal);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const isVue = /\.(?:vue|nvue|uvue)$/i.test(locator);
|
|
170
|
+
if (platform === UNIAPP && isVue && /<template\b|<component\b/.test(text)) {
|
|
171
|
+
kinds.add("ui-construction");
|
|
172
|
+
signals.add("vue-component");
|
|
173
|
+
}
|
|
174
|
+
const transportSignals = signals.has("url") || signals.has("call-execution");
|
|
175
|
+
if (transportSignals) {
|
|
176
|
+
const requestPrimitive = /\bnewCall\s*\(|Request\.Builder|HttpUrl\.(?:Builder|parse)|openConnection|XMLHttpRequest|(?:uni|wx|my|swan|tt|Taro)\.(?:request|uploadFile|downloadFile)|axios|fetch\s*\(|\$https?\.|\$api\.|uniCloud\.callFunction|Volley|JsonObjectRequest|StringRequest|@(?:GET|POST|PUT|DELETE|PATCH|HTTP|Query|QueryMap|Path|Body|Header|Field)\b|\b\w*[Cc]lient\.(?:get|post|put|delete|request)\s*\(|\.(?:execute|enqueue)\s*\(\s*\)|\b(?:Call|Response|ResponseBody|okhttp3)\b/.test(code);
|
|
177
|
+
const strongTransportSignal = [...signals].some(signal => STRONG_TRANSPORT_SIGNALS.has(signal));
|
|
178
|
+
if (!requestPrimitive && !strongTransportSignal) {
|
|
179
|
+
kinds.delete("transport");
|
|
180
|
+
signals.delete("url");
|
|
181
|
+
signals.delete("call-execution");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const fileStem = path.basename(locator).replace(/\.[^.]+$/, "");
|
|
185
|
+
if (platform === JVM
|
|
186
|
+
&& /(?:Adapter|View|Fragment|Dialog)$/.test(fileStem)
|
|
187
|
+
&& new RegExp(`\\b(?:class|interface|struct|object|fun|typealias)\\s+${fileStem.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`).test(code)) {
|
|
188
|
+
kinds.add("ui-construction");
|
|
189
|
+
signals.add("ui-type-declaration");
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
platform,
|
|
193
|
+
kinds: [...kinds].sort(cmp),
|
|
194
|
+
signals: [...signals].sort(cmp),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function callHint(locator, targetSymbol) {
|
|
199
|
+
const stem = path.basename(locator).replace(/\.[^.]+$/, "");
|
|
200
|
+
// The symbol is tested on its own: concatenating it before the stem pinned `$` to the file
|
|
201
|
+
// name, so a `...Client`/`...Request` callee whose file is `Factories.kt` never hinted.
|
|
202
|
+
const symbol = String(targetSymbol ?? "").trim().replace(/\(.*$/, "");
|
|
203
|
+
return DEFER_HINT_RE.test(stem) || DEFER_HINT_RE.test(symbol);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function fileContracts(text, locator) {
|
|
207
|
+
const code = scanText(text, locator);
|
|
208
|
+
const isVue = /\.(?:vue|nvue|uvue)$/i.test(locator);
|
|
209
|
+
const uiText = isVue ? vueTemplateText(text) : "";
|
|
210
|
+
const hasTransport = /\bnewCall\s*\(|Request\.Builder|HttpUrl\.(?:Builder|parse)|openConnection|XMLHttpRequest|(?:uni|wx|my|swan|tt|Taro)\.(?:request|uploadFile|downloadFile)|axios|fetch\s*\(/.test(code);
|
|
211
|
+
const responseAccessor = /\b(?:JSONObject|JsonObject|optString|optInt|optBoolean|optLong|optDouble)\b/.test(code)
|
|
212
|
+
? matchAll(code, /(?:get|opt\w*|has)\s*\(\s*["']([^"']+)["']/g)
|
|
213
|
+
: [];
|
|
214
|
+
return {
|
|
215
|
+
urls: uniqueSorted(matchAll(code, /https?:\/\/[^\s"'`)]+/g)),
|
|
216
|
+
query_params: uniqueSorted([
|
|
217
|
+
...matchAll(code, /addQueryParameter\s*\(\s*["']([^"']+)["']/g),
|
|
218
|
+
...matchAll(code, /@(?:Query|Path|Header)\s*\(\s*(?:value\s*=\s*)?["']([^"']+)["']/g),
|
|
219
|
+
...matchAll(code, /params\.append\s*\(\s*["']([^"']+)["']/g),
|
|
220
|
+
...(hasTransport
|
|
221
|
+
? matchAll(code, /(?:data|params)\s*:\s*\{([\s\S]*?)\}/g)
|
|
222
|
+
.flatMap(block => matchAll(block, /([A-Za-z_$][\w$]*)\s*:/g))
|
|
223
|
+
: []),
|
|
224
|
+
]),
|
|
225
|
+
response_fields: uniqueSorted([
|
|
226
|
+
...matchAll(code, /@SerializedName\s*\(\s*["']([^"']+)["']/g),
|
|
227
|
+
...responseAccessor,
|
|
228
|
+
]),
|
|
229
|
+
ui_constructors: uniqueSorted([
|
|
230
|
+
...(platformOf(locator) === JVM
|
|
231
|
+
? matchAll(code, /new\s+([A-Za-z_$][\w$]*(?:Adapter|View|Fragment|Dialog))\b/g)
|
|
232
|
+
: matchAll(uiText || code, /<([A-Z][\w$]*)\b/g)),
|
|
233
|
+
]),
|
|
234
|
+
resource_keys: uniqueSorted([
|
|
235
|
+
...matchAll(code, /R\.(?:string|array|menu)\.([A-Za-z0-9_]+)/g),
|
|
236
|
+
...matchAll(code, /(?:\$t|i18n\.t)\s*\(\s*["']([^"']+)["']/g),
|
|
237
|
+
]),
|
|
238
|
+
storage_keys: uniqueSorted(
|
|
239
|
+
matchAll(code, /(?:putString|getString|setStorageSync|getStorageSync|setStorage|getStorage)\s*\(\s*["']([^"']+)["']/g),
|
|
240
|
+
),
|
|
241
|
+
routes: uniqueSorted(
|
|
242
|
+
matchAll(code, /uni\.(?:navigateTo|redirectTo|switchTab|reLaunch)\s*\(\s*\{[^}]*url\s*:\s*["']([^"']+)["']/g),
|
|
243
|
+
),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const CONTRACT_KEYS = [
|
|
248
|
+
"urls", "query_params", "response_fields", "ui_constructors",
|
|
249
|
+
"resource_keys", "storage_keys", "routes",
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Extract an independent source-side contract inventory from the kept files.
|
|
254
|
+
* This does not depend on the call classifier, so a missed call edge cannot
|
|
255
|
+
* hide the URL/parameter/resource it contains.
|
|
256
|
+
*/
|
|
257
|
+
export function extractSourceContracts(contracts = []) {
|
|
258
|
+
const merged = Object.fromEntries(CONTRACT_KEYS.map(key => [key, []]));
|
|
259
|
+
for (const contract of contracts) {
|
|
260
|
+
for (const key of CONTRACT_KEYS) {
|
|
261
|
+
merged[key].push(...(contract?.[key] ?? []));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
for (const key of CONTRACT_KEYS) merged[key] = uniqueSorted(merged[key]);
|
|
265
|
+
return merged;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function emptyResult(pageId) {
|
|
269
|
+
const sourceContracts = extractSourceContracts([]);
|
|
270
|
+
const payload = {
|
|
271
|
+
schema_version: CONTRACT_CALLS_SCHEMA_VERSION,
|
|
272
|
+
page_id: pageId,
|
|
273
|
+
calls: [],
|
|
274
|
+
targets: [],
|
|
275
|
+
dispositions: [],
|
|
276
|
+
deferred: [],
|
|
277
|
+
omitted: [],
|
|
278
|
+
source_contracts: sourceContracts,
|
|
279
|
+
counts: {
|
|
280
|
+
calls: 0, kept: 0, deferred: 0, not_contract: 0,
|
|
281
|
+
reviewed_scope: 0, contract_path: 0, omitted: 0,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
payload.digest = stableDigest(payload);
|
|
285
|
+
return payload;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function reviewedFiles(entry, requiredLocators = []) {
|
|
289
|
+
const files = new Set();
|
|
290
|
+
const add = value => {
|
|
291
|
+
const locator = normalizeLocator(value);
|
|
292
|
+
if (locator !== null) files.add(locator);
|
|
293
|
+
};
|
|
294
|
+
add(entry?.resolvedFile);
|
|
295
|
+
for (const locator of entry?.composition ?? []) add(locator);
|
|
296
|
+
for (const locator of entry?.bodyInheritance ?? []) add(locator);
|
|
297
|
+
for (const locator of entry?.directInheritance ?? []) add(locator);
|
|
298
|
+
for (const unit of entry?.origin_units ?? []) add(unit?.resolvedFile);
|
|
299
|
+
for (const locator of requiredLocators) add(locator);
|
|
300
|
+
return [...files].sort(cmp);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function readText(cache, sourceProject, locator) {
|
|
304
|
+
if (cache.text.has(locator)) return cache.text.get(locator);
|
|
305
|
+
let text = null;
|
|
306
|
+
const canonical = canonicalSourcePath(locator, sourceProject);
|
|
307
|
+
if (canonical !== null) {
|
|
308
|
+
try {
|
|
309
|
+
if (!cache.rootReal) cache.rootReal = fs.realpathSync(sourceProject);
|
|
310
|
+
const file = path.resolve(sourceProject, canonical);
|
|
311
|
+
const real = fs.realpathSync(file);
|
|
312
|
+
if (real !== cache.rootReal && !real.startsWith(`${cache.rootReal}${path.sep}`)) {
|
|
313
|
+
cache.text.set(locator, null);
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
if (fs.statSync(real).size <= MAX_SOURCE_BYTES) {
|
|
317
|
+
text = fs.readFileSync(real, "utf8");
|
|
318
|
+
if (text.includes("\u0000")) text = null;
|
|
319
|
+
}
|
|
320
|
+
} catch {
|
|
321
|
+
text = null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
cache.text.set(locator, text);
|
|
325
|
+
return text;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function fileInfo(cache, sourceProject, locator) {
|
|
329
|
+
if (cache.files.has(locator)) return cache.files.get(locator);
|
|
330
|
+
const text = readText(cache, sourceProject, locator);
|
|
331
|
+
const info = text === null
|
|
332
|
+
? null
|
|
333
|
+
: {
|
|
334
|
+
classification: classifyContractSignals(text, locator),
|
|
335
|
+
contracts: fileContracts(text, locator),
|
|
336
|
+
};
|
|
337
|
+
cache.files.set(locator, info);
|
|
338
|
+
return info;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function callRows(cache, db, locator) {
|
|
342
|
+
if (cache.rows.has(locator)) return cache.rows.get(locator);
|
|
343
|
+
let rows = [];
|
|
344
|
+
try {
|
|
345
|
+
if (!cache.rowsStmt) {
|
|
346
|
+
cache.rowsStmt = db.prepare(`
|
|
347
|
+
SELECT n1.file_path AS from_file, n2.file_path AS target_file,
|
|
348
|
+
n2.name AS target_symbol, e.kind, e.line, e.col
|
|
349
|
+
FROM nodes n1
|
|
350
|
+
JOIN edges e ON e.source = n1.id
|
|
351
|
+
LEFT JOIN nodes n2 ON n2.id = e.target
|
|
352
|
+
WHERE n1.file_path = ? AND e.kind IN ('calls', 'instantiates')
|
|
353
|
+
ORDER BY e.line, e.col, e.kind, n2.name, n2.file_path
|
|
354
|
+
`);
|
|
355
|
+
}
|
|
356
|
+
rows = cache.rowsStmt.all(locator);
|
|
357
|
+
} catch {
|
|
358
|
+
rows = [];
|
|
359
|
+
}
|
|
360
|
+
cache.rows.set(locator, rows);
|
|
361
|
+
return rows;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function targetSortKey(target) {
|
|
365
|
+
const priority = Math.min(...(target.kinds ?? []).map(kind => KIND_PRIORITY.get(kind) ?? 99), 99);
|
|
366
|
+
return `${priority}\u0000${target.locator}`;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function callSortKey(call) {
|
|
370
|
+
return [
|
|
371
|
+
call.from, call.target ?? "", call.line ?? -1, call.col ?? -1,
|
|
372
|
+
call.kind ?? "", (call.signals ?? []).join(","),
|
|
373
|
+
].join("\u0000");
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Collect contract-only calls for one page.
|
|
378
|
+
*
|
|
379
|
+
* @param {object} args
|
|
380
|
+
* @param {import("node:sqlite").DatabaseSync|null} args.db
|
|
381
|
+
* @param {string} args.sourceProject
|
|
382
|
+
* @param {{page_id: string}} args.page
|
|
383
|
+
* @param {object} args.entry footprint entry
|
|
384
|
+
* @param {string[]} [args.requiredLocators] already-reviewed required evidence
|
|
385
|
+
* @param {number} [args.maxTargets]
|
|
386
|
+
* @param {{rows?: Map, text?: Map}} [args.cache]
|
|
387
|
+
*/
|
|
388
|
+
export function collectContractCalls({
|
|
389
|
+
db = null,
|
|
390
|
+
sourceProject,
|
|
391
|
+
page,
|
|
392
|
+
entry,
|
|
393
|
+
requiredLocators = [],
|
|
394
|
+
maxTargets = DEFAULT_MAX_CONTRACT_TARGETS,
|
|
395
|
+
isExcludedTarget = null,
|
|
396
|
+
cache = { rows: new Map(), text: new Map(), files: new Map() },
|
|
397
|
+
} = {}) {
|
|
398
|
+
const pageId = page?.page_id ?? null;
|
|
399
|
+
if (!db || typeof db.prepare !== "function" || typeof sourceProject !== "string" || sourceProject === "") {
|
|
400
|
+
return emptyResult(pageId);
|
|
401
|
+
}
|
|
402
|
+
cache.files ??= new Map();
|
|
403
|
+
|
|
404
|
+
const scope = reviewedFiles(entry, requiredLocators);
|
|
405
|
+
const scopeSet = new Set(scope);
|
|
406
|
+
const targets = new Map();
|
|
407
|
+
const dispositions = new Map();
|
|
408
|
+
const deferred = [];
|
|
409
|
+
const calls = [];
|
|
410
|
+
const traversed = new Map();
|
|
411
|
+
const deferredWrappers = new Set();
|
|
412
|
+
const progressedFrom = new Set();
|
|
413
|
+
const markProgress = file => {
|
|
414
|
+
let current = file;
|
|
415
|
+
while (current && !progressedFrom.has(current)) {
|
|
416
|
+
progressedFrom.add(current);
|
|
417
|
+
current = traversed.get(current);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
const seenCalls = new Set();
|
|
421
|
+
let callCount = 0;
|
|
422
|
+
|
|
423
|
+
const pushDeferred = record => {
|
|
424
|
+
deferred.push({ ...record, from_scope: scopeSet.has(record.from) });
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const dispose = (locator, disposition, reason, extra = {}) => {
|
|
428
|
+
if (dispositions.has(locator)) return;
|
|
429
|
+
dispositions.set(locator, { locator, disposition, reason, ...extra });
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
const visited = new Set(scope);
|
|
433
|
+
const queue = scope.map(file => ({ file, depth: 0 }));
|
|
434
|
+
const enqueue = (locator, depth, from, deferredHint = false) => {
|
|
435
|
+
if (visited.has(locator)) return;
|
|
436
|
+
const maxDepth = TRAVERSAL_PATH_RE.test(locator) ? 3 : 1;
|
|
437
|
+
if (depth > maxDepth) {
|
|
438
|
+
const info = fileInfo(cache, sourceProject, locator);
|
|
439
|
+
if (info !== null && info.classification.kinds.length > 0) {
|
|
440
|
+
if (!deferred.some(record => record.target === locator)) {
|
|
441
|
+
pushDeferred({
|
|
442
|
+
from,
|
|
443
|
+
target: locator,
|
|
444
|
+
target_symbol: null,
|
|
445
|
+
kind: "calls",
|
|
446
|
+
line: null,
|
|
447
|
+
col: null,
|
|
448
|
+
reason: "traversal-depth-limit",
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
dispositions.set(locator, {
|
|
452
|
+
locator,
|
|
453
|
+
disposition: "deferred",
|
|
454
|
+
reason: "traversal-depth-limit",
|
|
455
|
+
});
|
|
456
|
+
} else {
|
|
457
|
+
dispositions.set(locator, {
|
|
458
|
+
locator,
|
|
459
|
+
disposition: "not-contract",
|
|
460
|
+
reason: "traversal-depth-limit-no-contract",
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
visited.add(locator);
|
|
466
|
+
traversed.set(locator, from);
|
|
467
|
+
if (deferredHint) deferredWrappers.add(locator);
|
|
468
|
+
dispositions.set(locator, {
|
|
469
|
+
locator,
|
|
470
|
+
disposition: "contract-path",
|
|
471
|
+
reason: "wrapper-traversed",
|
|
472
|
+
});
|
|
473
|
+
queue.push({ file: locator, depth });
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
while (queue.length > 0) {
|
|
477
|
+
const { file: from, depth } = queue.shift();
|
|
478
|
+
for (const row of callRows(cache, db, from)) {
|
|
479
|
+
callCount += 1;
|
|
480
|
+
const target = normalizeLocator(row.target_file);
|
|
481
|
+
const targetSymbol = typeof row.target_symbol === "string" ? row.target_symbol : null;
|
|
482
|
+
const kind = row.kind ?? "calls";
|
|
483
|
+
|
|
484
|
+
if (target === null) {
|
|
485
|
+
pushDeferred({
|
|
486
|
+
from, target: null, target_symbol: targetSymbol, kind,
|
|
487
|
+
line: Number.isInteger(row.line) ? row.line : null,
|
|
488
|
+
col: Number.isInteger(row.col) ? row.col : null,
|
|
489
|
+
reason: "unresolved-call-target",
|
|
490
|
+
});
|
|
491
|
+
markProgress(from);
|
|
492
|
+
if (targetSymbol !== null) {
|
|
493
|
+
dispose(`symbol:${targetSymbol}`, "deferred", "unresolved-call-target", {
|
|
494
|
+
target_symbol: targetSymbol,
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
if (target === from || EXCLUDED_TARGET_RE.test(target)) continue;
|
|
500
|
+
if (typeof isExcludedTarget === "function" && isExcludedTarget(target)) {
|
|
501
|
+
dispose(target, "not-contract", "runtime-source");
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
if (scopeSet.has(target)) {
|
|
505
|
+
markProgress(from);
|
|
506
|
+
dispose(target, "reviewed-scope", "already-reviewed-source-unit");
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const info = fileInfo(cache, sourceProject, target);
|
|
511
|
+
if (info === null) {
|
|
512
|
+
pushDeferred({
|
|
513
|
+
from, target, target_symbol: targetSymbol, kind,
|
|
514
|
+
line: Number.isInteger(row.line) ? row.line : null,
|
|
515
|
+
col: Number.isInteger(row.col) ? row.col : null,
|
|
516
|
+
reason: "unreadable-call-target",
|
|
517
|
+
});
|
|
518
|
+
markProgress(from);
|
|
519
|
+
dispose(target, "deferred", "unreadable-call-target", { target_symbol: targetSymbol });
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const targetDepth = depth + 1;
|
|
524
|
+
const targetMaxDepth = TRAVERSAL_PATH_RE.test(target) ? 3 : 2;
|
|
525
|
+
if (targetDepth > targetMaxDepth
|
|
526
|
+
&& info.classification.kinds.length > 0
|
|
527
|
+
&& !targets.has(target)) {
|
|
528
|
+
if (!deferred.some(record => record.target === target)) {
|
|
529
|
+
pushDeferred({
|
|
530
|
+
from, target, target_symbol: targetSymbol, kind,
|
|
531
|
+
line: Number.isInteger(row.line) ? row.line : null,
|
|
532
|
+
col: Number.isInteger(row.col) ? row.col : null,
|
|
533
|
+
reason: "traversal-depth-limit",
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
dispose(target, "deferred", "traversal-depth-limit", {
|
|
537
|
+
target_symbol: targetSymbol,
|
|
538
|
+
kinds: info.classification.kinds,
|
|
539
|
+
});
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const classification = info.classification;
|
|
544
|
+
const hint = callHint(target, targetSymbol);
|
|
545
|
+
if (classification.kinds.length === 0) {
|
|
546
|
+
const delegates = callRows(cache, db, target).length > 0;
|
|
547
|
+
if (hint && delegates) {
|
|
548
|
+
pushDeferred({
|
|
549
|
+
from, target, target_symbol: targetSymbol, kind,
|
|
550
|
+
line: Number.isInteger(row.line) ? row.line : null,
|
|
551
|
+
col: Number.isInteger(row.col) ? row.col : null,
|
|
552
|
+
reason: "contract-target-unclassified",
|
|
553
|
+
});
|
|
554
|
+
dispose(target, "deferred", "contract-target-unclassified", {
|
|
555
|
+
target_symbol: targetSymbol,
|
|
556
|
+
signals: classification.signals,
|
|
557
|
+
kinds: classification.kinds,
|
|
558
|
+
});
|
|
559
|
+
enqueue(target, depth + 1, from, true);
|
|
560
|
+
} else if (delegates) {
|
|
561
|
+
enqueue(target, depth + 1, from, false);
|
|
562
|
+
} else { dispose(target, "not-contract", "leaf-no-delegation", {
|
|
563
|
+
target_symbol: targetSymbol,
|
|
564
|
+
signals: classification.signals,
|
|
565
|
+
kinds: classification.kinds,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
markProgress(from);
|
|
572
|
+
if (!targets.has(target)) {
|
|
573
|
+
targets.set(target, {
|
|
574
|
+
locator: target,
|
|
575
|
+
target_symbol: targetSymbol,
|
|
576
|
+
platform: classification.platform,
|
|
577
|
+
kinds: [...classification.kinds],
|
|
578
|
+
signals: [...classification.signals],
|
|
579
|
+
call_sites: [],
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
const targetRecord = targets.get(target);
|
|
583
|
+
targetRecord.kinds = [...new Set([...targetRecord.kinds, ...classification.kinds])].sort(cmp);
|
|
584
|
+
targetRecord.signals = [...new Set([...targetRecord.signals, ...classification.signals])].sort(cmp);
|
|
585
|
+
targetRecord.call_sites.push({
|
|
586
|
+
from,
|
|
587
|
+
kind,
|
|
588
|
+
line: Number.isInteger(row.line) ? row.line : null,
|
|
589
|
+
col: Number.isInteger(row.col) ? row.col : null,
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
const callKey = `${from}\u0000${target}\u0000${targetSymbol ?? ""}\u0000${row.line ?? ""}\u0000${row.col ?? ""}\u0000${kind}`;
|
|
593
|
+
if (!seenCalls.has(callKey)) {
|
|
594
|
+
seenCalls.add(callKey);
|
|
595
|
+
calls.push({
|
|
596
|
+
from, target, target_symbol: targetSymbol, kind,
|
|
597
|
+
line: Number.isInteger(row.line) ? row.line : null,
|
|
598
|
+
col: Number.isInteger(row.col) ? row.col : null,
|
|
599
|
+
kinds: [...classification.kinds],
|
|
600
|
+
signals: [...classification.signals],
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
for (const target of targets.values()) {
|
|
607
|
+
target.call_sites.sort((a, b) => cmp(
|
|
608
|
+
`${a.from}\u0000${a.line ?? -1}\u0000${a.col ?? -1}\u0000${a.kind}`,
|
|
609
|
+
`${b.from}\u0000${b.line ?? -1}\u0000${b.col ?? -1}\u0000${b.kind}`,
|
|
610
|
+
));
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const ranked = [...targets.values()].sort((a, b) => cmp(targetSortKey(a), targetSortKey(b)));
|
|
614
|
+
const kept = ranked.slice(0, Math.max(0, maxTargets));
|
|
615
|
+
const omitted = ranked.slice(Math.max(0, maxTargets));
|
|
616
|
+
for (const target of kept) {
|
|
617
|
+
dispose(target.locator, "kept", "contract-signal", {
|
|
618
|
+
target_symbol: target.target_symbol,
|
|
619
|
+
kinds: target.kinds,
|
|
620
|
+
signals: target.signals,
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
for (const target of omitted) {
|
|
624
|
+
dispose(target.locator, "omitted", "contract-evidence-limit", {
|
|
625
|
+
target_symbol: target.target_symbol,
|
|
626
|
+
kinds: target.kinds,
|
|
627
|
+
signals: target.signals,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// A wrapper that led to kept/deferred evidence is not itself a dead end.
|
|
632
|
+
// A dead-end *hinted* wrapper downgrades back to deferred and keeps its
|
|
633
|
+
// record; a dead-end traversal-only wrapper is simply not a contract.
|
|
634
|
+
for (const [locator, from] of traversed) {
|
|
635
|
+
if (progressedFrom.has(locator)) continue;
|
|
636
|
+
const existing = dispositions.get(locator);
|
|
637
|
+
if (!deferredWrappers.has(locator)) {
|
|
638
|
+
dispositions.set(locator, {
|
|
639
|
+
locator,
|
|
640
|
+
disposition: "not-contract",
|
|
641
|
+
reason: "no-contract-signal-after-traversal",
|
|
642
|
+
});
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
dispositions.set(locator, {
|
|
646
|
+
locator,
|
|
647
|
+
disposition: "deferred",
|
|
648
|
+
reason: "contract-target-unclassified",
|
|
649
|
+
...(existing?.target_symbol ? { target_symbol: existing.target_symbol } : {}),
|
|
650
|
+
});
|
|
651
|
+
if (!deferred.some(record => record.target === locator)) {
|
|
652
|
+
pushDeferred({
|
|
653
|
+
from,
|
|
654
|
+
target: locator,
|
|
655
|
+
target_symbol: null,
|
|
656
|
+
kind: "calls",
|
|
657
|
+
line: null,
|
|
658
|
+
col: null,
|
|
659
|
+
reason: "contract-target-unclassified",
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const deferredCalls = deferred
|
|
664
|
+
.filter(record => record.target === null
|
|
665
|
+
|| !traversed.has(record.target)
|
|
666
|
+
|| deferredWrappers.has(record.target))
|
|
667
|
+
.filter(record => !(record.target !== null
|
|
668
|
+
&& traversed.has(record.target)
|
|
669
|
+
&& progressedFrom.has(record.target)))
|
|
670
|
+
.sort((a, b) => cmp(
|
|
671
|
+
`${a.from}\u0000${a.target ?? ""}\u0000${a.target_symbol ?? ""}\u0000${a.reason}\u0000${a.line ?? -1}\u0000${a.col ?? -1}`,
|
|
672
|
+
`${b.from}\u0000${b.target ?? ""}\u0000${b.target_symbol ?? ""}\u0000${b.reason}\u0000${b.line ?? -1}\u0000${b.col ?? -1}`,
|
|
673
|
+
));
|
|
674
|
+
|
|
675
|
+
const keptSet = new Set(kept.map(target => target.locator));
|
|
676
|
+
const keptCalls = calls
|
|
677
|
+
.filter(call => keptSet.has(call.target))
|
|
678
|
+
.sort((a, b) => cmp(callSortKey(a), callSortKey(b)));
|
|
679
|
+
|
|
680
|
+
const inventoryFiles = new Set([
|
|
681
|
+
...kept.map(target => target.locator),
|
|
682
|
+
...omitted.map(target => target.locator),
|
|
683
|
+
...visited,
|
|
684
|
+
]);
|
|
685
|
+
const contracts = [];
|
|
686
|
+
for (const locator of [...inventoryFiles].sort(cmp)) {
|
|
687
|
+
if (typeof isExcludedTarget === "function" && isExcludedTarget(locator)) continue;
|
|
688
|
+
const info = fileInfo(cache, sourceProject, locator);
|
|
689
|
+
if (info !== null) contracts.push(info.contracts);
|
|
690
|
+
}
|
|
691
|
+
const sourceContracts = extractSourceContracts(contracts);
|
|
692
|
+
|
|
693
|
+
const dispositionList = [...dispositions.values()].sort((a, b) => cmp(a.locator, b.locator));
|
|
694
|
+
const payload = {
|
|
695
|
+
schema_version: CONTRACT_CALLS_SCHEMA_VERSION,
|
|
696
|
+
page_id: pageId,
|
|
697
|
+
calls: keptCalls,
|
|
698
|
+
targets: kept,
|
|
699
|
+
dispositions: dispositionList,
|
|
700
|
+
deferred: deferredCalls,
|
|
701
|
+
omitted,
|
|
702
|
+
source_contracts: sourceContracts,
|
|
703
|
+
counts: {
|
|
704
|
+
calls: callCount,
|
|
705
|
+
kept: kept.length,
|
|
706
|
+
deferred: dispositionList.filter(item => item.disposition === "deferred").length,
|
|
707
|
+
not_contract: dispositionList.filter(item => item.disposition === "not-contract").length,
|
|
708
|
+
reviewed_scope: dispositionList.filter(item => item.disposition === "reviewed-scope").length,
|
|
709
|
+
contract_path: dispositionList.filter(item => item.disposition === "contract-path").length,
|
|
710
|
+
omitted: omitted.length,
|
|
711
|
+
},
|
|
712
|
+
};
|
|
713
|
+
payload.digest = stableDigest(payload);
|
|
714
|
+
return payload;
|
|
715
|
+
}
|