@buaa_smat/hometrans 0.1.20 → 26.0.0-devecocli.3
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/LICENSE +21 -21
- package/agents/build-fixer.md +406 -0
- package/agents/code-reviewer.md +461 -496
- package/agents/model-render-worker.md +34 -0
- package/agents/model-worker.md +23 -0
- package/agents/specgen-worker.md +18 -0
- package/commands/hometrans.md +17 -0
- package/devecocli-plugin/common.ts +2203 -0
- package/devecocli-plugin/install.ts +61 -0
- package/devecocli-plugin/uninstall.ts +26 -0
- package/devecocli-plugin/update.ts +66 -0
- package/index.js +1418 -0
- package/package.json +81 -64
- package/platforms/atomcode/agents/build-fixer.frontmatter.md +6 -0
- package/platforms/atomcode/agents/code-reviewer.frontmatter.md +6 -0
- package/platforms/atomcode/agents/model-render-worker.frontmatter.md +6 -0
- package/platforms/atomcode/agents/model-worker.frontmatter.md +6 -0
- package/platforms/atomcode/agents/specgen-worker.frontmatter.md +6 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/deveco/agents/model-worker.frontmatter.md +5 -0
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +5 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/opencode/agents/model-worker.frontmatter.md +5 -0
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +5 -0
- package/plugin.jsonc +12 -0
- package/skills/a2h-app-migrate/SKILL.md +181 -0
- package/skills/a2h-app-migrate/references/config.example.json +27 -0
- package/skills/a2h-app-migrate/references/specs.example.json +19 -0
- package/skills/a2h-app-migrate/references/stage-map.md +33 -0
- package/skills/a2h-app-migrate/references/workflow.yaml +1600 -0
- package/skills/a2h-app-migrate/scripts/android_index.mjs +109 -0
- package/skills/a2h-app-migrate/scripts/check_arch_done.mjs +80 -0
- package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +95 -0
- package/skills/a2h-app-migrate/scripts/check_signing.mjs +152 -0
- package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +114 -0
- package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +277 -0
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +77 -0
- package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +147 -0
- package/skills/a2h-app-migrate/scripts/cli_values.mjs +32 -0
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1412 -0
- package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +651 -0
- package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +53 -0
- package/skills/a2h-app-migrate/scripts/json_io.mjs +35 -0
- package/skills/a2h-app-migrate/scripts/ledger.mjs +104 -0
- package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +288 -0
- package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +881 -0
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +205 -0
- package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +121 -0
- package/skills/a2h-app-migrate/scripts/run_dir.mjs +212 -0
- package/skills/a2h-app-migrate/scripts/spec_layout.mjs +30 -0
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +455 -0
- package/skills/a2h-app-migrate/test/test_android_index.mjs +80 -0
- package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
- package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
- package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +92 -0
- package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
- package/skills/a2h-app-migrate/test/test_entry_guards.mjs +93 -0
- package/skills/a2h-app-migrate/test/test_env_requirements.mjs +544 -0
- package/skills/a2h-app-migrate/test/test_finalize.mjs +89 -0
- package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
- package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
- package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +91 -0
- package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
- package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
- package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +109 -0
- package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +53 -0
- package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
- package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +144 -0
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +100 -0
- package/skills/a2h-app-migrate/test/test_run_dir.mjs +315 -0
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +133 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +133 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +158 -0
- package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +181 -0
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +53 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
- package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
- package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +39 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +168 -0
- package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
- package/skills/a2h-arch-generate/SKILL.md +375 -0
- package/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
- package/skills/a2h-arch-generate/examples/simple-conversion-android.md +103 -0
- package/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
- package/skills/a2h-arch-generate/examples/simple-conversion-uniapp.md +106 -0
- package/skills/{hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md → a2h-arch-generate/references/arkts-mvvm-v2.md} +1407 -1407
- package/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
- package/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
- package/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
- package/skills/a2h-arch-generate/references/clustering-guidance.md +33 -0
- package/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
- package/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
- package/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
- package/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
- package/skills/a2h-arch-generate/references/homegraph-workflow.md +120 -0
- package/skills/a2h-arch-generate/references/module-evidence-subagent.md +45 -0
- package/skills/a2h-arch-generate/references/reconciliation-model.md +204 -0
- package/skills/a2h-arch-generate/references/scope-policy.md +28 -0
- package/skills/a2h-arch-generate/references/semantic-review.md +65 -0
- package/skills/a2h-arch-generate/references/source-baseline.md +93 -0
- package/skills/a2h-arch-generate/references/source-ecosystems.md +54 -0
- package/skills/a2h-arch-generate/references/transformation-model.md +78 -0
- package/skills/a2h-arch-generate/scripts/check_module_staleness.mjs +284 -0
- package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +260 -0
- package/skills/a2h-arch-generate/scripts/compute_processing_order.mjs +325 -0
- package/skills/a2h-arch-generate/scripts/create_project.mjs +149 -0
- package/skills/a2h-arch-generate/scripts/dump_core_facts.mjs +151 -0
- package/skills/a2h-arch-generate/scripts/extract_core_components.mjs +167 -0
- package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +363 -0
- package/skills/a2h-arch-generate/scripts/generate_state.mjs +60 -0
- package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +326 -0
- package/skills/a2h-arch-generate/scripts/inspect_android_project.mjs +3739 -0
- package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +800 -0
- package/skills/a2h-arch-generate/scripts/inspect_project.mjs +251 -0
- package/skills/a2h-arch-generate/scripts/inspect_uniapp_project.mjs +809 -0
- package/skills/a2h-arch-generate/scripts/lib/py_compat.mjs +1454 -0
- package/skills/a2h-arch-generate/scripts/module_create/create.mjs +136 -0
- package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +636 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/build-profile.json5 +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/hvigorfile.ts +6 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/obfuscation-rules.txt +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/oh-package.json5 +10 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/applicationability/ApplicationAbility.ets +43 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/module.json5 +26 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/color.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/float.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/element/string.json +16 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/background.png +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/foreground.png +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/layered_image.json +7 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/mock/mock-config.json5 +2 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/ohosTest/module.json5 +11 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/test/LocalUnit.test.ets +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/Index.ets +1 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/build-profile.json5 +36 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/hvigorfile.ts +6 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/obfuscation-rules.txt +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/oh-package.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +19 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/module.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/float.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/resources/base/element/string.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/ohosTest/module.json5 +11 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/har/src/test/LocalUnit.test.ets +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/Index.ets +1 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/build-profile.json5 +36 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/consumer-rules.txt +0 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/hvigorfile.ts +6 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/obfuscation-rules.txt +23 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/oh-package.json5 +10 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +20 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/utils/Calc.ets +3 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/module.json5 +12 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/float.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/element/string.json +8 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/ohosTest/module.json5 +11 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/List.test.ets +5 -0
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/test/LocalUnit.test.ets +33 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
- package/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
- package/skills/a2h-arch-generate/scripts/resolve_android_stores.mjs +529 -0
- package/skills/a2h-arch-generate/scripts/scaffold_project.mjs +230 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
- package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1122 -0
- package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +191 -0
- package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
- package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
- package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +138 -0
- package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +829 -0
- package/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +937 -0
- package/skills/a2h-arch-generate/scripts/validate_homegraph_artifacts.mjs +542 -0
- package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +415 -0
- package/skills/a2h-arkts-logic-coder/SKILL.md +125 -0
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +6 -0
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +124 -0
- package/skills/a2h-arkts-logic-coder/scripts/check_module_scope.ts +224 -0
- package/skills/a2h-arkts-logic-coder/scripts/check_mvvm.ts +377 -0
- package/skills/a2h-arkts-logic-coder/scripts/stop_check_hook.ts +443 -0
- package/skills/a2h-arkts-logic-coder/scripts/test_check_scripts.ts +211 -0
- package/skills/a2h-arkts-logic-coder/scripts/test_worktree_compat.ts +81 -0
- package/skills/a2h-batch-ui-align/SKILL.md +321 -0
- package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +81 -0
- package/skills/a2h-batch-ui-align/flowchart.html +271 -0
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +572 -0
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +139 -0
- package/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -2533
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +558 -555
- package/skills/{hmos-incremental-ui-align/references → a2h-batch-ui-align/references/mappings}/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243 → a2h-batch-ui-align/references/mvvm}//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -206
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -373
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -158
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -750
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -1704
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -1012
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -164
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -840
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -856
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -83
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -294
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -1407
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -1220
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -47
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -133
- package/skills/{hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2 → a2h-batch-ui-align/references/mvvm-v2}//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -840
- package/skills/a2h-batch-ui-align/references/source-only-tier.md +32 -0
- package/skills/a2h-batch-ui-align/references/step3-capture.md +214 -0
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +196 -0
- package/skills/a2h-batch-ui-align/references/step5-convert.md +205 -0
- package/skills/a2h-batch-ui-align/scripts/agent_cli.mjs +572 -0
- package/skills/{hmos-batch-ui-align → a2h-batch-ui-align}/scripts/android_parse_fast.ts +246 -39
- package/skills/a2h-batch-ui-align/scripts/answers_check.mjs +86 -0
- package/skills/a2h-batch-ui-align/scripts/arkts_static_check.ts +3858 -0
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +1675 -0
- package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
- package/skills/a2h-batch-ui-align/scripts/detach.mjs +258 -0
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1644 -0
- package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
- package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +166 -0
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1627 -0
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1869 -0
- package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +696 -0
- package/skills/a2h-batch-ui-align/scripts/harmony_index.mjs +218 -0
- package/skills/a2h-batch-ui-align/scripts/host_env.mjs +208 -0
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1229 -0
- package/skills/a2h-batch-ui-align/scripts/occlusion.mjs +141 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1179 -0
- package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1036 -0
- package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +217 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +253 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +241 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +341 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +445 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +356 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +290 -0
- package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +74 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +564 -0
- package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +241 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1451 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
- package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +170 -0
- package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
- package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +244 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +166 -0
- package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
- package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +219 -0
- package/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
- package/skills/a2h-coldstart-smoke-gate/SKILL.md +57 -0
- package/skills/a2h-dashboard-render/SKILL.md +65 -0
- package/skills/a2h-dashboard-render/references/artifact-contract.jsonc +147 -0
- package/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
- package/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
- package/skills/a2h-dashboard-render/references//347/234/213/346/235/277/350/257/264/346/230/216.md +83 -0
- package/skills/a2h-dashboard-render/scripts/artifact_contract.mjs +138 -0
- package/skills/a2h-dashboard-render/scripts/check-registry.mjs +87 -0
- package/skills/a2h-dashboard-render/scripts/dashboard.mjs +3215 -0
- package/skills/a2h-dashboard-render/scripts/device_capture.mjs +2010 -0
- package/skills/a2h-dashboard-render/scripts/page_capture.mjs +828 -0
- package/skills/a2h-dashboard-render/scripts/usage_readers.mjs +459 -0
- package/skills/a2h-dashboard-render/scripts/usage_worker.mjs +13 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
- package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +170 -0
- package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +182 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +64 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1172 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +251 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
- package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
- package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +303 -0
- package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
- package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +444 -0
- package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/SKILL.md +305 -293
- package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/arkts-strict-patterns.md +219 -219
- package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/known-patterns.md +157 -157
- package/skills/{hmos-fix-build-errors → a2h-fix-build-errors}/references/rdb-entity-pattern.md +131 -131
- package/skills/a2h-module-semantic-docs/SKILL.md +227 -0
- package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +168 -0
- package/skills/a2h-module-semantic-docs/scripts/lib/py_compat.mjs +688 -0
- package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +1021 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
- package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
- package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
- package/skills/a2h-resource-convert/SKILL.md +369 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/code-vector-icon-rules.md +335 -335
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/conversion-rules.md +687 -676
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/dependency-analysis-rules.md +410 -410
- package/skills/a2h-resource-convert/references/incremental-page-migration.md +251 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/lottie-conversion-rules.md +219 -219
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/resource-mapping-rules.md +493 -482
- package/skills/a2h-resource-convert/references/step3_5-dependency-filter.md +54 -0
- package/skills/a2h-resource-convert/references/step4-qualifiers-and-values.md +142 -0
- package/skills/a2h-resource-convert/references/step4-resource-types.md +249 -0
- package/skills/a2h-resource-convert/references/step5-reference-resolution.md +154 -0
- package/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/references/xml-drawable-to-svg-rules.md +630 -592
- package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/a2h_resource_convert.ts +2529 -2163
- package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +1072 -0
- package/skills/a2h-resource-convert/scripts/app_identity.ts +947 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/code_vector_icons.ts +607 -591
- package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +989 -0
- package/skills/a2h-resource-convert/scripts/extract_project_resources.ts +1464 -0
- package/skills/{hmos-resources-convert → a2h-resource-convert}/scripts/svg_fidelity_check.ts +632 -632
- package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
- package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
- package/skills/a2h-spec-design/SKILL.md +336 -0
- package/skills/a2h-spec-design/scripts/inspect_spec_design_inputs.mjs +146 -0
- package/skills/a2h-spec-design/scripts/lib/py_compat.mjs +481 -0
- package/skills/a2h-spec-design/scripts/move_spec_technical_reference.mjs +159 -0
- package/skills/a2h-spec-design/scripts/resolve_module_design.mjs +102 -0
- package/skills/a2h-spec-design/scripts/validate_spec_design_output.mjs +285 -0
- package/skills/a2h-spec-design/test/golden/inspect_happy.json +20 -0
- package/skills/a2h-spec-design/test/golden/move_design.md +18 -0
- package/skills/a2h-spec-design/test/golden/move_design_crlf.md +18 -0
- package/skills/a2h-spec-design/test/golden/move_spec.md +7 -0
- package/skills/a2h-spec-design/test/golden/resolve_cases.json +36 -0
- package/skills/a2h-spec-design/test/golden/validate_issue_file.md +12 -0
- package/skills/a2h-spec-design/test/golden/validate_issues.json +57 -0
- package/skills/a2h-spec-design/test/test_spec_design_scripts.mjs +381 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +228 -0
- package/skills/a2h-spec-design-pipeline/package.json +4 -0
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +63 -0
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +69 -0
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +24 -0
- package/skills/a2h-spec-design-pipeline/references/initialization.md +57 -0
- package/skills/a2h-spec-design-pipeline/references/merge-queue.md +21 -0
- package/skills/a2h-spec-design-pipeline/references/scripts.md +27 -0
- package/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +21 -0
- package/skills/a2h-spec-design-pipeline/scripts/atomic_write.ts +42 -0
- package/skills/a2h-spec-design-pipeline/scripts/audit_claims.ts +252 -0
- package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +77 -0
- package/skills/a2h-spec-design-pipeline/scripts/deps_ready.ts +195 -0
- package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +651 -0
- package/skills/a2h-spec-design-pipeline/scripts/git_baseline.ts +124 -0
- package/skills/a2h-spec-design-pipeline/scripts/inflight.mjs +944 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/bgcli.mjs +95 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +502 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_waves.ts +475 -0
- package/skills/a2h-spec-design-pipeline/scripts/reconcile.mjs +218 -0
- package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +164 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_atomic_write.ts +44 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_audit_claims.ts +301 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_bgcli.mjs +64 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_branch_landed.ts +87 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_deps_ready.ts +265 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +675 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_git_baseline.ts +105 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_inflight.mjs +452 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +375 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_waves.ts +561 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_reconcile.mjs +182 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +138 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_watchdog.mjs +289 -0
- package/skills/a2h-spec-design-pipeline/scripts/watchdog.mjs +441 -0
- package/skills/a2h-spec-generate/SKILL.md +285 -0
- package/skills/a2h-spec-generate/package.json +9 -0
- package/skills/a2h-spec-generate/references/batch-mode.md +151 -0
- package/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +114 -0
- package/skills/a2h-spec-generate/references/input-formats.md +27 -0
- package/skills/a2h-spec-generate/references/library-evidence.md +3 -0
- package/skills/a2h-spec-generate/references/method-discipline.md +64 -0
- package/skills/a2h-spec-generate/references/optional-gates.json +45 -0
- package/skills/a2h-spec-generate/references/recall-guide.md +83 -0
- package/skills/a2h-spec-generate/references/recall-terse.md +3 -0
- package/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
- package/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
- package/skills/a2h-spec-generate/references/review-checklist.md +21 -0
- package/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
- package/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
- package/skills/a2h-spec-generate/references/spec-samples.md +65 -0
- package/skills/a2h-spec-generate/references/specs.schema.json +79 -0
- package/skills/a2h-spec-generate/references/synthesis-rules.md +143 -0
- package/skills/a2h-spec-generate/references/transfer-file.md +5 -0
- package/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
- package/skills/a2h-spec-generate/references/worker-rules.md +126 -0
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +514 -0
- package/skills/a2h-spec-generate/scripts/check_spec.ts +361 -0
- package/skills/a2h-spec-generate/scripts/collect-specs.mjs +470 -0
- package/skills/a2h-spec-generate/scripts/detect-project.mjs +271 -0
- package/skills/a2h-spec-generate/scripts/ensure-index.mjs +188 -0
- package/skills/a2h-spec-generate/scripts/feature-stem.mjs +150 -0
- package/skills/a2h-spec-generate/scripts/inspect-uniapp.mjs +733 -0
- package/skills/{hmos-spec-generate → a2h-spec-generate}/scripts/parse_requirements.ts +515 -515
- package/skills/a2h-spec-generate/scripts/prepare-facts.mjs +307 -0
- package/skills/a2h-spec-generate/scripts/publication-verdict.mjs +171 -0
- package/skills/a2h-spec-generate/scripts/publish-specs.mjs +280 -0
- package/skills/a2h-spec-generate/scripts/render-tasks.mjs +399 -0
- package/skills/a2h-spec-generate/scripts/report.mjs +132 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/dashboard.html +149 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-api.js +49 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-code-view.js +140 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-format.js +16 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-handoff.js +42 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-splitters.js +78 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-state.js +47 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-tree.js +194 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz-virtual-list.js +118 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.css +245 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.html +99 -0
- package/skills/a2h-spec-generate/scripts/reqgen/assets/viz.js +220 -0
- package/skills/a2h-spec-generate/scripts/reqgen/package-lock.json +47 -0
- package/skills/a2h-spec-generate/scripts/reqgen/package.json +23 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/agent-render/serve.ts +95 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/callback-call-sites.ts +82 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/area-ownership.ts +496 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/callback-flow.ts +386 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/index.ts +24 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/index.ts +22 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1270 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/index.ts +10 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/projection.ts +804 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/render-projection.ts +51 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/android-interaction-registry.ts +286 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/builder.ts +453 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/compose-api-registry.ts +526 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/source-facts/index.ts +15 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/connector/index.ts +1 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/connector/utg-inbound.ts +763 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/area-graph.ts +383 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/artifact.ts +68 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/common.ts +88 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/diagnostic.ts +64 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/gap-audit.ts +113 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/index.ts +12 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/name-traceability.ts +108 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/raw-fact.ts +377 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/req-model.ts +238 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/run.ts +134 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/semantic-completeness.ts +35 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/source-facts.ts +48 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/contracts/utg.ts +133 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/core/output-guard.ts +42 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/core/stable-id.ts +118 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/cross-area-tally-cli.ts +179 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dashboard-cli.ts +188 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dump/dump.ts +1184 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dump/index.ts +1 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/dump-cli.ts +373 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1014 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-output.ts +32 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +142 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +312 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +310 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +685 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/graph/paths.ts +575 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/homegraph-cli.ts +50 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/android-resource-resolver.ts +391 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/androidx-preference-contracts.ts +44 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +640 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/cross-area.ts +207 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/finalizer.ts +1297 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/identity.ts +186 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/index.ts +16 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/planner.ts +312 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/preference-enrichment.ts +793 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/raw-facts.ts +355 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/rules.ts +271 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/scanner.ts +666 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/schema.ts +365 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/stable-key.ts +144 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +301 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/uniapp-utg-adapter.ts +543 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/xml-adapter.ts +262 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/assemble.ts +2079 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +157 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +809 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/index.ts +17 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/io.ts +165 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +806 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/query.ts +360 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/seeds.ts +218 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/spec-bindings-sidecar.ts +240 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +359 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/model-cli.ts +500 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/index.ts +7 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/pipeline/output.ts +307 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +172 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/index.ts +1 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-cov/source-cov.ts +176 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/area-graph.ts +490 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/index.ts +23 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-model.ts +957 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +248 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/semantic-area-graph.ts +1600 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/types.ts +10 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/artifact-data.ts +201 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-api.ts +74 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-code-view.ts +180 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-format.ts +18 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-handoff.ts +55 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-splitters.ts +78 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-state.ts +66 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-tree.ts +232 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz-virtual-list.ts +179 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/client/viz.ts +240 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/contracts.d.ts +86 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/index.ts +3 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/server.ts +239 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz/source-project.ts +316 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/viz-cli.ts +200 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +290 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1323 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +574 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +831 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +548 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +396 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +298 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
- package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.json +16 -0
- package/skills/a2h-spec-generate/scripts/reqgen/tsconfig.viz-client.json +12 -0
- package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.txt +22 -22
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +632 -0
- package/skills/a2h-spec-generate/test/check-spec.test.ts +200 -0
- package/skills/a2h-spec-generate/test/collect-specs.test.mjs +538 -0
- package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
- package/skills/a2h-spec-generate/test/ensure-index.test.mjs +45 -0
- package/skills/a2h-spec-generate/test/feature-stem.test.mjs +147 -0
- package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
- package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
- package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
- package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
- package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
- package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +157 -0
- package/skills/a2h-spec-generate/test/publish-specs.test.mjs +282 -0
- package/skills/a2h-spec-generate/test/render-tasks.test.mjs +593 -0
- package/skills/a2h-utg-explorer/SKILL.md +120 -0
- package/skills/a2h-utg-explorer/assets/final_viewer.html +64 -0
- package/skills/a2h-utg-explorer/assets/u2.LICENSE +21 -0
- package/skills/a2h-utg-explorer/assets/u2.NOTICE +25 -0
- package/skills/a2h-utg-explorer/assets/u2.jar +0 -0
- package/skills/a2h-utg-explorer/references/architecture.md +270 -0
- package/skills/a2h-utg-explorer/references/protocol.md +9 -0
- package/skills/a2h-utg-explorer/scripts/app_settings.mjs +143 -0
- package/skills/a2h-utg-explorer/scripts/audit.mjs +167 -0
- package/skills/a2h-utg-explorer/scripts/close_phases.mjs +66 -0
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +749 -0
- package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +597 -0
- package/skills/a2h-utg-explorer/scripts/device_health.mjs +227 -0
- package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +276 -0
- package/skills/a2h-utg-explorer/scripts/evidence.mjs +108 -0
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +428 -0
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +89 -0
- package/skills/a2h-utg-explorer/scripts/plan.mjs +258 -0
- package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +170 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +467 -0
- package/skills/a2h-utg-explorer/scripts/recover_b.mjs +542 -0
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +369 -0
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +203 -0
- package/skills/a2h-utg-explorer/scripts/report.mjs +143 -0
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +844 -0
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +137 -0
- package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
- package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
- package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +243 -0
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +223 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +88 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
- package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +136 -0
- package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
- package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
- package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +251 -0
- package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +42 -0
- package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +162 -0
- package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
- package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +204 -0
- package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +355 -0
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +267 -0
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
- package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +453 -0
- package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +131 -0
- package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
- package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
- package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
- package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
- package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
- package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
- package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/_device_io.mjs +244 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/_py.mjs +2097 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +1231 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/attest.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/chain.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/coverage.mjs +89 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/device_lock.mjs +46 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1200 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +1558 -0
- package/skills/a2h-utg-explorer/scripts/variant.mjs +75 -0
- package/skills/a2h-utg-explorer/scripts/worklist_parts.mjs +122 -0
- package/skills/a2h-utg-static/SKILL.md +361 -0
- package/skills/a2h-utg-static/config.json +19 -0
- package/skills/a2h-utg-static/references/extractors.md +217 -0
- package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
- package/skills/a2h-utg-static/references/view-interactions.md +215 -0
- package/skills/a2h-utg-static/scripts/_graph.mjs +361 -0
- package/skills/a2h-utg-static/scripts/_py.mjs +2177 -0
- package/skills/a2h-utg-static/scripts/_spawn.mjs +45 -0
- package/skills/a2h-utg-static/scripts/activity_nav.mjs +738 -0
- package/skills/a2h-utg-static/scripts/activity_widgets.mjs +254 -0
- package/skills/a2h-utg-static/scripts/adapter_nav.mjs +229 -0
- package/skills/a2h-utg-static/scripts/androidfragment_nav.mjs +208 -0
- package/skills/a2h-utg-static/scripts/assemble.mjs +2065 -0
- package/skills/a2h-utg-static/scripts/audit.mjs +268 -0
- package/skills/a2h-utg-static/scripts/carry_answers.mjs +201 -0
- package/skills/a2h-utg-static/scripts/click_paths.mjs +594 -0
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +226 -0
- package/skills/a2h-utg-static/scripts/compose_merge.mjs +263 -0
- package/skills/a2h-utg-static/scripts/compose_nav.mjs +1216 -0
- package/skills/a2h-utg-static/scripts/compose_navbar_nav.mjs +238 -0
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +2760 -0
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +365 -0
- package/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
- package/skills/a2h-utg-static/scripts/dialog_listener_nav.mjs +237 -0
- package/skills/a2h-utg-static/scripts/dialogshow_nav.mjs +308 -0
- package/skills/a2h-utg-static/scripts/fragfactory_nav.mjs +170 -0
- package/skills/a2h-utg-static/scripts/fragment_nav.mjs +1136 -0
- package/skills/a2h-utg-static/scripts/guard_subjects.mjs +162 -0
- package/skills/a2h-utg-static/scripts/hg_query.mjs +137 -0
- package/skills/a2h-utg-static/scripts/host_resolve.mjs +393 -0
- package/skills/a2h-utg-static/scripts/hybrid_bundle.mjs +165 -0
- package/skills/a2h-utg-static/scripts/hybrid_pages.mjs +713 -0
- package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +660 -0
- package/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
- package/skills/a2h-utg-static/scripts/io_utils.mjs +59 -0
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +864 -0
- package/skills/a2h-utg-static/scripts/launch_extras.mjs +91 -0
- package/skills/a2h-utg-static/scripts/layout_resolve.mjs +148 -0
- package/skills/a2h-utg-static/scripts/manifest.mjs +483 -0
- package/skills/a2h-utg-static/scripts/measure/measure_corpus.mjs +297 -0
- package/skills/a2h-utg-static/scripts/measure/measure_guards.mjs +98 -0
- package/skills/a2h-utg-static/scripts/media_browse_nav.mjs +356 -0
- package/skills/a2h-utg-static/scripts/menu_nav.mjs +603 -0
- package/skills/a2h-utg-static/scripts/navactions_nav.mjs +255 -0
- package/skills/a2h-utg-static/scripts/nl_hints.mjs +453 -0
- package/skills/a2h-utg-static/scripts/orphan_overlay_nav.mjs +89 -0
- package/skills/a2h-utg-static/scripts/phase_plan.mjs +108 -0
- package/skills/a2h-utg-static/scripts/phase_planner.mjs +119 -0
- package/skills/a2h-utg-static/scripts/plaindialog_nav.mjs +411 -0
- package/skills/a2h-utg-static/scripts/preference_nav.mjs +761 -0
- package/skills/a2h-utg-static/scripts/preference_widgets.mjs +142 -0
- package/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
- package/skills/a2h-utg-static/scripts/registry_nav.mjs +288 -0
- package/skills/a2h-utg-static/scripts/run_pipeline.mjs +870 -0
- package/skills/a2h-utg-static/scripts/scope_utils.mjs +430 -0
- package/skills/a2h-utg-static/scripts/screen_merge.mjs +287 -0
- package/skills/a2h-utg-static/scripts/screen_nav.mjs +279 -0
- package/skills/a2h-utg-static/scripts/single_host_nav.mjs +291 -0
- package/skills/a2h-utg-static/scripts/starter_nav.mjs +198 -0
- package/skills/a2h-utg-static/scripts/state_guard.mjs +579 -0
- package/skills/a2h-utg-static/scripts/static_prior.mjs +904 -0
- package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
- package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
- package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
- package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +90 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
- package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
- package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
- package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
- package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +284 -0
- package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
- package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
- package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
- package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
- package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +119 -0
- package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
- package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
- package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +33 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
- package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
- package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
- package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
- package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
- package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
- package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
- package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
- package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
- package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
- package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
- package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
- package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
- package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
- package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
- package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
- package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
- package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
- package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
- package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
- package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1119 -0
- package/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
- package/skills/a2h-utg-static/scripts/utg_html.mjs +721 -0
- package/skills/a2h-utg-static/scripts/view_interactions.mjs +799 -0
- package/skills/a2h-utg-static/scripts/view_widgets.mjs +512 -0
- package/skills/a2h-utg-static/scripts/viewpage_nav.mjs +589 -0
- package/skills/a2h-utg-static/scripts/vm_nav.mjs +422 -0
- package/skills/a2h-utg-static/scripts/window_nav.mjs +240 -0
- package/skills/a2h-utg-static/scripts/worklist_parts.mjs +154 -0
- package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
- package/skills/a2h-utg-static/tools/package.json +3 -0
- package/README.md +0 -445
- package/agents/logic-coder.md +0 -224
- package/agents/logic-context-builder.md +0 -212
- package/agents/scripts/hmos-precheck/backends/arkts.mjs +0 -567
- package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +0 -159
- package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +0 -398
- package/agents/scripts/hmos-precheck/backends/codelinter.mjs +0 -250
- package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +0 -321
- package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +0 -247
- package/agents/scripts/hmos-precheck/core/config.mjs +0 -184
- package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +0 -20
- package/agents/scripts/hmos-precheck/core/process_adapter.mjs +0 -47
- package/agents/scripts/hmos-precheck/core/project_catalog.mjs +0 -50
- package/agents/scripts/hmos-precheck/core/result_projection.mjs +0 -147
- package/agents/scripts/hmos-precheck/core/scope_plan.mjs +0 -131
- package/agents/scripts/hmos-precheck/core/sdk_context.mjs +0 -67
- package/agents/scripts/hmos-precheck/docs/architecture.md +0 -37
- package/agents/scripts/hmos-precheck/docs/performance-optimization.md +0 -28
- package/agents/scripts/hmos-precheck/docs/upstream-reference.json +0 -19
- package/agents/scripts/hmos-precheck/docs/validation.md +0 -50
- package/agents/scripts/hmos-precheck/index.mjs +0 -17
- package/agents/scripts/hmos-precheck/invocation.mjs +0 -231
- package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +0 -32
- package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +0 -64
- package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +0 -59
- package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +0 -54
- package/agents/scripts/platform_query.mjs +0 -626
- package/agents/scripts/platform_query.test.mjs +0 -422
- package/agents/self-test-fixer.md +0 -298
- package/agents/self-tester.md +0 -55
- package/agents/test-case-generation-generator.md +0 -317
- package/agents/test-case-generation-validator.md +0 -231
- package/dist/cli/config-store.js +0 -310
- package/dist/cli/config.js +0 -44
- package/dist/cli/env-vars.js +0 -127
- package/dist/cli/index.js +0 -56
- package/dist/cli/init.js +0 -1187
- package/dist/cli/uninstall.js +0 -427
- package/dist/utils/regex.js +0 -8
- package/env-requirements.json +0 -179
- package/resource/choose_editor.png +0 -0
- package/resource/convert_pipeline_process.svg +0 -103
- package/resource/project_architecture.svg +0 -122
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.png +0 -0
- package/resource/set_sdk.png +0 -0
- package/resource/title_dark.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +0 -413
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +0 -661
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +0 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +0 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +0 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +0 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -903
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -355
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +0 -11
- package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +0 -206
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +0 -750
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +0 -840
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +0 -856
- package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +0 -294
- package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +0 -1220
- package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +0 -840
- package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +0 -1592
- package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +0 -752
- package/skills/hmos-convert-pipeline/SKILL.md +0 -486
- package/skills/hmos-incremental-ui-align/README.md +0 -251
- package/skills/hmos-incremental-ui-align/SKILL.md +0 -375
- package/skills/hmos-incremental-ui-align/diff_analysis.md +0 -53
- package/skills/hmos-incremental-ui-align/page_align.md +0 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +0 -38
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +0 -2089
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +0 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +0 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +0 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +0 -373
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +0 -158
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +0 -1704
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +0 -1012
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +0 -164
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +0 -83
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +0 -47
- package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +0 -74
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +0 -34
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +0 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +0 -555
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +0 -937
- package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +0 -343
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +0 -76
- package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +0 -977
- package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +0 -188
- package/skills/hmos-integration-test/README.md +0 -341
- package/skills/hmos-integration-test/SKILL.md +0 -464
- package/skills/hmos-integration-test/scripts/report-tool.ts +0 -791
- package/skills/hmos-integration-test/scripts/resolve-metadata-tool.ts +0 -125
- package/skills/hmos-integration-test/scripts/self-test-runner.ts +0 -756
- package/skills/hmos-integration-test/scripts/testcases-tool.ts +0 -239
- package/skills/hmos-resources-convert/SKILL.md +0 -891
- package/skills/hmos-spec-generate/SKILL.md +0 -404
- package/skills/hmos-test-case-generation/README.md +0 -241
- package/skills/hmos-test-case-generation/SKILL.md +0 -324
- package/skills/hmos-test-case-generation/references/contract.md +0 -315
- package/skills/hmos-test-case-generation/references/review-notes-template.md +0 -84
- package/skills/hmos-test-case-generation/references/ui-elements-schema.md +0 -142
- package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +0 -550
- package/skills/hmos-test-case-generation/tools/validate.ts +0 -1312
- package/tools/bfs-crawl/README.md +0 -73
- package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +0 -1662
- /package/{README.en.md → skills/a2h-arch-generate/scripts/module_create/har/consumer-rules.txt} +0 -0
- /package/skills/{hmos-spec-generate → a2h-spec-generate}/template/REQ.xlsx +0 -0
|
@@ -0,0 +1,2203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件生命周期脚本(install / uninstall / update)的公共逻辑。
|
|
3
|
+
*
|
|
4
|
+
* 这些脚本由外部工具直接以 `node devecocli-plugin/<cmd>.ts [--agent <name>] [--dir <path>]`
|
|
5
|
+
* 运行(Node >= 22.18 原生支持 TypeScript 类型擦除),因此只依赖 Node 内置模块,
|
|
6
|
+
* 且只使用可擦除的 TS 语法(不用 enum / namespace / 参数属性)。
|
|
7
|
+
*
|
|
8
|
+
* 参数:
|
|
9
|
+
* --agent <name> 目标智能体,必须是 plugin.jsonc 中 `agent` 列表里的名字;
|
|
10
|
+
* 旧版带空格的名字 claude code / deveco code 仍被接受,
|
|
11
|
+
* 由 canonicalAgentName 自动映射到 claude-code / deveco。
|
|
12
|
+
* 可重复传入,或用逗号分隔多个。各平台的 skills / agents /
|
|
13
|
+
* commands 目录按下方平台描述符独立解析(codex 支持 CODEX_HOME
|
|
14
|
+
* 环境变量;pi 的全局 skills 与子代理 profile 都在 ~/.pi 下
|
|
15
|
+
* (skills 在 ~/.pi/skills、profile 在 ~/.pi/agent/agents);
|
|
16
|
+
* dsh 无文件式 subagent,只装 skills)。
|
|
17
|
+
* --dir <path> 智能体的直接路径,即目标 skills / agents / commands 文件夹的父目录;
|
|
18
|
+
* 必须是已存在的目录。--dir 目标不识别平台,一律原样拷贝、不做转换。
|
|
19
|
+
* --project <path> 工程根目录,必须是已存在的目录;各智能体按工程级布局
|
|
20
|
+
* <project>/<agent 工程目录>/{skills,agents,commands} 安装
|
|
21
|
+
* (目录名默认 .<agent>,特例见 toProjectPlatform 的
|
|
22
|
+
* PROJECT_ROOT_NAME:trae-cn → .trae、claude-code → .claude;
|
|
23
|
+
* 其他平台特例:pi 忽略工程级 profile 等)。
|
|
24
|
+
* 与 --dir 互斥;可与 --agent 组合。
|
|
25
|
+
* --dry-run 只打印将要执行的动作,不写 / 不删任何文件(install / update 支持)。
|
|
26
|
+
* --verbose 打印逐目标的安装明细(汇总行 / 转换说明 / 校验结果);
|
|
27
|
+
* 默认静默——成功时无输出,仅校验 ERROR 仍打印到 stderr。
|
|
28
|
+
* 环境变量 HOMETRANS_PLUGIN_VERBOSE=1|true|yes 等效(deveco-cli
|
|
29
|
+
* 插件契约路径没有旗标可传,只能经环境变量开启,见 isVerboseEnv)。
|
|
30
|
+
*
|
|
31
|
+
* 同时指定 --agent 与 --project 时按工程级安装指定智能体;--agent 与 --dir
|
|
32
|
+
* 同时指定时分别处理;都不指定时处理 plugin.jsonc 中的全部智能体(跳过本机
|
|
33
|
+
* 未安装的;--project 下同样以"编辑器本机已安装"为判定)。
|
|
34
|
+
*
|
|
35
|
+
* 多平台适配(路径与 src/cli/config-store.ts 的 defaultEditors() 对齐):
|
|
36
|
+
* - skill frontmatter:allowed-tools 仅 pi / codebuddy / claude-code 原生支持
|
|
37
|
+
* (pi 侧做小写规范化并去掉 Agent/Task);argument-hint 仅 claude-code 保留,
|
|
38
|
+
* OpenCode 系(opencode / deveco)转写为 metadata 的 opencode/slash 以暴露
|
|
39
|
+
* 斜杠命令;其余非标顶层字段(type / domain 等)统一迁入标准 metadata 字段。
|
|
40
|
+
* - agent md:OpenCode 系原样透传(mode / permission 原生);claude-code /
|
|
41
|
+
* codebuddy / trae 把 permission 的 deny 项映射为 disallowedTools 黑名单;
|
|
42
|
+
* qoder / pi 映射为 tools 白名单;cursor 的 edit deny 映射 readonly;codex 转
|
|
43
|
+
* TOML(sandbox_mode 在自定义 agent 中不生效、不再写入;bash deny →
|
|
44
|
+
* features.shell_tool = false);atomcode 转为角色格式(permission + difficulty
|
|
45
|
+
* 必填,difficulty 统一 hard);dsh 无文件式 subagent,跳过。无法保留的语义
|
|
46
|
+
* 在安装日志中逐条说明。
|
|
47
|
+
* - command md:frontmatter 按平台字段矩阵
|
|
48
|
+
* 路由——description 全平台保留;argument-hint 仅 codebuddy / codex /
|
|
49
|
+
* claude-code;agent / subtask 仅 OpenCode 系原生(claude-code 把
|
|
50
|
+
* subtask: true 译为 context: fork);正文模板不动($ARGUMENTS / $1-$3
|
|
51
|
+
* 是全平台交集)。目录:trae 的全局命令目录 ~/.trae-cn/commands、pi 的
|
|
52
|
+
* prompt template 目录 ~/.pi/prompts 恢复安装;codex 命令转换为 skill
|
|
53
|
+
* 装入 skills/($ARGUMENTS 替换为参数说明,openai.yaml 关闭隐式调用);
|
|
54
|
+
* dsh 同样转 skill(原生键组合实现仅用户调用);cursor 命令全局装到
|
|
55
|
+
* ~/.cursor/commands、工程级 .cursor/commands(仅保留 description);
|
|
56
|
+
* atomcode 同样转 skill(每个 skill 自动成为 /<skill-name>,$ 菜单可
|
|
57
|
+
* 内联传参)。
|
|
58
|
+
* - 安装完成后对落盘文件按各平台规则做读回校验;仅当平台确实有该限制时
|
|
59
|
+
* 才检查 description 上限(如 OpenCode/Pi/DevEco 的 1024),超限仅输出
|
|
60
|
+
* WARN,不阻断安装,也不修改打包的源文件。WARN 与 PASS 明细仅
|
|
61
|
+
* --verbose / HOMETRANS_PLUGIN_VERBOSE=1 时输出;ERROR 始终输出(stderr,
|
|
62
|
+
* 独立运行模式下并以退出码 1 结束)。
|
|
63
|
+
*/
|
|
64
|
+
import fs from 'node:fs/promises';
|
|
65
|
+
import { existsSync, statSync } from 'node:fs';
|
|
66
|
+
import os from 'node:os';
|
|
67
|
+
import path from 'node:path';
|
|
68
|
+
import { fileURLToPath } from 'node:url';
|
|
69
|
+
|
|
70
|
+
/** 插件目录(本文件所在目录;打包形态下即包根 index.js 所在目录)。 */
|
|
71
|
+
export const PLUGIN_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
72
|
+
/**
|
|
73
|
+
* 包根目录(plugin.jsonc 所在目录)。
|
|
74
|
+
* 两种运行形态:
|
|
75
|
+
* - 打包形态(@buaa_smat/hometrans 包根的 index.js):本模块被 esbuild 打包
|
|
76
|
+
* 到包根,打包内容就在模块同级目录(见 scripts/build.js 的插件打包步骤);
|
|
77
|
+
* - 源码形态(node devecocli-plugin/<cmd>.ts):本文件在 devecocli-plugin/ 下,
|
|
78
|
+
* 包根在上级目录。
|
|
79
|
+
* 判定锚点为包根的 `plugin.jsonc`(或安装源 `skills/`):打包形态下
|
|
80
|
+
* index.js 与 plugin.jsonc / skills/ 同级;源码形态下本文件在 devecocli-plugin/
|
|
81
|
+
* 下,包根在上级目录。
|
|
82
|
+
*/
|
|
83
|
+
const looksLikePackageRoot = (dir: string): boolean =>
|
|
84
|
+
existsSync(path.join(dir, 'plugin.jsonc')) || existsSync(path.join(dir, 'skills'));
|
|
85
|
+
|
|
86
|
+
export const PACKAGE_ROOT = looksLikePackageRoot(PLUGIN_DIR)
|
|
87
|
+
? PLUGIN_DIR
|
|
88
|
+
: path.resolve(PLUGIN_DIR, '..');
|
|
89
|
+
/**
|
|
90
|
+
* 平台定义根目录(`platforms/<agent>/...`):
|
|
91
|
+
* - 源码 / 打包形态下与 plugin.jsonc 同级(本包必须随包发布 platforms/);
|
|
92
|
+
* - 若包内没有 platforms/,回退到本文件上级目录旁的 platforms/,便于
|
|
93
|
+
* 在仓库内直接以源码形态运行。
|
|
94
|
+
*/
|
|
95
|
+
export const PLATFORMS_ROOT = existsSync(path.join(PACKAGE_ROOT, 'platforms'))
|
|
96
|
+
? path.join(PACKAGE_ROOT, 'platforms')
|
|
97
|
+
: path.resolve(PLUGIN_DIR, '..', 'platforms');
|
|
98
|
+
/**
|
|
99
|
+
* 安装源根目录:仓库根(打包形态为包根)的 skills / agents / commands
|
|
100
|
+
* —— 根目录即 base,不再有 `platforms/base/` 镜像。
|
|
101
|
+
* 平台差异由 `platforms/<agent>/` 的 frontmatter / unique 补丁叠加。
|
|
102
|
+
*/
|
|
103
|
+
export const SKILLS_ROOT = path.join(PACKAGE_ROOT, 'skills');
|
|
104
|
+
export const AGENTS_ROOT = path.join(PACKAGE_ROOT, 'agents');
|
|
105
|
+
export const COMMANDS_ROOT = path.join(PACKAGE_ROOT, 'commands');
|
|
106
|
+
|
|
107
|
+
export interface PluginManifest {
|
|
108
|
+
id: string;
|
|
109
|
+
version: string;
|
|
110
|
+
name: string;
|
|
111
|
+
description: string;
|
|
112
|
+
publisher: string;
|
|
113
|
+
repo: string;
|
|
114
|
+
agent: string[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export class PluginError extends Error {}
|
|
118
|
+
|
|
119
|
+
/* ------------------------------------------------------------------ */
|
|
120
|
+
/* plugin.jsonc */
|
|
121
|
+
/* ------------------------------------------------------------------ */
|
|
122
|
+
|
|
123
|
+
/** 去掉 JSONC 中的注释与尾随逗号(跳过字符串内部,避免误伤 "https://")。 */
|
|
124
|
+
export function stripJsonc(text: string): string {
|
|
125
|
+
let out = '';
|
|
126
|
+
let i = 0;
|
|
127
|
+
while (i < text.length) {
|
|
128
|
+
const ch = text[i];
|
|
129
|
+
if (ch === '"') {
|
|
130
|
+
let j = i + 1;
|
|
131
|
+
while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1;
|
|
132
|
+
out += text.slice(i, j + 1);
|
|
133
|
+
i = j + 1;
|
|
134
|
+
} else if (ch === '/' && text[i + 1] === '/') {
|
|
135
|
+
while (i < text.length && text[i] !== '\n') i++;
|
|
136
|
+
} else if (ch === '/' && text[i + 1] === '*') {
|
|
137
|
+
const end = text.indexOf('*/', i + 2);
|
|
138
|
+
i = end < 0 ? text.length : end + 2;
|
|
139
|
+
} else {
|
|
140
|
+
out += ch;
|
|
141
|
+
i++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return out.replace(/,(\s*[}\]])/g, '$1');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export async function loadManifest(): Promise<PluginManifest> {
|
|
148
|
+
// plugin.jsonc 在包根(PACKAGE_ROOT):打包形态 = index.js 同级;源码形态 = 上级目录
|
|
149
|
+
const raw = await fs.readFile(path.join(PACKAGE_ROOT, 'plugin.jsonc'), 'utf-8');
|
|
150
|
+
return JSON.parse(stripJsonc(raw)) as PluginManifest;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* ------------------------------------------------------------------ */
|
|
154
|
+
/* YAML frontmatter 子集:解析与序列化 */
|
|
155
|
+
/* ------------------------------------------------------------------ */
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 只支持打包文件实际用到的 YAML 语法:顶层 `key: value`(裸值或引号值)、一层
|
|
159
|
+
* 嵌套 map(`key:` + 缩进 `subkey: value`,如 agent 的 permission)、块列表
|
|
160
|
+
* (`key:` + 缩进 `- item`,如 allowed-tools)。boolean 只在转换器构造时产生。
|
|
161
|
+
*/
|
|
162
|
+
export type FmValue = string | boolean | string[] | Record<string, string>;
|
|
163
|
+
export type Frontmatter = Record<string, FmValue>;
|
|
164
|
+
|
|
165
|
+
export interface ParsedMarkdown {
|
|
166
|
+
fm: Frontmatter;
|
|
167
|
+
/** frontmatter 结束标记之后的原文(含其后的空行),未解析 frontmatter 时为全文。 */
|
|
168
|
+
body: string;
|
|
169
|
+
hasFrontmatter: boolean;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** 去掉引号并反转义;裸值原样返回。 */
|
|
173
|
+
function parseScalar(v: string): string {
|
|
174
|
+
if (v.length >= 2 && v.startsWith('"') && v.endsWith('"')) {
|
|
175
|
+
return v.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
176
|
+
}
|
|
177
|
+
if (v.length >= 2 && v.startsWith("'") && v.endsWith("'")) {
|
|
178
|
+
return v.slice(1, -1).replace(/''/g, "'");
|
|
179
|
+
}
|
|
180
|
+
return v;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function parseFrontmatter(raw: string): ParsedMarkdown {
|
|
184
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(raw);
|
|
185
|
+
if (!m) return { fm: {}, body: raw, hasFrontmatter: false };
|
|
186
|
+
const fm: Frontmatter = {};
|
|
187
|
+
let parent: string | null = null;
|
|
188
|
+
for (const line of m[1].split(/\r?\n/)) {
|
|
189
|
+
if (!line.trim() || line.trim().startsWith('#')) continue;
|
|
190
|
+
const indented = line[0] === ' ' || line[0] === '\t';
|
|
191
|
+
const trimmed = line.trim();
|
|
192
|
+
// 块列表项:`- item`,归属最近的顶层 key
|
|
193
|
+
if (trimmed.startsWith('- ') && parent !== null) {
|
|
194
|
+
const item = parseScalar(trimmed.slice(2).trim());
|
|
195
|
+
const cur = fm[parent];
|
|
196
|
+
fm[parent] = Array.isArray(cur) ? [...cur, item] : [item];
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const idx = line.indexOf(':');
|
|
200
|
+
if (idx < 0) continue;
|
|
201
|
+
const key = line.slice(0, idx).trim();
|
|
202
|
+
const value = line.slice(idx + 1).trim();
|
|
203
|
+
if (!indented) {
|
|
204
|
+
parent = key;
|
|
205
|
+
if (value === '') {
|
|
206
|
+
// `key:` 可能是嵌套 map 也可能是块列表,先占位,由后续缩进行决定
|
|
207
|
+
if (!(key in fm)) fm[key] = {};
|
|
208
|
+
} else {
|
|
209
|
+
fm[key] = parseScalar(value);
|
|
210
|
+
}
|
|
211
|
+
} else if (parent !== null && value !== '') {
|
|
212
|
+
// 一层嵌套 map 的子键(如 permission.edit)
|
|
213
|
+
const cur = fm[parent];
|
|
214
|
+
const map: Record<string, string> =
|
|
215
|
+
Array.isArray(cur) || typeof cur !== 'object' || cur === undefined ? {} : cur;
|
|
216
|
+
map[key] = parseScalar(value);
|
|
217
|
+
fm[parent] = map;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return { fm, body: raw.slice(m[0].length), hasFrontmatter: true };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** 裸值仅限保守的安全字符集;布尔样式的字符串加引号避免被解析成布尔。 */
|
|
224
|
+
const BARE_SAFE = /^[A-Za-z0-9_][A-Za-z0-9_ ./+|=-]*$/;
|
|
225
|
+
const BOOL_LIKE = /^(true|false|yes|no|on|off|null|~)$/i;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 各平台 frontmatter 中语义为布尔的字段(subtask / disable-model-invocation /
|
|
229
|
+
* disable / hidden 等)。这些字段的 true/false 保持裸布尔输出——加引号会让
|
|
230
|
+
* YAML 解析成字符串,OpenCode 等平台的 schema 期望布尔。
|
|
231
|
+
*/
|
|
232
|
+
const NATIVE_BOOLEAN_KEYS = new Set([
|
|
233
|
+
'subtask',
|
|
234
|
+
'disable-model-invocation',
|
|
235
|
+
'user-invocable',
|
|
236
|
+
'disable',
|
|
237
|
+
'hidden',
|
|
238
|
+
'is_background',
|
|
239
|
+
'background',
|
|
240
|
+
'readonly',
|
|
241
|
+
]);
|
|
242
|
+
|
|
243
|
+
function formatScalar(key: string, v: string): string {
|
|
244
|
+
if (v === '') return '""';
|
|
245
|
+
if (NATIVE_BOOLEAN_KEYS.has(key) && /^(true|false)$/i.test(v)) return v.toLowerCase();
|
|
246
|
+
if (!BARE_SAFE.test(v) || BOOL_LIKE.test(v) || v !== v.trim()) {
|
|
247
|
+
return '"' + v.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
248
|
+
}
|
|
249
|
+
return v;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** 序列化为 `---\n...\n---\n` 块(末尾恰好一个换行,拼接 body 后与原文件结构一致)。 */
|
|
253
|
+
export function serializeFrontmatter(fm: Frontmatter): string {
|
|
254
|
+
const lines: string[] = ['---'];
|
|
255
|
+
for (const [key, value] of Object.entries(fm)) {
|
|
256
|
+
if (Array.isArray(value)) {
|
|
257
|
+
if (value.length === 0) {
|
|
258
|
+
lines.push(`${key}: []`);
|
|
259
|
+
} else {
|
|
260
|
+
lines.push(`${key}:`);
|
|
261
|
+
for (const item of value) lines.push(` - ${formatScalar(key, item)}`);
|
|
262
|
+
}
|
|
263
|
+
} else if (typeof value === 'boolean') {
|
|
264
|
+
lines.push(`${key}: ${value ? 'true' : 'false'}`);
|
|
265
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
266
|
+
const entries = Object.entries(value);
|
|
267
|
+
if (entries.length === 0) {
|
|
268
|
+
lines.push(`${key}: {}`);
|
|
269
|
+
} else {
|
|
270
|
+
lines.push(`${key}:`);
|
|
271
|
+
for (const [k, v] of entries) lines.push(` ${k}: ${formatScalar(k, v)}`);
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
lines.push(`${key}: ${formatScalar(key, value)}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
lines.push('---', '');
|
|
278
|
+
return lines.join('\n');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function asString(v: FmValue | undefined): string | undefined {
|
|
282
|
+
return typeof v === 'string' ? v : undefined;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function asRecord(v: FmValue | undefined): Record<string, string> {
|
|
286
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v) ? v : {};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** 非标字段迁入 metadata 时压平成字符串。 */
|
|
290
|
+
function fmValueToString(v: FmValue): string {
|
|
291
|
+
if (typeof v === 'string') return v;
|
|
292
|
+
if (typeof v === 'boolean') return v ? 'true' : 'false';
|
|
293
|
+
if (Array.isArray(v)) return v.join(', ');
|
|
294
|
+
return Object.entries(v)
|
|
295
|
+
.map(([k, val]) => `${k}=${val}`)
|
|
296
|
+
.join(', ');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* ------------------------------------------------------------------ */
|
|
300
|
+
/* 平台描述符 */
|
|
301
|
+
/* ------------------------------------------------------------------ */
|
|
302
|
+
|
|
303
|
+
/** subagent 定义在目标平台上的格式。 */
|
|
304
|
+
export type AgentFormat =
|
|
305
|
+
| 'passthrough' // OpenCode 系(opencode / deveco):mode / permission 原生支持
|
|
306
|
+
| 'claude' // Claude Code:permission deny -> disallowedTools
|
|
307
|
+
| 'codebuddy' // CodeBuddy:同 Claude 系黑名单
|
|
308
|
+
| 'cursor' // Cursor:edit deny -> readonly(无工具级黑名单)
|
|
309
|
+
| 'qoder' // Qoder:permission -> tools 白名单
|
|
310
|
+
| 'trae' // Trae:permission deny -> disallowedTools(无 Task 工具)
|
|
311
|
+
| 'pi-profile' // Pi simple-subagents profile:permission -> 小写 tools
|
|
312
|
+
| 'codex-toml' // Codex:md -> TOML
|
|
313
|
+
| 'atomcode-role' // AtomCode:角色格式(permission + difficulty 必填)
|
|
314
|
+
| 'none'; // DSH:无文件式 subagent,跳过
|
|
315
|
+
|
|
316
|
+
/** 旧版本插件安装过的位置;安装与卸载时顺带清理,避免新旧并存。 */
|
|
317
|
+
export interface LegacyDir {
|
|
318
|
+
skillsDir?: string;
|
|
319
|
+
agentsDir?: string;
|
|
320
|
+
commandsDir?: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface AgentPlatform {
|
|
324
|
+
/** plugin.jsonc `agent` 列表里的名字。 */
|
|
325
|
+
name: string;
|
|
326
|
+
/** 本机已安装检测目录(marker)。 */
|
|
327
|
+
markerDir: string;
|
|
328
|
+
/** 全局 skills 目录;null = 该平台无 skills 概念。 */
|
|
329
|
+
skillsDir: string | null;
|
|
330
|
+
/** subagent 定义目录;null = 该平台无文件式 subagent(跳过安装)。 */
|
|
331
|
+
agentsDir: string | null;
|
|
332
|
+
/** 斜杠命令目录;null = 不安装 commands。 */
|
|
333
|
+
commandsDir: string | null;
|
|
334
|
+
agentFormat: AgentFormat;
|
|
335
|
+
/** skill frontmatter 保留 allowed-tools(pi / codebuddy / claude-code 支持)。 */
|
|
336
|
+
skillKeepAllowedTools: boolean;
|
|
337
|
+
/** skill frontmatter 保留 argument-hint(仅 claude-code 原生支持)。 */
|
|
338
|
+
skillKeepArgumentHint: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* skill description 的硬上限(字符数)。只有真正存在该限制的平台才设置;
|
|
341
|
+
* 未设置 = 不做长度警告(如 Trae / Cursor / CodeBuddy / Qoder / Codex /
|
|
342
|
+
* AtomCode)。当前已知限制:OpenCode / Pi / DevEco = 1024。
|
|
343
|
+
*/
|
|
344
|
+
skillDescriptionLimit?: number;
|
|
345
|
+
/** 有 argument-hint 的 skill 写 metadata 的 opencode/slash(OpenCode 系暴露斜杠命令)。 */
|
|
346
|
+
skillSlashMetadata: boolean;
|
|
347
|
+
/** command md frontmatter 保留的字段。 */
|
|
348
|
+
commandKeepKeys: string[];
|
|
349
|
+
/** 无 commands 目录时的跳过说明(含平台等价机制)。 */
|
|
350
|
+
commandsSkipNote?: string;
|
|
351
|
+
/** 无 agents 目录时的跳过说明;缺省为"该平台无文件式 subagent"。 */
|
|
352
|
+
agentsSkipNote?: string;
|
|
353
|
+
/**
|
|
354
|
+
* 命令以 skill 形式装入 skills 目录(Codex:custom prompts 已弃用,官方
|
|
355
|
+
* 推荐 skills 承载)。为 true 时 commandsDir 无效。
|
|
356
|
+
*/
|
|
357
|
+
commandsAsSkills?: boolean;
|
|
358
|
+
/** --dir 目标:不识别平台,skills / agents 原样拷贝。 */
|
|
359
|
+
verbatim: boolean;
|
|
360
|
+
legacyDirs: LegacyDir[];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function home(...segments: string[]): string {
|
|
364
|
+
return path.join(os.homedir(), ...segments);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* 各平台的安装布局与转换策略。目录依据:
|
|
369
|
+
* - opencode / deveco:~/.config/{opencode,deveco}(deveco-code 基于 OpenCode;
|
|
370
|
+
* 与 src/cli/config-store.ts 的 defaultEditors() 一致);commands 的
|
|
371
|
+
* agent / subtask 字段为两平台原生
|
|
372
|
+
* - trae-cn:~/.trae-cn(Windows 官方即 %userprofile%/.trae-cn);全局命令
|
|
373
|
+
* 目录 ~/.trae-cn/commands
|
|
374
|
+
* - pi:全局 skills 在 ~/.pi/skills(pi 专属目录,不用 ht init 兜底的共享
|
|
375
|
+
* 目录 ~/.agents/skills,原因见 pi 平台条目);subagent 是 simple-subagents
|
|
376
|
+
* 扩展的 profile,位于 ~/.pi/agent/agents(项目级 profile 被忽略);命令
|
|
377
|
+
* 以 prompt template 形式装到 ~/.pi/prompts(模板名即命令名)
|
|
378
|
+
* - cursor:~/.cursor;命令装到 ~/.cursor/commands(工程级 .cursor/commands),
|
|
379
|
+
* 与 src/cli/config-store.ts 的 defaultEditors() 对齐
|
|
380
|
+
* - codebuddy / qoder / claude-code:各自的用户目录;claude-code 的
|
|
381
|
+
* commands / 为旧格式但仍有效(等价渲染为 skill)
|
|
382
|
+
* - codex:$CODEX_HOME(未设置时 ~/.codex);命令不装 prompts(custom
|
|
383
|
+
* prompts 已弃用),转换为 skill 装入 skills/(openai.yaml 关闭隐式调用,
|
|
384
|
+
* 旧版 prompts 位置纳入遗留清理);subagent 用 TOML 定义
|
|
385
|
+
* - atomcode:~/.atomcode;agent 是角色格式(permission/difficulty 必填,
|
|
386
|
+
* name/description 不被读取);无独立命令目录,命令转换为 skill 装入
|
|
387
|
+
* skills/(每个 skill 自动成为 /<skill-name> 命令)
|
|
388
|
+
* - dsh:~/.dsh(skills rank 400);无文件式 subagent;命令同样无文件形式,
|
|
389
|
+
* 转换为 skill 装入 skills/(原生键 disable-model-invocation +
|
|
390
|
+
* user-invocable 保留“仅用户调用”语义)
|
|
391
|
+
*/
|
|
392
|
+
export function resolvePlatforms(): Map<string, AgentPlatform> {
|
|
393
|
+
const codexRoot = process.env.CODEX_HOME
|
|
394
|
+
? path.resolve(process.env.CODEX_HOME)
|
|
395
|
+
: home('.codex');
|
|
396
|
+
const platforms: AgentPlatform[] = [
|
|
397
|
+
{
|
|
398
|
+
name: 'opencode',
|
|
399
|
+
markerDir: home('.config', 'opencode'),
|
|
400
|
+
skillsDir: home('.config', 'opencode', 'skills'),
|
|
401
|
+
agentsDir: home('.config', 'opencode', 'agents'),
|
|
402
|
+
commandsDir: home('.config', 'opencode', 'commands'),
|
|
403
|
+
agentFormat: 'passthrough',
|
|
404
|
+
skillKeepAllowedTools: false,
|
|
405
|
+
skillKeepArgumentHint: false,
|
|
406
|
+
skillDescriptionLimit: 1024,
|
|
407
|
+
skillSlashMetadata: true,
|
|
408
|
+
commandKeepKeys: ['description', 'agent', 'subtask', 'model'],
|
|
409
|
+
verbatim: false,
|
|
410
|
+
legacyDirs: [],
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: 'trae',
|
|
414
|
+
markerDir: home('.trae'),
|
|
415
|
+
skillsDir: home('.trae', 'skills'),
|
|
416
|
+
agentsDir: home('.trae', 'agents'),
|
|
417
|
+
commandsDir: home('.trae', 'commands'),
|
|
418
|
+
agentFormat: 'trae',
|
|
419
|
+
skillKeepAllowedTools: false,
|
|
420
|
+
skillKeepArgumentHint: false,
|
|
421
|
+
skillSlashMetadata: false,
|
|
422
|
+
commandKeepKeys: ['name', 'description'],
|
|
423
|
+
verbatim: false,
|
|
424
|
+
legacyDirs: [],
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: 'pi',
|
|
428
|
+
markerDir: home('.pi'),
|
|
429
|
+
// 全局 skills 放 pi 专属的 ~/.pi/skills,而不是开放标准共享目录
|
|
430
|
+
// ~/.agents/skills —— 共享目录是 ht init 的兜底安装位置(见 src/cli/
|
|
431
|
+
// config-store.ts 的 SHARED_AGENTS_FALLBACK),opencode / 新版 codex
|
|
432
|
+
// 等也会读取:装进去会污染其他智能体看到的内容,检测会把共享目录里的
|
|
433
|
+
// 同名 skill 误判为 pi 已安装,卸载会误删别的工具装入的内容
|
|
434
|
+
skillsDir: home('.pi', 'skills'),
|
|
435
|
+
agentsDir: home('.pi', 'agent', 'agents'),
|
|
436
|
+
// Pi 的斜杠命令以 prompt template 形式提供:~/.pi/prompts 下的 md 模板
|
|
437
|
+
// 按模板名成为命令
|
|
438
|
+
commandsDir: home('.pi', 'prompts'),
|
|
439
|
+
agentFormat: 'pi-profile',
|
|
440
|
+
skillKeepAllowedTools: true,
|
|
441
|
+
skillKeepArgumentHint: false,
|
|
442
|
+
skillDescriptionLimit: 1024,
|
|
443
|
+
skillSlashMetadata: false,
|
|
444
|
+
commandKeepKeys: ['description'],
|
|
445
|
+
verbatim: false,
|
|
446
|
+
// 曾有版本把 pi skills 装到共享目录 ~/.agents/skills;有意不纳入遗留
|
|
447
|
+
// 清理:该目录归 ht init / 其他智能体共享,删除会误伤别的工具装入的
|
|
448
|
+
// 同名内容(ht uninstall 会对称处理自己的安装)
|
|
449
|
+
legacyDirs: [
|
|
450
|
+
{
|
|
451
|
+
agentsDir: home('.pi', 'agents'),
|
|
452
|
+
commandsDir: home('.pi', 'commands'),
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: 'deveco',
|
|
458
|
+
markerDir: home('.config', 'deveco'),
|
|
459
|
+
skillsDir: home('.config', 'deveco', 'skills'),
|
|
460
|
+
agentsDir: home('.config', 'deveco', 'agents'),
|
|
461
|
+
commandsDir: home('.config', 'deveco', 'commands'),
|
|
462
|
+
agentFormat: 'passthrough',
|
|
463
|
+
skillKeepAllowedTools: false,
|
|
464
|
+
skillKeepArgumentHint: false,
|
|
465
|
+
skillDescriptionLimit: 1024,
|
|
466
|
+
skillSlashMetadata: true,
|
|
467
|
+
commandKeepKeys: ['description', 'agent', 'subtask', 'model'],
|
|
468
|
+
verbatim: false,
|
|
469
|
+
legacyDirs: [],
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: 'cursor',
|
|
473
|
+
markerDir: home('.cursor'),
|
|
474
|
+
skillsDir: home('.cursor', 'skills'),
|
|
475
|
+
agentsDir: home('.cursor', 'agents'),
|
|
476
|
+
commandsDir: home('.cursor', 'commands'),
|
|
477
|
+
agentFormat: 'cursor',
|
|
478
|
+
skillKeepAllowedTools: false,
|
|
479
|
+
skillKeepArgumentHint: false,
|
|
480
|
+
skillSlashMetadata: false,
|
|
481
|
+
commandKeepKeys: ['description'],
|
|
482
|
+
verbatim: false,
|
|
483
|
+
legacyDirs: [],
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: 'codebuddy',
|
|
487
|
+
markerDir: home('.codebuddy'),
|
|
488
|
+
skillsDir: home('.codebuddy', 'skills'),
|
|
489
|
+
agentsDir: home('.codebuddy', 'agents'),
|
|
490
|
+
commandsDir: home('.codebuddy', 'commands'),
|
|
491
|
+
agentFormat: 'codebuddy',
|
|
492
|
+
skillKeepAllowedTools: true,
|
|
493
|
+
skillKeepArgumentHint: false,
|
|
494
|
+
skillSlashMetadata: false,
|
|
495
|
+
commandKeepKeys: [
|
|
496
|
+
'description',
|
|
497
|
+
'argument-hint',
|
|
498
|
+
'model',
|
|
499
|
+
'allowed-tools',
|
|
500
|
+
'disable-model-invocation',
|
|
501
|
+
],
|
|
502
|
+
verbatim: false,
|
|
503
|
+
legacyDirs: [],
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: 'qoder',
|
|
507
|
+
markerDir: home('.qoder'),
|
|
508
|
+
skillsDir: home('.qoder', 'skills'),
|
|
509
|
+
agentsDir: home('.qoder', 'agents'),
|
|
510
|
+
commandsDir: home('.qoder', 'commands'),
|
|
511
|
+
agentFormat: 'qoder',
|
|
512
|
+
skillKeepAllowedTools: false,
|
|
513
|
+
skillKeepArgumentHint: false,
|
|
514
|
+
skillSlashMetadata: false,
|
|
515
|
+
commandKeepKeys: ['description'],
|
|
516
|
+
verbatim: false,
|
|
517
|
+
legacyDirs: [],
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: 'claude-code',
|
|
521
|
+
markerDir: home('.claude'),
|
|
522
|
+
skillsDir: home('.claude', 'skills'),
|
|
523
|
+
agentsDir: home('.claude', 'agents'),
|
|
524
|
+
commandsDir: home('.claude', 'commands'),
|
|
525
|
+
agentFormat: 'claude',
|
|
526
|
+
skillKeepAllowedTools: true,
|
|
527
|
+
skillKeepArgumentHint: true,
|
|
528
|
+
skillSlashMetadata: false,
|
|
529
|
+
commandKeepKeys: [
|
|
530
|
+
'description',
|
|
531
|
+
'argument-hint',
|
|
532
|
+
'allowed-tools',
|
|
533
|
+
'model',
|
|
534
|
+
'disable-model-invocation',
|
|
535
|
+
'context',
|
|
536
|
+
],
|
|
537
|
+
verbatim: false,
|
|
538
|
+
legacyDirs: [],
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
name: 'codex',
|
|
542
|
+
markerDir: codexRoot,
|
|
543
|
+
skillsDir: path.join(codexRoot, 'skills'),
|
|
544
|
+
agentsDir: path.join(codexRoot, 'agents'),
|
|
545
|
+
// 命令不装 prompts(custom prompts 已弃用),转换为 skill 装入 skills/
|
|
546
|
+
// 目录;旧版 prompts 位置纳入遗留清理
|
|
547
|
+
commandsDir: null,
|
|
548
|
+
agentFormat: 'codex-toml',
|
|
549
|
+
skillKeepAllowedTools: false,
|
|
550
|
+
skillKeepArgumentHint: false,
|
|
551
|
+
skillSlashMetadata: false,
|
|
552
|
+
commandKeepKeys: [],
|
|
553
|
+
commandsAsSkills: true,
|
|
554
|
+
verbatim: false,
|
|
555
|
+
legacyDirs: [{ commandsDir: path.join(codexRoot, 'prompts') }],
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: 'atomcode',
|
|
559
|
+
markerDir: home('.atomcode'),
|
|
560
|
+
skillsDir: home('.atomcode', 'skills'),
|
|
561
|
+
agentsDir: home('.atomcode', 'agents'),
|
|
562
|
+
commandsDir: null,
|
|
563
|
+
agentFormat: 'atomcode-role',
|
|
564
|
+
skillKeepAllowedTools: false,
|
|
565
|
+
skillKeepArgumentHint: false,
|
|
566
|
+
skillSlashMetadata: false,
|
|
567
|
+
commandKeepKeys: [],
|
|
568
|
+
// AtomCode 无独立命令目录:斜杠命令的来源是 skills(每个 skill 自动
|
|
569
|
+
// 成为 /<skill-name>,$ 菜单支持 $<name> <args> 内联传参)与自家
|
|
570
|
+
// /plugin 插件包(带 插件名: 前缀,不走本安装路径),命令转 skill 落
|
|
571
|
+
// skills/ 后 /hometrans 即原样出现
|
|
572
|
+
commandsAsSkills: true,
|
|
573
|
+
verbatim: false,
|
|
574
|
+
legacyDirs: [{ commandsDir: home('.atomcode', 'commands') }],
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: 'dsh',
|
|
578
|
+
markerDir: home('.dsh'),
|
|
579
|
+
skillsDir: home('.dsh', 'skills'),
|
|
580
|
+
agentsDir: null,
|
|
581
|
+
// DSH 无文件式命令(命令走插件 API 注册):命令转换为 skill 装入
|
|
582
|
+
// skills/,用原生键 disable-model-invocation + user-invocable 保留
|
|
583
|
+
// “仅用户调用”的命令语义
|
|
584
|
+
commandsDir: null,
|
|
585
|
+
agentFormat: 'none',
|
|
586
|
+
skillKeepAllowedTools: false,
|
|
587
|
+
skillKeepArgumentHint: false,
|
|
588
|
+
skillSlashMetadata: false,
|
|
589
|
+
commandKeepKeys: [],
|
|
590
|
+
commandsAsSkills: true,
|
|
591
|
+
verbatim: false,
|
|
592
|
+
legacyDirs: [
|
|
593
|
+
{
|
|
594
|
+
agentsDir: home('.dsh', 'agents'),
|
|
595
|
+
commandsDir: home('.dsh', 'commands'),
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
},
|
|
599
|
+
];
|
|
600
|
+
return new Map(platforms.map((p) => [p.name, p]));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export interface AgentTarget {
|
|
604
|
+
/** 输出用的名字:智能体名,或 --dir 的路径。 */
|
|
605
|
+
name: string;
|
|
606
|
+
/** 由 --agent / --dir 显式指定;未显式指定的目标会跳过本机未安装的智能体。 */
|
|
607
|
+
explicit: boolean;
|
|
608
|
+
platform: AgentPlatform;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/* ------------------------------------------------------------------ */
|
|
612
|
+
/* 工程级平台目录 */
|
|
613
|
+
/* ------------------------------------------------------------------ */
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* 工程级布局差异表:默认规则是 `<projectRoot>/.<agent>/{skills,agents,commands}`
|
|
617
|
+
* (全局目录为 null 的保持 null),下列平台覆盖个别目录或附带跳过说明。
|
|
618
|
+
*/
|
|
619
|
+
const PROJECT_DIR_OVERRIDES: Record<
|
|
620
|
+
string,
|
|
621
|
+
Partial<{
|
|
622
|
+
skills: string | null;
|
|
623
|
+
agents: string | null;
|
|
624
|
+
commands: string | null;
|
|
625
|
+
agentsSkipNote: string;
|
|
626
|
+
commandsSkipNote: string;
|
|
627
|
+
}>
|
|
628
|
+
> = {
|
|
629
|
+
// pi:skills 落 .pi/skills(deveco-cli 工程级约定);工程级 profile 被平台
|
|
630
|
+
// 忽略,prompt templates 仅全局(~/.pi/prompts),两者跳过并说明
|
|
631
|
+
pi: {
|
|
632
|
+
agents: null,
|
|
633
|
+
commands: null,
|
|
634
|
+
agentsSkipNote: 'pi ignores project-level subagent profiles',
|
|
635
|
+
commandsSkipNote: 'pi prompt templates are global-only (~/.pi/prompts)',
|
|
636
|
+
},
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* 工程级根目录名:默认 `.<agent>`。个别平台工程内目录名与全局名不同:
|
|
641
|
+
* trae-cn 全局在 ~/.trae-cn,工程内是 .trae;claude-code 的目录名本就是
|
|
642
|
+
* .claude(不是 .claude-code)。
|
|
643
|
+
*/
|
|
644
|
+
const PROJECT_ROOT_NAME: Record<string, string> = {
|
|
645
|
+
'trae-cn': '.trae',
|
|
646
|
+
'claude-code': '.claude',
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* 把全局平台描述符映射为工程级(`<projectRoot>/<PROJECT_ROOT_NAME>/…`)。
|
|
651
|
+
*
|
|
652
|
+
* - markerDir 保持全局检测目录不变:工程级目标仍以"编辑器本机已安装"为准,
|
|
653
|
+
* 工程内的 agent 目录由安装过程创建,不能作为存在性判据。
|
|
654
|
+
* - legacyDirs 清空:遗留位置清理只针对旧版全局安装的错误位置,与工程无关。
|
|
655
|
+
* - skillsDir(deveco-cli 契约的 ctx.skillsDir,可选)优先采用:工程根取其
|
|
656
|
+
* 父目录(如 <project>/.agents/skills → <project>/.agents),agents /
|
|
657
|
+
* commands 落同一根下;未提供时按默认规则推导。仅当平台本身有 skills
|
|
658
|
+
* 目录概念(platform.skillsDir !== null)时才生效。
|
|
659
|
+
*/
|
|
660
|
+
export function toProjectPlatform(
|
|
661
|
+
platform: AgentPlatform,
|
|
662
|
+
projectRoot: string,
|
|
663
|
+
skillsDir?: string,
|
|
664
|
+
): AgentPlatform {
|
|
665
|
+
const override = PROJECT_DIR_OVERRIDES[platform.name] ?? {};
|
|
666
|
+
const cliSkillsDir =
|
|
667
|
+
typeof skillsDir === 'string' && platform.skillsDir !== null
|
|
668
|
+
? skillsDir
|
|
669
|
+
: undefined;
|
|
670
|
+
const root = cliSkillsDir
|
|
671
|
+
? path.dirname(cliSkillsDir)
|
|
672
|
+
: path.join(
|
|
673
|
+
projectRoot,
|
|
674
|
+
PROJECT_ROOT_NAME[platform.name] ?? '.' + platform.name,
|
|
675
|
+
);
|
|
676
|
+
const resolveDir = (
|
|
677
|
+
globalDir: string | null,
|
|
678
|
+
sub: 'skills' | 'agents' | 'commands',
|
|
679
|
+
overrideValue: string | null | undefined,
|
|
680
|
+
): string | null => {
|
|
681
|
+
if (overrideValue !== undefined) {
|
|
682
|
+
return overrideValue === null ? null : path.join(root, overrideValue);
|
|
683
|
+
}
|
|
684
|
+
return globalDir === null ? null : path.join(root, sub);
|
|
685
|
+
};
|
|
686
|
+
return {
|
|
687
|
+
...platform,
|
|
688
|
+
skillsDir:
|
|
689
|
+
cliSkillsDir ?? resolveDir(platform.skillsDir, 'skills', override.skills),
|
|
690
|
+
agentsDir: resolveDir(platform.agentsDir, 'agents', override.agents),
|
|
691
|
+
commandsDir: resolveDir(
|
|
692
|
+
platform.commandsDir,
|
|
693
|
+
'commands',
|
|
694
|
+
override.commands
|
|
695
|
+
),
|
|
696
|
+
agentsSkipNote: override.agentsSkipNote ?? platform.agentsSkipNote,
|
|
697
|
+
commandsSkipNote: override.commandsSkipNote ?? platform.commandsSkipNote,
|
|
698
|
+
legacyDirs: [],
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** commands 的安装目标描述(commandsAsSkills 平台指向 skills 目录)。 */
|
|
703
|
+
export function commandsDirLabel(platform: AgentPlatform): string | null {
|
|
704
|
+
if (platform.commandsDir) return platform.commandsDir;
|
|
705
|
+
if (platform.commandsAsSkills && platform.skillsDir) return `${platform.skillsDir} (as skills)`;
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* 把平台安装到任意指定目录:skills / agents / commands 分别落到
|
|
711
|
+
* `<targetRoot>/skills|agents|commands`(平台本身没有的目录保持 null)。
|
|
712
|
+
*
|
|
713
|
+
* 与 `toProjectPlatform` 的区别:
|
|
714
|
+
* - 不再追加 `.<agent>` 前缀,目标目录本身就是安装根;
|
|
715
|
+
* - 保留平台自身的格式(Codex TOML、commandsAsSkills、AtomCode 角色等);
|
|
716
|
+
* - 清空 legacyDirs,避免误删目标目录之外的历史全局安装。
|
|
717
|
+
*/
|
|
718
|
+
export function toDirPlatform(platform: AgentPlatform, targetRoot: string): AgentPlatform {
|
|
719
|
+
const resolveDir = (
|
|
720
|
+
globalDir: string | null,
|
|
721
|
+
sub: 'skills' | 'agents' | 'commands',
|
|
722
|
+
): string | null => (globalDir === null ? null : path.join(targetRoot, sub));
|
|
723
|
+
return {
|
|
724
|
+
...platform,
|
|
725
|
+
markerDir: targetRoot,
|
|
726
|
+
skillsDir: resolveDir(platform.skillsDir, 'skills'),
|
|
727
|
+
agentsDir: resolveDir(platform.agentsDir, 'agents'),
|
|
728
|
+
commandsDir: resolveDir(platform.commandsDir, 'commands'),
|
|
729
|
+
legacyDirs: [],
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/* ------------------------------------------------------------------ */
|
|
734
|
+
/* skill 转换:frontmatter 逐字段路由 */
|
|
735
|
+
/* ------------------------------------------------------------------ */
|
|
736
|
+
|
|
737
|
+
/** Agent Skills 标准字段(allowed-tools 单独路由)。 */
|
|
738
|
+
const SKILL_STANDARD_KEYS = new Set(['name', 'description', 'license', 'compatibility', 'metadata']);
|
|
739
|
+
|
|
740
|
+
export interface SkillTransform {
|
|
741
|
+
content: string;
|
|
742
|
+
/** true = 无需改写,直接拷贝原文。 */
|
|
743
|
+
rawCopy: boolean;
|
|
744
|
+
notes: string[];
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function toolItems(v: FmValue): string[] {
|
|
748
|
+
if (Array.isArray(v)) return v.map((s) => s.trim()).filter(Boolean);
|
|
749
|
+
if (typeof v === 'string') return v.split(',').map((s) => s.trim()).filter(Boolean);
|
|
750
|
+
return [];
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/** Pi 的工具名是小写且子代理无嵌套(无 Agent/Task);去掉 Bash(...) 之类的参数修饰。 */
|
|
754
|
+
function normalizePiTools(v: FmValue): string[] {
|
|
755
|
+
const out: string[] = [];
|
|
756
|
+
for (const t of toolItems(v)) {
|
|
757
|
+
const base = t.replace(/\(.*\)$/, '').toLowerCase();
|
|
758
|
+
if (!base || base === 'agent' || base === 'task') continue;
|
|
759
|
+
if (!out.includes(base)) out.push(base);
|
|
760
|
+
}
|
|
761
|
+
return out;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
export function transformSkillMd(platform: AgentPlatform, raw: string): SkillTransform {
|
|
765
|
+
if (platform.verbatim) return { content: raw, rawCopy: true, notes: [] };
|
|
766
|
+
const { fm, body, hasFrontmatter } = parseFrontmatter(raw);
|
|
767
|
+
if (!hasFrontmatter) return { content: raw, rawCopy: true, notes: [] };
|
|
768
|
+
const out: Frontmatter = {};
|
|
769
|
+
const metadata: Record<string, string> = { ...asRecord(fm.metadata) };
|
|
770
|
+
let dirty = false;
|
|
771
|
+
const notes: string[] = [];
|
|
772
|
+
|
|
773
|
+
for (const [key, value] of Object.entries(fm)) {
|
|
774
|
+
if (key === 'metadata') continue; // 已并入 metadata,最后统一写回
|
|
775
|
+
if (SKILL_STANDARD_KEYS.has(key)) {
|
|
776
|
+
out[key] = value;
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
779
|
+
if (key === 'allowed-tools') {
|
|
780
|
+
if (platform.skillKeepAllowedTools) {
|
|
781
|
+
if (platform.name === 'pi') {
|
|
782
|
+
const normalized = normalizePiTools(value);
|
|
783
|
+
if (JSON.stringify(normalized) === JSON.stringify(toolItems(value))) {
|
|
784
|
+
out['allowed-tools'] = value;
|
|
785
|
+
} else {
|
|
786
|
+
out['allowed-tools'] = normalized;
|
|
787
|
+
dirty = true;
|
|
788
|
+
notes.push('allowed-tools normalized for pi (lowercase, Agent/Task dropped)');
|
|
789
|
+
}
|
|
790
|
+
} else {
|
|
791
|
+
out['allowed-tools'] = value;
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
dirty = true;
|
|
795
|
+
notes.push(`dropped allowed-tools (${platform.name} has no skill-level tool allowlist)`);
|
|
796
|
+
}
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
if (key === 'argument-hint') {
|
|
800
|
+
if (platform.skillKeepArgumentHint) {
|
|
801
|
+
out['argument-hint'] = value;
|
|
802
|
+
} else if (platform.skillSlashMetadata) {
|
|
803
|
+
// argument-hint 的语义 = 用户可带参显式调用;OpenCode 暴露为斜杠命令
|
|
804
|
+
metadata['opencode/slash'] = 'true';
|
|
805
|
+
dirty = true;
|
|
806
|
+
notes.push('argument-hint -> metadata opencode/slash (slash command exposure)');
|
|
807
|
+
} else {
|
|
808
|
+
dirty = true;
|
|
809
|
+
notes.push(`dropped argument-hint (no equivalent on ${platform.name})`);
|
|
810
|
+
}
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
// 其余非标顶层字段:迁入标准 metadata,保留数据且符合
|
|
814
|
+
// "不得新增顶层字段" 的平台要求(OpenCode / DevEco / Claude Code 上传路径)
|
|
815
|
+
metadata[key] = fmValueToString(value);
|
|
816
|
+
dirty = true;
|
|
817
|
+
notes.push(`relocated top-level ${key} -> metadata.${key}`);
|
|
818
|
+
}
|
|
819
|
+
if (Object.keys(metadata).length > 0) {
|
|
820
|
+
out.metadata = metadata;
|
|
821
|
+
if (!('metadata' in fm)) dirty = true;
|
|
822
|
+
}
|
|
823
|
+
if (!dirty) return { content: raw, rawCopy: true, notes: [] };
|
|
824
|
+
return { content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/* ------------------------------------------------------------------ */
|
|
828
|
+
/* agent 转换:按平台格式生成 */
|
|
829
|
+
/* ------------------------------------------------------------------ */
|
|
830
|
+
|
|
831
|
+
export interface AgentTransform {
|
|
832
|
+
fileName: string;
|
|
833
|
+
content: string;
|
|
834
|
+
rawCopy: boolean;
|
|
835
|
+
notes: string[];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/** 源 permission 键 -> Claude 系工具名(edit 覆盖 Edit+Write;task 兼容 Agent/Task 两种命名)。 */
|
|
839
|
+
const PERMISSION_TO_TOOLS: Record<string, string[]> = {
|
|
840
|
+
edit: ['Edit', 'Write'],
|
|
841
|
+
bash: ['Bash'],
|
|
842
|
+
task: ['Agent', 'Task'],
|
|
843
|
+
webfetch: ['WebFetch'],
|
|
844
|
+
websearch: ['WebSearch'],
|
|
845
|
+
read: ['Read'],
|
|
846
|
+
glob: ['Glob'],
|
|
847
|
+
grep: ['Grep'],
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
/** 单行 TOML 基本字符串(转义反斜杠与双引号)。 */
|
|
851
|
+
function tomlInline(s: string): string {
|
|
852
|
+
return '"' + s.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/** 多行 TOML 字面量字符串;内容含 ''' 时回退为转义的基本字符串。 */
|
|
856
|
+
function tomlMultiline(s: string): string {
|
|
857
|
+
const body = s.replace(/\r\n/g, '\n');
|
|
858
|
+
if (!body.includes("'''")) return `'''\n${body}\n'''`;
|
|
859
|
+
return (
|
|
860
|
+
'"' + body.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\r/g, '\\r').replace(/\n/g, '\\n') + '"'
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/** 取 description 的第一句作为 AtomCode 的 when(无句号时取全文,超长截断)。 */
|
|
865
|
+
function firstSentence(text: string, max = 200): string {
|
|
866
|
+
const m = /^[\s\S]*?[.!?](\s|$)/.exec(text);
|
|
867
|
+
let s = (m ? m[0] : text).trim();
|
|
868
|
+
if (s.length > max) s = s.slice(0, max - 1).replace(/\s+\S*$/, '') + '…';
|
|
869
|
+
return s;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* mode 字段丢弃说明。mode: all = 「主代理 + 子代理」双身份,其中主代理半边
|
|
874
|
+
* 仅 OpenCode 系存在;claude-code 的 `claude --agent <name>` 会话级用法原生
|
|
875
|
+
* 等价,其余平台无对应机制(子代理半边在各平台原生保留)。
|
|
876
|
+
*/
|
|
877
|
+
function droppedModeNote(mode: string | undefined, platform: AgentPlatform): string | undefined {
|
|
878
|
+
if (mode === undefined) return undefined;
|
|
879
|
+
if (mode !== 'all') return `dropped mode: ${mode}`;
|
|
880
|
+
if (platform.agentFormat === 'claude') {
|
|
881
|
+
return "dropped mode: all - primary-style use natively available via 'claude --agent <name>'";
|
|
882
|
+
}
|
|
883
|
+
return `dropped mode: all - ${platform.name} has no primary-agent concept (subagent dispatch preserved)`;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* 把打包的 agent md(OpenCode 风格 frontmatter:name / description / mode /
|
|
888
|
+
* permission + 正文)转换为目标平台格式。返回 null 表示该平台无文件式
|
|
889
|
+
* subagent(dsh),调用方跳过。
|
|
890
|
+
*/
|
|
891
|
+
export function transformAgentMd(
|
|
892
|
+
platform: AgentPlatform,
|
|
893
|
+
fileName: string,
|
|
894
|
+
raw: string,
|
|
895
|
+
): AgentTransform | null {
|
|
896
|
+
if (platform.agentFormat === 'none') return null;
|
|
897
|
+
if (platform.verbatim || platform.agentFormat === 'passthrough') {
|
|
898
|
+
// OpenCode 系:mode / permission 原生支持,原样透传
|
|
899
|
+
return { fileName, content: raw, rawCopy: true, notes: [] };
|
|
900
|
+
}
|
|
901
|
+
const { fm, body } = parseFrontmatter(raw);
|
|
902
|
+
const name = asString(fm.name) || fileName.replace(/\.md$/, '');
|
|
903
|
+
const description = asString(fm.description) ?? '';
|
|
904
|
+
const permission = asRecord(fm.permission);
|
|
905
|
+
const denies = Object.keys(permission).filter((k) => permission[k] === 'deny');
|
|
906
|
+
const allows = Object.keys(permission).filter((k) => permission[k] === 'allow');
|
|
907
|
+
const bodyText = body.replace(/^\r?\n/, '').replace(/\s+$/, '');
|
|
908
|
+
const modeNote = droppedModeNote(asString(fm.mode), platform);
|
|
909
|
+
|
|
910
|
+
switch (platform.agentFormat) {
|
|
911
|
+
case 'claude':
|
|
912
|
+
case 'codebuddy': {
|
|
913
|
+
const out: Frontmatter = { name, description };
|
|
914
|
+
const notes: string[] = [];
|
|
915
|
+
const disallowed = [...new Set(denies.flatMap((k) => PERMISSION_TO_TOOLS[k] ?? []))];
|
|
916
|
+
if (disallowed.length > 0) {
|
|
917
|
+
out.disallowedTools = disallowed;
|
|
918
|
+
notes.push(`permission deny (${denies.join(', ')}) -> disallowedTools: ${disallowed.join(', ')}`);
|
|
919
|
+
}
|
|
920
|
+
if (modeNote) notes.push(modeNote);
|
|
921
|
+
return { fileName, content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
922
|
+
}
|
|
923
|
+
case 'cursor': {
|
|
924
|
+
const out: Frontmatter = { name, description };
|
|
925
|
+
const notes: string[] = [];
|
|
926
|
+
if (permission.edit === 'deny') {
|
|
927
|
+
out.readonly = true;
|
|
928
|
+
notes.push('permission edit deny -> readonly: true');
|
|
929
|
+
}
|
|
930
|
+
const rest = denies.filter((k) => k !== 'edit');
|
|
931
|
+
if (rest.length > 0) {
|
|
932
|
+
notes.push(`dropped permission deny (${rest.join(', ')}) - no Cursor equivalent`);
|
|
933
|
+
}
|
|
934
|
+
if (modeNote) notes.push(modeNote);
|
|
935
|
+
return { fileName, content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
936
|
+
}
|
|
937
|
+
case 'qoder': {
|
|
938
|
+
const out: Frontmatter = { name, description };
|
|
939
|
+
const notes: string[] = [];
|
|
940
|
+
if (Object.keys(permission).length > 0) {
|
|
941
|
+
// Qoder 无黑名单,只能白名单:基础读取工具 + permission 允许项
|
|
942
|
+
//(Qoder 工具集没有 Agent/Task)
|
|
943
|
+
const tools = new Set<string>(['Read', 'Glob', 'Grep']);
|
|
944
|
+
for (const k of allows) {
|
|
945
|
+
for (const t of PERMISSION_TO_TOOLS[k] ?? []) {
|
|
946
|
+
if (t !== 'Agent' && t !== 'Task') tools.add(t);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
out.tools = [...tools];
|
|
950
|
+
notes.push(`permission -> tools whitelist: ${out.tools.join(', ')}`);
|
|
951
|
+
}
|
|
952
|
+
if (modeNote) notes.push(modeNote);
|
|
953
|
+
return { fileName, content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
954
|
+
}
|
|
955
|
+
case 'trae': {
|
|
956
|
+
const out: Frontmatter = { name, description };
|
|
957
|
+
const notes: string[] = [];
|
|
958
|
+
// Trae 工具集没有 Agent/Task,task deny 无对应物
|
|
959
|
+
const disallowed = [
|
|
960
|
+
...new Set(denies.flatMap((k) => PERMISSION_TO_TOOLS[k] ?? [])),
|
|
961
|
+
].filter((t) => t !== 'Agent' && t !== 'Task');
|
|
962
|
+
if (disallowed.length > 0) {
|
|
963
|
+
// Trae 的工具字段约定是逗号分隔字符串(tools 文档明示);
|
|
964
|
+
// 块列表形式会导致 frontmatter 解析失败、整个文件被跳过
|
|
965
|
+
out.disallowedTools = disallowed.join(', ');
|
|
966
|
+
notes.push(`permission deny (${denies.join(', ')}) -> disallowedTools: ${out.disallowedTools}`);
|
|
967
|
+
}
|
|
968
|
+
if (denies.includes('task')) {
|
|
969
|
+
notes.push('dropped permission task deny - Trae subagents have no Task tool');
|
|
970
|
+
}
|
|
971
|
+
if (modeNote) notes.push(modeNote);
|
|
972
|
+
return { fileName, content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
973
|
+
}
|
|
974
|
+
case 'pi-profile': {
|
|
975
|
+
const out: Frontmatter = { name, description };
|
|
976
|
+
const notes: string[] = [];
|
|
977
|
+
if (Object.keys(permission).length > 0) {
|
|
978
|
+
// Pi profile 的 tools 是逗号分隔的小写工具名;Pi 子代理本身禁止嵌套
|
|
979
|
+
const tools = new Set<string>(['read', 'glob', 'grep']);
|
|
980
|
+
if (allows.includes('edit')) {
|
|
981
|
+
tools.add('edit');
|
|
982
|
+
tools.add('write');
|
|
983
|
+
}
|
|
984
|
+
if (allows.includes('bash')) tools.add('bash');
|
|
985
|
+
if (allows.includes('webfetch')) tools.add('webfetch');
|
|
986
|
+
if (allows.includes('websearch')) tools.add('websearch');
|
|
987
|
+
out.tools = [...tools].join(', ');
|
|
988
|
+
notes.push(`permission -> tools: ${out.tools}`);
|
|
989
|
+
}
|
|
990
|
+
if (modeNote) notes.push(modeNote);
|
|
991
|
+
return { fileName, content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
992
|
+
}
|
|
993
|
+
case 'codex-toml': {
|
|
994
|
+
const notes: string[] = ['converted to Codex subagent TOML (body -> developer_instructions)'];
|
|
995
|
+
const lines: string[] = [`name = ${tomlInline(name)}`];
|
|
996
|
+
if (description) lines.push(`description = ${tomlInline(description)}`);
|
|
997
|
+
// sandbox_mode 不写:Codex 自定义 agent 继承父会话沙箱,自定义文件中设置无效
|
|
998
|
+
let instructions = bodyText;
|
|
999
|
+
if (permission.edit === 'deny') {
|
|
1000
|
+
instructions +=
|
|
1001
|
+
'\n\nConstraint: never modify, create, or delete any file - this agent is read-only.';
|
|
1002
|
+
notes.push('permission edit deny -> read-only constraint appended (no per-agent write sandbox)');
|
|
1003
|
+
}
|
|
1004
|
+
lines.push(`developer_instructions = ${tomlMultiline(instructions)}`);
|
|
1005
|
+
if (permission.bash === 'deny') {
|
|
1006
|
+
// [features] 表必须放在所有顶层键之后
|
|
1007
|
+
lines.push('', '[features]', 'shell_tool = false');
|
|
1008
|
+
notes.push('permission bash deny -> features.shell_tool = false');
|
|
1009
|
+
}
|
|
1010
|
+
if (modeNote) notes.push(modeNote);
|
|
1011
|
+
return {
|
|
1012
|
+
fileName: fileName.replace(/\.md$/, '.toml'),
|
|
1013
|
+
content: lines.join('\n') + '\n',
|
|
1014
|
+
rawCopy: false,
|
|
1015
|
+
notes,
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
case 'atomcode-role': {
|
|
1019
|
+
// AtomCode 角色格式:不读 name/description,必填 permission + difficulty;
|
|
1020
|
+
// difficulty 统一 hard(避免复杂任务路由到快模型)
|
|
1021
|
+
const permissionValue = permission.edit === 'deny' ? 'explore' : 'worker';
|
|
1022
|
+
const out: Frontmatter = {
|
|
1023
|
+
permission: permissionValue,
|
|
1024
|
+
difficulty: 'hard',
|
|
1025
|
+
when: firstSentence(description),
|
|
1026
|
+
name,
|
|
1027
|
+
description,
|
|
1028
|
+
};
|
|
1029
|
+
const notes: string[] = [
|
|
1030
|
+
`converted to AtomCode role format (permission: ${permissionValue}, difficulty: hard)`,
|
|
1031
|
+
'difficulty defaults to hard (no source equivalent)',
|
|
1032
|
+
];
|
|
1033
|
+
return { fileName, content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
1034
|
+
}
|
|
1035
|
+
default:
|
|
1036
|
+
return { fileName, content: raw, rawCopy: true, notes: [] };
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/* ------------------------------------------------------------------ */
|
|
1041
|
+
/* command 转换:frontmatter 逐字段路由 */
|
|
1042
|
+
/* ------------------------------------------------------------------ */
|
|
1043
|
+
|
|
1044
|
+
export interface CommandTransform {
|
|
1045
|
+
content: string;
|
|
1046
|
+
/** true = 无需改写,直接拷贝原文。 */
|
|
1047
|
+
rawCopy: boolean;
|
|
1048
|
+
notes: string[];
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* 把打包的 command md 按平台路由 frontmatter 字段:commandKeepKeys 之外的键
|
|
1053
|
+
* 丢弃并说明;claude-code 额外把 subtask: true(强制子代理执行)译为
|
|
1054
|
+
* context: fork。正文模板不动($ARGUMENTS / $1-$3 是全平台交集占位符)。
|
|
1055
|
+
*/
|
|
1056
|
+
export function transformCommandMd(platform: AgentPlatform, raw: string): CommandTransform {
|
|
1057
|
+
if (platform.verbatim || platform.commandsDir === null) {
|
|
1058
|
+
return { content: raw, rawCopy: true, notes: [] };
|
|
1059
|
+
}
|
|
1060
|
+
const { fm, body, hasFrontmatter } = parseFrontmatter(raw);
|
|
1061
|
+
if (!hasFrontmatter) return { content: raw, rawCopy: true, notes: [] };
|
|
1062
|
+
const keep = new Set(platform.commandKeepKeys);
|
|
1063
|
+
const out: Frontmatter = {};
|
|
1064
|
+
let dirty = false;
|
|
1065
|
+
const notes: string[] = [];
|
|
1066
|
+
for (const [key, value] of Object.entries(fm)) {
|
|
1067
|
+
if (keep.has(key)) {
|
|
1068
|
+
out[key] = value;
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
if (key === 'subtask' && platform.agentFormat === 'claude' && value === 'true') {
|
|
1072
|
+
// subtask: true(OpenCode 系强制子代理执行)≈ Claude Code 的 context: fork
|
|
1073
|
+
out.context = 'fork';
|
|
1074
|
+
dirty = true;
|
|
1075
|
+
notes.push('subtask: true -> context: fork');
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
dirty = true;
|
|
1079
|
+
notes.push(`dropped ${key} (not supported in ${platform.name} commands)`);
|
|
1080
|
+
}
|
|
1081
|
+
if (!dirty) return { content: raw, rawCopy: true, notes: [] };
|
|
1082
|
+
// 无任何受支持字段(如命令缺少 description):整块 frontmatter 移除,仅保留
|
|
1083
|
+
// 正文 —— 空 `---\n---` 块过不了读回校验,且平台本身也不解析它
|
|
1084
|
+
if (Object.keys(out).length === 0) {
|
|
1085
|
+
return { content: body, rawCopy: false, notes };
|
|
1086
|
+
}
|
|
1087
|
+
return { content: serializeFrontmatter(out) + body, rawCopy: false, notes };
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
export interface CommandSkillTransform {
|
|
1091
|
+
/** 转换后的 skill 名(命令文件名去 .md,即 skills/ 下的目录名)。 */
|
|
1092
|
+
skillName: string;
|
|
1093
|
+
/** SKILL.md 内容。 */
|
|
1094
|
+
content: string;
|
|
1095
|
+
/** Codex 的 agents/openai.yaml 内容;null = 该平台不需要 sidecar。 */
|
|
1096
|
+
openaiYaml: string | null;
|
|
1097
|
+
notes: string[];
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* 把打包的 command md 转换为 skill(Codex 的 custom prompts 已弃用、DSH /
|
|
1102
|
+
* AtomCode 无文件式命令,官方载体均为 skill)。name +
|
|
1103
|
+
* description 构成 skill frontmatter;$ARGUMENTS 占位符替换为参数来源说明
|
|
1104
|
+
* (skill 无模板展开机制);subtask / argument-hint 无 skill 对应物,丢弃并
|
|
1105
|
+
* 说明。“仅用户显式触发”的命令语义按平台用原生机制保留:
|
|
1106
|
+
* - codex:agents/openai.yaml 的 policy.allow_implicit_invocation = false;
|
|
1107
|
+
* - dsh:frontmatter 原生键 disable-model-invocation + user-invocable
|
|
1108
|
+
* (组合 = 仅用户可调用)。
|
|
1109
|
+
* - atomcode:无原生保留机制(模型可经 use_skill 自动调用),仅日志说明。
|
|
1110
|
+
*/
|
|
1111
|
+
export function commandToSkillMd(
|
|
1112
|
+
platform: AgentPlatform,
|
|
1113
|
+
fileName: string,
|
|
1114
|
+
raw: string,
|
|
1115
|
+
): CommandSkillTransform {
|
|
1116
|
+
const { fm, body } = parseFrontmatter(raw);
|
|
1117
|
+
const skillName = fileName.replace(/\.md$/, '');
|
|
1118
|
+
const notes: string[] = [];
|
|
1119
|
+
const out: Frontmatter = { name: skillName };
|
|
1120
|
+
const description = asString(fm.description);
|
|
1121
|
+
if (description) out.description = description;
|
|
1122
|
+
if ('subtask' in fm) notes.push('dropped subtask (no skill equivalent)');
|
|
1123
|
+
if ('argument-hint' in fm) notes.push('dropped argument-hint (no skill equivalent)');
|
|
1124
|
+
let openaiYaml: string | null = null;
|
|
1125
|
+
if (platform.name === 'codex') {
|
|
1126
|
+
notes.push('converted command to skill (Codex custom prompts deprecated)');
|
|
1127
|
+
notes.push('openai.yaml: allow_implicit_invocation=false (commands are user-triggered)');
|
|
1128
|
+
openaiYaml = 'policy:\n allow_implicit_invocation: false\n';
|
|
1129
|
+
} else if (platform.name === 'dsh') {
|
|
1130
|
+
notes.push('converted command to skill (DSH has no file-based commands)');
|
|
1131
|
+
out['disable-model-invocation'] = true;
|
|
1132
|
+
out['user-invocable'] = true;
|
|
1133
|
+
notes.push('disable-model-invocation + user-invocable -> user-only invocation (DSH native keys)');
|
|
1134
|
+
} else if (platform.name === 'atomcode') {
|
|
1135
|
+
notes.push(
|
|
1136
|
+
'converted command to skill (each skill appears as /<skill-name>; $<skill-name> <args> carries inline arguments)',
|
|
1137
|
+
);
|
|
1138
|
+
notes.push('user-only invocation not preservable (AtomCode model may auto-invoke via use_skill)');
|
|
1139
|
+
} else {
|
|
1140
|
+
notes.push('converted command to skill');
|
|
1141
|
+
}
|
|
1142
|
+
const bodyText = body.replaceAll('$ARGUMENTS', '(用户调用本技能时在消息中提供的参数)');
|
|
1143
|
+
if (bodyText !== body) notes.push('$ARGUMENTS placeholder replaced with argument-source note');
|
|
1144
|
+
return {
|
|
1145
|
+
skillName,
|
|
1146
|
+
content: serializeFrontmatter(out) + bodyText,
|
|
1147
|
+
openaiYaml,
|
|
1148
|
+
notes,
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/* ------------------------------------------------------------------ */
|
|
1153
|
+
/* 校验器:安装后读回检查 */
|
|
1154
|
+
/* ------------------------------------------------------------------ */
|
|
1155
|
+
|
|
1156
|
+
export interface ValidationIssue {
|
|
1157
|
+
level: 'error' | 'warn';
|
|
1158
|
+
message: string;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
const SKILL_NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
1162
|
+
|
|
1163
|
+
/** 通用规则;`descriptionLimit` 仅在目标平台确实有该硬限制时传入。 */
|
|
1164
|
+
export function validateSkillMd(
|
|
1165
|
+
skillName: string,
|
|
1166
|
+
raw: string,
|
|
1167
|
+
descriptionLimit?: number,
|
|
1168
|
+
): ValidationIssue[] {
|
|
1169
|
+
const issues: ValidationIssue[] = [];
|
|
1170
|
+
const { fm, hasFrontmatter } = parseFrontmatter(raw);
|
|
1171
|
+
if (!hasFrontmatter) {
|
|
1172
|
+
issues.push({
|
|
1173
|
+
level: 'error',
|
|
1174
|
+
message: `${skillName}: SKILL.md has no frontmatter block starting with --- on line 1`,
|
|
1175
|
+
});
|
|
1176
|
+
return issues;
|
|
1177
|
+
}
|
|
1178
|
+
const name = asString(fm.name);
|
|
1179
|
+
if (!name) {
|
|
1180
|
+
issues.push({ level: 'error', message: `${skillName}: missing name` });
|
|
1181
|
+
} else {
|
|
1182
|
+
if (!SKILL_NAME_RE.test(name)) {
|
|
1183
|
+
issues.push({ level: 'error', message: `${skillName}: name "${name}" is not kebab-case` });
|
|
1184
|
+
}
|
|
1185
|
+
if (name.length > 64) {
|
|
1186
|
+
issues.push({ level: 'error', message: `${skillName}: name exceeds 64 chars` });
|
|
1187
|
+
}
|
|
1188
|
+
if (name !== skillName) {
|
|
1189
|
+
issues.push({ level: 'error', message: `${skillName}: name "${name}" != directory name` });
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
const description = asString(fm.description);
|
|
1193
|
+
if (!description) {
|
|
1194
|
+
issues.push({ level: 'error', message: `${skillName}: missing description` });
|
|
1195
|
+
} else if (descriptionLimit !== undefined && description.length > descriptionLimit) {
|
|
1196
|
+
issues.push({
|
|
1197
|
+
level: 'warn',
|
|
1198
|
+
message: `${skillName}: description ${description.length} chars > ${descriptionLimit} (platform hard limit); installed as-is, platform may refuse to load`,
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
return issues;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
export function validateAgentFile(
|
|
1205
|
+
platform: AgentPlatform,
|
|
1206
|
+
fileName: string,
|
|
1207
|
+
raw: string,
|
|
1208
|
+
): ValidationIssue[] {
|
|
1209
|
+
const issues: ValidationIssue[] = [];
|
|
1210
|
+
const base = fileName.replace(/\.(md|toml)$/, '');
|
|
1211
|
+
if (platform.agentFormat === 'codex-toml') {
|
|
1212
|
+
if (!/^name\s*=/m.test(raw)) issues.push({ level: 'error', message: `${base}.toml: missing name` });
|
|
1213
|
+
if (!/^description\s*=/m.test(raw)) {
|
|
1214
|
+
issues.push({ level: 'error', message: `${base}.toml: missing description` });
|
|
1215
|
+
}
|
|
1216
|
+
if (!/^developer_instructions\s*=/m.test(raw)) {
|
|
1217
|
+
issues.push({ level: 'error', message: `${base}.toml: missing developer_instructions` });
|
|
1218
|
+
}
|
|
1219
|
+
return issues;
|
|
1220
|
+
}
|
|
1221
|
+
const { fm, hasFrontmatter } = parseFrontmatter(raw);
|
|
1222
|
+
if (!hasFrontmatter) {
|
|
1223
|
+
issues.push({ level: 'error', message: `${base}: no frontmatter block starting with --- on line 1` });
|
|
1224
|
+
return issues;
|
|
1225
|
+
}
|
|
1226
|
+
if (platform.agentFormat === 'atomcode-role') {
|
|
1227
|
+
const permission = asString(fm.permission);
|
|
1228
|
+
if (permission !== 'explore' && permission !== 'worker') {
|
|
1229
|
+
issues.push({ level: 'error', message: `${base}: permission must be explore|worker` });
|
|
1230
|
+
}
|
|
1231
|
+
const difficulty = asString(fm.difficulty);
|
|
1232
|
+
if (difficulty !== 'simple' && difficulty !== 'hard') {
|
|
1233
|
+
issues.push({ level: 'error', message: `${base}: difficulty must be simple|hard` });
|
|
1234
|
+
}
|
|
1235
|
+
return issues;
|
|
1236
|
+
}
|
|
1237
|
+
const name = asString(fm.name);
|
|
1238
|
+
if (!name) {
|
|
1239
|
+
issues.push({ level: 'error', message: `${base}: missing name` });
|
|
1240
|
+
} else {
|
|
1241
|
+
if (platform.name === 'trae-cn' && name.length > 50) {
|
|
1242
|
+
issues.push({ level: 'error', message: `${base}: name ${name.length} chars > 50 (trae limit)` });
|
|
1243
|
+
}
|
|
1244
|
+
if (platform.name === 'claude-code') {
|
|
1245
|
+
if (name.length > 256) {
|
|
1246
|
+
issues.push({ level: 'error', message: `${base}: name exceeds 256 chars` });
|
|
1247
|
+
}
|
|
1248
|
+
if (name.includes(':')) {
|
|
1249
|
+
issues.push({ level: 'error', message: `${base}: name must not contain ':'` });
|
|
1250
|
+
}
|
|
1251
|
+
if (name.startsWith('-')) {
|
|
1252
|
+
issues.push({ level: 'error', message: `${base}: name must not start with '-'` });
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
if (!asString(fm.description)) {
|
|
1257
|
+
issues.push({ level: 'error', message: `${base}: missing description` });
|
|
1258
|
+
}
|
|
1259
|
+
return issues;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* command md 的跨平台规则:文件名小写 kebab-case(trae / qoder / codex 命名
|
|
1264
|
+
* 约束);frontmatter 完整性;
|
|
1265
|
+
* description 缺失仅 warn(补全列表为空、qoder 可能不列出);codebuddy 的
|
|
1266
|
+
* `` !`cmd` `` 注入要求 allowed-tools 含 Bash。
|
|
1267
|
+
*/
|
|
1268
|
+
export function validateCommandMd(
|
|
1269
|
+
platform: AgentPlatform,
|
|
1270
|
+
fileName: string,
|
|
1271
|
+
raw: string,
|
|
1272
|
+
): ValidationIssue[] {
|
|
1273
|
+
const issues: ValidationIssue[] = [];
|
|
1274
|
+
const base = fileName.replace(/\.md$/, '');
|
|
1275
|
+
if (!SKILL_NAME_RE.test(base)) {
|
|
1276
|
+
issues.push({
|
|
1277
|
+
level: 'error',
|
|
1278
|
+
message: `${fileName}: command name "${base}" is not lowercase kebab-case (trae/qoder/codex naming constraint)`,
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
if (!raw.startsWith('---')) {
|
|
1282
|
+
issues.push({
|
|
1283
|
+
level: 'warn',
|
|
1284
|
+
message: `${fileName}: no frontmatter block - description missing from command list`,
|
|
1285
|
+
});
|
|
1286
|
+
return issues;
|
|
1287
|
+
}
|
|
1288
|
+
const { fm, body, hasFrontmatter } = parseFrontmatter(raw);
|
|
1289
|
+
if (!hasFrontmatter) {
|
|
1290
|
+
issues.push({
|
|
1291
|
+
level: 'error',
|
|
1292
|
+
message: `${fileName}: malformed frontmatter (--- must open and close the block)`,
|
|
1293
|
+
});
|
|
1294
|
+
return issues;
|
|
1295
|
+
}
|
|
1296
|
+
if (!asString(fm.description)) {
|
|
1297
|
+
issues.push({
|
|
1298
|
+
level: 'warn',
|
|
1299
|
+
message: `${fileName}: no description - autocomplete shows nothing (qoder may not list it)`,
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
if (body.trim() === '') {
|
|
1303
|
+
issues.push({
|
|
1304
|
+
level: 'warn',
|
|
1305
|
+
message: `${fileName}: empty body - qoder will not list this command`,
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
if (platform.agentFormat === 'codebuddy' && body.includes('!`')) {
|
|
1309
|
+
const allowed =
|
|
1310
|
+
typeof fm['allowed-tools'] === 'string'
|
|
1311
|
+
? fm['allowed-tools']
|
|
1312
|
+
: Array.isArray(fm['allowed-tools'])
|
|
1313
|
+
? fm['allowed-tools'].join(',')
|
|
1314
|
+
: '';
|
|
1315
|
+
if (!/\bBash\b/.test(allowed)) {
|
|
1316
|
+
issues.push({
|
|
1317
|
+
level: 'warn',
|
|
1318
|
+
message: `${fileName}: body uses !\`cmd\` injection but allowed-tools lacks Bash (codebuddy requires it)`,
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return issues;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
/* ------------------------------------------------------------------ */
|
|
1326
|
+
/* 文件操作 */
|
|
1327
|
+
/* ------------------------------------------------------------------ */
|
|
1328
|
+
|
|
1329
|
+
export async function exists(p: string): Promise<boolean> {
|
|
1330
|
+
try {
|
|
1331
|
+
await fs.access(p);
|
|
1332
|
+
return true;
|
|
1333
|
+
} catch {
|
|
1334
|
+
return false;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/** 打包的 skill 目录名(含 SKILL.md 的子目录)。 */
|
|
1339
|
+
export async function listBundledSkills(): Promise<string[]> {
|
|
1340
|
+
const entries = await fs.readdir(SKILLS_ROOT, { withFileTypes: true }).catch(() => []);
|
|
1341
|
+
const names: string[] = [];
|
|
1342
|
+
for (const entry of entries) {
|
|
1343
|
+
if (entry.isDirectory() && (await exists(path.join(SKILLS_ROOT, entry.name, 'SKILL.md')))) {
|
|
1344
|
+
names.push(entry.name);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
return names;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/** 打包的 agents/ 顶层条目名(文件与目录)。 */
|
|
1351
|
+
export async function listBundledAgents(): Promise<string[]> {
|
|
1352
|
+
const entries = await fs.readdir(AGENTS_ROOT, { withFileTypes: true }).catch(() => []);
|
|
1353
|
+
return entries.filter((e) => e.isFile() || e.isDirectory()).map((e) => e.name);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/** 打包的 commands/ 下的斜杠命令文件名(*.md)。 */
|
|
1357
|
+
export async function listBundledCommands(): Promise<string[]> {
|
|
1358
|
+
const entries = await fs.readdir(COMMANDS_ROOT, { withFileTypes: true }).catch(() => []);
|
|
1359
|
+
return entries.filter((e) => e.isFile() && e.name.endsWith('.md')).map((e) => e.name);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
async function copyRecursive(src: string, dest: string): Promise<void> {
|
|
1363
|
+
await fs.cp(src, dest, { recursive: true, force: true });
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* 文件级覆盖(skills / 目录形 agents):把 platforms/<platform>/<kind>/<name>/ 下的文件
|
|
1368
|
+
* 复制到 dest——同名覆盖(platforms 版优先于打包根目录版),新增文件也带上。
|
|
1369
|
+
* exclude 里的文件名跳过:skills 的 SKILL.frontmatter.md / SKILL.unique.md 是拼装输入、
|
|
1370
|
+
* SKILL.md 是拼装输出(installTo 最后写入),三者不参与覆盖。
|
|
1371
|
+
* dryRun 只统计不落盘。返回复制的文件数。
|
|
1372
|
+
*/
|
|
1373
|
+
async function copyOverlayFiles(
|
|
1374
|
+
overlayDir: string,
|
|
1375
|
+
dest: string,
|
|
1376
|
+
exclude: ReadonlySet<string>,
|
|
1377
|
+
dryRun: boolean,
|
|
1378
|
+
): Promise<number> {
|
|
1379
|
+
if (!(await exists(overlayDir))) return 0;
|
|
1380
|
+
let count = 0;
|
|
1381
|
+
const walk = async (src: string, out: string): Promise<void> => {
|
|
1382
|
+
const entries = await fs.readdir(src, { withFileTypes: true }).catch(() => []);
|
|
1383
|
+
for (const entry of entries) {
|
|
1384
|
+
const s = path.join(src, entry.name);
|
|
1385
|
+
const o = path.join(out, entry.name);
|
|
1386
|
+
if (entry.isDirectory()) {
|
|
1387
|
+
await walk(s, o);
|
|
1388
|
+
} else if (entry.isFile() && !exclude.has(entry.name)) {
|
|
1389
|
+
count++;
|
|
1390
|
+
if (!dryRun) {
|
|
1391
|
+
await fs.mkdir(path.dirname(o), { recursive: true });
|
|
1392
|
+
await fs.copyFile(s, o);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
await walk(overlayDir, dest);
|
|
1398
|
+
return count;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/** skills 文件级覆盖时跳过的拼装三件套(两个输入 + 一个输出)。 */
|
|
1402
|
+
const SKILL_OVERLAY_EXCLUDE = new Set(['SKILL.frontmatter.md', 'SKILL.unique.md', 'SKILL.md']);
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* 同名源文件优先 platforms(文件形 agents / commands):platforms/<platform>/<kind>/<name>
|
|
1406
|
+
* 存在时用它作为拼装源正文(同名 → platforms 版优先),否则回退打包根目录。
|
|
1407
|
+
*/
|
|
1408
|
+
async function platformSourcePath(
|
|
1409
|
+
platformName: string,
|
|
1410
|
+
kind: 'agents' | 'commands',
|
|
1411
|
+
name: string,
|
|
1412
|
+
): Promise<{ src: string; overlay: boolean }> {
|
|
1413
|
+
const overlay = path.join(PLATFORMS_ROOT, platformName, kind, name);
|
|
1414
|
+
if (await exists(overlay)) return { src: overlay, overlay: true };
|
|
1415
|
+
return { src: path.join(kind === 'agents' ? AGENTS_ROOT : COMMANDS_ROOT, name), overlay: false };
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/** 卸载 / 检测时要清理的 agent 文件名:codex 目标额外清理历史版本拷贝的原始 md。 */
|
|
1419
|
+
function agentFileCandidates(platform: AgentPlatform, mdName: string): string[] {
|
|
1420
|
+
return platform.agentFormat === 'codex-toml'
|
|
1421
|
+
? [mdName.replace(/\.md$/, '.toml'), mdName]
|
|
1422
|
+
: [mdName];
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/** 删除旧版本安装在错误位置的打包内容(不影响用户自己的文件)。 */
|
|
1426
|
+
async function cleanLegacyDirs(platform: AgentPlatform): Promise<void> {
|
|
1427
|
+
if (platform.legacyDirs.length === 0) return;
|
|
1428
|
+
const skills = await listBundledSkills();
|
|
1429
|
+
const agents = await listBundledAgents();
|
|
1430
|
+
const commands = await listBundledCommands();
|
|
1431
|
+
for (const legacy of platform.legacyDirs) {
|
|
1432
|
+
if (legacy.skillsDir) {
|
|
1433
|
+
for (const s of skills) await fs.rm(path.join(legacy.skillsDir, s), { recursive: true, force: true });
|
|
1434
|
+
}
|
|
1435
|
+
if (legacy.agentsDir) {
|
|
1436
|
+
for (const a of agents) await fs.rm(path.join(legacy.agentsDir, a), { recursive: true, force: true });
|
|
1437
|
+
}
|
|
1438
|
+
if (legacy.commandsDir) {
|
|
1439
|
+
for (const c of commands) await fs.rm(path.join(legacy.commandsDir, c), { force: true });
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
export interface ActionResult {
|
|
1445
|
+
skills: number;
|
|
1446
|
+
agents: number;
|
|
1447
|
+
commands: number;
|
|
1448
|
+
/** 跳过的安装项及原因(如 dsh 无文件式 subagent)。 */
|
|
1449
|
+
skipped: string[];
|
|
1450
|
+
/** 聚合后的转换说明(同类 note 合并计数)。 */
|
|
1451
|
+
notes: string[];
|
|
1452
|
+
/** 安装后读回校验发现的问题。 */
|
|
1453
|
+
issues: ValidationIssue[];
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/* ------------------------------------------------------------------ */
|
|
1457
|
+
/* 平台正文拼装:frontmatter 取自 platforms/,正文 = unique + 根文档 */
|
|
1458
|
+
/* ------------------------------------------------------------------ */
|
|
1459
|
+
|
|
1460
|
+
export type DocKind = 'skill' | 'agent' | 'command';
|
|
1461
|
+
|
|
1462
|
+
interface PlatformPaths {
|
|
1463
|
+
headerMd: string;
|
|
1464
|
+
headerToml: string | null;
|
|
1465
|
+
unique: string;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
interface ComposedDoc {
|
|
1469
|
+
/** 平台定义的 YAML frontmatter 块(含 --- 分隔线);null = 平台未定义。 */
|
|
1470
|
+
header: string | null;
|
|
1471
|
+
/** 平台定义的 Codex TOML 头;null = 未定义。 */
|
|
1472
|
+
headerToml: string | null;
|
|
1473
|
+
/** 平台 `.frontmatter.md` 的原始文本;用于兼容「TOML 写在 .md 里」的历史产物。 */
|
|
1474
|
+
headerRaw: string | null;
|
|
1475
|
+
/** unique 补丁原文;null = 无补丁。 */
|
|
1476
|
+
unique: string | null;
|
|
1477
|
+
/** 根目录文档的 frontmatter 块;null = 根文档无 frontmatter。 */
|
|
1478
|
+
rootHeader: string | null;
|
|
1479
|
+
/** 拼装后的正文(unique + 根文档正文),首尾已归一化。 */
|
|
1480
|
+
body: string;
|
|
1481
|
+
/** 回退用:根 frontmatter + 拼装正文。 */
|
|
1482
|
+
legacyRaw: string;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
function normalizeText(raw: string): string {
|
|
1486
|
+
const noBom = raw.charCodeAt(0) === 0xfeff ? raw.slice(1) : raw;
|
|
1487
|
+
return noBom.replace(/\r\n/g, '\n');
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
/** 取出 `---\n…\n---` 块(含分隔线,不含块后换行);无块返回 null。 */
|
|
1491
|
+
function extractYamlHeader(raw: string): string | null {
|
|
1492
|
+
const m = /^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(raw);
|
|
1493
|
+
return m ? m[0].replace(/\r\n/g, '\n').replace(/\n+$/, '') : null;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
function trimmedBody(raw: string): string {
|
|
1497
|
+
const { body, hasFrontmatter } = parseFrontmatter(raw);
|
|
1498
|
+
return (hasFrontmatter ? body : raw)
|
|
1499
|
+
.replace(/^(?:\r?\n)+/, '')
|
|
1500
|
+
.replace(/\s+$/, '');
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
function platformPaths(platformName: string, kind: DocKind, name: string): PlatformPaths {
|
|
1504
|
+
const base = path.join(PLATFORMS_ROOT, platformName);
|
|
1505
|
+
if (kind === 'skill') {
|
|
1506
|
+
const dir = path.join(base, 'skills', name);
|
|
1507
|
+
return {
|
|
1508
|
+
headerMd: path.join(dir, 'SKILL.frontmatter.md'),
|
|
1509
|
+
headerToml: null,
|
|
1510
|
+
unique: path.join(dir, 'SKILL.unique.md'),
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
const dir = path.join(base, kind === 'agent' ? 'agents' : 'commands');
|
|
1514
|
+
const stem = name.replace(/\.md$/, '');
|
|
1515
|
+
return {
|
|
1516
|
+
headerMd: path.join(dir, `${stem}.frontmatter.md`),
|
|
1517
|
+
headerToml: kind === 'agent' ? path.join(dir, `${stem}.frontmatter.toml`) : null,
|
|
1518
|
+
unique: path.join(dir, `${stem}.unique.md`),
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
async function readOptional(p: string): Promise<string | null> {
|
|
1523
|
+
try {
|
|
1524
|
+
return normalizeText(await fs.readFile(p, 'utf-8'));
|
|
1525
|
+
} catch {
|
|
1526
|
+
return null;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
function joinYamlBody(header: string, body: string): string {
|
|
1531
|
+
const h = header.replace(/\n+$/, '');
|
|
1532
|
+
return body ? `${h}\n\n${body}\n` : `${h}\n`;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* 读取平台的 frontmatter / unique,并与根文档正文拼装。
|
|
1537
|
+
* frontmatter 不再由代码改写:平台有定义就用平台定义,没有才回退旧转换。
|
|
1538
|
+
*/
|
|
1539
|
+
async function composeDoc(
|
|
1540
|
+
platform: AgentPlatform,
|
|
1541
|
+
kind: DocKind,
|
|
1542
|
+
name: string,
|
|
1543
|
+
rootRaw: string,
|
|
1544
|
+
): Promise<ComposedDoc> {
|
|
1545
|
+
const rootText = normalizeText(rootRaw);
|
|
1546
|
+
const rootHeader = extractYamlHeader(rootText);
|
|
1547
|
+
const rootBody = trimmedBody(rootText);
|
|
1548
|
+
const paths = platformPaths(platform.name, kind, name);
|
|
1549
|
+
const [headerFile, tomlFile, uniqueFile] = await Promise.all([
|
|
1550
|
+
readOptional(paths.headerMd),
|
|
1551
|
+
paths.headerToml ? readOptional(paths.headerToml) : Promise.resolve(null),
|
|
1552
|
+
readOptional(paths.unique),
|
|
1553
|
+
]);
|
|
1554
|
+
const uniqueText = uniqueFile?.trimEnd() ?? null;
|
|
1555
|
+
const body = [uniqueText, rootBody].filter((s): s is string => !!s).join('\n\n');
|
|
1556
|
+
return {
|
|
1557
|
+
header: headerFile ? extractYamlHeader(headerFile) : null,
|
|
1558
|
+
headerToml: tomlFile ? tomlFile.replace(/\s+$/, '') : null,
|
|
1559
|
+
headerRaw: headerFile ? headerFile.replace(/\s+$/, '') : null,
|
|
1560
|
+
unique: uniqueText,
|
|
1561
|
+
rootHeader,
|
|
1562
|
+
body,
|
|
1563
|
+
legacyRaw: rootHeader ? joinYamlBody(rootHeader, body) : body ? `${body}\n` : '',
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
function sourceNotes(c: ComposedDoc): string[] {
|
|
1568
|
+
return [
|
|
1569
|
+
c.header || c.headerToml ? 'frontmatter: platforms definition' : 'frontmatter: root fallback',
|
|
1570
|
+
c.unique ? 'body: unique patch + root body' : 'body: root body',
|
|
1571
|
+
];
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
export interface ComposedTransform {
|
|
1575
|
+
content: string;
|
|
1576
|
+
rawCopy: boolean;
|
|
1577
|
+
notes: string[];
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/** 平台 YAML 头 + 拼装正文;没有平台头时调用方回退旧转换。 */
|
|
1581
|
+
function composeYamlDoc(c: ComposedDoc): ComposedTransform {
|
|
1582
|
+
return {
|
|
1583
|
+
content: joinYamlBody(c.header as string, c.body),
|
|
1584
|
+
rawCopy: false,
|
|
1585
|
+
notes: sourceNotes(c),
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
/* ------------------------------------------------------------------ */
|
|
1590
|
+
/* Skill / Agent / Command 内容构建 */
|
|
1591
|
+
/* ------------------------------------------------------------------ */
|
|
1592
|
+
|
|
1593
|
+
export async function buildSkillContent(
|
|
1594
|
+
platform: AgentPlatform,
|
|
1595
|
+
skillName: string,
|
|
1596
|
+
rootRaw: string,
|
|
1597
|
+
): Promise<ComposedTransform> {
|
|
1598
|
+
if (platform.verbatim) return { content: rootRaw, rawCopy: true, notes: [] };
|
|
1599
|
+
const c = await composeDoc(platform, 'skill', skillName, rootRaw);
|
|
1600
|
+
if (c.header) return composeYamlDoc(c);
|
|
1601
|
+
const t = transformSkillMd(platform, c.legacyRaw);
|
|
1602
|
+
return {
|
|
1603
|
+
content: t.content,
|
|
1604
|
+
// unique 补丁已并入正文(content != 源文件):即使 frontmatter 无需改写也
|
|
1605
|
+
// 不能标 rawCopy,否则 installTo 按“原样拷贝已正确”跳过落盘,unique 被丢弃
|
|
1606
|
+
rawCopy: t.rawCopy && !c.unique,
|
|
1607
|
+
notes: [...sourceNotes(c), 'platform frontmatter absent: legacy transform applied', ...t.notes],
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
export interface AgentComposedTransform extends ComposedTransform {
|
|
1612
|
+
fileName: string;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
/** Codex:TOML 头 + 正文写入 developer_instructions(已存在则不改写)。 */
|
|
1616
|
+
function injectCodexInstructions(
|
|
1617
|
+
toml: string,
|
|
1618
|
+
body: string,
|
|
1619
|
+
): { content: string; notes: string[] } {
|
|
1620
|
+
const notes: string[] = [];
|
|
1621
|
+
let text = toml
|
|
1622
|
+
.split('\n')
|
|
1623
|
+
.filter(
|
|
1624
|
+
(line) =>
|
|
1625
|
+
!(/^\s*#/.test(line) && /developer_instructions\s*=/.test(line)),
|
|
1626
|
+
)
|
|
1627
|
+
.join('\n')
|
|
1628
|
+
.replace(/\s+$/, '');
|
|
1629
|
+
if (/^developer_instructions\s*=/m.test(text)) {
|
|
1630
|
+
notes.push('developer_instructions already defined in platform TOML: body not injected');
|
|
1631
|
+
return { content: text + '\n', notes };
|
|
1632
|
+
}
|
|
1633
|
+
const key = `developer_instructions = ${tomlMultiline(body)}`;
|
|
1634
|
+
const lines = text.split('\n');
|
|
1635
|
+
const firstTable = lines.findIndex((line) => /^\s*\[/.test(line));
|
|
1636
|
+
if (firstTable >= 0) {
|
|
1637
|
+
lines.splice(firstTable, 0, key, '');
|
|
1638
|
+
} else {
|
|
1639
|
+
lines.push('', key);
|
|
1640
|
+
}
|
|
1641
|
+
notes.push('developer_instructions injected from composed body');
|
|
1642
|
+
return { content: lines.join('\n').replace(/\n{3,}$/, '\n\n') + '\n', notes };
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
export async function buildAgentContent(
|
|
1646
|
+
platform: AgentPlatform,
|
|
1647
|
+
fileName: string,
|
|
1648
|
+
rootRaw: string,
|
|
1649
|
+
): Promise<AgentComposedTransform | null> {
|
|
1650
|
+
if (platform.agentFormat === 'none') return null;
|
|
1651
|
+
if (platform.verbatim) {
|
|
1652
|
+
return { fileName, content: rootRaw, rawCopy: true, notes: [] };
|
|
1653
|
+
}
|
|
1654
|
+
const c = await composeDoc(platform, 'agent', fileName, rootRaw);
|
|
1655
|
+
// codex:权威 TOML 头是 .frontmatter.toml;历史产物把 TOML 写在 .frontmatter.md 里
|
|
1656
|
+
// (无 --- 围栏),这里作为兼容输入,保证「platform 前言优先于 base」这一条不退化。
|
|
1657
|
+
const tomlHeader =
|
|
1658
|
+
c.headerToml ?? (platform.agentFormat === 'codex-toml' && !c.header ? c.headerRaw : null);
|
|
1659
|
+
if (platform.agentFormat === 'codex-toml' && tomlHeader) {
|
|
1660
|
+
const out = injectCodexInstructions(tomlHeader, c.body);
|
|
1661
|
+
const notes = sourceNotes(c);
|
|
1662
|
+
if (!c.headerToml && !c.header) notes[0] = 'frontmatter: platforms definition (TOML in .frontmatter.md, legacy name)';
|
|
1663
|
+
return {
|
|
1664
|
+
fileName: fileName.replace(/\.md$/, '.toml'),
|
|
1665
|
+
content: out.content,
|
|
1666
|
+
rawCopy: false,
|
|
1667
|
+
notes: [...notes, ...out.notes],
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
if (c.header) {
|
|
1671
|
+
return { fileName, ...composeYamlDoc(c) };
|
|
1672
|
+
}
|
|
1673
|
+
const t = transformAgentMd(platform, fileName, c.legacyRaw);
|
|
1674
|
+
if (!t) return null;
|
|
1675
|
+
return {
|
|
1676
|
+
fileName: t.fileName,
|
|
1677
|
+
content: t.content,
|
|
1678
|
+
// 同 buildSkillContent:unique 补丁改变了内容时不能标 rawCopy(保持契约一致)
|
|
1679
|
+
rawCopy: t.rawCopy && !c.unique,
|
|
1680
|
+
notes: [...sourceNotes(c), 'platform frontmatter absent: legacy transform applied', ...t.notes],
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
export async function buildCommandContent(
|
|
1685
|
+
platform: AgentPlatform,
|
|
1686
|
+
fileName: string,
|
|
1687
|
+
rootRaw: string,
|
|
1688
|
+
): Promise<ComposedTransform> {
|
|
1689
|
+
if (platform.verbatim) return { content: rootRaw, rawCopy: true, notes: [] };
|
|
1690
|
+
const c = await composeDoc(platform, 'command', fileName, rootRaw);
|
|
1691
|
+
if (c.header) return composeYamlDoc(c);
|
|
1692
|
+
const t = transformCommandMd(platform, c.legacyRaw);
|
|
1693
|
+
return {
|
|
1694
|
+
content: t.content,
|
|
1695
|
+
// 同 buildSkillContent:unique 补丁改变了内容时不能标 rawCopy
|
|
1696
|
+
// (installTo 的 rawCopy 分支按源文件原样拷贝,会丢弃 unique)
|
|
1697
|
+
rawCopy: t.rawCopy && !c.unique,
|
|
1698
|
+
notes: [...sourceNotes(c), ...t.notes],
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
export interface ComposedCommandSkill extends CommandSkillTransform {
|
|
1703
|
+
notes: string[];
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
export async function buildCommandSkill(
|
|
1707
|
+
platform: AgentPlatform,
|
|
1708
|
+
fileName: string,
|
|
1709
|
+
rootRaw: string,
|
|
1710
|
+
): Promise<ComposedCommandSkill> {
|
|
1711
|
+
const c = await composeDoc(platform, 'command', fileName, rootRaw);
|
|
1712
|
+
const t = commandToSkillMd(platform, fileName, c.legacyRaw);
|
|
1713
|
+
return { ...t, notes: [...sourceNotes(c), ...t.notes] };
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
export interface InstallOptions {
|
|
1718
|
+
dryRun?: boolean;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* 把打包的 skills / agents / commands 按平台适配后安装到目标智能体目录
|
|
1723
|
+
* (同名覆盖;skills 先删后拷避免旧版本残留)。
|
|
1724
|
+
*
|
|
1725
|
+
* 文件级覆盖(platforms/<agent>/… 下的内容优先于打包根目录):
|
|
1726
|
+
* - skills:platforms/<agent>/skills/<name>/ 下的文件复制到目标,同名覆盖、新增皆可
|
|
1727
|
+
* (SKILL.frontmatter.md / SKILL.unique.md 是拼装输入、SKILL.md 是拼装输出,不参与覆盖);
|
|
1728
|
+
* - agents / commands:platforms/<agent>/<kind>/<name> 同名源文件作为拼装源正文。
|
|
1729
|
+
*/
|
|
1730
|
+
export async function installTo(
|
|
1731
|
+
target: AgentTarget,
|
|
1732
|
+
opts: InstallOptions = {},
|
|
1733
|
+
): Promise<ActionResult> {
|
|
1734
|
+
const platform = target.platform;
|
|
1735
|
+
const dryRun = opts.dryRun === true;
|
|
1736
|
+
const noteCounts = new Map<string, number>();
|
|
1737
|
+
const issues: ValidationIssue[] = [];
|
|
1738
|
+
const skipped: string[] = [];
|
|
1739
|
+
const addNote = (note: string): void => {
|
|
1740
|
+
noteCounts.set(note, (noteCounts.get(note) ?? 0) + 1);
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
// 安装源就是包根/仓库根的 skills|agents|commands(根目录即 base)。缺了它们
|
|
1744
|
+
// 说明这个包在发布时把安装源排除了——直接报错,避免静默装出 0 个 skill。
|
|
1745
|
+
if (!existsSync(SKILLS_ROOT) || !existsSync(AGENTS_ROOT) || !existsSync(COMMANDS_ROOT)) {
|
|
1746
|
+
throw new Error(
|
|
1747
|
+
`插件包不完整:${PACKAGE_ROOT} 下缺少安装源(skills/、agents/、commands/)。` +
|
|
1748
|
+
'该版本的发布配置把根目录内容排除了,请升级插件或检查 package.json 的 files/exclusion。',
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
// 清理旧版本错误位置的残留,避免与当前位置并存
|
|
1753
|
+
if (!dryRun) await cleanLegacyDirs(platform);
|
|
1754
|
+
|
|
1755
|
+
let skills = 0;
|
|
1756
|
+
const bundledSkills = await listBundledSkills();
|
|
1757
|
+
if (platform.skillsDir && bundledSkills.length > 0 && !dryRun) {
|
|
1758
|
+
await fs.mkdir(platform.skillsDir, { recursive: true });
|
|
1759
|
+
}
|
|
1760
|
+
if (platform.skillsDir) {
|
|
1761
|
+
for (const name of bundledSkills) {
|
|
1762
|
+
const sourceRaw = await fs.readFile(path.join(SKILLS_ROOT, name, 'SKILL.md'), 'utf-8');
|
|
1763
|
+
const t = await buildSkillContent(platform, name, sourceRaw);
|
|
1764
|
+
const dest = path.join(platform.skillsDir, name);
|
|
1765
|
+
if (!dryRun) {
|
|
1766
|
+
await fs.rm(dest, { recursive: true, force: true });
|
|
1767
|
+
await copyRecursive(path.join(SKILLS_ROOT, name), dest);
|
|
1768
|
+
}
|
|
1769
|
+
// 文件级覆盖:platforms/<agent>/skills/<name>/ 下的文件盖到目标(同名 platforms 版优先)
|
|
1770
|
+
const overlayCount = await copyOverlayFiles(
|
|
1771
|
+
path.join(PLATFORMS_ROOT, platform.name, 'skills', name),
|
|
1772
|
+
dest,
|
|
1773
|
+
SKILL_OVERLAY_EXCLUDE,
|
|
1774
|
+
dryRun,
|
|
1775
|
+
);
|
|
1776
|
+
if (overlayCount > 0) {
|
|
1777
|
+
addNote(`file overlay: platforms/${platform.name}/skills/${name} (${overlayCount} files)`);
|
|
1778
|
+
}
|
|
1779
|
+
if (!dryRun && !t.rawCopy) await fs.writeFile(path.join(dest, 'SKILL.md'), t.content, 'utf-8');
|
|
1780
|
+
for (const n of t.notes) addNote(n);
|
|
1781
|
+
// 读回落盘内容校验(dry-run 时校验待写内容),证明目标平台可解析
|
|
1782
|
+
const finalRaw = dryRun
|
|
1783
|
+
? t.rawCopy
|
|
1784
|
+
? sourceRaw
|
|
1785
|
+
: t.content
|
|
1786
|
+
: await fs.readFile(path.join(platform.skillsDir, name, 'SKILL.md'), 'utf-8');
|
|
1787
|
+
issues.push(...validateSkillMd(name, finalRaw, platform.skillDescriptionLimit));
|
|
1788
|
+
skills++;
|
|
1789
|
+
}
|
|
1790
|
+
} else if (bundledSkills.length > 0) {
|
|
1791
|
+
skipped.push(`${target.name}: skills skipped - platform has no skills directory`);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
let agents = 0;
|
|
1795
|
+
const bundledAgents = await listBundledAgents();
|
|
1796
|
+
if (platform.agentsDir && bundledAgents.length > 0 && !dryRun) {
|
|
1797
|
+
await fs.mkdir(platform.agentsDir, { recursive: true });
|
|
1798
|
+
}
|
|
1799
|
+
if (platform.agentsDir) {
|
|
1800
|
+
for (const name of bundledAgents) {
|
|
1801
|
+
const srcPath = path.join(AGENTS_ROOT, name);
|
|
1802
|
+
if ((await fs.stat(srcPath)).isDirectory()) {
|
|
1803
|
+
// 子目录形式的 agent(当前未使用):原样拷贝 + platforms 文件级覆盖
|
|
1804
|
+
const dest = path.join(platform.agentsDir, name);
|
|
1805
|
+
if (!dryRun) {
|
|
1806
|
+
await fs.rm(dest, { recursive: true, force: true });
|
|
1807
|
+
await copyRecursive(srcPath, dest);
|
|
1808
|
+
}
|
|
1809
|
+
const dirOverlay = await copyOverlayFiles(
|
|
1810
|
+
path.join(PLATFORMS_ROOT, platform.name, 'agents', name),
|
|
1811
|
+
dest,
|
|
1812
|
+
new Set(),
|
|
1813
|
+
dryRun,
|
|
1814
|
+
);
|
|
1815
|
+
if (dirOverlay > 0) {
|
|
1816
|
+
addNote(`file overlay: platforms/${platform.name}/agents/${name} (${dirOverlay} files)`);
|
|
1817
|
+
}
|
|
1818
|
+
agents++;
|
|
1819
|
+
continue;
|
|
1820
|
+
}
|
|
1821
|
+
if (!name.endsWith('.md')) continue;
|
|
1822
|
+
// 同名源文件优先:platforms/<agent>/agents/<name> 存在时作为拼装源正文
|
|
1823
|
+
const source = await platformSourcePath(platform.name, 'agents', name);
|
|
1824
|
+
if (source.overlay) addNote(`source overlay: platforms/${platform.name}/agents/${name}`);
|
|
1825
|
+
const raw = await fs.readFile(source.src, 'utf-8');
|
|
1826
|
+
const t = await buildAgentContent(platform, name, raw);
|
|
1827
|
+
if (!t) continue; // 'none' 格式的平台不会进入该分支(agentsDir 为 null)
|
|
1828
|
+
if (!dryRun) {
|
|
1829
|
+
await fs.writeFile(path.join(platform.agentsDir, t.fileName), t.content, 'utf-8');
|
|
1830
|
+
// 清理 codex 目标下历史版本直接拷贝的原始 md
|
|
1831
|
+
if (t.fileName !== name) {
|
|
1832
|
+
await fs.rm(path.join(platform.agentsDir, name), { force: true });
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
for (const n of t.notes) addNote(n);
|
|
1836
|
+
const finalRaw = dryRun
|
|
1837
|
+
? t.content
|
|
1838
|
+
: await fs.readFile(path.join(platform.agentsDir, t.fileName), 'utf-8');
|
|
1839
|
+
issues.push(...validateAgentFile(platform, t.fileName, finalRaw));
|
|
1840
|
+
agents++;
|
|
1841
|
+
}
|
|
1842
|
+
} else if (bundledAgents.length > 0) {
|
|
1843
|
+
skipped.push(
|
|
1844
|
+
`${target.name}: agents skipped - ${platform.agentsSkipNote ?? 'platform has no file-based subagent'}`,
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
let commands = 0;
|
|
1849
|
+
const bundledCommands = await listBundledCommands();
|
|
1850
|
+
if (platform.commandsAsSkills && platform.skillsDir) {
|
|
1851
|
+
// 命令以 skill 形式装入 skills 目录(codex:custom prompts 已弃用;
|
|
1852
|
+
// dsh:无文件式命令),“仅用户显式触发”语义按平台原生机制保留
|
|
1853
|
+
if (bundledCommands.length > 0) {
|
|
1854
|
+
if (!dryRun) await fs.mkdir(platform.skillsDir, { recursive: true });
|
|
1855
|
+
addNote(`commands installed as skills into ${platform.skillsDir}`);
|
|
1856
|
+
}
|
|
1857
|
+
for (const name of bundledCommands) {
|
|
1858
|
+
const source = await platformSourcePath(platform.name, 'commands', name);
|
|
1859
|
+
if (source.overlay) addNote(`source overlay: platforms/${platform.name}/commands/${name}`);
|
|
1860
|
+
const sourceRaw = await fs.readFile(source.src, 'utf-8');
|
|
1861
|
+
const t = await buildCommandSkill(platform, name, sourceRaw);
|
|
1862
|
+
if (!dryRun) {
|
|
1863
|
+
const dest = path.join(platform.skillsDir, t.skillName);
|
|
1864
|
+
await fs.rm(dest, { recursive: true, force: true });
|
|
1865
|
+
await fs.mkdir(dest, { recursive: true });
|
|
1866
|
+
await fs.writeFile(path.join(dest, 'SKILL.md'), t.content, 'utf-8');
|
|
1867
|
+
if (t.openaiYaml !== null) {
|
|
1868
|
+
await fs.mkdir(path.join(dest, 'agents'), { recursive: true });
|
|
1869
|
+
await fs.writeFile(path.join(dest, 'agents', 'openai.yaml'), t.openaiYaml, 'utf-8');
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
for (const n of t.notes) addNote(n);
|
|
1873
|
+
const finalRaw = dryRun
|
|
1874
|
+
? t.content
|
|
1875
|
+
: await fs.readFile(path.join(platform.skillsDir, t.skillName, 'SKILL.md'), 'utf-8');
|
|
1876
|
+
issues.push(...validateSkillMd(t.skillName, finalRaw, platform.skillDescriptionLimit));
|
|
1877
|
+
commands++;
|
|
1878
|
+
}
|
|
1879
|
+
} else if (platform.commandsDir && bundledCommands.length > 0) {
|
|
1880
|
+
if (!dryRun) await fs.mkdir(platform.commandsDir, { recursive: true });
|
|
1881
|
+
for (const name of bundledCommands) {
|
|
1882
|
+
const source = await platformSourcePath(platform.name, 'commands', name);
|
|
1883
|
+
if (source.overlay) addNote(`source overlay: platforms/${platform.name}/commands/${name}`);
|
|
1884
|
+
const sourceRaw = await fs.readFile(source.src, 'utf-8');
|
|
1885
|
+
const t = await buildCommandContent(platform, name, sourceRaw);
|
|
1886
|
+
if (!dryRun) {
|
|
1887
|
+
const dest = path.join(platform.commandsDir, name);
|
|
1888
|
+
if (t.rawCopy) {
|
|
1889
|
+
await fs.copyFile(source.src, dest);
|
|
1890
|
+
} else {
|
|
1891
|
+
await fs.writeFile(dest, t.content, 'utf-8');
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
for (const n of t.notes) addNote(n);
|
|
1895
|
+
const finalRaw = dryRun
|
|
1896
|
+
? t.rawCopy
|
|
1897
|
+
? sourceRaw
|
|
1898
|
+
: t.content
|
|
1899
|
+
: await fs.readFile(path.join(platform.commandsDir, name), 'utf-8');
|
|
1900
|
+
issues.push(...validateCommandMd(platform, name, finalRaw));
|
|
1901
|
+
commands++;
|
|
1902
|
+
}
|
|
1903
|
+
} else if (bundledCommands.length > 0) {
|
|
1904
|
+
skipped.push(
|
|
1905
|
+
platform.commandsSkipNote
|
|
1906
|
+
? `${target.name}: commands skipped - ${platform.commandsSkipNote}`
|
|
1907
|
+
: `${target.name}: commands skipped - platform has no slash-command directory`,
|
|
1908
|
+
);
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
const notes = [...noteCounts.entries()].map(([note, n]) => (n > 1 ? `${note} (${n} files)` : note));
|
|
1912
|
+
return { skills, agents, commands, skipped, notes, issues };
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
/** 删除目标智能体目录中与打包内容同名的 skills / agents / commands(含旧版残留位置);不碰其他文件。 */
|
|
1916
|
+
export async function uninstallFrom(target: AgentTarget): Promise<ActionResult> {
|
|
1917
|
+
const platform = target.platform;
|
|
1918
|
+
const result: ActionResult = { skills: 0, agents: 0, commands: 0, skipped: [], notes: [], issues: [] };
|
|
1919
|
+
const skills = await listBundledSkills();
|
|
1920
|
+
const agents = await listBundledAgents();
|
|
1921
|
+
const commands = await listBundledCommands();
|
|
1922
|
+
|
|
1923
|
+
const skillDirs = [platform.skillsDir, ...platform.legacyDirs.map((l) => l.skillsDir)].filter(
|
|
1924
|
+
(d): d is string => !!d,
|
|
1925
|
+
);
|
|
1926
|
+
for (const name of skills) {
|
|
1927
|
+
let removed = false;
|
|
1928
|
+
for (const dir of skillDirs) {
|
|
1929
|
+
const p = path.join(dir, name);
|
|
1930
|
+
if (await exists(p)) {
|
|
1931
|
+
await fs.rm(p, { recursive: true, force: true });
|
|
1932
|
+
removed = true;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
if (removed) result.skills++;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
const agentDirs = [platform.agentsDir, ...platform.legacyDirs.map((l) => l.agentsDir)].filter(
|
|
1939
|
+
(d): d is string => !!d,
|
|
1940
|
+
);
|
|
1941
|
+
for (const name of agents) {
|
|
1942
|
+
let removed = false;
|
|
1943
|
+
for (const dir of agentDirs) {
|
|
1944
|
+
for (const candidate of agentFileCandidates(platform, name)) {
|
|
1945
|
+
const p = path.join(dir, candidate);
|
|
1946
|
+
if (await exists(p)) {
|
|
1947
|
+
await fs.rm(p, { recursive: true, force: true });
|
|
1948
|
+
removed = true;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
if (removed) result.agents++;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
const commandDirs = [platform.commandsDir, ...platform.legacyDirs.map((l) => l.commandsDir)].filter(
|
|
1956
|
+
(d): d is string => !!d,
|
|
1957
|
+
);
|
|
1958
|
+
for (const name of commands) {
|
|
1959
|
+
let removed = false;
|
|
1960
|
+
for (const dir of commandDirs) {
|
|
1961
|
+
const p = path.join(dir, name);
|
|
1962
|
+
if (await exists(p)) {
|
|
1963
|
+
await fs.rm(p, { force: true });
|
|
1964
|
+
removed = true;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
// commandsAsSkills 平台:命令以 <skillsDir>/<name>/ skill 目录形式存在
|
|
1968
|
+
if (platform.commandsAsSkills && platform.skillsDir) {
|
|
1969
|
+
const p = path.join(platform.skillsDir, name.replace(/\.md$/, ''));
|
|
1970
|
+
if (await exists(p)) {
|
|
1971
|
+
await fs.rm(p, { recursive: true, force: true });
|
|
1972
|
+
removed = true;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
if (removed) result.commands++;
|
|
1976
|
+
}
|
|
1977
|
+
return result;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/** 目标智能体目录中是否已装有本插件的任一 skill / agent / command(含旧版残留位置)。 */
|
|
1981
|
+
export async function isInstalledIn(target: AgentTarget): Promise<boolean> {
|
|
1982
|
+
const platform = target.platform;
|
|
1983
|
+
const skills = await listBundledSkills();
|
|
1984
|
+
const agents = await listBundledAgents();
|
|
1985
|
+
const commands = await listBundledCommands();
|
|
1986
|
+
for (const name of skills) {
|
|
1987
|
+
for (const dir of [platform.skillsDir, ...platform.legacyDirs.map((l) => l.skillsDir)]) {
|
|
1988
|
+
if (dir && (await exists(path.join(dir, name)))) return true;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
for (const name of agents) {
|
|
1992
|
+
for (const dir of [platform.agentsDir, ...platform.legacyDirs.map((l) => l.agentsDir)]) {
|
|
1993
|
+
if (!dir) continue;
|
|
1994
|
+
for (const candidate of agentFileCandidates(platform, name)) {
|
|
1995
|
+
if (await exists(path.join(dir, candidate))) return true;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
for (const name of commands) {
|
|
2000
|
+
for (const dir of [platform.commandsDir, ...platform.legacyDirs.map((l) => l.commandsDir)]) {
|
|
2001
|
+
if (dir && (await exists(path.join(dir, name)))) return true;
|
|
2002
|
+
}
|
|
2003
|
+
if (
|
|
2004
|
+
platform.commandsAsSkills &&
|
|
2005
|
+
platform.skillsDir &&
|
|
2006
|
+
(await exists(path.join(platform.skillsDir, name.replace(/\.md$/, ''))))
|
|
2007
|
+
) {
|
|
2008
|
+
return true;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
return false;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
/* ------------------------------------------------------------------ */
|
|
2015
|
+
/* 参数解析 */
|
|
2016
|
+
/* ------------------------------------------------------------------ */
|
|
2017
|
+
|
|
2018
|
+
export interface CliOptions {
|
|
2019
|
+
targets: AgentTarget[];
|
|
2020
|
+
dryRun: boolean;
|
|
2021
|
+
/** --verbose 或 HOMETRANS_PLUGIN_VERBOSE=1:打印逐目标明细(默认静默)。 */
|
|
2022
|
+
verbose: boolean;
|
|
2023
|
+
/** --project 解析出的工程根目录(绝对路径)。 */
|
|
2024
|
+
projectRoot?: string;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* 旧版 plugin.jsonc / 存量脚本使用带空格的智能体名,本版改名后仍作为别名
|
|
2029
|
+
* 接受(映射到当前平台表中的规范名),避免 DevEco CLI 或用户脚本传旧名
|
|
2030
|
+
* 直接报错。未知名字仅小写化后原样返回,由调用方校验报错。
|
|
2031
|
+
*/
|
|
2032
|
+
const AGENT_NAME_ALIASES: Record<string, string> = {
|
|
2033
|
+
'claude code': 'claude-code',
|
|
2034
|
+
'deveco code': 'deveco',
|
|
2035
|
+
};
|
|
2036
|
+
|
|
2037
|
+
export function canonicalAgentName(name: string): string {
|
|
2038
|
+
const n = name.trim().toLowerCase();
|
|
2039
|
+
return AGENT_NAME_ALIASES[n] ?? n;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
/**
|
|
2043
|
+
* 详细输出开关(环境变量形态)。install / uninstall / update 默认静默:
|
|
2044
|
+
* 成功时不产生任何控制台输出,仅校验 ERROR 仍可见。deveco-cli 插件契约
|
|
2045
|
+
* 路径(index.ts 的 hook)由宿主调用、没有旗标可传,环境变量是唯一入口;
|
|
2046
|
+
* 独立运行模式除本变量外还接受 --verbose 旗标(parseArgs 取两者的或)。
|
|
2047
|
+
*/
|
|
2048
|
+
export function isVerboseEnv(): boolean {
|
|
2049
|
+
const v = process.env.HOMETRANS_PLUGIN_VERBOSE;
|
|
2050
|
+
return v !== undefined && /^(1|true|yes)$/i.test(v.trim());
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
export function parseArgs(
|
|
2054
|
+
argv: string[],
|
|
2055
|
+
manifest: PluginManifest,
|
|
2056
|
+
platforms: Map<string, AgentPlatform>,
|
|
2057
|
+
): CliOptions {
|
|
2058
|
+
const agentNames: string[] = [];
|
|
2059
|
+
let dir: string | undefined;
|
|
2060
|
+
let project: string | undefined;
|
|
2061
|
+
let dryRun = false;
|
|
2062
|
+
let verboseFlag = false;
|
|
2063
|
+
|
|
2064
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2065
|
+
const arg = argv[i];
|
|
2066
|
+
let key = arg;
|
|
2067
|
+
let value: string | undefined;
|
|
2068
|
+
const eq = arg.indexOf('=');
|
|
2069
|
+
if (arg.startsWith('--') && eq > 0) {
|
|
2070
|
+
key = arg.slice(0, eq);
|
|
2071
|
+
value = arg.slice(eq + 1);
|
|
2072
|
+
}
|
|
2073
|
+
if (key === '--dry-run' && value === undefined) {
|
|
2074
|
+
dryRun = true;
|
|
2075
|
+
continue;
|
|
2076
|
+
}
|
|
2077
|
+
if (key === '--verbose' && value === undefined) {
|
|
2078
|
+
verboseFlag = true;
|
|
2079
|
+
continue;
|
|
2080
|
+
}
|
|
2081
|
+
if (key !== '--agent' && key !== '--dir' && key !== '--project') {
|
|
2082
|
+
throw new PluginError(`unknown option ${arg}`);
|
|
2083
|
+
}
|
|
2084
|
+
if (value === undefined) {
|
|
2085
|
+
value = argv[++i];
|
|
2086
|
+
if (value === undefined || value.startsWith('--')) {
|
|
2087
|
+
throw new PluginError(`option ${key} requires a value`);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
if (key === '--agent') {
|
|
2091
|
+
for (const piece of value.split(',').map((s) => s.trim()).filter(Boolean)) {
|
|
2092
|
+
const canonical = canonicalAgentName(piece);
|
|
2093
|
+
if (canonical !== piece.toLowerCase()) {
|
|
2094
|
+
console.error(`note: agent name "${piece}" is deprecated, use "${canonical}"`);
|
|
2095
|
+
}
|
|
2096
|
+
agentNames.push(canonical);
|
|
2097
|
+
}
|
|
2098
|
+
} else if (key === '--dir') {
|
|
2099
|
+
dir = value;
|
|
2100
|
+
} else {
|
|
2101
|
+
project = value;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
const allowed = manifest.agent.map((a) => a.toLowerCase());
|
|
2106
|
+
for (const name of agentNames) {
|
|
2107
|
+
if (!allowed.includes(name.toLowerCase())) {
|
|
2108
|
+
throw new PluginError(`agent name ${name} invalid`);
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
if (dir !== undefined && project !== undefined) {
|
|
2112
|
+
throw new PluginError('--dir and --project cannot be used together');
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
let dirTarget: AgentTarget | undefined;
|
|
2116
|
+
if (dir !== undefined) {
|
|
2117
|
+
const resolved = path.resolve(dir.replace(/^~(?=$|[\\/])/, os.homedir()));
|
|
2118
|
+
let isDir = false;
|
|
2119
|
+
try {
|
|
2120
|
+
isDir = statSync(resolved).isDirectory();
|
|
2121
|
+
} catch {
|
|
2122
|
+
isDir = false;
|
|
2123
|
+
}
|
|
2124
|
+
if (!isDir) throw new PluginError('dir path invalid');
|
|
2125
|
+
// --dir 不识别平台:skills / agents 原样拷贝,不做任何转换
|
|
2126
|
+
dirTarget = {
|
|
2127
|
+
name: resolved,
|
|
2128
|
+
explicit: true,
|
|
2129
|
+
platform: {
|
|
2130
|
+
name: `dir(${resolved})`,
|
|
2131
|
+
markerDir: resolved,
|
|
2132
|
+
skillsDir: path.join(resolved, 'skills'),
|
|
2133
|
+
agentsDir: path.join(resolved, 'agents'),
|
|
2134
|
+
commandsDir: path.join(resolved, 'commands'),
|
|
2135
|
+
agentFormat: 'passthrough',
|
|
2136
|
+
skillKeepAllowedTools: true,
|
|
2137
|
+
skillKeepArgumentHint: true,
|
|
2138
|
+
skillSlashMetadata: false,
|
|
2139
|
+
commandKeepKeys: [],
|
|
2140
|
+
commandsAsSkills: false,
|
|
2141
|
+
verbatim: true,
|
|
2142
|
+
legacyDirs: [],
|
|
2143
|
+
},
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
// 工程根目录必须是已存在的目录(工程内的 .<agent> 由安装过程创建)
|
|
2148
|
+
let projectRoot: string | undefined;
|
|
2149
|
+
if (project !== undefined) {
|
|
2150
|
+
const resolved = path.resolve(project.replace(/^~(?=$|[\\/])/, os.homedir()));
|
|
2151
|
+
let isDir = false;
|
|
2152
|
+
try {
|
|
2153
|
+
isDir = statSync(resolved).isDirectory();
|
|
2154
|
+
} catch {
|
|
2155
|
+
isDir = false;
|
|
2156
|
+
}
|
|
2157
|
+
if (!isDir) throw new PluginError('project path invalid');
|
|
2158
|
+
projectRoot = resolved;
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
const explicitAgent = agentNames.length > 0;
|
|
2162
|
+
// 只给了 --dir 时只处理该路径;都没给(或只给了 --project)时处理全部智能体
|
|
2163
|
+
// (agentNames 已经过 canonicalAgentName 规范为小写规范名)
|
|
2164
|
+
const selected = explicitAgent
|
|
2165
|
+
? agentNames
|
|
2166
|
+
: dir === undefined
|
|
2167
|
+
? allowed
|
|
2168
|
+
: [];
|
|
2169
|
+
const targets: AgentTarget[] = [];
|
|
2170
|
+
for (const name of new Set(selected)) {
|
|
2171
|
+
const platform = platforms.get(name);
|
|
2172
|
+
if (!platform) throw new PluginError(`agent name ${name} invalid`);
|
|
2173
|
+
targets.push({
|
|
2174
|
+
name,
|
|
2175
|
+
explicit: explicitAgent,
|
|
2176
|
+
platform: projectRoot ? toProjectPlatform(platform, projectRoot) : platform,
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
// --dir 与某个 --agent 的目录相同时只处理一次
|
|
2180
|
+
if (dirTarget && !targets.some((t) => t.platform.markerDir === dirTarget!.platform.markerDir)) {
|
|
2181
|
+
targets.push(dirTarget);
|
|
2182
|
+
}
|
|
2183
|
+
return { targets, dryRun, verbose: verboseFlag || isVerboseEnv(), projectRoot };
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
/* ------------------------------------------------------------------ */
|
|
2187
|
+
/* 入口包装 */
|
|
2188
|
+
/* ------------------------------------------------------------------ */
|
|
2189
|
+
|
|
2190
|
+
/** 解析参数并运行命令;参数错误打印到 stderr 并以退出码 1 结束。 */
|
|
2191
|
+
export async function runCommand(
|
|
2192
|
+
run: (opts: CliOptions, manifest: PluginManifest) => Promise<void>,
|
|
2193
|
+
): Promise<void> {
|
|
2194
|
+
try {
|
|
2195
|
+
const manifest = await loadManifest();
|
|
2196
|
+
const platforms = resolvePlatforms();
|
|
2197
|
+
const opts = parseArgs(process.argv.slice(2), manifest, platforms);
|
|
2198
|
+
await run(opts, manifest);
|
|
2199
|
+
} catch (err) {
|
|
2200
|
+
console.error(err instanceof PluginError ? err.message : (err as Error).stack ?? String(err));
|
|
2201
|
+
process.exitCode = 1;
|
|
2202
|
+
}
|
|
2203
|
+
}
|