@thinkingai/ae-cli 6.1.30 → 6.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/README.zh.md +18 -7
- package/bin/ai-monitor.js +2 -0
- package/bin/runtime-capabilities.json +1 -1
- package/dist/ai-monitor-OHTSU6SV.js +33 -0
- package/dist/ai-monitor.js +136 -0
- package/dist/{auth-ADZHUIJR.js → auth-2MOK4OI6.js} +24 -14
- package/dist/{automation-FD2QZUP6.js → automation-6L6IAYRK.js} +6 -7
- package/dist/{capability-QXFRJYZD.js → capability-EMIHQJA3.js} +31 -34
- package/dist/{chunk-OAWPT7VP.js → chunk-2I5SZ5DS.js} +2 -2
- package/dist/{chunk-HRUOV6EQ.js → chunk-4IQYPWCX.js} +22 -21
- package/dist/{chunk-EUFP4M2A.js → chunk-7DHSB3FL.js} +85 -33
- package/dist/{chunk-4PSTYEG5.js → chunk-AMURHMS3.js} +11 -7
- package/dist/{chunk-KPQY44JQ.js → chunk-AWW2T2WL.js} +3 -0
- package/dist/chunk-BQFLABJQ.js +186 -0
- package/dist/{chunk-E25OSZLJ.js → chunk-COOMXFUG.js} +3 -3
- package/dist/{chunk-AVXDJAFC.js → chunk-DWAG2QJM.js} +52 -15
- package/dist/{chunk-CG773QXN.js → chunk-E3ONSFUN.js} +528 -299
- package/dist/chunk-EFGUBGA6.js +64 -0
- package/dist/chunk-EWVEAERM.js +563 -0
- package/dist/{chunk-VDICGXCY.js → chunk-HIMOBNEY.js} +2 -2
- package/dist/{chunk-JEUXDY3B.js → chunk-HQED4YB4.js} +1 -1
- package/dist/{chunk-2F64AZYH.js → chunk-KA5WKR5P.js} +2 -2
- package/dist/{chunk-TFORY6WY.js → chunk-KD5UC33N.js} +23 -9
- package/dist/{chunk-YVG6QD3V.js → chunk-LFJ7N36I.js} +103 -8
- package/dist/chunk-NNK3JBH4.js +60 -0
- package/dist/{chunk-YULUBP3R.js → chunk-O45NOIWR.js} +2 -2
- package/dist/{chunk-SOSFRU3O.js → chunk-PLNS5J33.js} +58 -26
- package/dist/chunk-PUSFEC6B.js +29 -0
- package/dist/{chunk-Z3Q2AEIN.js → chunk-R2SVAO4G.js} +14 -2
- package/dist/{chunk-Y3AM6LIO.js → chunk-RC3PPCYD.js} +16 -11
- package/dist/{chunk-AWVZTN2B.js → chunk-THTROEGD.js} +1 -1
- package/dist/{chunk-QVRIDN42.js → chunk-UCMO4LKL.js} +2 -2
- package/dist/{chunk-JSBLCLFE.js → chunk-VLOGOM7N.js} +13 -7
- package/dist/{chunk-72NJKS7O.js → chunk-XZDKAR4N.js} +4 -4
- package/dist/chunk-YE6MJB5V.js +1285 -0
- package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-ULRNXLQV.js} +1 -1
- package/dist/{compat-check-HERBTQZN.js → compat-check-CADG7GND.js} +5 -4
- package/dist/{config-E3KANXMK.js → config-PFD3KWQG.js} +28 -14
- package/dist/{context-CDB5H5PD.js → context-SOQDFZIB.js} +8 -6
- package/dist/{data-integration-QE37EQ3A.js → data-integration-UNJ7EPW2.js} +6 -6
- package/dist/{evaluation-LR4YDYWL.js → evaluation-Q3AIGFOG.js} +14 -159
- package/dist/index.js +95 -593
- package/dist/{local-data-upload-client-KCMG6J62.js → local-data-upload-client-YTWMAAGE.js} +1 -1
- package/dist/{memory-SNFR5M23.js → memory-HKNGUIPK.js} +6 -7
- package/dist/{metadata-EXQYDZTH.js → metadata-GFWR5ZHC.js} +11 -10
- package/dist/{model-KEVCEXWD.js → model-NAKQWK4W.js} +4 -5
- package/dist/{personal-semantic-preference-ETY3KU2O.js → personal-semantic-preference-JCTKXLC3.js} +46 -15
- package/dist/{project-semantic-UHRMVOJF.js → project-semantic-B2NWQOKK.js} +19 -16
- package/dist/{sync-XKEBXESC.js → sync-UQH4J4BD.js} +9 -9
- package/dist/{te-agent-S6UQR4IE.js → te-agent-L6EYFQCC.js} +303 -17
- package/dist/{te-analysis-WOFFCIBC.js → te-analysis-U7NNOY66.js} +397 -203
- package/dist/{te-community-R7B6QYOO.js → te-community-3UQEW3KD.js} +14 -12
- package/dist/{te-dataops-KPILYVHA.js → te-dataops-SUNYXF5G.js} +13 -11
- package/dist/{te-engage-IAUM6ONX.js → te-engage-KMXZJ2KN.js} +10 -9
- package/dist/{te-experiment-TMLRA7B3.js → te-experiment-IEYKP6VC.js} +477 -45
- package/dist/{te-kb-GKWPSLSY.js → te-kb-MT3V5ZMH.js} +78 -18
- package/dist/{te-system-CYWSK3UN.js → te-system-F4ZU2HRQ.js} +6 -7
- package/dist/{te-team-ISN52YNG.js → te-team-M6E6XQ5H.js} +9 -8
- package/dist/{things-DDQ52Z3Q.js → things-FRLBZV2Z.js} +9 -8
- package/dist/{update-CTLNTX35.js → update-NULYHVE6.js} +8 -6
- package/dist/{workspace-2CKQX2XL.js → workspace-Z7L33OBQ.js} +6 -7
- package/package.json +13 -8
- package/skills/ae-agent/SKILL.md +19 -5
- package/skills/ae-agent/references/a2a.md +103 -0
- package/skills/ae-agent/references/command_index.md +11 -0
- package/skills/ae-ai-monitor/SKILL.md +179 -0
- package/skills/ae-ai-monitor/references/read-commands.md +866 -0
- package/skills/ae-analysis/SKILL.md +43 -25
- package/skills/ae-analysis/references/adhoc_export.md +3 -1
- package/skills/ae-analysis/references/ai_models/path.md +5 -6
- package/skills/ae-analysis/references/ai_models.md +1 -0
- package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
- package/skills/ae-analysis/references/analysis_gateway_assets.md +2 -0
- package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
- package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
- package/skills/ae-analysis/references/asset_search.md +1 -1
- package/skills/ae-analysis/references/bad_case_begin.md +12 -0
- package/skills/ae-analysis/references/bad_case_get.md +12 -0
- package/skills/ae-analysis/references/bad_case_history.md +12 -0
- package/skills/ae-analysis/references/bad_case_list.md +12 -0
- package/skills/ae-analysis/references/bad_case_review.md +51 -0
- package/skills/ae-analysis/references/bad_case_run.md +12 -0
- package/skills/ae-analysis/references/bad_case_submit.md +12 -0
- package/skills/ae-analysis/references/bad_case_submit_to_page.md +12 -0
- package/skills/ae-analysis/references/bad_case_sync_evaluation.md +11 -0
- package/skills/ae-analysis/references/bi_panel_list.md +1 -1
- package/skills/ae-analysis/references/bi_panel_share.md +3 -1
- package/skills/ae-analysis/references/catalog_list.md +2 -0
- package/skills/ae-analysis/references/command_index.md +44 -35
- package/skills/ae-analysis/references/dashboard_daily_report_update.md +2 -0
- package/skills/ae-analysis/references/dashboard_handover.md +3 -1
- package/skills/ae-analysis/references/dashboard_list.md +3 -3
- package/skills/ae-analysis/references/dashboard_report_data_export.md +1 -1
- package/skills/ae-analysis/references/dashboard_share.md +3 -1
- package/skills/ae-analysis/references/dashboard_update.md +3 -2
- package/skills/ae-analysis/references/filter_value_list.md +2 -0
- package/skills/ae-analysis/references/folder_share.md +8 -2
- package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
- package/skills/ae-analysis/references/governance_recommendation_run_update.md +3 -1
- package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
- package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
- package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
- package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
- package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
- package/skills/ae-analysis/references/project_data_power_upsert.md +3 -1
- package/skills/ae-analysis/references/project_mark_time_create.md +2 -0
- package/skills/ae-analysis/references/project_mark_time_update.md +2 -0
- package/skills/ae-analysis/references/project_member_add.md +3 -1
- package/skills/ae-analysis/references/project_member_batch_update.md +3 -1
- package/skills/ae-analysis/references/project_member_handover_run.md +3 -1
- package/skills/ae-analysis/references/project_member_update.md +3 -1
- package/skills/ae-analysis/references/project_owner_update.md +8 -2
- package/skills/ae-analysis/references/project_role_upsert.md +5 -3
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +16 -1
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +14 -1
- package/skills/ae-analysis/references/project_space_share.md +8 -2
- package/skills/ae-analysis/references/property_get.md +2 -0
- package/skills/ae-analysis/references/public_link_list.md +3 -1
- package/skills/ae-analysis/references/query_cancel.md +4 -1
- package/skills/ae-analysis/references/report_data_run.md +1 -1
- package/skills/ae-analysis/references/report_list.md +3 -3
- package/skills/ae-analysis/references/scenario_append.md +2 -2
- package/skills/ae-analysis/references/scenario_collect.md +15 -4
- package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
- package/skills/ae-analysis/references/scenario_list.md +7 -7
- package/skills/ae-analysis/references/system_oauth2_update.md +3 -1
- package/skills/ae-analysis/references/system_third_party_login_upsert.md +4 -2
- package/skills/ae-analysis/references/user_tag_create.md +4 -1
- package/skills/ae-analysis/references/user_tag_get.md +2 -0
- package/skills/ae-analysis/references/user_tag_models.md +8 -2
- package/skills/ae-analysis/references/user_tag_update.md +5 -2
- package/skills/ae-analysis/references/virtual_property_create.md +12 -1
- package/skills/ae-analysis/references/virtual_property_sql_rule_update.md +10 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +55 -13
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +2 -2
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +2 -2
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +7 -1
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/wait-compile-run.mjs +79 -0
- package/skills/ae-automation/SKILL.md +4 -2
- package/skills/ae-capability/SKILL.md +16 -8
- package/skills/ae-community/SKILL.md +1 -0
- package/skills/ae-dataops/SKILL.md +1 -0
- package/skills/ae-engage/SKILL.md +1 -0
- package/skills/ae-evaluation/SKILL.md +17 -2
- package/skills/ae-experiment/SKILL.md +69 -13
- package/skills/ae-experiment/references/experiment_approval.md +229 -0
- package/skills/ae-experiment/references/manage_experiment.md +15 -2
- package/skills/ae-experiment/references/manage_traffic_domains.md +131 -0
- package/skills/ae-experiment/references/query_experiment_detail.md +8 -0
- package/skills/ae-experiment/references/query_experiment_list.md +6 -0
- package/skills/ae-experiment/references/save_experiment.md +56 -10
- package/skills/ae-experiment/references/save_metric.md +29 -2
- package/skills/ae-experiment/references/save_submit_experiment.md +22 -3
- package/skills/ae-experiment/references/save_submit_external_experiment.md +59 -3
- package/skills/ae-experiment/references/save_traffic_layer.md +17 -1
- package/skills/ae-generate-tracking-plan/SKILL.md +5 -0
- package/skills/ae-kb/SKILL.md +8 -4
- package/skills/ae-kb/references/analysis-workflow.md +11 -2
- package/skills/ae-kb/references/publication.md +45 -0
- package/skills/ae-kb/references/query-workflow.md +3 -1
- package/skills/ae-kb/references/versions.md +1 -1
- package/skills/ae-metadata/SKILL.md +1 -0
- package/skills/ae-migrate-tracking-code/SKILL.md +2 -1
- package/skills/ae-team/SKILL.md +1 -1
- package/skills/ae-tracking-matrix/SKILL.md +170 -0
- package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
- package/skills/ae-tracking-matrix/i18n.yaml +12 -0
- package/skills/ae-tracking-matrix/references/ae-capabilities.md +93 -0
- package/skills/ae-tracking-matrix/references/business-semantic-checks.md +30 -0
- package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +256 -0
- package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +213 -0
- package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +407 -0
- package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +218 -0
- package/skills/ae-tracking-matrix/references/categories/casual_music.md +112 -0
- package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +301 -0
- package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +356 -0
- package/skills/ae-tracking-matrix/references/categories/fishing.md +775 -0
- package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +89 -0
- package/skills/ae-tracking-matrix/references/categories/idle_card.md +27 -0
- package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +415 -0
- package/skills/ae-tracking-matrix/references/categories/interactive_video.md +133 -0
- package/skills/ae-tracking-matrix/references/categories/merge.md +639 -0
- package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +406 -0
- package/skills/ae-tracking-matrix/references/categories/mmo_web.md +230 -0
- package/skills/ae-tracking-matrix/references/categories/music.md +137 -0
- package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +414 -0
- package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +199 -0
- package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +158 -0
- package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +546 -0
- package/skills/ae-tracking-matrix/references/categories/rpg.md +195 -0
- package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +115 -0
- package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +151 -0
- package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +260 -0
- package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +232 -0
- package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +359 -0
- package/skills/ae-tracking-matrix/references/categories/tower_defense.md +365 -0
- package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +211 -0
- package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +132 -0
- package/skills/ae-tracking-matrix/references/category-registry.md +77 -0
- package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +230 -0
- package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +406 -0
- package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +128 -0
- package/skills/ae-tracking-matrix/references/eval-cases.md +74 -0
- package/skills/ae-tracking-matrix/references/naming-dict.md +238 -0
- package/skills/ae-tracking-matrix/references/optimization-checklist.md +85 -0
- package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +142 -0
- package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +47 -0
- package/skills/ae-tracking-matrix/references/plan-generation/reference.md +794 -0
- package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +94 -0
- package/skills/ae-tracking-matrix/references/scene-routing.md +80 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +3787 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +827 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +655 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +953 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +1128 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +714 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +1268 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +776 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +182 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +2755 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +1182 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +1300 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +1369 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +1692 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +902 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +763 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +1107 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +1532 -0
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +845 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +228 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +149 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +407 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +163 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +149 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +153 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +232 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +314 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +117 -0
- package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +148 -0
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +645 -0
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +307 -0
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +347 -0
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +72 -0
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +264 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +566 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +409 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +446 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +557 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +457 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +490 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +523 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +484 -0
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +442 -0
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +391 -0
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +91 -0
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +635 -0
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +113 -0
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +466 -0
- package/skills/ae-tracking-matrix/references/standard-base/README.md +22 -0
- package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +174 -0
- package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +20 -0
- package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +7 -0
- package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +14 -0
- package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +370 -0
- package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +47 -0
- package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +37 -0
- package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +27 -0
- package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +23 -0
- package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +14 -0
- package/skills/ae-tracking-matrix/references/standard-base/user_data.md +46 -0
- package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +13 -0
- package/skills/ae-tracking-matrix/references/system-fields.md +297 -0
- package/skills/ae-tracking-matrix/references/te-field-translations.md +1791 -0
- package/skills/ae-tracking-matrix/references/workflows/data-verification.md +232 -0
- package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +829 -0
- package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +355 -0
- package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +283 -0
- package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +168 -0
- package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +205 -0
- package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +75 -0
- package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +36 -0
- package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +107 -0
- package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +114 -0
- package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +53 -0
- package/skills/ae-tracking-matrix/scripts/finalize_plan.py +166 -0
- package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +674 -0
- package/skills/ae-tracking-matrix/scripts/plan_contract.py +200 -0
- package/skills/ae-tracking-matrix/scripts/plan_types.py +60 -0
- package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +169 -0
- package/skills/ae-tracking-matrix/scripts/sync_plan.py +296 -0
- package/skills/ae-tracking-matrix/scripts/upload_plan.py +340 -0
- package/dist/chunk-AMBFK2K3.js +0 -28
- package/dist/chunk-Y74WTIKJ.js +0 -10
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
getLocalCliPackageInfo
|
|
4
|
+
} from "./chunk-PUSFEC6B.js";
|
|
5
|
+
import {
|
|
6
|
+
internalCallSourceHeaders,
|
|
3
7
|
peekCliToken
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PLNS5J33.js";
|
|
5
9
|
import {
|
|
6
10
|
getActiveHost,
|
|
7
11
|
getConfigDir,
|
|
8
12
|
isAeSandboxRuntime,
|
|
9
13
|
readSandboxCliTokenEntry
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-AMURHMS3.js";
|
|
11
15
|
import {
|
|
12
16
|
PermissionError,
|
|
13
17
|
externalCliTokenRequestOptions,
|
|
14
18
|
normalizeUrl,
|
|
15
19
|
readExternalCliToken
|
|
16
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-R2SVAO4G.js";
|
|
17
21
|
|
|
18
22
|
// src/core/compat-check.ts
|
|
19
23
|
import fs10 from "fs";
|
|
20
24
|
import path10 from "path";
|
|
21
|
-
import { createHash as
|
|
25
|
+
import { createHash as createHash3 } from "crypto";
|
|
22
26
|
import { Agent } from "undici";
|
|
23
27
|
|
|
24
28
|
// src/core/update-check.ts
|
|
@@ -313,39 +317,15 @@ import path8 from "path";
|
|
|
313
317
|
// src/core/installation.ts
|
|
314
318
|
import fs7 from "fs";
|
|
315
319
|
import path7 from "path";
|
|
316
|
-
import
|
|
317
|
-
|
|
318
|
-
// src/core/package-info.ts
|
|
319
|
-
import fs2 from "fs";
|
|
320
|
-
import path2 from "path";
|
|
321
|
-
import { fileURLToPath } from "url";
|
|
322
|
-
function getLocalCliPackageInfo() {
|
|
323
|
-
let dir = path2.dirname(fileURLToPath(import.meta.url));
|
|
324
|
-
for (let i = 0; i < 8; i += 1) {
|
|
325
|
-
const candidate = path2.join(dir, "package.json");
|
|
326
|
-
try {
|
|
327
|
-
if (fs2.existsSync(candidate)) {
|
|
328
|
-
const pkg = JSON.parse(fs2.readFileSync(candidate, "utf8"));
|
|
329
|
-
if (pkg.name && pkg.version && String(pkg.name).includes("ae-cli")) {
|
|
330
|
-
return { name: pkg.name, version: pkg.version, root: dir };
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
} catch {
|
|
334
|
-
}
|
|
335
|
-
const parent = path2.dirname(dir);
|
|
336
|
-
if (parent === dir) break;
|
|
337
|
-
dir = parent;
|
|
338
|
-
}
|
|
339
|
-
return { name: "@tant/ae-cli", version: "0.0.0", root: "" };
|
|
340
|
-
}
|
|
320
|
+
import crypto3 from "crypto";
|
|
341
321
|
|
|
342
322
|
// src/core/skills-install.ts
|
|
343
|
-
import
|
|
323
|
+
import fs2 from "fs";
|
|
344
324
|
import os from "os";
|
|
345
|
-
import
|
|
325
|
+
import path2 from "path";
|
|
346
326
|
import { parseDocument } from "yaml";
|
|
347
327
|
function globalSkillsDirectory() {
|
|
348
|
-
return
|
|
328
|
+
return path2.join(os.homedir(), ".agents", "skills");
|
|
349
329
|
}
|
|
350
330
|
function skillName(content) {
|
|
351
331
|
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
@@ -357,26 +337,39 @@ function skillName(content) {
|
|
|
357
337
|
return data.name;
|
|
358
338
|
}
|
|
359
339
|
function readFiles(root, prefix = "", files = /* @__PURE__ */ new Map()) {
|
|
360
|
-
for (const entry of
|
|
340
|
+
for (const entry of fs2.readdirSync(path2.join(root, prefix), { withFileTypes: true })) {
|
|
361
341
|
if (entry.name.startsWith(".") || ["metadata.json", "__pycache__", "__pypackages__"].includes(entry.name)) continue;
|
|
362
|
-
const relative =
|
|
342
|
+
const relative = path2.join(prefix, entry.name);
|
|
363
343
|
if (entry.isSymbolicLink()) throw new Error("Bundled Skills must contain regular files.");
|
|
364
344
|
if (entry.isDirectory()) readFiles(root, relative, files);
|
|
365
|
-
else if (entry.isFile()) files.set(relative,
|
|
345
|
+
else if (entry.isFile()) files.set(relative, fs2.readFileSync(path2.join(root, relative)));
|
|
366
346
|
}
|
|
367
347
|
return files;
|
|
368
348
|
}
|
|
369
|
-
function readBundledSkills(directory) {
|
|
370
|
-
const
|
|
349
|
+
function readBundledSkills(directory, select) {
|
|
350
|
+
const entries = fs2.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith("."));
|
|
351
|
+
const names = /* @__PURE__ */ new Set();
|
|
352
|
+
const skills = entries.flatMap((entry) => {
|
|
371
353
|
try {
|
|
372
|
-
|
|
373
|
-
|
|
354
|
+
let selectedName;
|
|
355
|
+
if (select) {
|
|
356
|
+
const header = path2.join(directory, entry.name, "SKILL.md");
|
|
357
|
+
if (!fs2.lstatSync(header).isFile()) throw new Error("Bundled Skill metadata must be a regular file.");
|
|
358
|
+
selectedName = skillName(fs2.readFileSync(header, "utf8"));
|
|
359
|
+
if (names.has(selectedName)) throw new Error("Duplicate bundled Skill name.");
|
|
360
|
+
names.add(selectedName);
|
|
361
|
+
if (!select(selectedName)) return [];
|
|
362
|
+
}
|
|
363
|
+
const files = readFiles(path2.join(directory, entry.name));
|
|
364
|
+
const name = skillName(files.get("SKILL.md").toString("utf8"));
|
|
365
|
+
if (selectedName !== void 0 && selectedName !== name) throw new Error("Bundled Skill metadata changed.");
|
|
366
|
+
return [{ name, files }];
|
|
374
367
|
} catch {
|
|
375
368
|
const name = /^[a-z0-9-]+$/.test(entry.name) ? entry.name : "(invalid name)";
|
|
376
369
|
throw new Error(`Invalid bundled Skill ${name}: missing files or YAML/frontmatter error.`);
|
|
377
370
|
}
|
|
378
371
|
});
|
|
379
|
-
if (!
|
|
372
|
+
if (!entries.length || !select && new Set(skills.map((skill) => skill.name)).size !== skills.length) {
|
|
380
373
|
throw new Error("Bundled Skills are empty or contain duplicate names.");
|
|
381
374
|
}
|
|
382
375
|
return skills;
|
|
@@ -385,12 +378,12 @@ function verifyGlobalSkills(skills, directory) {
|
|
|
385
378
|
return skills.flatMap((skill) => {
|
|
386
379
|
let reason = "";
|
|
387
380
|
try {
|
|
388
|
-
const target =
|
|
389
|
-
if (skillName(
|
|
381
|
+
const target = path2.join(directory, skill.name);
|
|
382
|
+
if (skillName(fs2.readFileSync(path2.join(target, "SKILL.md"), "utf8")) !== skill.name) {
|
|
390
383
|
reason = "Installed Skill name does not match the bundled Skill.";
|
|
391
384
|
} else {
|
|
392
385
|
for (const [file, expected] of skill.files) {
|
|
393
|
-
if (!
|
|
386
|
+
if (!fs2.readFileSync(path2.join(target, file)).equals(expected)) {
|
|
394
387
|
reason = "Installed files do not match the CLI package version.";
|
|
395
388
|
break;
|
|
396
389
|
}
|
|
@@ -404,9 +397,9 @@ function verifyGlobalSkills(skills, directory) {
|
|
|
404
397
|
}
|
|
405
398
|
|
|
406
399
|
// src/core/business-config.ts
|
|
407
|
-
import
|
|
408
|
-
import
|
|
409
|
-
import
|
|
400
|
+
import crypto2 from "crypto";
|
|
401
|
+
import fs6 from "fs";
|
|
402
|
+
import path6 from "path";
|
|
410
403
|
|
|
411
404
|
// src/core/skill-businesses.json
|
|
412
405
|
var skill_businesses_default = {
|
|
@@ -421,7 +414,8 @@ var skill_businesses_default = {
|
|
|
421
414
|
"ae-generate-tracking-code",
|
|
422
415
|
"ae-generate-tracking-plan",
|
|
423
416
|
"ae-metadata",
|
|
424
|
-
"ae-migrate-tracking-code"
|
|
417
|
+
"ae-migrate-tracking-code",
|
|
418
|
+
"ae-tracking-matrix"
|
|
425
419
|
],
|
|
426
420
|
dataops: [
|
|
427
421
|
"ae-dataops"
|
|
@@ -439,6 +433,7 @@ var skill_businesses_default = {
|
|
|
439
433
|
],
|
|
440
434
|
agent: [
|
|
441
435
|
"ae-agent",
|
|
436
|
+
"ae-ai-monitor",
|
|
442
437
|
"ae-automation",
|
|
443
438
|
"ae-current-context",
|
|
444
439
|
"ae-evaluation",
|
|
@@ -483,7 +478,9 @@ var COMMAND_BUSINESSES = {
|
|
|
483
478
|
evaluation: "agent",
|
|
484
479
|
sync: "agent",
|
|
485
480
|
model: "agent",
|
|
486
|
-
context: "agent"
|
|
481
|
+
context: "agent",
|
|
482
|
+
"ai-monitor": "agent",
|
|
483
|
+
ai_monitor: "agent"
|
|
487
484
|
};
|
|
488
485
|
var AGENT_SYSTEM_COMMANDS = /* @__PURE__ */ new Set([
|
|
489
486
|
"channel",
|
|
@@ -586,153 +583,65 @@ function canManageGlobalSkills() {
|
|
|
586
583
|
return !readExternalCliToken() && !isSandboxExecutionContext();
|
|
587
584
|
}
|
|
588
585
|
|
|
589
|
-
// src/core/business-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return path4.join(getConfigDir(), "business-config.json");
|
|
594
|
-
}
|
|
595
|
-
function cacheKey(host, token) {
|
|
596
|
-
return `${normalizeUrl(host)}#${crypto.createHash("sha256").update(token).digest("hex")}`;
|
|
597
|
-
}
|
|
598
|
-
function readStore() {
|
|
599
|
-
try {
|
|
600
|
-
const value = JSON.parse(fs4.readFileSync(cachePath(), "utf8"));
|
|
601
|
-
if (value?.entries && typeof value.entries === "object" && !Array.isArray(value.entries)) return value;
|
|
602
|
-
} catch {
|
|
603
|
-
}
|
|
604
|
-
return { entries: {} };
|
|
605
|
-
}
|
|
606
|
-
function remember(host, token, entry) {
|
|
607
|
-
const store = readStore();
|
|
608
|
-
store.entries[cacheKey(host, token)] = entry;
|
|
609
|
-
const target = cachePath();
|
|
610
|
-
const temporary = `${target}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`;
|
|
611
|
-
try {
|
|
612
|
-
fs4.mkdirSync(path4.dirname(target), { recursive: true });
|
|
613
|
-
fs4.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
|
|
614
|
-
fs4.renameSync(temporary, target);
|
|
615
|
-
fs4.chmodSync(target, 384);
|
|
616
|
-
} catch {
|
|
617
|
-
try {
|
|
618
|
-
fs4.rmSync(temporary, { force: true });
|
|
619
|
-
} catch {
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
function rememberBusinessConfig(host, token, businesses, now = Date.now()) {
|
|
624
|
-
remember(host, token, { businesses: normalizeBusinesses(businesses), fetchedAt: now });
|
|
625
|
-
}
|
|
626
|
-
function peekBusinessConfig(host, token, now = Date.now()) {
|
|
627
|
-
const entry = readStore().entries[cacheKey(host, token)];
|
|
628
|
-
if (entry?.unavailableAt !== void 0 && now >= entry.unavailableAt && now - entry.unavailableAt < UNAVAILABLE_TTL_MS) return {};
|
|
629
|
-
if (!entry || !Number.isFinite(entry.fetchedAt) || now < entry.fetchedAt || now - entry.fetchedAt >= BUSINESS_CONFIG_TTL_MS) return void 0;
|
|
630
|
-
return normalizeBusinesses(entry.businesses);
|
|
631
|
-
}
|
|
632
|
-
function readBusinessConfig(host, token) {
|
|
633
|
-
const entry = readStore().entries[cacheKey(host, token)];
|
|
634
|
-
return entry && Number.isFinite(entry.fetchedAt) && entry.fetchedAt > 0 ? normalizeBusinesses(entry.businesses) : void 0;
|
|
635
|
-
}
|
|
636
|
-
function readCurrentBusinessConfig(hostOverride) {
|
|
637
|
-
try {
|
|
638
|
-
if (isSandboxExecutionContext()) return {};
|
|
639
|
-
const host = hostOverride || getActiveHost();
|
|
640
|
-
if (!host) return {};
|
|
641
|
-
const token = peekCliToken(host);
|
|
642
|
-
return token ? readBusinessConfig(host, token) ?? {} : {};
|
|
643
|
-
} catch {
|
|
644
|
-
return {};
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
async function resolveBusinessConfig(host, token, fetchRemote, now = Date.now()) {
|
|
648
|
-
const cached = peekBusinessConfig(host, token, now);
|
|
649
|
-
if (cached !== void 0) return cached;
|
|
650
|
-
const config = await fetchRemote().catch(() => null);
|
|
651
|
-
if (!config) {
|
|
652
|
-
const previous = readStore().entries[cacheKey(host, token)];
|
|
653
|
-
remember(host, token, {
|
|
654
|
-
businesses: normalizeBusinesses(previous?.businesses),
|
|
655
|
-
fetchedAt: previous?.fetchedAt ?? 0,
|
|
656
|
-
unavailableAt: now
|
|
657
|
-
});
|
|
658
|
-
return {};
|
|
659
|
-
}
|
|
660
|
-
const businesses = normalizeBusinesses(config.businesses);
|
|
661
|
-
rememberBusinessConfig(host, token, businesses, now);
|
|
662
|
-
return businesses;
|
|
663
|
-
}
|
|
664
|
-
var BusinessDisabledError = class extends PermissionError {
|
|
665
|
-
constructor(business) {
|
|
666
|
-
super(
|
|
667
|
-
`The '${business}' business is not enabled for the current environment.`,
|
|
668
|
-
"BUSINESS_NOT_ENABLED",
|
|
669
|
-
"Contact your administrator if this business should be enabled, then run: ae-cli config refresh"
|
|
670
|
-
);
|
|
671
|
-
this.business = business;
|
|
672
|
-
this.name = "BusinessDisabledError";
|
|
673
|
-
}
|
|
674
|
-
business;
|
|
675
|
-
};
|
|
676
|
-
async function readBusinessConfigForExecution(hostOverride) {
|
|
677
|
-
try {
|
|
678
|
-
if (isSandboxExecutionContext()) return {};
|
|
679
|
-
const host = hostOverride || getActiveHost();
|
|
680
|
-
if (!host) return {};
|
|
681
|
-
const token = peekCliToken(host);
|
|
682
|
-
if (!token) return {};
|
|
683
|
-
return await resolveBusinessConfig(host, token, async () => {
|
|
684
|
-
const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-HERBTQZN.js");
|
|
685
|
-
return fetchCliConfig2(host, token);
|
|
686
|
-
});
|
|
687
|
-
} catch {
|
|
688
|
-
return {};
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
async function assertBusinessEnabled(business, hostOverride) {
|
|
692
|
-
if (business && (await readBusinessConfigForExecution(hostOverride))[business] === false) {
|
|
693
|
-
throw new BusinessDisabledError(business);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
586
|
+
// src/core/business-skill-refresh.ts
|
|
587
|
+
import crypto from "crypto";
|
|
588
|
+
import fs5 from "fs";
|
|
589
|
+
import path5 from "path";
|
|
696
590
|
|
|
697
591
|
// src/core/business-skill-sync.ts
|
|
698
|
-
import
|
|
699
|
-
import
|
|
700
|
-
import
|
|
592
|
+
import fs4 from "fs";
|
|
593
|
+
import os3 from "os";
|
|
594
|
+
import path4 from "path";
|
|
595
|
+
import { createHash as createHash2, randomUUID } from "crypto";
|
|
701
596
|
|
|
702
597
|
// src/core/skills-tool.ts
|
|
703
|
-
import
|
|
598
|
+
import fs3 from "fs";
|
|
704
599
|
import os2 from "os";
|
|
705
|
-
import
|
|
600
|
+
import path3 from "path";
|
|
706
601
|
import { createHash } from "crypto";
|
|
707
602
|
import { createRequire, isBuiltin } from "module";
|
|
708
603
|
import { pathToFileURL } from "url";
|
|
709
604
|
import spawn2 from "cross-spawn";
|
|
710
605
|
var MANAGED_SKILLS_TOOL_VERSION = "1.5.12";
|
|
711
606
|
var TOOL_SOURCE_SHA256 = "5a2c18ddd70886d5367e39a0f88827ffd1024420e4d9db08149742386c088d2d";
|
|
607
|
+
function skillPathIdentity(file) {
|
|
608
|
+
try {
|
|
609
|
+
const stat = fs3.lstatSync(file, { bigint: true });
|
|
610
|
+
return {
|
|
611
|
+
dev: String(stat.dev),
|
|
612
|
+
ino: String(stat.ino),
|
|
613
|
+
type: stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "other",
|
|
614
|
+
...stat.isSymbolicLink() ? { link: fs3.readlinkSync(file) } : {}
|
|
615
|
+
};
|
|
616
|
+
} catch (error) {
|
|
617
|
+
if (error.code === "ENOENT") return null;
|
|
618
|
+
throw error;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
712
621
|
function realSkillPath(file) {
|
|
713
622
|
try {
|
|
714
|
-
return
|
|
623
|
+
return fs3.realpathSync(file);
|
|
715
624
|
} catch (error) {
|
|
716
625
|
if (error.code !== "ENOENT") throw error;
|
|
717
|
-
const parent =
|
|
626
|
+
const parent = path3.dirname(file);
|
|
718
627
|
if (parent === file) throw error;
|
|
719
|
-
return
|
|
628
|
+
return path3.join(realSkillPath(parent), path3.basename(file));
|
|
720
629
|
}
|
|
721
630
|
}
|
|
722
631
|
function skillPathProblem(targetDirectory, skill, sourceRoot) {
|
|
723
632
|
try {
|
|
724
|
-
const target = realSkillPath(
|
|
725
|
-
const source =
|
|
726
|
-
const overlaps = (a, b) => a === b || a.startsWith(b +
|
|
633
|
+
const target = realSkillPath(path3.resolve(targetDirectory, skill));
|
|
634
|
+
const source = realSkillPath(path3.resolve(sourceRoot));
|
|
635
|
+
const overlaps = (a, b) => a === b || a.startsWith(b + path3.sep);
|
|
727
636
|
if (overlaps(target, source) || overlaps(source, target)) return "package_source_overlap";
|
|
728
|
-
let parent =
|
|
637
|
+
let parent = path3.resolve(targetDirectory);
|
|
729
638
|
while (true) {
|
|
730
639
|
try {
|
|
731
|
-
if (
|
|
640
|
+
if (fs3.lstatSync(parent).isSymbolicLink()) return "copy_parent_linked";
|
|
732
641
|
} catch (error) {
|
|
733
642
|
if (error.code !== "ENOENT") throw error;
|
|
734
643
|
}
|
|
735
|
-
const next =
|
|
644
|
+
const next = path3.dirname(parent);
|
|
736
645
|
if (next === parent) return null;
|
|
737
646
|
parent = next;
|
|
738
647
|
}
|
|
@@ -742,27 +651,27 @@ function skillPathProblem(targetDirectory, skill, sourceRoot) {
|
|
|
742
651
|
}
|
|
743
652
|
function skillCopyHash(directory, source = false) {
|
|
744
653
|
try {
|
|
745
|
-
if (!
|
|
654
|
+
if (!fs3.lstatSync(directory).isDirectory()) throw new Error("Not a regular Skill directory.");
|
|
746
655
|
} catch (error) {
|
|
747
656
|
if (error.code === "ENOENT") return null;
|
|
748
657
|
throw error;
|
|
749
658
|
}
|
|
750
659
|
const hash = createHash("sha256");
|
|
751
660
|
const visit = (relative) => {
|
|
752
|
-
for (const name of
|
|
661
|
+
for (const name of fs3.readdirSync(path3.join(directory, relative)).sort()) {
|
|
753
662
|
if (name === ".DS_Store") continue;
|
|
754
|
-
const child =
|
|
755
|
-
const absolute =
|
|
756
|
-
const stat =
|
|
663
|
+
const child = path3.join(relative, name);
|
|
664
|
+
const absolute = path3.join(directory, child);
|
|
665
|
+
const stat = fs3.lstatSync(absolute);
|
|
757
666
|
if (source && (name === "metadata.json" || stat.isDirectory() && [".git", "__pycache__", "__pypackages__"].includes(name))) continue;
|
|
758
|
-
const normalized = child.split(
|
|
667
|
+
const normalized = child.split(path3.sep).join("/");
|
|
759
668
|
if (stat.isSymbolicLink()) throw new Error("Symbolic links are not managed Skill copies.");
|
|
760
669
|
if (stat.isDirectory()) {
|
|
761
670
|
hash.update(`directory:${normalized}\0`);
|
|
762
671
|
visit(child);
|
|
763
672
|
} else if (stat.isFile()) {
|
|
764
673
|
hash.update(`file:${normalized}\0${stat.size}\0`);
|
|
765
|
-
hash.update(
|
|
674
|
+
hash.update(fs3.readFileSync(absolute));
|
|
766
675
|
} else throw new Error("Unsupported Skill file type.");
|
|
767
676
|
}
|
|
768
677
|
};
|
|
@@ -780,6 +689,11 @@ function adaptedToolSource(source, entry) {
|
|
|
780
689
|
let remove = source.slice(removeStart, removeEnd);
|
|
781
690
|
remove = replaceOnce(remove, "const agentResult = await detectAgent();", "const agentResult = { isAgent: false };");
|
|
782
691
|
remove = replaceOnce(remove, "const spinner = Y();", "const spinner = { start() {}, stop() {} };");
|
|
692
|
+
remove = replaceOnce(
|
|
693
|
+
remove,
|
|
694
|
+
"for (const entry of entries) if (entry.isDirectory()) skillNamesSet.add(entry.name);",
|
|
695
|
+
"for (const entry of entries) if (entry.isDirectory() || options.__aeCliAllowedPaths.has(join(dir, entry.name))) skillNamesSet.add(entry.name);"
|
|
696
|
+
);
|
|
783
697
|
remove = replaceOnce(
|
|
784
698
|
remove,
|
|
785
699
|
"if (pathToCleanup === canonicalPath) continue;",
|
|
@@ -814,7 +728,7 @@ function adaptedToolSource(source, entry) {
|
|
|
814
728
|
);
|
|
815
729
|
source = replaceOnce(source, "main().finally(() => flushTelemetry().then(() => process.exit(0)));", "");
|
|
816
730
|
const require2 = createRequire(entry);
|
|
817
|
-
const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ?
|
|
731
|
+
const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ? path3.resolve(path3.dirname(entry), specifier) : require2.resolve(specifier)).href;
|
|
818
732
|
source = source.replace(
|
|
819
733
|
/\bfrom (['"])([^'"]+)\1/g,
|
|
820
734
|
(_match, quote, specifier) => `from ${quote}${resolveImport(specifier)}${quote}`
|
|
@@ -827,7 +741,6 @@ function adaptedToolSource(source, entry) {
|
|
|
827
741
|
}
|
|
828
742
|
var WORKER_SOURCE = String.raw`
|
|
829
743
|
import * as __aeCliFs from 'node:fs';
|
|
830
|
-
import * as __aeCliPath from 'node:path';
|
|
831
744
|
const __aeCliQuiet = () => {};
|
|
832
745
|
let __aeCliTargetOverride = null;
|
|
833
746
|
let __aeCliBeforeInstallMutation = null;
|
|
@@ -843,7 +756,7 @@ function __aeCliRealPath(file) {
|
|
|
843
756
|
function __aeCliPathProblem(targetDirectory, skill, sourceRoot) {
|
|
844
757
|
try {
|
|
845
758
|
const target = __aeCliRealPath(resolve(targetDirectory, skill));
|
|
846
|
-
const source =
|
|
759
|
+
const source = __aeCliRealPath(resolve(sourceRoot));
|
|
847
760
|
const overlaps = (a, b) => a === b || a.startsWith(b + sep);
|
|
848
761
|
if (overlaps(target, source) || overlaps(source, target)) return 'package_source_overlap';
|
|
849
762
|
let parent = resolve(targetDirectory);
|
|
@@ -876,46 +789,49 @@ function __aeCliHash(directory, source = false) {
|
|
|
876
789
|
visit('');
|
|
877
790
|
return hash.digest('hex');
|
|
878
791
|
}
|
|
792
|
+
function __aeCliDirectInstallerLink(text, file, target) {
|
|
793
|
+
if (typeof text !== 'string') return false;
|
|
794
|
+
let value = text;
|
|
795
|
+
if (process.platform === 'win32') {
|
|
796
|
+
if (value.toUpperCase().startsWith('\\\\?\\UNC\\')) value = '\\\\' + value.slice(8);
|
|
797
|
+
else if (value.startsWith('\\\\?\\') || value.startsWith('\\??\\')) value = value.slice(4);
|
|
798
|
+
return [target, relative(dirname(file), target)].some(expected => value.toLowerCase() === expected.toLowerCase());
|
|
799
|
+
}
|
|
800
|
+
return value === target || value === relative(dirname(file), target);
|
|
801
|
+
}
|
|
879
802
|
function __aeCliLegacyLinkProblem(operation, targetPath, targets, guard) {
|
|
880
803
|
try {
|
|
881
804
|
const canonical = resolve(getCanonicalSkillsDir(true));
|
|
882
805
|
const canonicalTarget = targets.find(target => target.agent === 'universal' && target.directory === canonical);
|
|
883
806
|
const link = operation.legacy_link;
|
|
807
|
+
const removing = operation.action === 'remove';
|
|
884
808
|
if (!canonicalTarget || link.target !== join(canonical, operation.skill) || targetPath === link.target
|
|
885
|
-
|| !guard.ledger_file || operation.expected_hash !== operation.source_hash) return 'legacy_link_not_managed';
|
|
809
|
+
|| !guard.ledger_file || (!removing && operation.expected_hash !== operation.source_hash)) return 'legacy_link_not_managed';
|
|
886
810
|
const pathProblem = __aeCliPathProblem(canonical, operation.skill, operation.source_root);
|
|
887
811
|
if (pathProblem) return pathProblem;
|
|
888
812
|
const ledger = JSON.parse(__aeCliFs.readFileSync(guard.ledger_file, 'utf8'));
|
|
889
813
|
const owned = ledger.schema_version === 1 && ledger.copies?.[link.target];
|
|
890
814
|
if (!owned || owned.skill !== operation.skill || owned.agent !== canonicalTarget.agent
|
|
891
|
-
|| owned.hash !== operation.source_hash) return 'legacy_link_not_managed';
|
|
815
|
+
|| (!removing && owned.hash !== operation.source_hash)) return 'legacy_link_not_managed';
|
|
892
816
|
if (!__aeCliFs.lstatSync(targetPath).isSymbolicLink() || __aeCliFs.readlinkSync(targetPath) !== link.text
|
|
893
|
-
||
|
|
894
|
-
|| __aeCliFs.realpathSync(targetPath) !== __aeCliFs.realpathSync(link.target)) return 'legacy_link_changed';
|
|
895
|
-
if (__aeCliHash(link.target) !== operation.source_hash) return 'legacy_link_target_modified';
|
|
817
|
+
|| !__aeCliDirectInstallerLink(link.text, targetPath, link.target)
|
|
818
|
+
|| (!removing && __aeCliFs.realpathSync(targetPath) !== __aeCliFs.realpathSync(link.target))) return 'legacy_link_changed';
|
|
819
|
+
if (!removing && __aeCliHash(link.target) !== operation.source_hash) return 'legacy_link_target_modified';
|
|
896
820
|
return null;
|
|
897
821
|
} catch { return 'legacy_link_unreadable'; }
|
|
898
822
|
}
|
|
899
|
-
function
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
if (
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
if (++links > 64) throw new Error('Skill link chain is too deep.');
|
|
912
|
-
const text = __aeCliFs.readlinkSync(cursor);
|
|
913
|
-
const root = __aeCliPath.parse(text).root;
|
|
914
|
-
cursor = root || dirname(cursor);
|
|
915
|
-
// Expand a link before applying subsequent '..' components, matching filesystem lookup.
|
|
916
|
-
pending.unshift(...text.slice(root.length).split(sep));
|
|
917
|
-
}
|
|
918
|
-
return false;
|
|
823
|
+
function __aeCliRemovalProblem(operation, targetPath, guard) {
|
|
824
|
+
try {
|
|
825
|
+
const ledger = guard.ledger_file && JSON.parse(__aeCliFs.readFileSync(guard.ledger_file, 'utf8'));
|
|
826
|
+
const owned = ledger?.schema_version === 1 && ledger.copies?.[targetPath];
|
|
827
|
+
if (!owned || owned.skill !== operation.skill || owned.agent !== operation.target.agent) return 'copy_not_managed';
|
|
828
|
+
const expected = operation.expected_node;
|
|
829
|
+
const current = __aeCliFs.lstatSync(targetPath, { bigint: true });
|
|
830
|
+
const type = current.isSymbolicLink() ? 'symlink' : current.isDirectory() ? 'directory' : current.isFile() ? 'file' : 'other';
|
|
831
|
+
if (!expected || expected.dev !== String(current.dev) || expected.ino !== String(current.ino) || expected.type !== type
|
|
832
|
+
|| (type === 'symlink' && expected.link !== __aeCliFs.readlinkSync(targetPath))) return 'copy_changed';
|
|
833
|
+
return null;
|
|
834
|
+
} catch { return 'copy_unreadable'; }
|
|
919
835
|
}
|
|
920
836
|
async function __aeCliTargets() {
|
|
921
837
|
const detected = new Set(await detectInstalledAgents());
|
|
@@ -963,24 +879,16 @@ async function __aeCliMain() {
|
|
|
963
879
|
blockedReason = 'legacy_target_missing'; return false;
|
|
964
880
|
}
|
|
965
881
|
if (candidate !== targetPath) { blockedReason = 'copy_changed'; return false; }
|
|
966
|
-
if (
|
|
882
|
+
if (operation.action === 'remove') {
|
|
883
|
+
const problem = __aeCliRemovalProblem(operation, targetPath, request.guard);
|
|
884
|
+
if (problem) { blockedReason = problem; return false; }
|
|
885
|
+
} else {
|
|
886
|
+
if (__aeCliHash(operation.source, true) !== operation.source_hash) { blockedReason = 'package_changed'; return false; }
|
|
887
|
+
if (!operation.legacy_link && __aeCliHash(targetPath) !== operation.expected_hash) { blockedReason = 'copy_changed'; return false; }
|
|
888
|
+
}
|
|
967
889
|
if (operation.legacy_link) {
|
|
968
890
|
const problem = __aeCliLegacyLinkProblem(operation, targetPath, targets, request.guard);
|
|
969
891
|
if (problem) { blockedReason = problem; return false; }
|
|
970
|
-
} else if (__aeCliHash(targetPath) !== operation.expected_hash) { blockedReason = 'copy_changed'; return false; }
|
|
971
|
-
if (operation.action === 'remove') for (const other of targets) {
|
|
972
|
-
try {
|
|
973
|
-
// Preserve custom aliases too; only exact same-name installer links are migrated.
|
|
974
|
-
for (const name of __aeCliFs.readdirSync(other.directory)) {
|
|
975
|
-
const otherPath = join(other.directory, name);
|
|
976
|
-
if (otherPath === targetPath) continue;
|
|
977
|
-
try {
|
|
978
|
-
if (__aeCliFs.lstatSync(otherPath).isSymbolicLink() && __aeCliLinkDependsOn(otherPath, targetPath)) {
|
|
979
|
-
blockedReason = 'dependent_unmanaged_link'; return false;
|
|
980
|
-
}
|
|
981
|
-
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
982
|
-
}
|
|
983
|
-
} catch (error) { if (error.code !== 'ENOENT') { blockedReason = 'dependent_copy_unreadable'; return false; } }
|
|
984
892
|
}
|
|
985
893
|
return true;
|
|
986
894
|
} catch { blockedReason = 'copy_unreadable'; return false; }
|
|
@@ -1030,19 +938,19 @@ catch { process.stdout.write(JSON.stringify({ ok: false })); process.exitCode =
|
|
|
1030
938
|
`;
|
|
1031
939
|
function createPinnedSkillsTool(options = {}) {
|
|
1032
940
|
const require2 = createRequire(import.meta.url);
|
|
1033
|
-
const packageFile = options.entry ?
|
|
1034
|
-
const entry = options.entry ??
|
|
1035
|
-
const metadata = JSON.parse(
|
|
1036
|
-
const source =
|
|
941
|
+
const packageFile = options.entry ? path3.join(path3.dirname(options.entry), "..", "package.json") : require2.resolve("skills/package.json");
|
|
942
|
+
const entry = options.entry ?? path3.join(path3.dirname(packageFile), "dist", "cli.mjs");
|
|
943
|
+
const metadata = JSON.parse(fs3.readFileSync(packageFile, "utf8"));
|
|
944
|
+
const source = fs3.readFileSync(entry, "utf8");
|
|
1037
945
|
if (metadata.version !== MANAGED_SKILLS_TOOL_VERSION || createHash("sha256").update(source).digest("hex") !== TOOL_SOURCE_SHA256) {
|
|
1038
946
|
throw new Error("Managed Skill synchronization requires the verified skills@1.5.12 package.");
|
|
1039
947
|
}
|
|
1040
948
|
const script = adaptedToolSource(source, entry);
|
|
1041
949
|
const run = (request) => {
|
|
1042
|
-
const directory =
|
|
1043
|
-
const worker =
|
|
950
|
+
const directory = fs3.mkdtempSync(path3.join(os2.tmpdir(), "ae-cli-skills-tool-"));
|
|
951
|
+
const worker = path3.join(directory, "adapter.mjs");
|
|
1044
952
|
try {
|
|
1045
|
-
|
|
953
|
+
fs3.writeFileSync(worker, script, { mode: 384 });
|
|
1046
954
|
const result2 = spawn2.sync(process.execPath, [worker], {
|
|
1047
955
|
input: JSON.stringify(request),
|
|
1048
956
|
encoding: "utf8",
|
|
@@ -1059,7 +967,7 @@ function createPinnedSkillsTool(options = {}) {
|
|
|
1059
967
|
} catch {
|
|
1060
968
|
throw new Error("Skills adapter failed. Check the pinned package and directory permissions.");
|
|
1061
969
|
} finally {
|
|
1062
|
-
|
|
970
|
+
fs3.rmSync(directory, { recursive: true, force: true });
|
|
1063
971
|
}
|
|
1064
972
|
};
|
|
1065
973
|
return {
|
|
@@ -1072,14 +980,60 @@ function createPinnedSkillsTool(options = {}) {
|
|
|
1072
980
|
var CONTEXT_FILE = "business-skill-context.json";
|
|
1073
981
|
var LEDGER_FILE = "business-skills.json";
|
|
1074
982
|
var LOCK_FILE = "business-skills.lock";
|
|
983
|
+
var POLICY_HASH = createHash2("sha256").update(JSON.stringify({ removal_policy: 2, optional_businesses: OPTIONAL_BUSINESSES, skills: skill_businesses_default })).digest("hex");
|
|
984
|
+
function historicalCliSkills(options) {
|
|
985
|
+
const env = options.env ?? process.env;
|
|
986
|
+
const home = env.HOME || env.USERPROFILE || os3.homedir();
|
|
987
|
+
const file = env.XDG_STATE_HOME ? path4.join(env.XDG_STATE_HOME, "skills", ".skill-lock.json") : path4.join(home, ".agents", ".skill-lock.json");
|
|
988
|
+
const names = /* @__PURE__ */ new Set();
|
|
989
|
+
let content = "";
|
|
990
|
+
const isCliSource = (value, type) => {
|
|
991
|
+
if (typeof value !== "string") return false;
|
|
992
|
+
if (type === "local" && path4.isAbsolute(value)) {
|
|
993
|
+
const source2 = path4.resolve(value);
|
|
994
|
+
if (source2 === path4.resolve(options.skillsDirectory)) return true;
|
|
995
|
+
if (path4.basename(source2) !== "skills") return false;
|
|
996
|
+
try {
|
|
997
|
+
const pkg = JSON.parse(fs4.readFileSync(path4.join(source2, "..", "package.json"), "utf8"));
|
|
998
|
+
return ["@tant/ae-cli", "@thinkingai/ae-cli"].includes(pkg.name) && typeof pkg.bin?.["ae-cli"] === "string";
|
|
999
|
+
} catch {
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (!["git", "github"].includes(String(type))) return false;
|
|
1004
|
+
const source = value.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
1005
|
+
return [
|
|
1006
|
+
"ThinkingAIAgenticEngine/ae-cli",
|
|
1007
|
+
"https://github.com/ThinkingAIAgenticEngine/ae-cli",
|
|
1008
|
+
"git@github.com:ThinkingAIAgenticEngine/ae-cli",
|
|
1009
|
+
"ssh://git@gitlab.thinkingdata.cn:2222/te-ai/te-cli",
|
|
1010
|
+
"https://gitlab.thinkingdata.cn/te-ai/te-cli",
|
|
1011
|
+
"http://10.27.249.150:8888/te-ai/te-cli"
|
|
1012
|
+
].includes(source);
|
|
1013
|
+
};
|
|
1014
|
+
try {
|
|
1015
|
+
content = fs4.readFileSync(file, "utf8");
|
|
1016
|
+
const lock = JSON.parse(content);
|
|
1017
|
+
const mapped = new Set(Object.values(skill_businesses_default).flat());
|
|
1018
|
+
if (typeof lock.version === "number" && lock.skills && typeof lock.skills === "object") {
|
|
1019
|
+
for (const [name, entry] of Object.entries(lock.skills)) {
|
|
1020
|
+
if (!mapped.has(name) || !entry || typeof entry !== "object") continue;
|
|
1021
|
+
const record = entry;
|
|
1022
|
+
if (isCliSource(record.source, record.sourceType) || isCliSource(record.sourceUrl, record.sourceType)) names.add(name);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
} catch {
|
|
1026
|
+
}
|
|
1027
|
+
return { names, hash: createHash2("sha256").update(content).digest("hex") };
|
|
1028
|
+
}
|
|
1075
1029
|
function writeJson(file, value) {
|
|
1076
1030
|
const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
1077
1031
|
try {
|
|
1078
|
-
|
|
1079
|
-
|
|
1032
|
+
fs4.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
1033
|
+
fs4.renameSync(temporary, file);
|
|
1080
1034
|
} finally {
|
|
1081
1035
|
try {
|
|
1082
|
-
|
|
1036
|
+
fs4.unlinkSync(temporary);
|
|
1083
1037
|
} catch {
|
|
1084
1038
|
}
|
|
1085
1039
|
}
|
|
@@ -1099,15 +1053,15 @@ function contextIdentity(options) {
|
|
|
1099
1053
|
}
|
|
1100
1054
|
function reserveBusinessSkillContext(options) {
|
|
1101
1055
|
const directory = options.stateDirectory ?? getConfigDir();
|
|
1102
|
-
|
|
1056
|
+
fs4.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
1103
1057
|
const generation = randomUUID();
|
|
1104
|
-
writeJson(
|
|
1058
|
+
writeJson(path4.join(directory, CONTEXT_FILE), { ...contextIdentity(options), generation });
|
|
1105
1059
|
return generation;
|
|
1106
1060
|
}
|
|
1107
1061
|
function currentContext(options, file, generation) {
|
|
1108
1062
|
try {
|
|
1109
1063
|
if (options.isCurrentContext && !options.isCurrentContext()) return false;
|
|
1110
|
-
const active = JSON.parse(
|
|
1064
|
+
const active = JSON.parse(fs4.readFileSync(file, "utf8"));
|
|
1111
1065
|
const identity = contextIdentity(options);
|
|
1112
1066
|
return active.generation === generation && active.host === identity.host && active.token_fingerprint === identity.token_fingerprint;
|
|
1113
1067
|
} catch {
|
|
@@ -1115,12 +1069,12 @@ function currentContext(options, file, generation) {
|
|
|
1115
1069
|
}
|
|
1116
1070
|
}
|
|
1117
1071
|
function isBusinessSkillContextCurrent(options) {
|
|
1118
|
-
return currentContext(options,
|
|
1072
|
+
return currentContext(options, path4.join(options.stateDirectory ?? getConfigDir(), CONTEXT_FILE), options.generation);
|
|
1119
1073
|
}
|
|
1120
1074
|
function takeLock(file) {
|
|
1121
1075
|
const owner = randomUUID();
|
|
1122
1076
|
const ownerName = `owner-${process.pid}-${owner}.json`;
|
|
1123
|
-
const candidate =
|
|
1077
|
+
const candidate = fs4.mkdtempSync(`${file}.candidate-`);
|
|
1124
1078
|
const alive = (pid) => {
|
|
1125
1079
|
try {
|
|
1126
1080
|
process.kill(pid, 0);
|
|
@@ -1130,29 +1084,29 @@ function takeLock(file) {
|
|
|
1130
1084
|
}
|
|
1131
1085
|
};
|
|
1132
1086
|
try {
|
|
1133
|
-
|
|
1134
|
-
|
|
1087
|
+
fs4.chmodSync(candidate, 448);
|
|
1088
|
+
fs4.writeFileSync(path4.join(candidate, ownerName), JSON.stringify({ pid: process.pid, owner }), { mode: 384 });
|
|
1135
1089
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
1136
1090
|
try {
|
|
1137
|
-
|
|
1091
|
+
fs4.renameSync(candidate, file);
|
|
1138
1092
|
try {
|
|
1139
|
-
|
|
1093
|
+
fs4.unlinkSync(`${file}.reclaim`);
|
|
1140
1094
|
} catch {
|
|
1141
1095
|
}
|
|
1142
1096
|
return () => {
|
|
1143
1097
|
try {
|
|
1144
|
-
|
|
1098
|
+
fs4.unlinkSync(path4.join(file, ownerName));
|
|
1145
1099
|
} catch {
|
|
1146
1100
|
}
|
|
1147
1101
|
try {
|
|
1148
|
-
|
|
1102
|
+
fs4.rmdirSync(file);
|
|
1149
1103
|
} catch {
|
|
1150
1104
|
}
|
|
1151
1105
|
};
|
|
1152
1106
|
} catch (error) {
|
|
1153
1107
|
let stat;
|
|
1154
1108
|
try {
|
|
1155
|
-
stat =
|
|
1109
|
+
stat = fs4.lstatSync(file);
|
|
1156
1110
|
} catch (cause) {
|
|
1157
1111
|
if (cause.code === "ENOENT") continue;
|
|
1158
1112
|
throw error;
|
|
@@ -1161,12 +1115,12 @@ function takeLock(file) {
|
|
|
1161
1115
|
if (stat.isFile()) {
|
|
1162
1116
|
let pid;
|
|
1163
1117
|
try {
|
|
1164
|
-
pid = JSON.parse(
|
|
1118
|
+
pid = JSON.parse(fs4.readFileSync(file, "utf8")).pid;
|
|
1165
1119
|
} catch {
|
|
1166
1120
|
}
|
|
1167
1121
|
if (typeof pid === "number" && Number.isInteger(pid) && pid > 0 && alive(pid)) return null;
|
|
1168
1122
|
try {
|
|
1169
|
-
|
|
1123
|
+
fs4.unlinkSync(file);
|
|
1170
1124
|
} catch (cause) {
|
|
1171
1125
|
if (!["ENOENT", "EISDIR", "EPERM"].includes(cause.code ?? "")) throw cause;
|
|
1172
1126
|
}
|
|
@@ -1175,7 +1129,7 @@ function takeLock(file) {
|
|
|
1175
1129
|
if (!stat.isDirectory()) return null;
|
|
1176
1130
|
let names;
|
|
1177
1131
|
try {
|
|
1178
|
-
names =
|
|
1132
|
+
names = fs4.readdirSync(file);
|
|
1179
1133
|
} catch (cause) {
|
|
1180
1134
|
if (cause.code === "ENOENT") continue;
|
|
1181
1135
|
throw cause;
|
|
@@ -1186,13 +1140,13 @@ function takeLock(file) {
|
|
|
1186
1140
|
}
|
|
1187
1141
|
for (const name of names) {
|
|
1188
1142
|
try {
|
|
1189
|
-
|
|
1143
|
+
fs4.unlinkSync(path4.join(file, name));
|
|
1190
1144
|
} catch (cause) {
|
|
1191
1145
|
if (cause.code !== "ENOENT") throw cause;
|
|
1192
1146
|
}
|
|
1193
1147
|
}
|
|
1194
1148
|
try {
|
|
1195
|
-
|
|
1149
|
+
fs4.rmdirSync(file);
|
|
1196
1150
|
} catch (cause) {
|
|
1197
1151
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(cause.code ?? "")) throw cause;
|
|
1198
1152
|
}
|
|
@@ -1200,13 +1154,13 @@ function takeLock(file) {
|
|
|
1200
1154
|
}
|
|
1201
1155
|
return null;
|
|
1202
1156
|
} finally {
|
|
1203
|
-
|
|
1157
|
+
fs4.rmSync(candidate, { recursive: true, force: true });
|
|
1204
1158
|
}
|
|
1205
1159
|
}
|
|
1206
1160
|
function readLedger(file) {
|
|
1207
1161
|
let value;
|
|
1208
1162
|
try {
|
|
1209
|
-
value = JSON.parse(
|
|
1163
|
+
value = JSON.parse(fs4.readFileSync(file, "utf8"));
|
|
1210
1164
|
} catch (error) {
|
|
1211
1165
|
if (error.code === "ENOENT") return { schema_version: 1, copies: {} };
|
|
1212
1166
|
throw new Error("Managed Skill ledger is unreadable.");
|
|
@@ -1215,23 +1169,34 @@ function readLedger(file) {
|
|
|
1215
1169
|
throw new Error("Managed Skill ledger has an unsupported format.");
|
|
1216
1170
|
}
|
|
1217
1171
|
for (const [filePath, copy] of Object.entries(value.copies)) {
|
|
1218
|
-
if (!
|
|
1172
|
+
if (!path4.isAbsolute(filePath) || !copy || typeof copy.skill !== "string" || typeof copy.agent !== "string" || !/^[a-f0-9]{64}$/.test(copy.hash) || typeof copy.package_version !== "string") throw new Error("Managed Skill ledger has an invalid copy.");
|
|
1219
1173
|
}
|
|
1220
1174
|
return value;
|
|
1221
1175
|
}
|
|
1222
1176
|
function result(skill, target, reason) {
|
|
1223
|
-
return { skill, agent: target.agent, path:
|
|
1177
|
+
return { skill, agent: target.agent, path: path4.join(target.directory, skill), ...reason ? { reason } : {} };
|
|
1178
|
+
}
|
|
1179
|
+
function directInstallerLink(file, target, text) {
|
|
1180
|
+
if (typeof text !== "string") return false;
|
|
1181
|
+
let value = text;
|
|
1182
|
+
if (process.platform === "win32") {
|
|
1183
|
+
if (value.toUpperCase().startsWith("\\\\?\\UNC\\")) value = "\\\\" + value.slice(8);
|
|
1184
|
+
else if (value.startsWith("\\\\?\\") || value.startsWith("\\??\\")) value = value.slice(4);
|
|
1185
|
+
return [target, path4.relative(path4.dirname(file), target)].some((expected) => value.toLowerCase() === expected.toLowerCase());
|
|
1186
|
+
}
|
|
1187
|
+
return value === target || value === path4.relative(path4.dirname(file), target);
|
|
1224
1188
|
}
|
|
1225
|
-
function legacySkillLink(file, skill, sourceRoot, sourceHash, targets, ledger) {
|
|
1189
|
+
function legacySkillLink(file, skill, sourceRoot, sourceHash, targets, ledger, removing = false) {
|
|
1226
1190
|
const canonical = targets.find((target2) => target2.agent === "universal");
|
|
1227
1191
|
if (!canonical) return;
|
|
1228
|
-
const target =
|
|
1192
|
+
const target = path4.join(canonical.directory, skill);
|
|
1229
1193
|
const managed = ledger.copies[target];
|
|
1230
|
-
if (!managed || managed.skill !== skill || managed.agent !== canonical.agent || managed.hash !== sourceHash || skillPathProblem(canonical.directory, skill, sourceRoot)) return;
|
|
1194
|
+
if (!managed || managed.skill !== skill || managed.agent !== canonical.agent || !removing && managed.hash !== sourceHash || skillPathProblem(canonical.directory, skill, sourceRoot)) return;
|
|
1231
1195
|
try {
|
|
1232
|
-
if (!
|
|
1233
|
-
const text =
|
|
1234
|
-
if (
|
|
1196
|
+
if (!fs4.lstatSync(file).isSymbolicLink()) return;
|
|
1197
|
+
const text = fs4.readlinkSync(file);
|
|
1198
|
+
if (!directInstallerLink(file, target, text)) return;
|
|
1199
|
+
if (!removing && (skillCopyHash(target) !== sourceHash || fs4.realpathSync(file) !== fs4.realpathSync(target))) return;
|
|
1235
1200
|
return { target, text };
|
|
1236
1201
|
} catch {
|
|
1237
1202
|
return;
|
|
@@ -1248,20 +1213,20 @@ function syncBusinessSkills(options) {
|
|
|
1248
1213
|
managed_count: 0
|
|
1249
1214
|
};
|
|
1250
1215
|
const directory = options.stateDirectory ?? getConfigDir();
|
|
1251
|
-
const contextFile =
|
|
1216
|
+
const contextFile = path4.join(directory, CONTEXT_FILE);
|
|
1252
1217
|
let unlock = null;
|
|
1253
1218
|
try {
|
|
1254
1219
|
if (options.isCurrentContext && !options.isCurrentContext()) {
|
|
1255
1220
|
report.status = "stale";
|
|
1256
1221
|
return report;
|
|
1257
1222
|
}
|
|
1258
|
-
|
|
1223
|
+
fs4.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
1259
1224
|
const generation = options.generation ?? reserveBusinessSkillContext(options);
|
|
1260
1225
|
if (!currentContext(options, contextFile, generation)) {
|
|
1261
1226
|
report.status = "stale";
|
|
1262
1227
|
return report;
|
|
1263
1228
|
}
|
|
1264
|
-
unlock = takeLock(
|
|
1229
|
+
unlock = takeLock(path4.join(directory, LOCK_FILE));
|
|
1265
1230
|
if (!unlock) {
|
|
1266
1231
|
report.status = "busy";
|
|
1267
1232
|
return report;
|
|
@@ -1270,26 +1235,114 @@ function syncBusinessSkills(options) {
|
|
|
1270
1235
|
report.status = "stale";
|
|
1271
1236
|
return report;
|
|
1272
1237
|
}
|
|
1273
|
-
const ledgerFile =
|
|
1238
|
+
const ledgerFile = path4.join(directory, LEDGER_FILE);
|
|
1274
1239
|
const ledger = readLedger(ledgerFile);
|
|
1275
|
-
const tool = options.tool ?? createPinnedSkillsTool({ env: options.env });
|
|
1276
|
-
const targets = tool.targets();
|
|
1277
|
-
const skills = readBundledSkills(options.skillsDirectory);
|
|
1278
1240
|
const packageVersion = options.packageVersion ?? "unknown";
|
|
1241
|
+
const history = historicalCliSkills(options);
|
|
1242
|
+
const applied = {
|
|
1243
|
+
...contextIdentity(options),
|
|
1244
|
+
package_version: packageVersion,
|
|
1245
|
+
businesses: normalizeBusinesses(options.businesses),
|
|
1246
|
+
source_root: fs4.realpathSync(options.skillsDirectory),
|
|
1247
|
+
policy_hash: POLICY_HASH,
|
|
1248
|
+
history_hash: history.hash
|
|
1249
|
+
};
|
|
1250
|
+
let select;
|
|
1251
|
+
if (options.mode !== "adopt") {
|
|
1252
|
+
const previous = ledger.last_applied;
|
|
1253
|
+
if (options.onlyIfChanged && previous && previous.package_version === packageVersion && previous.source_root === applied.source_root && previous.policy_hash === applied.policy_hash && previous.history_hash === applied.history_hash) {
|
|
1254
|
+
const previousStates = normalizeBusinesses(previous.businesses);
|
|
1255
|
+
const changed = new Set(OPTIONAL_BUSINESSES.filter((business) => previousStates[business] !== applied.businesses[business] && applied.businesses[business] !== void 0));
|
|
1256
|
+
if (!changed.size) {
|
|
1257
|
+
if (!currentContext(options, contextFile, generation)) {
|
|
1258
|
+
report.status = "stale";
|
|
1259
|
+
return report;
|
|
1260
|
+
}
|
|
1261
|
+
if (JSON.stringify(previous) !== JSON.stringify(applied)) {
|
|
1262
|
+
ledger.last_applied = applied;
|
|
1263
|
+
writeJson(ledgerFile, ledger);
|
|
1264
|
+
}
|
|
1265
|
+
report.managed_count = Object.keys(ledger.copies).length;
|
|
1266
|
+
report.status = "success";
|
|
1267
|
+
return report;
|
|
1268
|
+
}
|
|
1269
|
+
select = (name) => {
|
|
1270
|
+
const business = businessForSkill(name);
|
|
1271
|
+
return business !== void 0 && changed.has(business);
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
if (ledger.last_applied) {
|
|
1275
|
+
delete ledger.last_applied;
|
|
1276
|
+
writeJson(ledgerFile, ledger);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
const bundled = readBundledSkills(options.skillsDirectory, select);
|
|
1280
|
+
const skills = new Set(bundled.map((skill) => skill.name));
|
|
1281
|
+
if (options.mode !== "adopt") {
|
|
1282
|
+
for (const name of [...history.names, ...Object.values(ledger.copies).map((copy) => copy.skill)]) {
|
|
1283
|
+
if (businessForSkill(name) && getSkillBusinessState(name, options.businesses) === false && (!select || select(name))) skills.add(name);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
const tool = options.tool ?? createPinnedSkillsTool({ env: options.env });
|
|
1287
|
+
const targets = [...tool.targets()].sort((a, b) => Number(b.agent === "universal") - Number(a.agent === "universal"));
|
|
1279
1288
|
const operations = [];
|
|
1280
|
-
for (const
|
|
1281
|
-
const
|
|
1282
|
-
const sourceHash = skillCopyHash(source, true);
|
|
1283
|
-
if (!sourceHash) throw new Error("Complete package Skill source is missing.");
|
|
1284
|
-
const state = getSkillBusinessState(skill.name, options.businesses);
|
|
1289
|
+
for (const name of skills) {
|
|
1290
|
+
const state = getSkillBusinessState(name, options.businesses);
|
|
1285
1291
|
if (options.mode !== "adopt" && state === void 0) continue;
|
|
1292
|
+
const source = path4.join(options.skillsDirectory, name);
|
|
1293
|
+
const sourceHash = bundled.some((skill) => skill.name === name) ? skillCopyHash(source, true) : null;
|
|
1294
|
+
if (!sourceHash && options.mode === "adopt") throw new Error("Complete package Skill source is missing.");
|
|
1286
1295
|
for (const target of targets) {
|
|
1287
|
-
const item = result(
|
|
1288
|
-
const pathProblem = skillPathProblem(target.directory,
|
|
1296
|
+
const item = result(name, target);
|
|
1297
|
+
const pathProblem = skillPathProblem(target.directory, name, options.skillsDirectory);
|
|
1289
1298
|
if (pathProblem) {
|
|
1290
1299
|
report.skipped.push({ ...item, reason: pathProblem });
|
|
1291
1300
|
continue;
|
|
1292
1301
|
}
|
|
1302
|
+
const managed = ledger.copies[item.path];
|
|
1303
|
+
if (options.mode !== "adopt" && state === false) {
|
|
1304
|
+
let node;
|
|
1305
|
+
try {
|
|
1306
|
+
node = skillPathIdentity(item.path);
|
|
1307
|
+
} catch {
|
|
1308
|
+
report.skipped.push({ ...item, reason: "copy_unreadable_or_linked" });
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
if (!node) {
|
|
1312
|
+
if (managed) delete ledger.copies[item.path];
|
|
1313
|
+
continue;
|
|
1314
|
+
}
|
|
1315
|
+
const legacyLink2 = node.type === "symlink" ? legacySkillLink(item.path, name, options.skillsDirectory, sourceHash ?? "", targets, ledger, true) : void 0;
|
|
1316
|
+
const canonical = targets.find((copy) => copy.agent === "universal");
|
|
1317
|
+
const historicalLink = node.type === "symlink" && canonical && directInstallerLink(item.path, path4.join(canonical.directory, name), node.link);
|
|
1318
|
+
const historicalCopy = history.names.has(name) && (target.agent === "universal" && node.type !== "symlink" || historicalLink);
|
|
1319
|
+
if (!managed && (legacyLink2 || historicalCopy)) {
|
|
1320
|
+
ledger.copies[item.path] = {
|
|
1321
|
+
skill: name,
|
|
1322
|
+
agent: target.agent,
|
|
1323
|
+
hash: sourceHash ?? "0".repeat(64),
|
|
1324
|
+
package_version: packageVersion
|
|
1325
|
+
};
|
|
1326
|
+
report.adopted.push(item);
|
|
1327
|
+
}
|
|
1328
|
+
const owned = ledger.copies[item.path];
|
|
1329
|
+
if (!owned || owned.skill !== name || owned.agent !== target.agent) {
|
|
1330
|
+
report.skipped.push({ ...item, reason: node.type === "symlink" ? "copy_unreadable_or_linked" : "copy_not_managed" });
|
|
1331
|
+
continue;
|
|
1332
|
+
}
|
|
1333
|
+
operations.push({
|
|
1334
|
+
action: "remove",
|
|
1335
|
+
skill: name,
|
|
1336
|
+
source,
|
|
1337
|
+
source_root: options.skillsDirectory,
|
|
1338
|
+
expected_hash: null,
|
|
1339
|
+
source_hash: sourceHash ?? "",
|
|
1340
|
+
target,
|
|
1341
|
+
expected_node: node,
|
|
1342
|
+
...legacyLink2 ? { legacy_link: legacyLink2 } : {}
|
|
1343
|
+
});
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1293
1346
|
let actualHash;
|
|
1294
1347
|
let legacyLink;
|
|
1295
1348
|
try {
|
|
@@ -1297,7 +1350,7 @@ function syncBusinessSkills(options) {
|
|
|
1297
1350
|
} catch {
|
|
1298
1351
|
if (options.mode !== "adopt") legacyLink = legacySkillLink(
|
|
1299
1352
|
item.path,
|
|
1300
|
-
|
|
1353
|
+
name,
|
|
1301
1354
|
options.skillsDirectory,
|
|
1302
1355
|
sourceHash,
|
|
1303
1356
|
targets,
|
|
@@ -1309,7 +1362,6 @@ function syncBusinessSkills(options) {
|
|
|
1309
1362
|
}
|
|
1310
1363
|
actualHash = sourceHash;
|
|
1311
1364
|
}
|
|
1312
|
-
const managed = ledger.copies[item.path];
|
|
1313
1365
|
if (options.mode === "adopt") {
|
|
1314
1366
|
if (actualHash === null) {
|
|
1315
1367
|
if (managed) delete ledger.copies[item.path];
|
|
@@ -1319,27 +1371,23 @@ function syncBusinessSkills(options) {
|
|
|
1319
1371
|
report.skipped.push({ ...item, reason: "copy_does_not_match_package" });
|
|
1320
1372
|
continue;
|
|
1321
1373
|
}
|
|
1322
|
-
ledger.copies[item.path] = { skill:
|
|
1374
|
+
ledger.copies[item.path] = { skill: name, agent: target.agent, hash: actualHash, package_version: packageVersion };
|
|
1323
1375
|
report.adopted.push(item);
|
|
1324
1376
|
continue;
|
|
1325
1377
|
}
|
|
1326
|
-
if (!legacyLink && actualHash !== null && (!managed || managed.skill !==
|
|
1378
|
+
if (!legacyLink && actualHash !== null && (!managed || managed.skill !== name || actualHash !== managed.hash)) {
|
|
1327
1379
|
report.skipped.push({ ...item, reason: managed ? "copy_modified" : "copy_not_managed" });
|
|
1328
1380
|
continue;
|
|
1329
1381
|
}
|
|
1330
|
-
if (actualHash ===
|
|
1382
|
+
if (actualHash === sourceHash && !legacyLink) continue;
|
|
1383
|
+
if (actualHash === null && !target.installable) {
|
|
1331
1384
|
if (managed) delete ledger.copies[item.path];
|
|
1332
1385
|
continue;
|
|
1333
1386
|
}
|
|
1334
|
-
if (
|
|
1335
|
-
if (state === true && actualHash === null && !target.installable) {
|
|
1336
|
-
if (managed) delete ledger.copies[item.path];
|
|
1337
|
-
continue;
|
|
1338
|
-
}
|
|
1339
|
-
if (state === true && actualHash === null && !target.detected && !managed && !fs6.existsSync(target.directory)) continue;
|
|
1387
|
+
if (actualHash === null && !target.detected && !managed && !fs4.existsSync(target.directory)) continue;
|
|
1340
1388
|
operations.push({
|
|
1341
|
-
action:
|
|
1342
|
-
skill:
|
|
1389
|
+
action: "install",
|
|
1390
|
+
skill: name,
|
|
1343
1391
|
source,
|
|
1344
1392
|
source_root: options.skillsDirectory,
|
|
1345
1393
|
target,
|
|
@@ -1356,7 +1404,8 @@ function syncBusinessSkills(options) {
|
|
|
1356
1404
|
if (options.mode === "adopt") {
|
|
1357
1405
|
writeJson(ledgerFile, ledger);
|
|
1358
1406
|
} else if (operations.length) {
|
|
1359
|
-
operations.sort((a, b) => Number(Boolean(b.legacy_link)) - Number(Boolean(a.legacy_link)));
|
|
1407
|
+
operations.sort((a, b) => Number(Boolean(b.legacy_link || b.expected_node?.type === "symlink")) - Number(Boolean(a.legacy_link || a.expected_node?.type === "symlink")));
|
|
1408
|
+
writeJson(ledgerFile, ledger);
|
|
1360
1409
|
const receipts = tool.apply(operations, { file: contextFile, generation, ledger_file: ledgerFile });
|
|
1361
1410
|
if (receipts.length !== operations.length) throw new Error("Skills adapter returned incomplete receipts.");
|
|
1362
1411
|
for (let index = 0; index < operations.length; index++) {
|
|
@@ -1367,7 +1416,7 @@ function syncBusinessSkills(options) {
|
|
|
1367
1416
|
if (receipt.status === "skipped") report.skipped.push(item);
|
|
1368
1417
|
else if (receipt.status !== "success") report.failed.push(item);
|
|
1369
1418
|
else if (operation.action === "remove") {
|
|
1370
|
-
if (
|
|
1419
|
+
if (skillPathIdentity(item.path) !== null) {
|
|
1371
1420
|
report.failed.push({ ...item, reason: "removal_not_verified" });
|
|
1372
1421
|
continue;
|
|
1373
1422
|
}
|
|
@@ -1387,6 +1436,10 @@ function syncBusinessSkills(options) {
|
|
|
1387
1436
|
} else writeJson(ledgerFile, ledger);
|
|
1388
1437
|
report.managed_count = Object.keys(ledger.copies).length;
|
|
1389
1438
|
report.status = !currentContext(options, contextFile, generation) ? "stale" : report.skipped.length || report.failed.length ? "partial" : "success";
|
|
1439
|
+
if (options.mode !== "adopt" && report.status === "success") {
|
|
1440
|
+
ledger.last_applied = applied;
|
|
1441
|
+
writeJson(ledgerFile, ledger);
|
|
1442
|
+
}
|
|
1390
1443
|
return report;
|
|
1391
1444
|
} catch {
|
|
1392
1445
|
report.status = report.installed.length || report.removed.length || report.adopted.length ? "partial" : "failed";
|
|
@@ -1396,6 +1449,162 @@ function syncBusinessSkills(options) {
|
|
|
1396
1449
|
}
|
|
1397
1450
|
}
|
|
1398
1451
|
|
|
1452
|
+
// src/core/business-skill-refresh.ts
|
|
1453
|
+
function beginBusinessSkillRefresh(host, token, enabled = true) {
|
|
1454
|
+
try {
|
|
1455
|
+
if (!enabled) return void 0;
|
|
1456
|
+
const normalized = normalizeUrl(host);
|
|
1457
|
+
const isCurrentContext = () => {
|
|
1458
|
+
try {
|
|
1459
|
+
return canManageGlobalSkills() && normalizeUrl(getActiveHost()) === normalized && peekCliToken(normalized) === token;
|
|
1460
|
+
} catch {
|
|
1461
|
+
return false;
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
if (!isCurrentContext()) return void 0;
|
|
1465
|
+
const identity = { host: normalized, tokenFingerprint: crypto.createHash("sha256").update(token).digest("hex") };
|
|
1466
|
+
return { ...identity, generation: reserveBusinessSkillContext(identity), isCurrentContext };
|
|
1467
|
+
} catch {
|
|
1468
|
+
return void 0;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
function isBusinessSkillRefreshCurrent(refresh) {
|
|
1472
|
+
return !refresh || isBusinessSkillContextCurrent(refresh);
|
|
1473
|
+
}
|
|
1474
|
+
function syncRefreshedBusinessSkills(refresh, businesses) {
|
|
1475
|
+
if (!refresh || !isBusinessSkillRefreshCurrent(refresh)) return;
|
|
1476
|
+
const states = normalizeBusinesses(businesses);
|
|
1477
|
+
if (!Object.keys(states).length) return;
|
|
1478
|
+
try {
|
|
1479
|
+
const pkg = getLocalCliPackageInfo();
|
|
1480
|
+
const options = { ...refresh, skillsDirectory: path5.join(pkg.root, "skills"), businesses: states, packageVersion: pkg.version };
|
|
1481
|
+
if (!fs5.existsSync(path5.join(getConfigDir(), "business-skills.json"))) {
|
|
1482
|
+
const adoption = syncBusinessSkills({ ...options, mode: "adopt" });
|
|
1483
|
+
if (["failed", "busy", "stale"].includes(adoption.status)) {
|
|
1484
|
+
if (adoption.status !== "stale") process.stderr.write("[ae-cli] Skills could not be synchronized. Retry: ae-cli config refresh\n");
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
const result2 = syncBusinessSkills({ ...options, onlyIfChanged: true });
|
|
1489
|
+
if (!["success", "stale"].includes(result2.status)) {
|
|
1490
|
+
process.stderr.write("[ae-cli] Some Skills could not be synchronized. Retry: ae-cli config refresh\n");
|
|
1491
|
+
}
|
|
1492
|
+
} catch {
|
|
1493
|
+
process.stderr.write("[ae-cli] Skills could not be synchronized. Retry: ae-cli config refresh\n");
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
// src/core/business-config.ts
|
|
1498
|
+
var BUSINESS_CONFIG_TTL_MS = 10 * 60 * 1e3;
|
|
1499
|
+
var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
|
|
1500
|
+
function cachePath() {
|
|
1501
|
+
return path6.join(getConfigDir(), "business-config.json");
|
|
1502
|
+
}
|
|
1503
|
+
function cacheKey(host, token) {
|
|
1504
|
+
return `${normalizeUrl(host)}#${crypto2.createHash("sha256").update(token).digest("hex")}`;
|
|
1505
|
+
}
|
|
1506
|
+
function readStore() {
|
|
1507
|
+
try {
|
|
1508
|
+
const value = JSON.parse(fs6.readFileSync(cachePath(), "utf8"));
|
|
1509
|
+
if (value?.entries && typeof value.entries === "object" && !Array.isArray(value.entries)) return value;
|
|
1510
|
+
} catch {
|
|
1511
|
+
}
|
|
1512
|
+
return { entries: {} };
|
|
1513
|
+
}
|
|
1514
|
+
function remember(host, token, entry) {
|
|
1515
|
+
const store = readStore();
|
|
1516
|
+
store.entries[cacheKey(host, token)] = entry;
|
|
1517
|
+
const target = cachePath();
|
|
1518
|
+
const temporary = `${target}.${process.pid}.${crypto2.randomBytes(6).toString("hex")}.tmp`;
|
|
1519
|
+
try {
|
|
1520
|
+
fs6.mkdirSync(path6.dirname(target), { recursive: true });
|
|
1521
|
+
fs6.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
|
|
1522
|
+
fs6.renameSync(temporary, target);
|
|
1523
|
+
fs6.chmodSync(target, 384);
|
|
1524
|
+
} catch {
|
|
1525
|
+
try {
|
|
1526
|
+
fs6.rmSync(temporary, { force: true });
|
|
1527
|
+
} catch {
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
function rememberBusinessConfig(host, token, businesses, now = Date.now()) {
|
|
1532
|
+
remember(host, token, { businesses: normalizeBusinesses(businesses), fetchedAt: now });
|
|
1533
|
+
}
|
|
1534
|
+
function peekBusinessConfig(host, token, now = Date.now()) {
|
|
1535
|
+
const entry = readStore().entries[cacheKey(host, token)];
|
|
1536
|
+
if (entry?.unavailableAt !== void 0 && now >= entry.unavailableAt && now - entry.unavailableAt < UNAVAILABLE_TTL_MS) return {};
|
|
1537
|
+
if (!entry || !Number.isFinite(entry.fetchedAt) || now < entry.fetchedAt || now - entry.fetchedAt >= BUSINESS_CONFIG_TTL_MS) return void 0;
|
|
1538
|
+
return normalizeBusinesses(entry.businesses);
|
|
1539
|
+
}
|
|
1540
|
+
function readBusinessConfig(host, token) {
|
|
1541
|
+
const entry = readStore().entries[cacheKey(host, token)];
|
|
1542
|
+
return entry && Number.isFinite(entry.fetchedAt) && entry.fetchedAt > 0 ? normalizeBusinesses(entry.businesses) : void 0;
|
|
1543
|
+
}
|
|
1544
|
+
function readCurrentBusinessConfig(hostOverride) {
|
|
1545
|
+
try {
|
|
1546
|
+
if (isSandboxExecutionContext()) return {};
|
|
1547
|
+
const host = hostOverride || getActiveHost();
|
|
1548
|
+
if (!host) return {};
|
|
1549
|
+
const token = peekCliToken(host);
|
|
1550
|
+
return token ? readBusinessConfig(host, token) ?? {} : {};
|
|
1551
|
+
} catch {
|
|
1552
|
+
return {};
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
async function resolveBusinessConfig(host, token, fetchRemote, now = Date.now(), synchronizeSkills = true) {
|
|
1556
|
+
const cached = peekBusinessConfig(host, token, now);
|
|
1557
|
+
if (cached !== void 0) return cached;
|
|
1558
|
+
const refresh = beginBusinessSkillRefresh(host, token, synchronizeSkills);
|
|
1559
|
+
const config = await fetchRemote().catch(() => null);
|
|
1560
|
+
if (!isBusinessSkillRefreshCurrent(refresh)) return peekBusinessConfig(host, token) ?? {};
|
|
1561
|
+
if (!config) {
|
|
1562
|
+
const previous = readStore().entries[cacheKey(host, token)];
|
|
1563
|
+
remember(host, token, {
|
|
1564
|
+
businesses: normalizeBusinesses(previous?.businesses),
|
|
1565
|
+
fetchedAt: previous?.fetchedAt ?? 0,
|
|
1566
|
+
unavailableAt: now
|
|
1567
|
+
});
|
|
1568
|
+
return {};
|
|
1569
|
+
}
|
|
1570
|
+
const businesses = normalizeBusinesses(config.businesses);
|
|
1571
|
+
rememberBusinessConfig(host, token, businesses, now);
|
|
1572
|
+
syncRefreshedBusinessSkills(refresh, config.businesses);
|
|
1573
|
+
return businesses;
|
|
1574
|
+
}
|
|
1575
|
+
var BusinessDisabledError = class extends PermissionError {
|
|
1576
|
+
constructor(business) {
|
|
1577
|
+
super(
|
|
1578
|
+
`The '${business}' business is not enabled for the current environment.`,
|
|
1579
|
+
"BUSINESS_NOT_ENABLED",
|
|
1580
|
+
"Contact your administrator if this business should be enabled, then run: ae-cli config refresh"
|
|
1581
|
+
);
|
|
1582
|
+
this.business = business;
|
|
1583
|
+
this.name = "BusinessDisabledError";
|
|
1584
|
+
}
|
|
1585
|
+
business;
|
|
1586
|
+
};
|
|
1587
|
+
async function readBusinessConfigForExecution(hostOverride, synchronizeSkills = !hostOverride) {
|
|
1588
|
+
try {
|
|
1589
|
+
if (isSandboxExecutionContext()) return {};
|
|
1590
|
+
const host = hostOverride || getActiveHost();
|
|
1591
|
+
if (!host) return {};
|
|
1592
|
+
const token = peekCliToken(host);
|
|
1593
|
+
if (!token) return {};
|
|
1594
|
+
return await resolveBusinessConfig(host, token, async () => {
|
|
1595
|
+
const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-CADG7GND.js");
|
|
1596
|
+
return fetchCliConfig2(host, token);
|
|
1597
|
+
}, Date.now(), synchronizeSkills);
|
|
1598
|
+
} catch {
|
|
1599
|
+
return {};
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
async function assertBusinessEnabled(business, hostOverride, synchronizeSkills = !hostOverride) {
|
|
1603
|
+
if (business && (await readBusinessConfigForExecution(hostOverride, synchronizeSkills))[business] === false) {
|
|
1604
|
+
throw new BusinessDisabledError(business);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1399
1608
|
// src/core/installation.ts
|
|
1400
1609
|
function distribution(packageName) {
|
|
1401
1610
|
if (packageName === "@thinkingai/ae-cli") return { registry: "https://registry.npmjs.org", repository: "ThinkingAIAgenticEngine/ae-cli" };
|
|
@@ -1440,7 +1649,7 @@ function installPlan(packageName, version, root = "<npm-root>") {
|
|
|
1440
1649
|
function currentSkillIdentity() {
|
|
1441
1650
|
const host = getActiveHost();
|
|
1442
1651
|
const token = host ? peekCliToken(host) : void 0;
|
|
1443
|
-
return { host, tokenFingerprint: token ?
|
|
1652
|
+
return { host, tokenFingerprint: token ? crypto3.createHash("sha256").update(token).digest("hex") : "" };
|
|
1444
1653
|
}
|
|
1445
1654
|
function skipGlobalSkillReason() {
|
|
1446
1655
|
try {
|
|
@@ -1854,7 +2063,7 @@ function autoSyncDirection(current, expected) {
|
|
|
1854
2063
|
}
|
|
1855
2064
|
|
|
1856
2065
|
// src/core/feature-config.ts
|
|
1857
|
-
import
|
|
2066
|
+
import crypto4 from "crypto";
|
|
1858
2067
|
import fs9 from "fs";
|
|
1859
2068
|
import path9 from "path";
|
|
1860
2069
|
var FEATURE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1863,7 +2072,7 @@ function cachePath2() {
|
|
|
1863
2072
|
return path9.join(getConfigDir(), "feature-config.json");
|
|
1864
2073
|
}
|
|
1865
2074
|
function cacheKey2(host, token) {
|
|
1866
|
-
const fingerprint =
|
|
2075
|
+
const fingerprint = crypto4.createHash("sha256").update(token).digest("hex");
|
|
1867
2076
|
return `${normalizeUrl(host)}#${fingerprint}`;
|
|
1868
2077
|
}
|
|
1869
2078
|
function readStore2() {
|
|
@@ -1876,7 +2085,7 @@ function readStore2() {
|
|
|
1876
2085
|
}
|
|
1877
2086
|
function writeStore(store) {
|
|
1878
2087
|
const target = cachePath2();
|
|
1879
|
-
const temp = `${target}.${process.pid}.${
|
|
2088
|
+
const temp = `${target}.${process.pid}.${crypto4.randomBytes(6).toString("hex")}.tmp`;
|
|
1880
2089
|
try {
|
|
1881
2090
|
fs9.mkdirSync(path9.dirname(target), { recursive: true });
|
|
1882
2091
|
fs9.writeFileSync(temp, JSON.stringify(store), { encoding: "utf8", mode: 384 });
|
|
@@ -1897,13 +2106,25 @@ function remember2(host, token, entry) {
|
|
|
1897
2106
|
function rememberKbAutoDiscoveryFeature(host, token, enabled) {
|
|
1898
2107
|
remember2(host, token, { enabled, available: true, fetchedAt: Date.now() });
|
|
1899
2108
|
}
|
|
1900
|
-
|
|
2109
|
+
function peekKbAutoDiscoveryFeature(host, token) {
|
|
2110
|
+
const entry = readStore2().entries[cacheKey2(host, token)];
|
|
2111
|
+
const ttl = entry?.available ? FEATURE_TTL_MS : UNAVAILABLE_TTL_MS2;
|
|
2112
|
+
if (!entry || !entry.available || Date.now() < entry.fetchedAt || Date.now() - entry.fetchedAt >= ttl) {
|
|
2113
|
+
return void 0;
|
|
2114
|
+
}
|
|
2115
|
+
return entry.enabled;
|
|
2116
|
+
}
|
|
2117
|
+
async function resolveKbAutoDiscoveryFeature(host, token, fetchRemote, isCurrent = () => true) {
|
|
1901
2118
|
const entry = readStore2().entries[cacheKey2(host, token)];
|
|
1902
2119
|
const ttl = entry?.available ? FEATURE_TTL_MS : UNAVAILABLE_TTL_MS2;
|
|
1903
2120
|
if (entry && Date.now() >= entry.fetchedAt && Date.now() - entry.fetchedAt < ttl) {
|
|
1904
2121
|
return { enabled: entry.enabled, source: entry.available ? "cache" : "unavailable" };
|
|
1905
2122
|
}
|
|
1906
2123
|
const remote = await fetchRemote().catch(() => null);
|
|
2124
|
+
if (!isCurrent()) {
|
|
2125
|
+
const latest = peekKbAutoDiscoveryFeature(host, token);
|
|
2126
|
+
return latest === void 0 ? { enabled: false, source: "unavailable" } : { enabled: latest, source: "cache" };
|
|
2127
|
+
}
|
|
1907
2128
|
if (!remote) {
|
|
1908
2129
|
remember2(host, token, { enabled: false, available: false, fetchedAt: Date.now() });
|
|
1909
2130
|
return { enabled: false, source: "unavailable" };
|
|
@@ -1995,7 +2216,7 @@ async function fetchCliConfig(host, cliToken) {
|
|
|
1995
2216
|
const options = {
|
|
1996
2217
|
dispatcher,
|
|
1997
2218
|
signal: controller.signal,
|
|
1998
|
-
headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
|
|
2219
|
+
headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {}, ...internalCallSourceHeaders() },
|
|
1999
2220
|
...externalCliTokenRequestOptions(url.toString())
|
|
2000
2221
|
};
|
|
2001
2222
|
resp = await fetch(url.toString(), options);
|
|
@@ -2075,7 +2296,7 @@ function setUpdateNotice(pkg, expected, cluster, verdict, state, stage, message)
|
|
|
2075
2296
|
message: message ?? `Current ae-cli is ${pkg.version}; this host requires ${expected}. Run: ae-cli update`
|
|
2076
2297
|
};
|
|
2077
2298
|
}
|
|
2078
|
-
async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
|
|
2299
|
+
async function refreshAndMaybeNotify(host, pkg, allowAutoSync, synchronizeSkills) {
|
|
2079
2300
|
const token = peekCliToken(host);
|
|
2080
2301
|
if (!token) return { status: "continue" };
|
|
2081
2302
|
const store = readStore3();
|
|
@@ -2085,10 +2306,13 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
|
|
|
2085
2306
|
let cluster = existing?.clusterVersion;
|
|
2086
2307
|
let fetchedAt = existing?.lastFetchedAt;
|
|
2087
2308
|
if (isCompatCacheStale(existing)) {
|
|
2309
|
+
const refresh = beginBusinessSkillRefresh(host, token, synchronizeSkills && allowAutoSync);
|
|
2088
2310
|
const remote = await fetchCliConfig(host, token);
|
|
2311
|
+
if (!isBusinessSkillRefreshCurrent(refresh)) return { status: "continue" };
|
|
2089
2312
|
if (remote) {
|
|
2090
2313
|
rememberKbAutoDiscoveryFeature(host, token, remote.projectSemanticKbAutoDiscovery ?? false);
|
|
2091
2314
|
rememberBusinessConfig(host, token, remote.businesses);
|
|
2315
|
+
syncRefreshedBusinessSkills(refresh, remote.businesses);
|
|
2092
2316
|
}
|
|
2093
2317
|
if (!remote?.aeCliVersion) {
|
|
2094
2318
|
return { status: "continue" };
|
|
@@ -2133,7 +2357,7 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
|
|
|
2133
2357
|
return false;
|
|
2134
2358
|
}
|
|
2135
2359
|
};
|
|
2136
|
-
const context = isCurrentLocalIdentity() ? { host, tokenFingerprint:
|
|
2360
|
+
const context = isCurrentLocalIdentity() ? { host, tokenFingerprint: createHash3("sha256").update(token).digest("hex") } : void 0;
|
|
2137
2361
|
const generation = context ? reserveBusinessSkillContext(context) : void 0;
|
|
2138
2362
|
const confirmed = await fetchCliConfig(host, token);
|
|
2139
2363
|
if (context && generation && !isBusinessSkillContextCurrent({
|
|
@@ -2144,6 +2368,9 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
|
|
|
2144
2368
|
if (confirmed) {
|
|
2145
2369
|
rememberKbAutoDiscoveryFeature(host, token, confirmed.projectSemanticKbAutoDiscovery ?? false);
|
|
2146
2370
|
rememberBusinessConfig(host, token, confirmed.businesses);
|
|
2371
|
+
if (context && generation && synchronizeSkills) {
|
|
2372
|
+
syncRefreshedBusinessSkills({ ...context, generation, isCurrentContext: isCurrentLocalIdentity }, confirmed.businesses);
|
|
2373
|
+
}
|
|
2147
2374
|
}
|
|
2148
2375
|
if (confirmed?.aeCliVersion) {
|
|
2149
2376
|
expected = confirmed.aeCliVersion;
|
|
@@ -2243,7 +2470,7 @@ async function runHostCompatCheck(pkg, hostOverride, argv = process.argv) {
|
|
|
2243
2470
|
const host = hostOverride || getActiveHost();
|
|
2244
2471
|
if (!host) return { status: "continue" };
|
|
2245
2472
|
try {
|
|
2246
|
-
return await refreshAndMaybeNotify(host, pkg, !shouldSkipAutoSync(argv));
|
|
2473
|
+
return await refreshAndMaybeNotify(host, pkg, !shouldSkipAutoSync(argv), !hostOverride);
|
|
2247
2474
|
} catch {
|
|
2248
2475
|
return { status: "continue" };
|
|
2249
2476
|
}
|
|
@@ -2255,18 +2482,20 @@ function notifyIfHostCompat(pkg, hostOverride) {
|
|
|
2255
2482
|
export {
|
|
2256
2483
|
exactVersion,
|
|
2257
2484
|
installHost,
|
|
2258
|
-
getLocalCliPackageInfo,
|
|
2259
2485
|
businessForCommand,
|
|
2260
2486
|
businessForCapability,
|
|
2261
2487
|
canManageGlobalSkills,
|
|
2488
|
+
reserveBusinessSkillContext,
|
|
2489
|
+
isBusinessSkillContextCurrent,
|
|
2490
|
+
syncBusinessSkills,
|
|
2491
|
+
beginBusinessSkillRefresh,
|
|
2492
|
+
isBusinessSkillRefreshCurrent,
|
|
2493
|
+
syncRefreshedBusinessSkills,
|
|
2262
2494
|
rememberBusinessConfig,
|
|
2263
2495
|
readCurrentBusinessConfig,
|
|
2264
2496
|
BusinessDisabledError,
|
|
2265
2497
|
readBusinessConfigForExecution,
|
|
2266
2498
|
assertBusinessEnabled,
|
|
2267
|
-
reserveBusinessSkillContext,
|
|
2268
|
-
isBusinessSkillContextCurrent,
|
|
2269
|
-
syncBusinessSkills,
|
|
2270
2499
|
newInstallationReport,
|
|
2271
2500
|
failInstallation,
|
|
2272
2501
|
recordVersionSyncResult,
|