@thinkingai/ae-cli 6.0.58 → 6.0.61

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.
Files changed (281) hide show
  1. package/README.md +14 -6
  2. package/README.zh.md +16 -6
  3. package/bin/ai-monitor.js +2 -0
  4. package/bin/runtime-capabilities.json +1 -1
  5. package/dist/ai-monitor-NUKSJPLE.js +33 -0
  6. package/dist/ai-monitor.js +136 -0
  7. package/dist/{auth-A5OO4VS4.js → auth-MVAEBGBP.js} +24 -15
  8. package/dist/{automation-FD2QZUP6.js → automation-6L6IAYRK.js} +6 -7
  9. package/dist/{capability-SKI4GHF4.js → capability-74N7AN5X.js} +35 -38
  10. package/dist/{chunk-OAWPT7VP.js → chunk-2I5SZ5DS.js} +2 -2
  11. package/dist/{chunk-QWSA3EOD.js → chunk-7WBCSJL6.js} +23 -9
  12. package/dist/{chunk-4PSTYEG5.js → chunk-AMURHMS3.js} +11 -7
  13. package/dist/{chunk-KPQY44JQ.js → chunk-AWW2T2WL.js} +3 -0
  14. package/dist/chunk-BQFLABJQ.js +186 -0
  15. package/dist/{chunk-E25OSZLJ.js → chunk-COOMXFUG.js} +3 -3
  16. package/dist/chunk-EFGUBGA6.js +64 -0
  17. package/dist/{chunk-HQCY3QCA.js → chunk-H35VDOAE.js} +18 -13
  18. package/dist/{chunk-VDICGXCY.js → chunk-HIMOBNEY.js} +2 -2
  19. package/dist/{chunk-JEUXDY3B.js → chunk-HQED4YB4.js} +1 -1
  20. package/dist/chunk-HRFYYEXR.js +1285 -0
  21. package/dist/{chunk-UYJMEHAF.js → chunk-JZY6WWAP.js} +22 -21
  22. package/dist/{chunk-2F64AZYH.js → chunk-KA5WKR5P.js} +2 -2
  23. package/dist/{chunk-YVG6QD3V.js → chunk-LFJ7N36I.js} +103 -8
  24. package/dist/{chunk-EEARZNHE.js → chunk-LPKIMGIU.js} +89 -37
  25. package/dist/chunk-NNK3JBH4.js +60 -0
  26. package/dist/{chunk-WMDO53YK.js → chunk-OTZ4JQDU.js} +2 -2
  27. package/dist/{chunk-SOSFRU3O.js → chunk-PLNS5J33.js} +58 -26
  28. package/dist/chunk-PUSFEC6B.js +29 -0
  29. package/dist/{chunk-Z3Q2AEIN.js → chunk-R2SVAO4G.js} +14 -2
  30. package/dist/{chunk-K2Z7QHDR.js → chunk-RB26WNLM.js} +52 -15
  31. package/dist/chunk-SVNED423.js +556 -0
  32. package/dist/{chunk-AWVZTN2B.js → chunk-THTROEGD.js} +1 -1
  33. package/dist/{chunk-QVRIDN42.js → chunk-UCMO4LKL.js} +2 -2
  34. package/dist/{chunk-JSBLCLFE.js → chunk-VLOGOM7N.js} +13 -7
  35. package/dist/{chunk-GBSACKFB.js → chunk-XPARQSYS.js} +528 -299
  36. package/dist/{chunk-72NJKS7O.js → chunk-XZDKAR4N.js} +4 -4
  37. package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-ULRNXLQV.js} +1 -1
  38. package/dist/{compat-check-WFEKVLTH.js → compat-check-W4XC27RG.js} +5 -4
  39. package/dist/{config-U4I7X25P.js → config-264GB6C7.js} +28 -14
  40. package/dist/{context-CDB5H5PD.js → context-SOQDFZIB.js} +8 -6
  41. package/dist/{data-integration-QE37EQ3A.js → data-integration-UNJ7EPW2.js} +6 -6
  42. package/dist/{evaluation-LR4YDYWL.js → evaluation-Q3AIGFOG.js} +14 -159
  43. package/dist/index.js +98 -589
  44. package/dist/{local-data-upload-client-KCMG6J62.js → local-data-upload-client-YTWMAAGE.js} +1 -1
  45. package/dist/{memory-SNFR5M23.js → memory-ZLTTULZK.js} +9 -10
  46. package/dist/{metadata-6QM6EED5.js → metadata-EN2IWCDI.js} +11 -10
  47. package/dist/{model-KEVCEXWD.js → model-NAKQWK4W.js} +4 -5
  48. package/dist/{personal-semantic-preference-7VXQPP2N.js → personal-semantic-preference-UGN67KTN.js} +46 -15
  49. package/dist/{project-semantic-PSEPYH2L.js → project-semantic-5OP3YPZD.js} +19 -16
  50. package/dist/{sync-22ACDK5Z.js → sync-LDJQZRQH.js} +9 -9
  51. package/dist/{te-agent-BJ36B4QI.js → te-agent-WNNAD4AJ.js} +303 -17
  52. package/dist/{te-analysis-WQ6D6YG4.js → te-analysis-KIMH6AGU.js} +399 -205
  53. package/dist/{te-community-VRWMFGI6.js → te-community-P7NNBVCS.js} +17 -15
  54. package/dist/{te-dataops-YTLFTTW7.js → te-dataops-ZRKSG4R7.js} +13 -11
  55. package/dist/{te-engage-V2QW7TIC.js → te-engage-PVBVNRSU.js} +13 -12
  56. package/dist/{te-kb-4AQLISDR.js → te-kb-W7PRC7QN.js} +80 -20
  57. package/dist/{te-system-CYWSK3UN.js → te-system-F4ZU2HRQ.js} +6 -7
  58. package/dist/{te-team-6ELNGBWT.js → te-team-5ONMRGKF.js} +9 -8
  59. package/dist/{things-HFWLGCUH.js → things-PFENSIF4.js} +9 -8
  60. package/dist/{update-3CRVVHV5.js → update-EUZ4GNND.js} +8 -6
  61. package/dist/{workspace-2CKQX2XL.js → workspace-Z7L33OBQ.js} +6 -7
  62. package/package.json +12 -7
  63. package/skills/ae-agent/SKILL.md +19 -5
  64. package/skills/ae-agent/references/a2a.md +103 -0
  65. package/skills/ae-agent/references/command_index.md +11 -0
  66. package/skills/ae-ai-monitor/SKILL.md +179 -0
  67. package/skills/ae-ai-monitor/references/read-commands.md +866 -0
  68. package/skills/ae-analysis/SKILL.md +43 -25
  69. package/skills/ae-analysis/references/adhoc_export.md +3 -1
  70. package/skills/ae-analysis/references/ai_models.md +1 -0
  71. package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
  72. package/skills/ae-analysis/references/analysis_gateway_assets.md +2 -0
  73. package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
  74. package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
  75. package/skills/ae-analysis/references/asset_search.md +1 -1
  76. package/skills/ae-analysis/references/bad_case_begin.md +12 -0
  77. package/skills/ae-analysis/references/bad_case_get.md +12 -0
  78. package/skills/ae-analysis/references/bad_case_history.md +12 -0
  79. package/skills/ae-analysis/references/bad_case_list.md +12 -0
  80. package/skills/ae-analysis/references/bad_case_review.md +51 -0
  81. package/skills/ae-analysis/references/bad_case_run.md +12 -0
  82. package/skills/ae-analysis/references/bad_case_submit.md +12 -0
  83. package/skills/ae-analysis/references/bad_case_submit_to_page.md +12 -0
  84. package/skills/ae-analysis/references/bad_case_sync_evaluation.md +11 -0
  85. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  86. package/skills/ae-analysis/references/bi_panel_share.md +3 -1
  87. package/skills/ae-analysis/references/catalog_list.md +2 -0
  88. package/skills/ae-analysis/references/command_index.md +44 -35
  89. package/skills/ae-analysis/references/dashboard_daily_report_update.md +2 -0
  90. package/skills/ae-analysis/references/dashboard_handover.md +3 -1
  91. package/skills/ae-analysis/references/dashboard_list.md +3 -3
  92. package/skills/ae-analysis/references/dashboard_report_data_export.md +1 -1
  93. package/skills/ae-analysis/references/dashboard_share.md +3 -1
  94. package/skills/ae-analysis/references/dashboard_update.md +3 -2
  95. package/skills/ae-analysis/references/filter_value_list.md +2 -0
  96. package/skills/ae-analysis/references/folder_share.md +8 -2
  97. package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
  98. package/skills/ae-analysis/references/governance_recommendation_run_update.md +3 -1
  99. package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
  100. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
  101. package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
  102. package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
  103. package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
  104. package/skills/ae-analysis/references/project_data_power_upsert.md +3 -1
  105. package/skills/ae-analysis/references/project_mark_time_create.md +2 -0
  106. package/skills/ae-analysis/references/project_mark_time_update.md +2 -0
  107. package/skills/ae-analysis/references/project_member_add.md +3 -1
  108. package/skills/ae-analysis/references/project_member_batch_update.md +3 -1
  109. package/skills/ae-analysis/references/project_member_handover_run.md +3 -1
  110. package/skills/ae-analysis/references/project_member_update.md +3 -1
  111. package/skills/ae-analysis/references/project_owner_update.md +8 -2
  112. package/skills/ae-analysis/references/project_role_upsert.md +5 -3
  113. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +16 -1
  114. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +14 -1
  115. package/skills/ae-analysis/references/project_space_share.md +8 -2
  116. package/skills/ae-analysis/references/property_get.md +2 -0
  117. package/skills/ae-analysis/references/public_link_list.md +3 -1
  118. package/skills/ae-analysis/references/query_cancel.md +4 -1
  119. package/skills/ae-analysis/references/report_data_run.md +1 -1
  120. package/skills/ae-analysis/references/report_list.md +3 -3
  121. package/skills/ae-analysis/references/scenario_append.md +2 -2
  122. package/skills/ae-analysis/references/scenario_collect.md +15 -4
  123. package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
  124. package/skills/ae-analysis/references/scenario_list.md +7 -7
  125. package/skills/ae-analysis/references/system_oauth2_update.md +3 -1
  126. package/skills/ae-analysis/references/system_third_party_login_upsert.md +4 -2
  127. package/skills/ae-analysis/references/user_tag_create.md +4 -1
  128. package/skills/ae-analysis/references/user_tag_get.md +2 -0
  129. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  130. package/skills/ae-analysis/references/user_tag_update.md +5 -2
  131. package/skills/ae-analysis/references/virtual_property_create.md +12 -1
  132. package/skills/ae-analysis/references/virtual_property_sql_rule_update.md +10 -0
  133. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +55 -13
  134. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +2 -2
  135. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +2 -2
  136. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +7 -1
  137. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/wait-compile-run.mjs +79 -0
  138. package/skills/ae-automation/SKILL.md +4 -2
  139. package/skills/ae-capability/SKILL.md +16 -8
  140. package/skills/ae-community/SKILL.md +1 -0
  141. package/skills/ae-dataops/SKILL.md +1 -0
  142. package/skills/ae-engage/SKILL.md +1 -0
  143. package/skills/ae-evaluation/SKILL.md +17 -2
  144. package/skills/ae-generate-tracking-plan/SKILL.md +5 -0
  145. package/skills/ae-kb/SKILL.md +8 -4
  146. package/skills/ae-kb/references/analysis-workflow.md +11 -2
  147. package/skills/ae-kb/references/publication.md +45 -0
  148. package/skills/ae-kb/references/query-workflow.md +3 -1
  149. package/skills/ae-kb/references/versions.md +1 -1
  150. package/skills/ae-metadata/SKILL.md +1 -0
  151. package/skills/ae-migrate-tracking-code/SKILL.md +2 -1
  152. package/skills/ae-team/SKILL.md +1 -1
  153. package/skills/ae-tracking-matrix/SKILL.md +170 -0
  154. package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
  155. package/skills/ae-tracking-matrix/i18n.yaml +12 -0
  156. package/skills/ae-tracking-matrix/references/ae-capabilities.md +93 -0
  157. package/skills/ae-tracking-matrix/references/business-semantic-checks.md +30 -0
  158. package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +256 -0
  159. package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +213 -0
  160. package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +407 -0
  161. package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +218 -0
  162. package/skills/ae-tracking-matrix/references/categories/casual_music.md +112 -0
  163. package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +301 -0
  164. package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +356 -0
  165. package/skills/ae-tracking-matrix/references/categories/fishing.md +775 -0
  166. package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +89 -0
  167. package/skills/ae-tracking-matrix/references/categories/idle_card.md +27 -0
  168. package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +415 -0
  169. package/skills/ae-tracking-matrix/references/categories/interactive_video.md +133 -0
  170. package/skills/ae-tracking-matrix/references/categories/merge.md +639 -0
  171. package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +406 -0
  172. package/skills/ae-tracking-matrix/references/categories/mmo_web.md +230 -0
  173. package/skills/ae-tracking-matrix/references/categories/music.md +137 -0
  174. package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +414 -0
  175. package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +199 -0
  176. package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +158 -0
  177. package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +546 -0
  178. package/skills/ae-tracking-matrix/references/categories/rpg.md +195 -0
  179. package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +115 -0
  180. package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +151 -0
  181. package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +260 -0
  182. package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +232 -0
  183. package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +359 -0
  184. package/skills/ae-tracking-matrix/references/categories/tower_defense.md +365 -0
  185. package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +211 -0
  186. package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +132 -0
  187. package/skills/ae-tracking-matrix/references/category-registry.md +77 -0
  188. package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +230 -0
  189. package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +406 -0
  190. package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +128 -0
  191. package/skills/ae-tracking-matrix/references/eval-cases.md +74 -0
  192. package/skills/ae-tracking-matrix/references/naming-dict.md +238 -0
  193. package/skills/ae-tracking-matrix/references/optimization-checklist.md +85 -0
  194. package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +142 -0
  195. package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +47 -0
  196. package/skills/ae-tracking-matrix/references/plan-generation/reference.md +794 -0
  197. package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +94 -0
  198. package/skills/ae-tracking-matrix/references/scene-routing.md +80 -0
  199. package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +3787 -0
  200. package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +827 -0
  201. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +655 -0
  202. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +953 -0
  203. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +1128 -0
  204. package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +714 -0
  205. package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +1268 -0
  206. package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +776 -0
  207. package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +182 -0
  208. package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +2755 -0
  209. package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +1182 -0
  210. package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +1300 -0
  211. package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +1369 -0
  212. package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +1692 -0
  213. package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +902 -0
  214. package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +763 -0
  215. package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +1107 -0
  216. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +1532 -0
  217. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +845 -0
  218. package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +228 -0
  219. package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +149 -0
  220. package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +407 -0
  221. package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +163 -0
  222. package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +149 -0
  223. package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +153 -0
  224. package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +232 -0
  225. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +314 -0
  226. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +117 -0
  227. package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +148 -0
  228. package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +645 -0
  229. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +307 -0
  230. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +347 -0
  231. package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +72 -0
  232. package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +264 -0
  233. package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +566 -0
  234. package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +409 -0
  235. package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +446 -0
  236. package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +557 -0
  237. package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +457 -0
  238. package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +490 -0
  239. package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +523 -0
  240. package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +484 -0
  241. package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +442 -0
  242. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +391 -0
  243. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +91 -0
  244. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +635 -0
  245. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +113 -0
  246. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +466 -0
  247. package/skills/ae-tracking-matrix/references/standard-base/README.md +22 -0
  248. package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +174 -0
  249. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +20 -0
  250. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +7 -0
  251. package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +14 -0
  252. package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +370 -0
  253. package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +47 -0
  254. package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +37 -0
  255. package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +27 -0
  256. package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +23 -0
  257. package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +14 -0
  258. package/skills/ae-tracking-matrix/references/standard-base/user_data.md +46 -0
  259. package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +13 -0
  260. package/skills/ae-tracking-matrix/references/system-fields.md +297 -0
  261. package/skills/ae-tracking-matrix/references/te-field-translations.md +1791 -0
  262. package/skills/ae-tracking-matrix/references/workflows/data-verification.md +232 -0
  263. package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +829 -0
  264. package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +355 -0
  265. package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +283 -0
  266. package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +168 -0
  267. package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +205 -0
  268. package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +75 -0
  269. package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +36 -0
  270. package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +107 -0
  271. package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +114 -0
  272. package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +53 -0
  273. package/skills/ae-tracking-matrix/scripts/finalize_plan.py +166 -0
  274. package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +674 -0
  275. package/skills/ae-tracking-matrix/scripts/plan_contract.py +200 -0
  276. package/skills/ae-tracking-matrix/scripts/plan_types.py +60 -0
  277. package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +169 -0
  278. package/skills/ae-tracking-matrix/scripts/sync_plan.py +296 -0
  279. package/skills/ae-tracking-matrix/scripts/upload_plan.py +340 -0
  280. package/dist/chunk-AMBFK2K3.js +0 -28
  281. 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-SOSFRU3O.js";
8
+ } from "./chunk-PLNS5J33.js";
5
9
  import {
6
10
  getActiveHost,
7
11
  getConfigDir,
8
12
  isAeSandboxRuntime,
9
13
  readSandboxCliTokenEntry
10
- } from "./chunk-4PSTYEG5.js";
14
+ } from "./chunk-AMURHMS3.js";
11
15
  import {
12
16
  PermissionError,
13
17
  externalCliTokenRequestOptions,
14
18
  normalizeUrl,
15
19
  readExternalCliToken
16
- } from "./chunk-Z3Q2AEIN.js";
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 createHash2 } from "crypto";
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 crypto2 from "crypto";
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 fs3 from "fs";
323
+ import fs2 from "fs";
344
324
  import os from "os";
345
- import path3 from "path";
325
+ import path2 from "path";
346
326
  import { parseDocument } from "yaml";
347
327
  function globalSkillsDirectory() {
348
- return path3.join(os.homedir(), ".agents", "skills");
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 fs3.readdirSync(path3.join(root, prefix), { withFileTypes: true })) {
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 = path3.join(prefix, entry.name);
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, fs3.readFileSync(path3.join(root, 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 skills = fs3.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => {
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
- const files = readFiles(path3.join(directory, entry.name));
373
- return { name: skillName(files.get("SKILL.md").toString("utf8")), files };
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 (!skills.length || new Set(skills.map((skill) => skill.name)).size !== skills.length) {
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 = path3.join(directory, skill.name);
389
- if (skillName(fs3.readFileSync(path3.join(target, "SKILL.md"), "utf8")) !== skill.name) {
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 (!fs3.readFileSync(path3.join(target, file)).equals(expected)) {
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 crypto from "crypto";
408
- import fs4 from "fs";
409
- import path4 from "path";
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"
@@ -434,6 +428,7 @@ var skill_businesses_default = {
434
428
  ],
435
429
  agent: [
436
430
  "ae-agent",
431
+ "ae-ai-monitor",
437
432
  "ae-automation",
438
433
  "ae-current-context",
439
434
  "ae-evaluation",
@@ -477,7 +472,9 @@ var COMMAND_BUSINESSES = {
477
472
  evaluation: "agent",
478
473
  sync: "agent",
479
474
  model: "agent",
480
- context: "agent"
475
+ context: "agent",
476
+ "ai-monitor": "agent",
477
+ ai_monitor: "agent"
481
478
  };
482
479
  var AGENT_SYSTEM_COMMANDS = /* @__PURE__ */ new Set([
483
480
  "channel",
@@ -580,153 +577,65 @@ function canManageGlobalSkills() {
580
577
  return !readExternalCliToken() && !isSandboxExecutionContext();
581
578
  }
582
579
 
583
- // src/core/business-config.ts
584
- var BUSINESS_CONFIG_TTL_MS = 10 * 60 * 1e3;
585
- var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
586
- function cachePath() {
587
- return path4.join(getConfigDir(), "business-config.json");
588
- }
589
- function cacheKey(host, token) {
590
- return `${normalizeUrl(host)}#${crypto.createHash("sha256").update(token).digest("hex")}`;
591
- }
592
- function readStore() {
593
- try {
594
- const value = JSON.parse(fs4.readFileSync(cachePath(), "utf8"));
595
- if (value?.entries && typeof value.entries === "object" && !Array.isArray(value.entries)) return value;
596
- } catch {
597
- }
598
- return { entries: {} };
599
- }
600
- function remember(host, token, entry) {
601
- const store = readStore();
602
- store.entries[cacheKey(host, token)] = entry;
603
- const target = cachePath();
604
- const temporary = `${target}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`;
605
- try {
606
- fs4.mkdirSync(path4.dirname(target), { recursive: true });
607
- fs4.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
608
- fs4.renameSync(temporary, target);
609
- fs4.chmodSync(target, 384);
610
- } catch {
611
- try {
612
- fs4.rmSync(temporary, { force: true });
613
- } catch {
614
- }
615
- }
616
- }
617
- function rememberBusinessConfig(host, token, businesses, now = Date.now()) {
618
- remember(host, token, { businesses: normalizeBusinesses(businesses), fetchedAt: now });
619
- }
620
- function peekBusinessConfig(host, token, now = Date.now()) {
621
- const entry = readStore().entries[cacheKey(host, token)];
622
- if (entry?.unavailableAt !== void 0 && now >= entry.unavailableAt && now - entry.unavailableAt < UNAVAILABLE_TTL_MS) return {};
623
- if (!entry || !Number.isFinite(entry.fetchedAt) || now < entry.fetchedAt || now - entry.fetchedAt >= BUSINESS_CONFIG_TTL_MS) return void 0;
624
- return normalizeBusinesses(entry.businesses);
625
- }
626
- function readBusinessConfig(host, token) {
627
- const entry = readStore().entries[cacheKey(host, token)];
628
- return entry && Number.isFinite(entry.fetchedAt) && entry.fetchedAt > 0 ? normalizeBusinesses(entry.businesses) : void 0;
629
- }
630
- function readCurrentBusinessConfig(hostOverride) {
631
- try {
632
- if (isSandboxExecutionContext()) return {};
633
- const host = hostOverride || getActiveHost();
634
- if (!host) return {};
635
- const token = peekCliToken(host);
636
- return token ? readBusinessConfig(host, token) ?? {} : {};
637
- } catch {
638
- return {};
639
- }
640
- }
641
- async function resolveBusinessConfig(host, token, fetchRemote, now = Date.now()) {
642
- const cached = peekBusinessConfig(host, token, now);
643
- if (cached !== void 0) return cached;
644
- const config = await fetchRemote().catch(() => null);
645
- if (!config) {
646
- const previous = readStore().entries[cacheKey(host, token)];
647
- remember(host, token, {
648
- businesses: normalizeBusinesses(previous?.businesses),
649
- fetchedAt: previous?.fetchedAt ?? 0,
650
- unavailableAt: now
651
- });
652
- return {};
653
- }
654
- const businesses = normalizeBusinesses(config.businesses);
655
- rememberBusinessConfig(host, token, businesses, now);
656
- return businesses;
657
- }
658
- var BusinessDisabledError = class extends PermissionError {
659
- constructor(business) {
660
- super(
661
- `The '${business}' business is not enabled for the current environment.`,
662
- "BUSINESS_NOT_ENABLED",
663
- "Contact your administrator if this business should be enabled, then run: ae-cli config refresh"
664
- );
665
- this.business = business;
666
- this.name = "BusinessDisabledError";
667
- }
668
- business;
669
- };
670
- async function readBusinessConfigForExecution(hostOverride) {
671
- try {
672
- if (isSandboxExecutionContext()) return {};
673
- const host = hostOverride || getActiveHost();
674
- if (!host) return {};
675
- const token = peekCliToken(host);
676
- if (!token) return {};
677
- return await resolveBusinessConfig(host, token, async () => {
678
- const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-WFEKVLTH.js");
679
- return fetchCliConfig2(host, token);
680
- });
681
- } catch {
682
- return {};
683
- }
684
- }
685
- async function assertBusinessEnabled(business, hostOverride) {
686
- if (business && (await readBusinessConfigForExecution(hostOverride))[business] === false) {
687
- throw new BusinessDisabledError(business);
688
- }
689
- }
580
+ // src/core/business-skill-refresh.ts
581
+ import crypto from "crypto";
582
+ import fs5 from "fs";
583
+ import path5 from "path";
690
584
 
691
585
  // src/core/business-skill-sync.ts
692
- import fs6 from "fs";
693
- import path6 from "path";
694
- import { randomUUID } from "crypto";
586
+ import fs4 from "fs";
587
+ import os3 from "os";
588
+ import path4 from "path";
589
+ import { createHash as createHash2, randomUUID } from "crypto";
695
590
 
696
591
  // src/core/skills-tool.ts
697
- import fs5 from "fs";
592
+ import fs3 from "fs";
698
593
  import os2 from "os";
699
- import path5 from "path";
594
+ import path3 from "path";
700
595
  import { createHash } from "crypto";
701
596
  import { createRequire, isBuiltin } from "module";
702
597
  import { pathToFileURL } from "url";
703
598
  import spawn2 from "cross-spawn";
704
599
  var MANAGED_SKILLS_TOOL_VERSION = "1.5.12";
705
600
  var TOOL_SOURCE_SHA256 = "5a2c18ddd70886d5367e39a0f88827ffd1024420e4d9db08149742386c088d2d";
601
+ function skillPathIdentity(file) {
602
+ try {
603
+ const stat = fs3.lstatSync(file, { bigint: true });
604
+ return {
605
+ dev: String(stat.dev),
606
+ ino: String(stat.ino),
607
+ type: stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "other",
608
+ ...stat.isSymbolicLink() ? { link: fs3.readlinkSync(file) } : {}
609
+ };
610
+ } catch (error) {
611
+ if (error.code === "ENOENT") return null;
612
+ throw error;
613
+ }
614
+ }
706
615
  function realSkillPath(file) {
707
616
  try {
708
- return fs5.realpathSync(file);
617
+ return fs3.realpathSync(file);
709
618
  } catch (error) {
710
619
  if (error.code !== "ENOENT") throw error;
711
- const parent = path5.dirname(file);
620
+ const parent = path3.dirname(file);
712
621
  if (parent === file) throw error;
713
- return path5.join(realSkillPath(parent), path5.basename(file));
622
+ return path3.join(realSkillPath(parent), path3.basename(file));
714
623
  }
715
624
  }
716
625
  function skillPathProblem(targetDirectory, skill, sourceRoot) {
717
626
  try {
718
- const target = realSkillPath(path5.resolve(targetDirectory, skill));
719
- const source = fs5.realpathSync(sourceRoot);
720
- const overlaps = (a, b) => a === b || a.startsWith(b + path5.sep);
627
+ const target = realSkillPath(path3.resolve(targetDirectory, skill));
628
+ const source = realSkillPath(path3.resolve(sourceRoot));
629
+ const overlaps = (a, b) => a === b || a.startsWith(b + path3.sep);
721
630
  if (overlaps(target, source) || overlaps(source, target)) return "package_source_overlap";
722
- let parent = path5.resolve(targetDirectory);
631
+ let parent = path3.resolve(targetDirectory);
723
632
  while (true) {
724
633
  try {
725
- if (fs5.lstatSync(parent).isSymbolicLink()) return "copy_parent_linked";
634
+ if (fs3.lstatSync(parent).isSymbolicLink()) return "copy_parent_linked";
726
635
  } catch (error) {
727
636
  if (error.code !== "ENOENT") throw error;
728
637
  }
729
- const next = path5.dirname(parent);
638
+ const next = path3.dirname(parent);
730
639
  if (next === parent) return null;
731
640
  parent = next;
732
641
  }
@@ -736,27 +645,27 @@ function skillPathProblem(targetDirectory, skill, sourceRoot) {
736
645
  }
737
646
  function skillCopyHash(directory, source = false) {
738
647
  try {
739
- if (!fs5.lstatSync(directory).isDirectory()) throw new Error("Not a regular Skill directory.");
648
+ if (!fs3.lstatSync(directory).isDirectory()) throw new Error("Not a regular Skill directory.");
740
649
  } catch (error) {
741
650
  if (error.code === "ENOENT") return null;
742
651
  throw error;
743
652
  }
744
653
  const hash = createHash("sha256");
745
654
  const visit = (relative) => {
746
- for (const name of fs5.readdirSync(path5.join(directory, relative)).sort()) {
655
+ for (const name of fs3.readdirSync(path3.join(directory, relative)).sort()) {
747
656
  if (name === ".DS_Store") continue;
748
- const child = path5.join(relative, name);
749
- const absolute = path5.join(directory, child);
750
- const stat = fs5.lstatSync(absolute);
657
+ const child = path3.join(relative, name);
658
+ const absolute = path3.join(directory, child);
659
+ const stat = fs3.lstatSync(absolute);
751
660
  if (source && (name === "metadata.json" || stat.isDirectory() && [".git", "__pycache__", "__pypackages__"].includes(name))) continue;
752
- const normalized = child.split(path5.sep).join("/");
661
+ const normalized = child.split(path3.sep).join("/");
753
662
  if (stat.isSymbolicLink()) throw new Error("Symbolic links are not managed Skill copies.");
754
663
  if (stat.isDirectory()) {
755
664
  hash.update(`directory:${normalized}\0`);
756
665
  visit(child);
757
666
  } else if (stat.isFile()) {
758
667
  hash.update(`file:${normalized}\0${stat.size}\0`);
759
- hash.update(fs5.readFileSync(absolute));
668
+ hash.update(fs3.readFileSync(absolute));
760
669
  } else throw new Error("Unsupported Skill file type.");
761
670
  }
762
671
  };
@@ -774,6 +683,11 @@ function adaptedToolSource(source, entry) {
774
683
  let remove = source.slice(removeStart, removeEnd);
775
684
  remove = replaceOnce(remove, "const agentResult = await detectAgent();", "const agentResult = { isAgent: false };");
776
685
  remove = replaceOnce(remove, "const spinner = Y();", "const spinner = { start() {}, stop() {} };");
686
+ remove = replaceOnce(
687
+ remove,
688
+ "for (const entry of entries) if (entry.isDirectory()) skillNamesSet.add(entry.name);",
689
+ "for (const entry of entries) if (entry.isDirectory() || options.__aeCliAllowedPaths.has(join(dir, entry.name))) skillNamesSet.add(entry.name);"
690
+ );
777
691
  remove = replaceOnce(
778
692
  remove,
779
693
  "if (pathToCleanup === canonicalPath) continue;",
@@ -808,7 +722,7 @@ function adaptedToolSource(source, entry) {
808
722
  );
809
723
  source = replaceOnce(source, "main().finally(() => flushTelemetry().then(() => process.exit(0)));", "");
810
724
  const require2 = createRequire(entry);
811
- const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ? path5.resolve(path5.dirname(entry), specifier) : require2.resolve(specifier)).href;
725
+ const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ? path3.resolve(path3.dirname(entry), specifier) : require2.resolve(specifier)).href;
812
726
  source = source.replace(
813
727
  /\bfrom (['"])([^'"]+)\1/g,
814
728
  (_match, quote, specifier) => `from ${quote}${resolveImport(specifier)}${quote}`
@@ -821,7 +735,6 @@ function adaptedToolSource(source, entry) {
821
735
  }
822
736
  var WORKER_SOURCE = String.raw`
823
737
  import * as __aeCliFs from 'node:fs';
824
- import * as __aeCliPath from 'node:path';
825
738
  const __aeCliQuiet = () => {};
826
739
  let __aeCliTargetOverride = null;
827
740
  let __aeCliBeforeInstallMutation = null;
@@ -837,7 +750,7 @@ function __aeCliRealPath(file) {
837
750
  function __aeCliPathProblem(targetDirectory, skill, sourceRoot) {
838
751
  try {
839
752
  const target = __aeCliRealPath(resolve(targetDirectory, skill));
840
- const source = __aeCliFs.realpathSync(sourceRoot);
753
+ const source = __aeCliRealPath(resolve(sourceRoot));
841
754
  const overlaps = (a, b) => a === b || a.startsWith(b + sep);
842
755
  if (overlaps(target, source) || overlaps(source, target)) return 'package_source_overlap';
843
756
  let parent = resolve(targetDirectory);
@@ -870,46 +783,49 @@ function __aeCliHash(directory, source = false) {
870
783
  visit('');
871
784
  return hash.digest('hex');
872
785
  }
786
+ function __aeCliDirectInstallerLink(text, file, target) {
787
+ if (typeof text !== 'string') return false;
788
+ let value = text;
789
+ if (process.platform === 'win32') {
790
+ if (value.toUpperCase().startsWith('\\\\?\\UNC\\')) value = '\\\\' + value.slice(8);
791
+ else if (value.startsWith('\\\\?\\') || value.startsWith('\\??\\')) value = value.slice(4);
792
+ return [target, relative(dirname(file), target)].some(expected => value.toLowerCase() === expected.toLowerCase());
793
+ }
794
+ return value === target || value === relative(dirname(file), target);
795
+ }
873
796
  function __aeCliLegacyLinkProblem(operation, targetPath, targets, guard) {
874
797
  try {
875
798
  const canonical = resolve(getCanonicalSkillsDir(true));
876
799
  const canonicalTarget = targets.find(target => target.agent === 'universal' && target.directory === canonical);
877
800
  const link = operation.legacy_link;
801
+ const removing = operation.action === 'remove';
878
802
  if (!canonicalTarget || link.target !== join(canonical, operation.skill) || targetPath === link.target
879
- || !guard.ledger_file || operation.expected_hash !== operation.source_hash) return 'legacy_link_not_managed';
803
+ || !guard.ledger_file || (!removing && operation.expected_hash !== operation.source_hash)) return 'legacy_link_not_managed';
880
804
  const pathProblem = __aeCliPathProblem(canonical, operation.skill, operation.source_root);
881
805
  if (pathProblem) return pathProblem;
882
806
  const ledger = JSON.parse(__aeCliFs.readFileSync(guard.ledger_file, 'utf8'));
883
807
  const owned = ledger.schema_version === 1 && ledger.copies?.[link.target];
884
808
  if (!owned || owned.skill !== operation.skill || owned.agent !== canonicalTarget.agent
885
- || owned.hash !== operation.source_hash) return 'legacy_link_not_managed';
809
+ || (!removing && owned.hash !== operation.source_hash)) return 'legacy_link_not_managed';
886
810
  if (!__aeCliFs.lstatSync(targetPath).isSymbolicLink() || __aeCliFs.readlinkSync(targetPath) !== link.text
887
- || resolve(dirname(targetPath), link.text) !== link.target
888
- || __aeCliFs.realpathSync(targetPath) !== __aeCliFs.realpathSync(link.target)) return 'legacy_link_changed';
889
- if (__aeCliHash(link.target) !== operation.source_hash) return 'legacy_link_target_modified';
811
+ || !__aeCliDirectInstallerLink(link.text, targetPath, link.target)
812
+ || (!removing && __aeCliFs.realpathSync(targetPath) !== __aeCliFs.realpathSync(link.target))) return 'legacy_link_changed';
813
+ if (!removing && __aeCliHash(link.target) !== operation.source_hash) return 'legacy_link_target_modified';
890
814
  return null;
891
815
  } catch { return 'legacy_link_unreadable'; }
892
816
  }
893
- function __aeCliLinkDependsOn(file, dependency) {
894
- const absolute = resolve(file);
895
- let cursor = __aeCliPath.parse(absolute).root;
896
- const pending = absolute.slice(cursor.length).split(sep);
897
- let links = 0;
898
- while (pending.length) {
899
- const part = pending.shift();
900
- if (!part || part === '.') continue;
901
- if (part === '..') { cursor = dirname(cursor); continue; }
902
- cursor = join(cursor, part);
903
- if (cursor === dependency || cursor.startsWith(dependency + sep)) return true;
904
- if (!__aeCliFs.lstatSync(cursor).isSymbolicLink()) continue;
905
- if (++links > 64) throw new Error('Skill link chain is too deep.');
906
- const text = __aeCliFs.readlinkSync(cursor);
907
- const root = __aeCliPath.parse(text).root;
908
- cursor = root || dirname(cursor);
909
- // Expand a link before applying subsequent '..' components, matching filesystem lookup.
910
- pending.unshift(...text.slice(root.length).split(sep));
911
- }
912
- return false;
817
+ function __aeCliRemovalProblem(operation, targetPath, guard) {
818
+ try {
819
+ const ledger = guard.ledger_file && JSON.parse(__aeCliFs.readFileSync(guard.ledger_file, 'utf8'));
820
+ const owned = ledger?.schema_version === 1 && ledger.copies?.[targetPath];
821
+ if (!owned || owned.skill !== operation.skill || owned.agent !== operation.target.agent) return 'copy_not_managed';
822
+ const expected = operation.expected_node;
823
+ const current = __aeCliFs.lstatSync(targetPath, { bigint: true });
824
+ const type = current.isSymbolicLink() ? 'symlink' : current.isDirectory() ? 'directory' : current.isFile() ? 'file' : 'other';
825
+ if (!expected || expected.dev !== String(current.dev) || expected.ino !== String(current.ino) || expected.type !== type
826
+ || (type === 'symlink' && expected.link !== __aeCliFs.readlinkSync(targetPath))) return 'copy_changed';
827
+ return null;
828
+ } catch { return 'copy_unreadable'; }
913
829
  }
914
830
  async function __aeCliTargets() {
915
831
  const detected = new Set(await detectInstalledAgents());
@@ -957,24 +873,16 @@ async function __aeCliMain() {
957
873
  blockedReason = 'legacy_target_missing'; return false;
958
874
  }
959
875
  if (candidate !== targetPath) { blockedReason = 'copy_changed'; return false; }
960
- if (__aeCliHash(operation.source, true) !== operation.source_hash) { blockedReason = 'package_changed'; return false; }
876
+ if (operation.action === 'remove') {
877
+ const problem = __aeCliRemovalProblem(operation, targetPath, request.guard);
878
+ if (problem) { blockedReason = problem; return false; }
879
+ } else {
880
+ if (__aeCliHash(operation.source, true) !== operation.source_hash) { blockedReason = 'package_changed'; return false; }
881
+ if (!operation.legacy_link && __aeCliHash(targetPath) !== operation.expected_hash) { blockedReason = 'copy_changed'; return false; }
882
+ }
961
883
  if (operation.legacy_link) {
962
884
  const problem = __aeCliLegacyLinkProblem(operation, targetPath, targets, request.guard);
963
885
  if (problem) { blockedReason = problem; return false; }
964
- } else if (__aeCliHash(targetPath) !== operation.expected_hash) { blockedReason = 'copy_changed'; return false; }
965
- if (operation.action === 'remove') for (const other of targets) {
966
- try {
967
- // Preserve custom aliases too; only exact same-name installer links are migrated.
968
- for (const name of __aeCliFs.readdirSync(other.directory)) {
969
- const otherPath = join(other.directory, name);
970
- if (otherPath === targetPath) continue;
971
- try {
972
- if (__aeCliFs.lstatSync(otherPath).isSymbolicLink() && __aeCliLinkDependsOn(otherPath, targetPath)) {
973
- blockedReason = 'dependent_unmanaged_link'; return false;
974
- }
975
- } catch (error) { if (error.code !== 'ENOENT') throw error; }
976
- }
977
- } catch (error) { if (error.code !== 'ENOENT') { blockedReason = 'dependent_copy_unreadable'; return false; } }
978
886
  }
979
887
  return true;
980
888
  } catch { blockedReason = 'copy_unreadable'; return false; }
@@ -1024,19 +932,19 @@ catch { process.stdout.write(JSON.stringify({ ok: false })); process.exitCode =
1024
932
  `;
1025
933
  function createPinnedSkillsTool(options = {}) {
1026
934
  const require2 = createRequire(import.meta.url);
1027
- const packageFile = options.entry ? path5.join(path5.dirname(options.entry), "..", "package.json") : require2.resolve("skills/package.json");
1028
- const entry = options.entry ?? path5.join(path5.dirname(packageFile), "dist", "cli.mjs");
1029
- const metadata = JSON.parse(fs5.readFileSync(packageFile, "utf8"));
1030
- const source = fs5.readFileSync(entry, "utf8");
935
+ const packageFile = options.entry ? path3.join(path3.dirname(options.entry), "..", "package.json") : require2.resolve("skills/package.json");
936
+ const entry = options.entry ?? path3.join(path3.dirname(packageFile), "dist", "cli.mjs");
937
+ const metadata = JSON.parse(fs3.readFileSync(packageFile, "utf8"));
938
+ const source = fs3.readFileSync(entry, "utf8");
1031
939
  if (metadata.version !== MANAGED_SKILLS_TOOL_VERSION || createHash("sha256").update(source).digest("hex") !== TOOL_SOURCE_SHA256) {
1032
940
  throw new Error("Managed Skill synchronization requires the verified skills@1.5.12 package.");
1033
941
  }
1034
942
  const script = adaptedToolSource(source, entry);
1035
943
  const run = (request) => {
1036
- const directory = fs5.mkdtempSync(path5.join(os2.tmpdir(), "ae-cli-skills-tool-"));
1037
- const worker = path5.join(directory, "adapter.mjs");
944
+ const directory = fs3.mkdtempSync(path3.join(os2.tmpdir(), "ae-cli-skills-tool-"));
945
+ const worker = path3.join(directory, "adapter.mjs");
1038
946
  try {
1039
- fs5.writeFileSync(worker, script, { mode: 384 });
947
+ fs3.writeFileSync(worker, script, { mode: 384 });
1040
948
  const result2 = spawn2.sync(process.execPath, [worker], {
1041
949
  input: JSON.stringify(request),
1042
950
  encoding: "utf8",
@@ -1053,7 +961,7 @@ function createPinnedSkillsTool(options = {}) {
1053
961
  } catch {
1054
962
  throw new Error("Skills adapter failed. Check the pinned package and directory permissions.");
1055
963
  } finally {
1056
- fs5.rmSync(directory, { recursive: true, force: true });
964
+ fs3.rmSync(directory, { recursive: true, force: true });
1057
965
  }
1058
966
  };
1059
967
  return {
@@ -1066,14 +974,60 @@ function createPinnedSkillsTool(options = {}) {
1066
974
  var CONTEXT_FILE = "business-skill-context.json";
1067
975
  var LEDGER_FILE = "business-skills.json";
1068
976
  var LOCK_FILE = "business-skills.lock";
977
+ var POLICY_HASH = createHash2("sha256").update(JSON.stringify({ removal_policy: 2, optional_businesses: OPTIONAL_BUSINESSES, skills: skill_businesses_default })).digest("hex");
978
+ function historicalCliSkills(options) {
979
+ const env = options.env ?? process.env;
980
+ const home = env.HOME || env.USERPROFILE || os3.homedir();
981
+ const file = env.XDG_STATE_HOME ? path4.join(env.XDG_STATE_HOME, "skills", ".skill-lock.json") : path4.join(home, ".agents", ".skill-lock.json");
982
+ const names = /* @__PURE__ */ new Set();
983
+ let content = "";
984
+ const isCliSource = (value, type) => {
985
+ if (typeof value !== "string") return false;
986
+ if (type === "local" && path4.isAbsolute(value)) {
987
+ const source2 = path4.resolve(value);
988
+ if (source2 === path4.resolve(options.skillsDirectory)) return true;
989
+ if (path4.basename(source2) !== "skills") return false;
990
+ try {
991
+ const pkg = JSON.parse(fs4.readFileSync(path4.join(source2, "..", "package.json"), "utf8"));
992
+ return ["@tant/ae-cli", "@thinkingai/ae-cli"].includes(pkg.name) && typeof pkg.bin?.["ae-cli"] === "string";
993
+ } catch {
994
+ return false;
995
+ }
996
+ }
997
+ if (!["git", "github"].includes(String(type))) return false;
998
+ const source = value.replace(/\/+$/, "").replace(/\.git$/, "");
999
+ return [
1000
+ "ThinkingAIAgenticEngine/ae-cli",
1001
+ "https://github.com/ThinkingAIAgenticEngine/ae-cli",
1002
+ "git@github.com:ThinkingAIAgenticEngine/ae-cli",
1003
+ "ssh://git@gitlab.thinkingdata.cn:2222/te-ai/te-cli",
1004
+ "https://gitlab.thinkingdata.cn/te-ai/te-cli",
1005
+ "http://10.27.249.150:8888/te-ai/te-cli"
1006
+ ].includes(source);
1007
+ };
1008
+ try {
1009
+ content = fs4.readFileSync(file, "utf8");
1010
+ const lock = JSON.parse(content);
1011
+ const mapped = new Set(Object.values(skill_businesses_default).flat());
1012
+ if (typeof lock.version === "number" && lock.skills && typeof lock.skills === "object") {
1013
+ for (const [name, entry] of Object.entries(lock.skills)) {
1014
+ if (!mapped.has(name) || !entry || typeof entry !== "object") continue;
1015
+ const record = entry;
1016
+ if (isCliSource(record.source, record.sourceType) || isCliSource(record.sourceUrl, record.sourceType)) names.add(name);
1017
+ }
1018
+ }
1019
+ } catch {
1020
+ }
1021
+ return { names, hash: createHash2("sha256").update(content).digest("hex") };
1022
+ }
1069
1023
  function writeJson(file, value) {
1070
1024
  const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
1071
1025
  try {
1072
- fs6.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n", { mode: 384, flag: "wx" });
1073
- fs6.renameSync(temporary, file);
1026
+ fs4.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n", { mode: 384, flag: "wx" });
1027
+ fs4.renameSync(temporary, file);
1074
1028
  } finally {
1075
1029
  try {
1076
- fs6.unlinkSync(temporary);
1030
+ fs4.unlinkSync(temporary);
1077
1031
  } catch {
1078
1032
  }
1079
1033
  }
@@ -1093,15 +1047,15 @@ function contextIdentity(options) {
1093
1047
  }
1094
1048
  function reserveBusinessSkillContext(options) {
1095
1049
  const directory = options.stateDirectory ?? getConfigDir();
1096
- fs6.mkdirSync(directory, { recursive: true, mode: 448 });
1050
+ fs4.mkdirSync(directory, { recursive: true, mode: 448 });
1097
1051
  const generation = randomUUID();
1098
- writeJson(path6.join(directory, CONTEXT_FILE), { ...contextIdentity(options), generation });
1052
+ writeJson(path4.join(directory, CONTEXT_FILE), { ...contextIdentity(options), generation });
1099
1053
  return generation;
1100
1054
  }
1101
1055
  function currentContext(options, file, generation) {
1102
1056
  try {
1103
1057
  if (options.isCurrentContext && !options.isCurrentContext()) return false;
1104
- const active = JSON.parse(fs6.readFileSync(file, "utf8"));
1058
+ const active = JSON.parse(fs4.readFileSync(file, "utf8"));
1105
1059
  const identity = contextIdentity(options);
1106
1060
  return active.generation === generation && active.host === identity.host && active.token_fingerprint === identity.token_fingerprint;
1107
1061
  } catch {
@@ -1109,12 +1063,12 @@ function currentContext(options, file, generation) {
1109
1063
  }
1110
1064
  }
1111
1065
  function isBusinessSkillContextCurrent(options) {
1112
- return currentContext(options, path6.join(options.stateDirectory ?? getConfigDir(), CONTEXT_FILE), options.generation);
1066
+ return currentContext(options, path4.join(options.stateDirectory ?? getConfigDir(), CONTEXT_FILE), options.generation);
1113
1067
  }
1114
1068
  function takeLock(file) {
1115
1069
  const owner = randomUUID();
1116
1070
  const ownerName = `owner-${process.pid}-${owner}.json`;
1117
- const candidate = fs6.mkdtempSync(`${file}.candidate-`);
1071
+ const candidate = fs4.mkdtempSync(`${file}.candidate-`);
1118
1072
  const alive = (pid) => {
1119
1073
  try {
1120
1074
  process.kill(pid, 0);
@@ -1124,29 +1078,29 @@ function takeLock(file) {
1124
1078
  }
1125
1079
  };
1126
1080
  try {
1127
- fs6.chmodSync(candidate, 448);
1128
- fs6.writeFileSync(path6.join(candidate, ownerName), JSON.stringify({ pid: process.pid, owner }), { mode: 384 });
1081
+ fs4.chmodSync(candidate, 448);
1082
+ fs4.writeFileSync(path4.join(candidate, ownerName), JSON.stringify({ pid: process.pid, owner }), { mode: 384 });
1129
1083
  for (let attempt = 0; attempt < 4; attempt++) {
1130
1084
  try {
1131
- fs6.renameSync(candidate, file);
1085
+ fs4.renameSync(candidate, file);
1132
1086
  try {
1133
- fs6.unlinkSync(`${file}.reclaim`);
1087
+ fs4.unlinkSync(`${file}.reclaim`);
1134
1088
  } catch {
1135
1089
  }
1136
1090
  return () => {
1137
1091
  try {
1138
- fs6.unlinkSync(path6.join(file, ownerName));
1092
+ fs4.unlinkSync(path4.join(file, ownerName));
1139
1093
  } catch {
1140
1094
  }
1141
1095
  try {
1142
- fs6.rmdirSync(file);
1096
+ fs4.rmdirSync(file);
1143
1097
  } catch {
1144
1098
  }
1145
1099
  };
1146
1100
  } catch (error) {
1147
1101
  let stat;
1148
1102
  try {
1149
- stat = fs6.lstatSync(file);
1103
+ stat = fs4.lstatSync(file);
1150
1104
  } catch (cause) {
1151
1105
  if (cause.code === "ENOENT") continue;
1152
1106
  throw error;
@@ -1155,12 +1109,12 @@ function takeLock(file) {
1155
1109
  if (stat.isFile()) {
1156
1110
  let pid;
1157
1111
  try {
1158
- pid = JSON.parse(fs6.readFileSync(file, "utf8")).pid;
1112
+ pid = JSON.parse(fs4.readFileSync(file, "utf8")).pid;
1159
1113
  } catch {
1160
1114
  }
1161
1115
  if (typeof pid === "number" && Number.isInteger(pid) && pid > 0 && alive(pid)) return null;
1162
1116
  try {
1163
- fs6.unlinkSync(file);
1117
+ fs4.unlinkSync(file);
1164
1118
  } catch (cause) {
1165
1119
  if (!["ENOENT", "EISDIR", "EPERM"].includes(cause.code ?? "")) throw cause;
1166
1120
  }
@@ -1169,7 +1123,7 @@ function takeLock(file) {
1169
1123
  if (!stat.isDirectory()) return null;
1170
1124
  let names;
1171
1125
  try {
1172
- names = fs6.readdirSync(file);
1126
+ names = fs4.readdirSync(file);
1173
1127
  } catch (cause) {
1174
1128
  if (cause.code === "ENOENT") continue;
1175
1129
  throw cause;
@@ -1180,13 +1134,13 @@ function takeLock(file) {
1180
1134
  }
1181
1135
  for (const name of names) {
1182
1136
  try {
1183
- fs6.unlinkSync(path6.join(file, name));
1137
+ fs4.unlinkSync(path4.join(file, name));
1184
1138
  } catch (cause) {
1185
1139
  if (cause.code !== "ENOENT") throw cause;
1186
1140
  }
1187
1141
  }
1188
1142
  try {
1189
- fs6.rmdirSync(file);
1143
+ fs4.rmdirSync(file);
1190
1144
  } catch (cause) {
1191
1145
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(cause.code ?? "")) throw cause;
1192
1146
  }
@@ -1194,13 +1148,13 @@ function takeLock(file) {
1194
1148
  }
1195
1149
  return null;
1196
1150
  } finally {
1197
- fs6.rmSync(candidate, { recursive: true, force: true });
1151
+ fs4.rmSync(candidate, { recursive: true, force: true });
1198
1152
  }
1199
1153
  }
1200
1154
  function readLedger(file) {
1201
1155
  let value;
1202
1156
  try {
1203
- value = JSON.parse(fs6.readFileSync(file, "utf8"));
1157
+ value = JSON.parse(fs4.readFileSync(file, "utf8"));
1204
1158
  } catch (error) {
1205
1159
  if (error.code === "ENOENT") return { schema_version: 1, copies: {} };
1206
1160
  throw new Error("Managed Skill ledger is unreadable.");
@@ -1209,23 +1163,34 @@ function readLedger(file) {
1209
1163
  throw new Error("Managed Skill ledger has an unsupported format.");
1210
1164
  }
1211
1165
  for (const [filePath, copy] of Object.entries(value.copies)) {
1212
- if (!path6.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.");
1166
+ 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.");
1213
1167
  }
1214
1168
  return value;
1215
1169
  }
1216
1170
  function result(skill, target, reason) {
1217
- return { skill, agent: target.agent, path: path6.join(target.directory, skill), ...reason ? { reason } : {} };
1171
+ return { skill, agent: target.agent, path: path4.join(target.directory, skill), ...reason ? { reason } : {} };
1172
+ }
1173
+ function directInstallerLink(file, target, text) {
1174
+ if (typeof text !== "string") return false;
1175
+ let value = text;
1176
+ if (process.platform === "win32") {
1177
+ if (value.toUpperCase().startsWith("\\\\?\\UNC\\")) value = "\\\\" + value.slice(8);
1178
+ else if (value.startsWith("\\\\?\\") || value.startsWith("\\??\\")) value = value.slice(4);
1179
+ return [target, path4.relative(path4.dirname(file), target)].some((expected) => value.toLowerCase() === expected.toLowerCase());
1180
+ }
1181
+ return value === target || value === path4.relative(path4.dirname(file), target);
1218
1182
  }
1219
- function legacySkillLink(file, skill, sourceRoot, sourceHash, targets, ledger) {
1183
+ function legacySkillLink(file, skill, sourceRoot, sourceHash, targets, ledger, removing = false) {
1220
1184
  const canonical = targets.find((target2) => target2.agent === "universal");
1221
1185
  if (!canonical) return;
1222
- const target = path6.join(canonical.directory, skill);
1186
+ const target = path4.join(canonical.directory, skill);
1223
1187
  const managed = ledger.copies[target];
1224
- if (!managed || managed.skill !== skill || managed.agent !== canonical.agent || managed.hash !== sourceHash || skillPathProblem(canonical.directory, skill, sourceRoot)) return;
1188
+ if (!managed || managed.skill !== skill || managed.agent !== canonical.agent || !removing && managed.hash !== sourceHash || skillPathProblem(canonical.directory, skill, sourceRoot)) return;
1225
1189
  try {
1226
- if (!fs6.lstatSync(file).isSymbolicLink() || skillCopyHash(target) !== sourceHash) return;
1227
- const text = fs6.readlinkSync(file);
1228
- if (path6.resolve(path6.dirname(file), text) !== target || fs6.realpathSync(file) !== fs6.realpathSync(target)) return;
1190
+ if (!fs4.lstatSync(file).isSymbolicLink()) return;
1191
+ const text = fs4.readlinkSync(file);
1192
+ if (!directInstallerLink(file, target, text)) return;
1193
+ if (!removing && (skillCopyHash(target) !== sourceHash || fs4.realpathSync(file) !== fs4.realpathSync(target))) return;
1229
1194
  return { target, text };
1230
1195
  } catch {
1231
1196
  return;
@@ -1242,20 +1207,20 @@ function syncBusinessSkills(options) {
1242
1207
  managed_count: 0
1243
1208
  };
1244
1209
  const directory = options.stateDirectory ?? getConfigDir();
1245
- const contextFile = path6.join(directory, CONTEXT_FILE);
1210
+ const contextFile = path4.join(directory, CONTEXT_FILE);
1246
1211
  let unlock = null;
1247
1212
  try {
1248
1213
  if (options.isCurrentContext && !options.isCurrentContext()) {
1249
1214
  report.status = "stale";
1250
1215
  return report;
1251
1216
  }
1252
- fs6.mkdirSync(directory, { recursive: true, mode: 448 });
1217
+ fs4.mkdirSync(directory, { recursive: true, mode: 448 });
1253
1218
  const generation = options.generation ?? reserveBusinessSkillContext(options);
1254
1219
  if (!currentContext(options, contextFile, generation)) {
1255
1220
  report.status = "stale";
1256
1221
  return report;
1257
1222
  }
1258
- unlock = takeLock(path6.join(directory, LOCK_FILE));
1223
+ unlock = takeLock(path4.join(directory, LOCK_FILE));
1259
1224
  if (!unlock) {
1260
1225
  report.status = "busy";
1261
1226
  return report;
@@ -1264,26 +1229,114 @@ function syncBusinessSkills(options) {
1264
1229
  report.status = "stale";
1265
1230
  return report;
1266
1231
  }
1267
- const ledgerFile = path6.join(directory, LEDGER_FILE);
1232
+ const ledgerFile = path4.join(directory, LEDGER_FILE);
1268
1233
  const ledger = readLedger(ledgerFile);
1269
- const tool = options.tool ?? createPinnedSkillsTool({ env: options.env });
1270
- const targets = tool.targets();
1271
- const skills = readBundledSkills(options.skillsDirectory);
1272
1234
  const packageVersion = options.packageVersion ?? "unknown";
1235
+ const history = historicalCliSkills(options);
1236
+ const applied = {
1237
+ ...contextIdentity(options),
1238
+ package_version: packageVersion,
1239
+ businesses: normalizeBusinesses(options.businesses),
1240
+ source_root: fs4.realpathSync(options.skillsDirectory),
1241
+ policy_hash: POLICY_HASH,
1242
+ history_hash: history.hash
1243
+ };
1244
+ let select;
1245
+ if (options.mode !== "adopt") {
1246
+ const previous = ledger.last_applied;
1247
+ 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) {
1248
+ const previousStates = normalizeBusinesses(previous.businesses);
1249
+ const changed = new Set(OPTIONAL_BUSINESSES.filter((business) => previousStates[business] !== applied.businesses[business] && applied.businesses[business] !== void 0));
1250
+ if (!changed.size) {
1251
+ if (!currentContext(options, contextFile, generation)) {
1252
+ report.status = "stale";
1253
+ return report;
1254
+ }
1255
+ if (JSON.stringify(previous) !== JSON.stringify(applied)) {
1256
+ ledger.last_applied = applied;
1257
+ writeJson(ledgerFile, ledger);
1258
+ }
1259
+ report.managed_count = Object.keys(ledger.copies).length;
1260
+ report.status = "success";
1261
+ return report;
1262
+ }
1263
+ select = (name) => {
1264
+ const business = businessForSkill(name);
1265
+ return business !== void 0 && changed.has(business);
1266
+ };
1267
+ }
1268
+ if (ledger.last_applied) {
1269
+ delete ledger.last_applied;
1270
+ writeJson(ledgerFile, ledger);
1271
+ }
1272
+ }
1273
+ const bundled = readBundledSkills(options.skillsDirectory, select);
1274
+ const skills = new Set(bundled.map((skill) => skill.name));
1275
+ if (options.mode !== "adopt") {
1276
+ for (const name of [...history.names, ...Object.values(ledger.copies).map((copy) => copy.skill)]) {
1277
+ if (businessForSkill(name) && getSkillBusinessState(name, options.businesses) === false && (!select || select(name))) skills.add(name);
1278
+ }
1279
+ }
1280
+ const tool = options.tool ?? createPinnedSkillsTool({ env: options.env });
1281
+ const targets = [...tool.targets()].sort((a, b) => Number(b.agent === "universal") - Number(a.agent === "universal"));
1273
1282
  const operations = [];
1274
- for (const skill of skills) {
1275
- const source = path6.join(options.skillsDirectory, skill.name);
1276
- const sourceHash = skillCopyHash(source, true);
1277
- if (!sourceHash) throw new Error("Complete package Skill source is missing.");
1278
- const state = getSkillBusinessState(skill.name, options.businesses);
1283
+ for (const name of skills) {
1284
+ const state = getSkillBusinessState(name, options.businesses);
1279
1285
  if (options.mode !== "adopt" && state === void 0) continue;
1286
+ const source = path4.join(options.skillsDirectory, name);
1287
+ const sourceHash = bundled.some((skill) => skill.name === name) ? skillCopyHash(source, true) : null;
1288
+ if (!sourceHash && options.mode === "adopt") throw new Error("Complete package Skill source is missing.");
1280
1289
  for (const target of targets) {
1281
- const item = result(skill.name, target);
1282
- const pathProblem = skillPathProblem(target.directory, skill.name, options.skillsDirectory);
1290
+ const item = result(name, target);
1291
+ const pathProblem = skillPathProblem(target.directory, name, options.skillsDirectory);
1283
1292
  if (pathProblem) {
1284
1293
  report.skipped.push({ ...item, reason: pathProblem });
1285
1294
  continue;
1286
1295
  }
1296
+ const managed = ledger.copies[item.path];
1297
+ if (options.mode !== "adopt" && state === false) {
1298
+ let node;
1299
+ try {
1300
+ node = skillPathIdentity(item.path);
1301
+ } catch {
1302
+ report.skipped.push({ ...item, reason: "copy_unreadable_or_linked" });
1303
+ continue;
1304
+ }
1305
+ if (!node) {
1306
+ if (managed) delete ledger.copies[item.path];
1307
+ continue;
1308
+ }
1309
+ const legacyLink2 = node.type === "symlink" ? legacySkillLink(item.path, name, options.skillsDirectory, sourceHash ?? "", targets, ledger, true) : void 0;
1310
+ const canonical = targets.find((copy) => copy.agent === "universal");
1311
+ const historicalLink = node.type === "symlink" && canonical && directInstallerLink(item.path, path4.join(canonical.directory, name), node.link);
1312
+ const historicalCopy = history.names.has(name) && (target.agent === "universal" && node.type !== "symlink" || historicalLink);
1313
+ if (!managed && (legacyLink2 || historicalCopy)) {
1314
+ ledger.copies[item.path] = {
1315
+ skill: name,
1316
+ agent: target.agent,
1317
+ hash: sourceHash ?? "0".repeat(64),
1318
+ package_version: packageVersion
1319
+ };
1320
+ report.adopted.push(item);
1321
+ }
1322
+ const owned = ledger.copies[item.path];
1323
+ if (!owned || owned.skill !== name || owned.agent !== target.agent) {
1324
+ report.skipped.push({ ...item, reason: node.type === "symlink" ? "copy_unreadable_or_linked" : "copy_not_managed" });
1325
+ continue;
1326
+ }
1327
+ operations.push({
1328
+ action: "remove",
1329
+ skill: name,
1330
+ source,
1331
+ source_root: options.skillsDirectory,
1332
+ expected_hash: null,
1333
+ source_hash: sourceHash ?? "",
1334
+ target,
1335
+ expected_node: node,
1336
+ ...legacyLink2 ? { legacy_link: legacyLink2 } : {}
1337
+ });
1338
+ continue;
1339
+ }
1287
1340
  let actualHash;
1288
1341
  let legacyLink;
1289
1342
  try {
@@ -1291,7 +1344,7 @@ function syncBusinessSkills(options) {
1291
1344
  } catch {
1292
1345
  if (options.mode !== "adopt") legacyLink = legacySkillLink(
1293
1346
  item.path,
1294
- skill.name,
1347
+ name,
1295
1348
  options.skillsDirectory,
1296
1349
  sourceHash,
1297
1350
  targets,
@@ -1303,7 +1356,6 @@ function syncBusinessSkills(options) {
1303
1356
  }
1304
1357
  actualHash = sourceHash;
1305
1358
  }
1306
- const managed = ledger.copies[item.path];
1307
1359
  if (options.mode === "adopt") {
1308
1360
  if (actualHash === null) {
1309
1361
  if (managed) delete ledger.copies[item.path];
@@ -1313,27 +1365,23 @@ function syncBusinessSkills(options) {
1313
1365
  report.skipped.push({ ...item, reason: "copy_does_not_match_package" });
1314
1366
  continue;
1315
1367
  }
1316
- ledger.copies[item.path] = { skill: skill.name, agent: target.agent, hash: actualHash, package_version: packageVersion };
1368
+ ledger.copies[item.path] = { skill: name, agent: target.agent, hash: actualHash, package_version: packageVersion };
1317
1369
  report.adopted.push(item);
1318
1370
  continue;
1319
1371
  }
1320
- if (!legacyLink && actualHash !== null && (!managed || managed.skill !== skill.name || actualHash !== managed.hash)) {
1372
+ if (!legacyLink && actualHash !== null && (!managed || managed.skill !== name || actualHash !== managed.hash)) {
1321
1373
  report.skipped.push({ ...item, reason: managed ? "copy_modified" : "copy_not_managed" });
1322
1374
  continue;
1323
1375
  }
1324
- if (actualHash === null && state === false) {
1376
+ if (actualHash === sourceHash && !legacyLink) continue;
1377
+ if (actualHash === null && !target.installable) {
1325
1378
  if (managed) delete ledger.copies[item.path];
1326
1379
  continue;
1327
1380
  }
1328
- if (state === true && actualHash === sourceHash && !legacyLink) continue;
1329
- if (state === true && actualHash === null && !target.installable) {
1330
- if (managed) delete ledger.copies[item.path];
1331
- continue;
1332
- }
1333
- if (state === true && actualHash === null && !target.detected && !managed && !fs6.existsSync(target.directory)) continue;
1381
+ if (actualHash === null && !target.detected && !managed && !fs4.existsSync(target.directory)) continue;
1334
1382
  operations.push({
1335
- action: state ? "install" : "remove",
1336
- skill: skill.name,
1383
+ action: "install",
1384
+ skill: name,
1337
1385
  source,
1338
1386
  source_root: options.skillsDirectory,
1339
1387
  target,
@@ -1350,7 +1398,8 @@ function syncBusinessSkills(options) {
1350
1398
  if (options.mode === "adopt") {
1351
1399
  writeJson(ledgerFile, ledger);
1352
1400
  } else if (operations.length) {
1353
- operations.sort((a, b) => Number(Boolean(b.legacy_link)) - Number(Boolean(a.legacy_link)));
1401
+ operations.sort((a, b) => Number(Boolean(b.legacy_link || b.expected_node?.type === "symlink")) - Number(Boolean(a.legacy_link || a.expected_node?.type === "symlink")));
1402
+ writeJson(ledgerFile, ledger);
1354
1403
  const receipts = tool.apply(operations, { file: contextFile, generation, ledger_file: ledgerFile });
1355
1404
  if (receipts.length !== operations.length) throw new Error("Skills adapter returned incomplete receipts.");
1356
1405
  for (let index = 0; index < operations.length; index++) {
@@ -1361,7 +1410,7 @@ function syncBusinessSkills(options) {
1361
1410
  if (receipt.status === "skipped") report.skipped.push(item);
1362
1411
  else if (receipt.status !== "success") report.failed.push(item);
1363
1412
  else if (operation.action === "remove") {
1364
- if (skillCopyHash(item.path) !== null) {
1413
+ if (skillPathIdentity(item.path) !== null) {
1365
1414
  report.failed.push({ ...item, reason: "removal_not_verified" });
1366
1415
  continue;
1367
1416
  }
@@ -1381,6 +1430,10 @@ function syncBusinessSkills(options) {
1381
1430
  } else writeJson(ledgerFile, ledger);
1382
1431
  report.managed_count = Object.keys(ledger.copies).length;
1383
1432
  report.status = !currentContext(options, contextFile, generation) ? "stale" : report.skipped.length || report.failed.length ? "partial" : "success";
1433
+ if (options.mode !== "adopt" && report.status === "success") {
1434
+ ledger.last_applied = applied;
1435
+ writeJson(ledgerFile, ledger);
1436
+ }
1384
1437
  return report;
1385
1438
  } catch {
1386
1439
  report.status = report.installed.length || report.removed.length || report.adopted.length ? "partial" : "failed";
@@ -1390,6 +1443,162 @@ function syncBusinessSkills(options) {
1390
1443
  }
1391
1444
  }
1392
1445
 
1446
+ // src/core/business-skill-refresh.ts
1447
+ function beginBusinessSkillRefresh(host, token, enabled = true) {
1448
+ try {
1449
+ if (!enabled) return void 0;
1450
+ const normalized = normalizeUrl(host);
1451
+ const isCurrentContext = () => {
1452
+ try {
1453
+ return canManageGlobalSkills() && normalizeUrl(getActiveHost()) === normalized && peekCliToken(normalized) === token;
1454
+ } catch {
1455
+ return false;
1456
+ }
1457
+ };
1458
+ if (!isCurrentContext()) return void 0;
1459
+ const identity = { host: normalized, tokenFingerprint: crypto.createHash("sha256").update(token).digest("hex") };
1460
+ return { ...identity, generation: reserveBusinessSkillContext(identity), isCurrentContext };
1461
+ } catch {
1462
+ return void 0;
1463
+ }
1464
+ }
1465
+ function isBusinessSkillRefreshCurrent(refresh) {
1466
+ return !refresh || isBusinessSkillContextCurrent(refresh);
1467
+ }
1468
+ function syncRefreshedBusinessSkills(refresh, businesses) {
1469
+ if (!refresh || !isBusinessSkillRefreshCurrent(refresh)) return;
1470
+ const states = normalizeBusinesses(businesses);
1471
+ if (!Object.keys(states).length) return;
1472
+ try {
1473
+ const pkg = getLocalCliPackageInfo();
1474
+ const options = { ...refresh, skillsDirectory: path5.join(pkg.root, "skills"), businesses: states, packageVersion: pkg.version };
1475
+ if (!fs5.existsSync(path5.join(getConfigDir(), "business-skills.json"))) {
1476
+ const adoption = syncBusinessSkills({ ...options, mode: "adopt" });
1477
+ if (["failed", "busy", "stale"].includes(adoption.status)) {
1478
+ if (adoption.status !== "stale") process.stderr.write("[ae-cli] Skills could not be synchronized. Retry: ae-cli config refresh\n");
1479
+ return;
1480
+ }
1481
+ }
1482
+ const result2 = syncBusinessSkills({ ...options, onlyIfChanged: true });
1483
+ if (!["success", "stale"].includes(result2.status)) {
1484
+ process.stderr.write("[ae-cli] Some Skills could not be synchronized. Retry: ae-cli config refresh\n");
1485
+ }
1486
+ } catch {
1487
+ process.stderr.write("[ae-cli] Skills could not be synchronized. Retry: ae-cli config refresh\n");
1488
+ }
1489
+ }
1490
+
1491
+ // src/core/business-config.ts
1492
+ var BUSINESS_CONFIG_TTL_MS = 10 * 60 * 1e3;
1493
+ var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
1494
+ function cachePath() {
1495
+ return path6.join(getConfigDir(), "business-config.json");
1496
+ }
1497
+ function cacheKey(host, token) {
1498
+ return `${normalizeUrl(host)}#${crypto2.createHash("sha256").update(token).digest("hex")}`;
1499
+ }
1500
+ function readStore() {
1501
+ try {
1502
+ const value = JSON.parse(fs6.readFileSync(cachePath(), "utf8"));
1503
+ if (value?.entries && typeof value.entries === "object" && !Array.isArray(value.entries)) return value;
1504
+ } catch {
1505
+ }
1506
+ return { entries: {} };
1507
+ }
1508
+ function remember(host, token, entry) {
1509
+ const store = readStore();
1510
+ store.entries[cacheKey(host, token)] = entry;
1511
+ const target = cachePath();
1512
+ const temporary = `${target}.${process.pid}.${crypto2.randomBytes(6).toString("hex")}.tmp`;
1513
+ try {
1514
+ fs6.mkdirSync(path6.dirname(target), { recursive: true });
1515
+ fs6.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
1516
+ fs6.renameSync(temporary, target);
1517
+ fs6.chmodSync(target, 384);
1518
+ } catch {
1519
+ try {
1520
+ fs6.rmSync(temporary, { force: true });
1521
+ } catch {
1522
+ }
1523
+ }
1524
+ }
1525
+ function rememberBusinessConfig(host, token, businesses, now = Date.now()) {
1526
+ remember(host, token, { businesses: normalizeBusinesses(businesses), fetchedAt: now });
1527
+ }
1528
+ function peekBusinessConfig(host, token, now = Date.now()) {
1529
+ const entry = readStore().entries[cacheKey(host, token)];
1530
+ if (entry?.unavailableAt !== void 0 && now >= entry.unavailableAt && now - entry.unavailableAt < UNAVAILABLE_TTL_MS) return {};
1531
+ if (!entry || !Number.isFinite(entry.fetchedAt) || now < entry.fetchedAt || now - entry.fetchedAt >= BUSINESS_CONFIG_TTL_MS) return void 0;
1532
+ return normalizeBusinesses(entry.businesses);
1533
+ }
1534
+ function readBusinessConfig(host, token) {
1535
+ const entry = readStore().entries[cacheKey(host, token)];
1536
+ return entry && Number.isFinite(entry.fetchedAt) && entry.fetchedAt > 0 ? normalizeBusinesses(entry.businesses) : void 0;
1537
+ }
1538
+ function readCurrentBusinessConfig(hostOverride) {
1539
+ try {
1540
+ if (isSandboxExecutionContext()) return {};
1541
+ const host = hostOverride || getActiveHost();
1542
+ if (!host) return {};
1543
+ const token = peekCliToken(host);
1544
+ return token ? readBusinessConfig(host, token) ?? {} : {};
1545
+ } catch {
1546
+ return {};
1547
+ }
1548
+ }
1549
+ async function resolveBusinessConfig(host, token, fetchRemote, now = Date.now(), synchronizeSkills = true) {
1550
+ const cached = peekBusinessConfig(host, token, now);
1551
+ if (cached !== void 0) return cached;
1552
+ const refresh = beginBusinessSkillRefresh(host, token, synchronizeSkills);
1553
+ const config = await fetchRemote().catch(() => null);
1554
+ if (!isBusinessSkillRefreshCurrent(refresh)) return peekBusinessConfig(host, token) ?? {};
1555
+ if (!config) {
1556
+ const previous = readStore().entries[cacheKey(host, token)];
1557
+ remember(host, token, {
1558
+ businesses: normalizeBusinesses(previous?.businesses),
1559
+ fetchedAt: previous?.fetchedAt ?? 0,
1560
+ unavailableAt: now
1561
+ });
1562
+ return {};
1563
+ }
1564
+ const businesses = normalizeBusinesses(config.businesses);
1565
+ rememberBusinessConfig(host, token, businesses, now);
1566
+ syncRefreshedBusinessSkills(refresh, config.businesses);
1567
+ return businesses;
1568
+ }
1569
+ var BusinessDisabledError = class extends PermissionError {
1570
+ constructor(business) {
1571
+ super(
1572
+ `The '${business}' business is not enabled for the current environment.`,
1573
+ "BUSINESS_NOT_ENABLED",
1574
+ "Contact your administrator if this business should be enabled, then run: ae-cli config refresh"
1575
+ );
1576
+ this.business = business;
1577
+ this.name = "BusinessDisabledError";
1578
+ }
1579
+ business;
1580
+ };
1581
+ async function readBusinessConfigForExecution(hostOverride, synchronizeSkills = !hostOverride) {
1582
+ try {
1583
+ if (isSandboxExecutionContext()) return {};
1584
+ const host = hostOverride || getActiveHost();
1585
+ if (!host) return {};
1586
+ const token = peekCliToken(host);
1587
+ if (!token) return {};
1588
+ return await resolveBusinessConfig(host, token, async () => {
1589
+ const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-W4XC27RG.js");
1590
+ return fetchCliConfig2(host, token);
1591
+ }, Date.now(), synchronizeSkills);
1592
+ } catch {
1593
+ return {};
1594
+ }
1595
+ }
1596
+ async function assertBusinessEnabled(business, hostOverride, synchronizeSkills = !hostOverride) {
1597
+ if (business && (await readBusinessConfigForExecution(hostOverride, synchronizeSkills))[business] === false) {
1598
+ throw new BusinessDisabledError(business);
1599
+ }
1600
+ }
1601
+
1393
1602
  // src/core/installation.ts
1394
1603
  function distribution(packageName) {
1395
1604
  if (packageName === "@thinkingai/ae-cli") return { registry: "https://registry.npmjs.org", repository: "ThinkingAIAgenticEngine/ae-cli" };
@@ -1434,7 +1643,7 @@ function installPlan(packageName, version, root = "<npm-root>") {
1434
1643
  function currentSkillIdentity() {
1435
1644
  const host = getActiveHost();
1436
1645
  const token = host ? peekCliToken(host) : void 0;
1437
- return { host, tokenFingerprint: token ? crypto2.createHash("sha256").update(token).digest("hex") : "" };
1646
+ return { host, tokenFingerprint: token ? crypto3.createHash("sha256").update(token).digest("hex") : "" };
1438
1647
  }
1439
1648
  function skipGlobalSkillReason() {
1440
1649
  try {
@@ -1848,7 +2057,7 @@ function autoSyncDirection(current, expected) {
1848
2057
  }
1849
2058
 
1850
2059
  // src/core/feature-config.ts
1851
- import crypto3 from "crypto";
2060
+ import crypto4 from "crypto";
1852
2061
  import fs9 from "fs";
1853
2062
  import path9 from "path";
1854
2063
  var FEATURE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -1857,7 +2066,7 @@ function cachePath2() {
1857
2066
  return path9.join(getConfigDir(), "feature-config.json");
1858
2067
  }
1859
2068
  function cacheKey2(host, token) {
1860
- const fingerprint = crypto3.createHash("sha256").update(token).digest("hex");
2069
+ const fingerprint = crypto4.createHash("sha256").update(token).digest("hex");
1861
2070
  return `${normalizeUrl(host)}#${fingerprint}`;
1862
2071
  }
1863
2072
  function readStore2() {
@@ -1870,7 +2079,7 @@ function readStore2() {
1870
2079
  }
1871
2080
  function writeStore(store) {
1872
2081
  const target = cachePath2();
1873
- const temp = `${target}.${process.pid}.${crypto3.randomBytes(6).toString("hex")}.tmp`;
2082
+ const temp = `${target}.${process.pid}.${crypto4.randomBytes(6).toString("hex")}.tmp`;
1874
2083
  try {
1875
2084
  fs9.mkdirSync(path9.dirname(target), { recursive: true });
1876
2085
  fs9.writeFileSync(temp, JSON.stringify(store), { encoding: "utf8", mode: 384 });
@@ -1891,13 +2100,25 @@ function remember2(host, token, entry) {
1891
2100
  function rememberKbAutoDiscoveryFeature(host, token, enabled) {
1892
2101
  remember2(host, token, { enabled, available: true, fetchedAt: Date.now() });
1893
2102
  }
1894
- async function resolveKbAutoDiscoveryFeature(host, token, fetchRemote) {
2103
+ function peekKbAutoDiscoveryFeature(host, token) {
2104
+ const entry = readStore2().entries[cacheKey2(host, token)];
2105
+ const ttl = entry?.available ? FEATURE_TTL_MS : UNAVAILABLE_TTL_MS2;
2106
+ if (!entry || !entry.available || Date.now() < entry.fetchedAt || Date.now() - entry.fetchedAt >= ttl) {
2107
+ return void 0;
2108
+ }
2109
+ return entry.enabled;
2110
+ }
2111
+ async function resolveKbAutoDiscoveryFeature(host, token, fetchRemote, isCurrent = () => true) {
1895
2112
  const entry = readStore2().entries[cacheKey2(host, token)];
1896
2113
  const ttl = entry?.available ? FEATURE_TTL_MS : UNAVAILABLE_TTL_MS2;
1897
2114
  if (entry && Date.now() >= entry.fetchedAt && Date.now() - entry.fetchedAt < ttl) {
1898
2115
  return { enabled: entry.enabled, source: entry.available ? "cache" : "unavailable" };
1899
2116
  }
1900
2117
  const remote = await fetchRemote().catch(() => null);
2118
+ if (!isCurrent()) {
2119
+ const latest = peekKbAutoDiscoveryFeature(host, token);
2120
+ return latest === void 0 ? { enabled: false, source: "unavailable" } : { enabled: latest, source: "cache" };
2121
+ }
1901
2122
  if (!remote) {
1902
2123
  remember2(host, token, { enabled: false, available: false, fetchedAt: Date.now() });
1903
2124
  return { enabled: false, source: "unavailable" };
@@ -1989,7 +2210,7 @@ async function fetchCliConfig(host, cliToken) {
1989
2210
  const options = {
1990
2211
  dispatcher,
1991
2212
  signal: controller.signal,
1992
- headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
2213
+ headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {}, ...internalCallSourceHeaders() },
1993
2214
  ...externalCliTokenRequestOptions(url.toString())
1994
2215
  };
1995
2216
  resp = await fetch(url.toString(), options);
@@ -2069,7 +2290,7 @@ function setUpdateNotice(pkg, expected, cluster, verdict, state, stage, message)
2069
2290
  message: message ?? `Current ae-cli is ${pkg.version}; this host requires ${expected}. Run: ae-cli update`
2070
2291
  };
2071
2292
  }
2072
- async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
2293
+ async function refreshAndMaybeNotify(host, pkg, allowAutoSync, synchronizeSkills) {
2073
2294
  const token = peekCliToken(host);
2074
2295
  if (!token) return { status: "continue" };
2075
2296
  const store = readStore3();
@@ -2079,10 +2300,13 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
2079
2300
  let cluster = existing?.clusterVersion;
2080
2301
  let fetchedAt = existing?.lastFetchedAt;
2081
2302
  if (isCompatCacheStale(existing)) {
2303
+ const refresh = beginBusinessSkillRefresh(host, token, synchronizeSkills && allowAutoSync);
2082
2304
  const remote = await fetchCliConfig(host, token);
2305
+ if (!isBusinessSkillRefreshCurrent(refresh)) return { status: "continue" };
2083
2306
  if (remote) {
2084
2307
  rememberKbAutoDiscoveryFeature(host, token, remote.projectSemanticKbAutoDiscovery ?? false);
2085
2308
  rememberBusinessConfig(host, token, remote.businesses);
2309
+ syncRefreshedBusinessSkills(refresh, remote.businesses);
2086
2310
  }
2087
2311
  if (!remote?.aeCliVersion) {
2088
2312
  return { status: "continue" };
@@ -2127,7 +2351,7 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
2127
2351
  return false;
2128
2352
  }
2129
2353
  };
2130
- const context = isCurrentLocalIdentity() ? { host, tokenFingerprint: createHash2("sha256").update(token).digest("hex") } : void 0;
2354
+ const context = isCurrentLocalIdentity() ? { host, tokenFingerprint: createHash3("sha256").update(token).digest("hex") } : void 0;
2131
2355
  const generation = context ? reserveBusinessSkillContext(context) : void 0;
2132
2356
  const confirmed = await fetchCliConfig(host, token);
2133
2357
  if (context && generation && !isBusinessSkillContextCurrent({
@@ -2138,6 +2362,9 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
2138
2362
  if (confirmed) {
2139
2363
  rememberKbAutoDiscoveryFeature(host, token, confirmed.projectSemanticKbAutoDiscovery ?? false);
2140
2364
  rememberBusinessConfig(host, token, confirmed.businesses);
2365
+ if (context && generation && synchronizeSkills) {
2366
+ syncRefreshedBusinessSkills({ ...context, generation, isCurrentContext: isCurrentLocalIdentity }, confirmed.businesses);
2367
+ }
2141
2368
  }
2142
2369
  if (confirmed?.aeCliVersion) {
2143
2370
  expected = confirmed.aeCliVersion;
@@ -2237,7 +2464,7 @@ async function runHostCompatCheck(pkg, hostOverride, argv = process.argv) {
2237
2464
  const host = hostOverride || getActiveHost();
2238
2465
  if (!host) return { status: "continue" };
2239
2466
  try {
2240
- return await refreshAndMaybeNotify(host, pkg, !shouldSkipAutoSync(argv));
2467
+ return await refreshAndMaybeNotify(host, pkg, !shouldSkipAutoSync(argv), !hostOverride);
2241
2468
  } catch {
2242
2469
  return { status: "continue" };
2243
2470
  }
@@ -2249,18 +2476,20 @@ function notifyIfHostCompat(pkg, hostOverride) {
2249
2476
  export {
2250
2477
  exactVersion,
2251
2478
  installHost,
2252
- getLocalCliPackageInfo,
2253
2479
  businessForCommand,
2254
2480
  businessForCapability,
2255
2481
  canManageGlobalSkills,
2482
+ reserveBusinessSkillContext,
2483
+ isBusinessSkillContextCurrent,
2484
+ syncBusinessSkills,
2485
+ beginBusinessSkillRefresh,
2486
+ isBusinessSkillRefreshCurrent,
2487
+ syncRefreshedBusinessSkills,
2256
2488
  rememberBusinessConfig,
2257
2489
  readCurrentBusinessConfig,
2258
2490
  BusinessDisabledError,
2259
2491
  readBusinessConfigForExecution,
2260
2492
  assertBusinessEnabled,
2261
- reserveBusinessSkillContext,
2262
- isBusinessSkillContextCurrent,
2263
- syncBusinessSkills,
2264
2493
  newInstallationReport,
2265
2494
  failInstallation,
2266
2495
  recordVersionSyncResult,