ali-skills 0.0.21 → 0.0.22

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 (633) hide show
  1. package/node_modules/@ali/cli-skills/dist/cli.mjs +1214 -287
  2. package/node_modules/@ali/cli-skills/package.json +5 -2
  3. package/node_modules/@ali/o2-open-client/.editorconfig +11 -0
  4. package/node_modules/@ali/o2-open-client/README.md +80 -0
  5. package/node_modules/@ali/o2-open-client/abc.json +8 -0
  6. package/node_modules/@ali/o2-open-client/es/browser/ee.d.ts +23 -0
  7. package/node_modules/@ali/o2-open-client/es/browser/ee.js +82 -0
  8. package/node_modules/@ali/o2-open-client/es/browser/entry.d.ts +32 -0
  9. package/node_modules/@ali/o2-open-client/es/browser/entry.js +306 -0
  10. package/node_modules/@ali/o2-open-client/es/browser/escape.d.ts +12 -0
  11. package/node_modules/@ali/o2-open-client/es/browser/escape.js +178 -0
  12. package/node_modules/@ali/o2-open-client/es/browser/fetch.d.ts +1 -0
  13. package/node_modules/@ali/o2-open-client/es/browser/fetch.js +14 -0
  14. package/node_modules/@ali/o2-open-client/es/browser/index.d.ts +1 -0
  15. package/node_modules/@ali/o2-open-client/es/browser/index.js +1 -0
  16. package/node_modules/@ali/o2-open-client/es/common/constant.d.ts +42 -0
  17. package/node_modules/@ali/o2-open-client/es/common/constant.js +53 -0
  18. package/node_modules/@ali/o2-open-client/es/common/format.d.ts +14 -0
  19. package/node_modules/@ali/o2-open-client/es/common/format.js +43 -0
  20. package/node_modules/@ali/o2-open-client/es/common/service-meta.d.ts +33 -0
  21. package/node_modules/@ali/o2-open-client/es/common/service-meta.js +33 -0
  22. package/node_modules/@ali/o2-open-client/es/index.d.ts +1 -0
  23. package/node_modules/@ali/o2-open-client/es/index.js +8 -0
  24. package/node_modules/@ali/o2-open-client/es/node/config.d.ts +47 -0
  25. package/node_modules/@ali/o2-open-client/es/node/config.js +188 -0
  26. package/node_modules/@ali/o2-open-client/es/node/escape.d.ts +22 -0
  27. package/node_modules/@ali/o2-open-client/es/node/escape.js +131 -0
  28. package/node_modules/@ali/o2-open-client/es/node/help.d.ts +10 -0
  29. package/node_modules/@ali/o2-open-client/es/node/help.js +96 -0
  30. package/node_modules/@ali/o2-open-client/es/node/index.d.ts +48 -0
  31. package/node_modules/@ali/o2-open-client/es/node/index.js +247 -0
  32. package/node_modules/@ali/o2-open-client/es/node/token-handler.d.ts +1 -0
  33. package/node_modules/@ali/o2-open-client/es/node/token-handler.js +21 -0
  34. package/node_modules/@ali/o2-open-client/lib/browser/ee.d.ts +23 -0
  35. package/node_modules/@ali/o2-open-client/lib/browser/ee.js +86 -0
  36. package/node_modules/@ali/o2-open-client/lib/browser/entry.d.ts +32 -0
  37. package/node_modules/@ali/o2-open-client/lib/browser/entry.js +310 -0
  38. package/node_modules/@ali/o2-open-client/lib/browser/escape.d.ts +12 -0
  39. package/node_modules/@ali/o2-open-client/lib/browser/escape.js +185 -0
  40. package/node_modules/@ali/o2-open-client/lib/browser/fetch.d.ts +1 -0
  41. package/node_modules/@ali/o2-open-client/lib/browser/fetch.js +18 -0
  42. package/node_modules/@ali/o2-open-client/lib/common/constant.d.ts +42 -0
  43. package/node_modules/@ali/o2-open-client/lib/common/constant.js +56 -0
  44. package/node_modules/@ali/o2-open-client/lib/common/format.d.ts +14 -0
  45. package/node_modules/@ali/o2-open-client/lib/common/format.js +48 -0
  46. package/node_modules/@ali/o2-open-client/lib/common/service-meta.d.ts +33 -0
  47. package/node_modules/@ali/o2-open-client/lib/common/service-meta.js +36 -0
  48. package/node_modules/@ali/o2-open-client/lib/index.d.ts +1 -0
  49. package/node_modules/@ali/o2-open-client/lib/index.js +20 -0
  50. package/node_modules/@ali/o2-open-client/lib/node/config.d.ts +47 -0
  51. package/node_modules/@ali/o2-open-client/lib/node/config.js +192 -0
  52. package/node_modules/@ali/o2-open-client/lib/node/escape.d.ts +22 -0
  53. package/node_modules/@ali/o2-open-client/lib/node/escape.js +137 -0
  54. package/node_modules/@ali/o2-open-client/lib/node/help.d.ts +10 -0
  55. package/node_modules/@ali/o2-open-client/lib/node/help.js +100 -0
  56. package/node_modules/@ali/o2-open-client/lib/node/index.d.ts +48 -0
  57. package/node_modules/@ali/o2-open-client/lib/node/index.js +250 -0
  58. package/node_modules/@ali/o2-open-client/lib/node/token-handler.d.ts +1 -0
  59. package/node_modules/@ali/o2-open-client/lib/node/token-handler.js +25 -0
  60. package/node_modules/@ali/o2-open-client/package.json +46 -0
  61. package/node_modules/@ali/o2-open-client/playwright.config.ts +54 -0
  62. package/node_modules/@ali/o2-open-client/tsconfig.es.json +31 -0
  63. package/node_modules/@ali/o2-open-client/tsconfig.json +31 -0
  64. package/node_modules/@ali/o2-open-client/tsx2doc.config.js +5 -0
  65. package/node_modules/@ali/o2-open-client/typings/index.d.ts +36 -0
  66. package/node_modules/@types/node/LICENSE +21 -0
  67. package/node_modules/@types/node/README.md +15 -0
  68. package/node_modules/@types/node/assert/strict.d.ts +8 -0
  69. package/node_modules/@types/node/assert.d.ts +1062 -0
  70. package/node_modules/@types/node/async_hooks.d.ts +605 -0
  71. package/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  72. package/node_modules/@types/node/buffer.d.ts +1936 -0
  73. package/node_modules/@types/node/child_process.d.ts +1475 -0
  74. package/node_modules/@types/node/cluster.d.ts +577 -0
  75. package/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  76. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  77. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  78. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  79. package/node_modules/@types/node/console.d.ts +452 -0
  80. package/node_modules/@types/node/constants.d.ts +21 -0
  81. package/node_modules/@types/node/crypto.d.ts +4590 -0
  82. package/node_modules/@types/node/dgram.d.ts +597 -0
  83. package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  84. package/node_modules/@types/node/dns/promises.d.ts +479 -0
  85. package/node_modules/@types/node/dns.d.ts +871 -0
  86. package/node_modules/@types/node/domain.d.ts +170 -0
  87. package/node_modules/@types/node/events.d.ts +977 -0
  88. package/node_modules/@types/node/fs/promises.d.ts +1270 -0
  89. package/node_modules/@types/node/fs.d.ts +4375 -0
  90. package/node_modules/@types/node/globals.d.ts +172 -0
  91. package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  92. package/node_modules/@types/node/http.d.ts +2049 -0
  93. package/node_modules/@types/node/http2.d.ts +2631 -0
  94. package/node_modules/@types/node/https.d.ts +578 -0
  95. package/node_modules/@types/node/index.d.ts +93 -0
  96. package/node_modules/@types/node/inspector.generated.d.ts +3966 -0
  97. package/node_modules/@types/node/module.d.ts +539 -0
  98. package/node_modules/@types/node/net.d.ts +1031 -0
  99. package/node_modules/@types/node/os.d.ts +506 -0
  100. package/node_modules/@types/node/package.json +140 -0
  101. package/node_modules/@types/node/path.d.ts +200 -0
  102. package/node_modules/@types/node/perf_hooks.d.ts +961 -0
  103. package/node_modules/@types/node/process.d.ts +1961 -0
  104. package/node_modules/@types/node/punycode.d.ts +117 -0
  105. package/node_modules/@types/node/querystring.d.ts +152 -0
  106. package/node_modules/@types/node/readline/promises.d.ts +162 -0
  107. package/node_modules/@types/node/readline.d.ts +589 -0
  108. package/node_modules/@types/node/repl.d.ts +430 -0
  109. package/node_modules/@types/node/sea.d.ts +153 -0
  110. package/node_modules/@types/node/stream/consumers.d.ts +38 -0
  111. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  112. package/node_modules/@types/node/stream/web.d.ts +533 -0
  113. package/node_modules/@types/node/stream.d.ts +1698 -0
  114. package/node_modules/@types/node/string_decoder.d.ts +67 -0
  115. package/node_modules/@types/node/test.d.ts +1787 -0
  116. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  117. package/node_modules/@types/node/timers.d.ts +286 -0
  118. package/node_modules/@types/node/tls.d.ts +1259 -0
  119. package/node_modules/@types/node/trace_events.d.ts +197 -0
  120. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  121. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
  122. package/node_modules/@types/node/ts5.6/index.d.ts +93 -0
  123. package/node_modules/@types/node/tty.d.ts +208 -0
  124. package/node_modules/@types/node/url.d.ts +964 -0
  125. package/node_modules/@types/node/util.d.ts +2331 -0
  126. package/node_modules/@types/node/v8.d.ts +809 -0
  127. package/node_modules/@types/node/vm.d.ts +1001 -0
  128. package/node_modules/@types/node/wasi.d.ts +181 -0
  129. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  130. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  131. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  132. package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
  133. package/node_modules/@types/node/worker_threads.d.ts +715 -0
  134. package/node_modules/@types/node/zlib.d.ts +598 -0
  135. package/node_modules/ansi-styles/index.d.ts +345 -0
  136. package/node_modules/ansi-styles/index.js +163 -0
  137. package/node_modules/ansi-styles/license +9 -0
  138. package/node_modules/ansi-styles/package.json +56 -0
  139. package/node_modules/ansi-styles/readme.md +152 -0
  140. package/node_modules/await-event/LICENSE +22 -0
  141. package/node_modules/await-event/README.md +48 -0
  142. package/node_modules/await-event/index.js +13 -0
  143. package/node_modules/await-event/package.json +33 -0
  144. package/node_modules/await-first/LICENSE +21 -0
  145. package/node_modules/await-first/README.md +80 -0
  146. package/node_modules/await-first/lib/index.js +21 -0
  147. package/node_modules/await-first/package.json +49 -0
  148. package/node_modules/byte/LICENSE.txt +21 -0
  149. package/node_modules/byte/README.md +207 -0
  150. package/node_modules/byte/lib/byte.js +635 -0
  151. package/node_modules/byte/lib/number.js +82 -0
  152. package/node_modules/byte/package.json +61 -0
  153. package/node_modules/chalk/index.d.ts +415 -0
  154. package/node_modules/chalk/license +9 -0
  155. package/node_modules/chalk/package.json +68 -0
  156. package/node_modules/chalk/readme.md +341 -0
  157. package/node_modules/chalk/source/index.js +229 -0
  158. package/node_modules/chalk/source/templates.js +134 -0
  159. package/node_modules/chalk/source/util.js +39 -0
  160. package/node_modules/circular-json-for-egg/LICENSE.txt +19 -0
  161. package/node_modules/circular-json-for-egg/README.md +148 -0
  162. package/node_modules/circular-json-for-egg/build/circular-json.amd.js +2 -0
  163. package/node_modules/circular-json-for-egg/build/circular-json.js +2 -0
  164. package/node_modules/circular-json-for-egg/build/circular-json.max.amd.js +210 -0
  165. package/node_modules/circular-json-for-egg/build/circular-json.max.js +210 -0
  166. package/node_modules/circular-json-for-egg/build/circular-json.node.js +207 -0
  167. package/node_modules/circular-json-for-egg/package.json +42 -0
  168. package/node_modules/cluster-client/LICENSE +21 -0
  169. package/node_modules/cluster-client/README.md +319 -0
  170. package/node_modules/cluster-client/index.js +66 -0
  171. package/node_modules/cluster-client/lib/api_client.js +74 -0
  172. package/node_modules/cluster-client/lib/connection.js +180 -0
  173. package/node_modules/cluster-client/lib/const.js +5 -0
  174. package/node_modules/cluster-client/lib/default_logger.js +11 -0
  175. package/node_modules/cluster-client/lib/default_transcode.js +6 -0
  176. package/node_modules/cluster-client/lib/follower.js +331 -0
  177. package/node_modules/cluster-client/lib/index.js +213 -0
  178. package/node_modules/cluster-client/lib/leader.js +437 -0
  179. package/node_modules/cluster-client/lib/protocol/byte_buffer.js +8 -0
  180. package/node_modules/cluster-client/lib/protocol/packet.js +103 -0
  181. package/node_modules/cluster-client/lib/protocol/request.js +17 -0
  182. package/node_modules/cluster-client/lib/protocol/response.js +14 -0
  183. package/node_modules/cluster-client/lib/server.js +256 -0
  184. package/node_modules/cluster-client/lib/symbol.js +20 -0
  185. package/node_modules/cluster-client/lib/utils.js +103 -0
  186. package/node_modules/cluster-client/lib/wrapper/base.js +210 -0
  187. package/node_modules/cluster-client/lib/wrapper/cluster.js +57 -0
  188. package/node_modules/cluster-client/lib/wrapper/single.js +192 -0
  189. package/node_modules/cluster-client/package.json +60 -0
  190. package/node_modules/co/LICENSE +22 -0
  191. package/node_modules/co/Readme.md +212 -0
  192. package/node_modules/co/index.js +237 -0
  193. package/node_modules/co/package.json +34 -0
  194. package/node_modules/color-convert/LICENSE +21 -0
  195. package/node_modules/color-convert/README.md +68 -0
  196. package/node_modules/color-convert/conversions.js +839 -0
  197. package/node_modules/color-convert/index.js +81 -0
  198. package/node_modules/color-convert/package.json +48 -0
  199. package/node_modules/color-convert/route.js +97 -0
  200. package/node_modules/color-name/LICENSE +8 -0
  201. package/node_modules/color-name/README.md +11 -0
  202. package/node_modules/color-name/index.js +152 -0
  203. package/node_modules/color-name/package.json +28 -0
  204. package/node_modules/core-util-is/LICENSE +19 -0
  205. package/node_modules/core-util-is/README.md +3 -0
  206. package/node_modules/core-util-is/lib/util.js +107 -0
  207. package/node_modules/core-util-is/package.json +38 -0
  208. package/node_modules/debug/LICENSE +20 -0
  209. package/node_modules/debug/README.md +481 -0
  210. package/node_modules/debug/package.json +64 -0
  211. package/node_modules/debug/src/browser.js +272 -0
  212. package/node_modules/debug/src/common.js +292 -0
  213. package/node_modules/debug/src/index.js +10 -0
  214. package/node_modules/debug/src/node.js +263 -0
  215. package/node_modules/depd/History.md +103 -0
  216. package/node_modules/depd/LICENSE +22 -0
  217. package/node_modules/depd/Readme.md +280 -0
  218. package/node_modules/depd/index.js +538 -0
  219. package/node_modules/depd/lib/browser/index.js +77 -0
  220. package/node_modules/depd/package.json +45 -0
  221. package/node_modules/ee-first/LICENSE +22 -0
  222. package/node_modules/ee-first/README.md +80 -0
  223. package/node_modules/ee-first/index.js +95 -0
  224. package/node_modules/ee-first/package.json +29 -0
  225. package/node_modules/egg-errors/LICENSE +21 -0
  226. package/node_modules/egg-errors/README.md +259 -0
  227. package/node_modules/egg-errors/lib/base.d.ts +10 -0
  228. package/node_modules/egg-errors/lib/base.js +28 -0
  229. package/node_modules/egg-errors/lib/base_error.d.ts +6 -0
  230. package/node_modules/egg-errors/lib/base_error.js +13 -0
  231. package/node_modules/egg-errors/lib/base_exception.d.ts +6 -0
  232. package/node_modules/egg-errors/lib/base_exception.js +13 -0
  233. package/node_modules/egg-errors/lib/error.d.ts +6 -0
  234. package/node_modules/egg-errors/lib/error.js +13 -0
  235. package/node_modules/egg-errors/lib/error_options.d.ts +5 -0
  236. package/node_modules/egg-errors/lib/error_options.js +6 -0
  237. package/node_modules/egg-errors/lib/error_type.d.ts +6 -0
  238. package/node_modules/egg-errors/lib/error_type.js +10 -0
  239. package/node_modules/egg-errors/lib/exception.d.ts +6 -0
  240. package/node_modules/egg-errors/lib/exception.js +13 -0
  241. package/node_modules/egg-errors/lib/framework/formatter.d.ts +6 -0
  242. package/node_modules/egg-errors/lib/framework/formatter.js +29 -0
  243. package/node_modules/egg-errors/lib/framework/framework_base_error.d.ts +10 -0
  244. package/node_modules/egg-errors/lib/framework/framework_base_error.js +32 -0
  245. package/node_modules/egg-errors/lib/http/400.d.ts +5 -0
  246. package/node_modules/egg-errors/lib/http/400.js +13 -0
  247. package/node_modules/egg-errors/lib/http/401.d.ts +5 -0
  248. package/node_modules/egg-errors/lib/http/401.js +13 -0
  249. package/node_modules/egg-errors/lib/http/402.d.ts +5 -0
  250. package/node_modules/egg-errors/lib/http/402.js +13 -0
  251. package/node_modules/egg-errors/lib/http/403.d.ts +5 -0
  252. package/node_modules/egg-errors/lib/http/403.js +13 -0
  253. package/node_modules/egg-errors/lib/http/404.d.ts +5 -0
  254. package/node_modules/egg-errors/lib/http/404.js +13 -0
  255. package/node_modules/egg-errors/lib/http/405.d.ts +5 -0
  256. package/node_modules/egg-errors/lib/http/405.js +13 -0
  257. package/node_modules/egg-errors/lib/http/406.d.ts +5 -0
  258. package/node_modules/egg-errors/lib/http/406.js +13 -0
  259. package/node_modules/egg-errors/lib/http/407.d.ts +5 -0
  260. package/node_modules/egg-errors/lib/http/407.js +13 -0
  261. package/node_modules/egg-errors/lib/http/408.d.ts +5 -0
  262. package/node_modules/egg-errors/lib/http/408.js +13 -0
  263. package/node_modules/egg-errors/lib/http/409.d.ts +5 -0
  264. package/node_modules/egg-errors/lib/http/409.js +13 -0
  265. package/node_modules/egg-errors/lib/http/410.d.ts +5 -0
  266. package/node_modules/egg-errors/lib/http/410.js +13 -0
  267. package/node_modules/egg-errors/lib/http/411.d.ts +5 -0
  268. package/node_modules/egg-errors/lib/http/411.js +13 -0
  269. package/node_modules/egg-errors/lib/http/412.d.ts +5 -0
  270. package/node_modules/egg-errors/lib/http/412.js +13 -0
  271. package/node_modules/egg-errors/lib/http/413.d.ts +5 -0
  272. package/node_modules/egg-errors/lib/http/413.js +13 -0
  273. package/node_modules/egg-errors/lib/http/414.d.ts +5 -0
  274. package/node_modules/egg-errors/lib/http/414.js +13 -0
  275. package/node_modules/egg-errors/lib/http/415.d.ts +5 -0
  276. package/node_modules/egg-errors/lib/http/415.js +13 -0
  277. package/node_modules/egg-errors/lib/http/416.d.ts +5 -0
  278. package/node_modules/egg-errors/lib/http/416.js +13 -0
  279. package/node_modules/egg-errors/lib/http/417.d.ts +5 -0
  280. package/node_modules/egg-errors/lib/http/417.js +13 -0
  281. package/node_modules/egg-errors/lib/http/418.d.ts +5 -0
  282. package/node_modules/egg-errors/lib/http/418.js +13 -0
  283. package/node_modules/egg-errors/lib/http/421.d.ts +5 -0
  284. package/node_modules/egg-errors/lib/http/421.js +13 -0
  285. package/node_modules/egg-errors/lib/http/422.d.ts +5 -0
  286. package/node_modules/egg-errors/lib/http/422.js +13 -0
  287. package/node_modules/egg-errors/lib/http/423.d.ts +5 -0
  288. package/node_modules/egg-errors/lib/http/423.js +13 -0
  289. package/node_modules/egg-errors/lib/http/424.d.ts +5 -0
  290. package/node_modules/egg-errors/lib/http/424.js +13 -0
  291. package/node_modules/egg-errors/lib/http/425.d.ts +5 -0
  292. package/node_modules/egg-errors/lib/http/425.js +13 -0
  293. package/node_modules/egg-errors/lib/http/426.d.ts +5 -0
  294. package/node_modules/egg-errors/lib/http/426.js +13 -0
  295. package/node_modules/egg-errors/lib/http/428.d.ts +5 -0
  296. package/node_modules/egg-errors/lib/http/428.js +13 -0
  297. package/node_modules/egg-errors/lib/http/429.d.ts +5 -0
  298. package/node_modules/egg-errors/lib/http/429.js +13 -0
  299. package/node_modules/egg-errors/lib/http/431.d.ts +5 -0
  300. package/node_modules/egg-errors/lib/http/431.js +13 -0
  301. package/node_modules/egg-errors/lib/http/451.d.ts +5 -0
  302. package/node_modules/egg-errors/lib/http/451.js +13 -0
  303. package/node_modules/egg-errors/lib/http/500.d.ts +5 -0
  304. package/node_modules/egg-errors/lib/http/500.js +13 -0
  305. package/node_modules/egg-errors/lib/http/501.d.ts +5 -0
  306. package/node_modules/egg-errors/lib/http/501.js +13 -0
  307. package/node_modules/egg-errors/lib/http/502.d.ts +5 -0
  308. package/node_modules/egg-errors/lib/http/502.js +13 -0
  309. package/node_modules/egg-errors/lib/http/503.d.ts +5 -0
  310. package/node_modules/egg-errors/lib/http/503.js +13 -0
  311. package/node_modules/egg-errors/lib/http/504.d.ts +5 -0
  312. package/node_modules/egg-errors/lib/http/504.js +13 -0
  313. package/node_modules/egg-errors/lib/http/505.d.ts +5 -0
  314. package/node_modules/egg-errors/lib/http/505.js +13 -0
  315. package/node_modules/egg-errors/lib/http/506.d.ts +5 -0
  316. package/node_modules/egg-errors/lib/http/506.js +13 -0
  317. package/node_modules/egg-errors/lib/http/507.d.ts +5 -0
  318. package/node_modules/egg-errors/lib/http/507.js +13 -0
  319. package/node_modules/egg-errors/lib/http/508.d.ts +5 -0
  320. package/node_modules/egg-errors/lib/http/508.js +13 -0
  321. package/node_modules/egg-errors/lib/http/509.d.ts +5 -0
  322. package/node_modules/egg-errors/lib/http/509.js +13 -0
  323. package/node_modules/egg-errors/lib/http/510.d.ts +5 -0
  324. package/node_modules/egg-errors/lib/http/510.js +13 -0
  325. package/node_modules/egg-errors/lib/http/511.d.ts +5 -0
  326. package/node_modules/egg-errors/lib/http/511.js +13 -0
  327. package/node_modules/egg-errors/lib/http/http_error.d.ts +10 -0
  328. package/node_modules/egg-errors/lib/http/http_error.js +13 -0
  329. package/node_modules/egg-errors/lib/http/http_error_options.d.ts +6 -0
  330. package/node_modules/egg-errors/lib/http/http_error_options.js +7 -0
  331. package/node_modules/egg-errors/lib/http/http_header.d.ts +3 -0
  332. package/node_modules/egg-errors/lib/http/http_header.js +3 -0
  333. package/node_modules/egg-errors/lib/index.d.ts +50 -0
  334. package/node_modules/egg-errors/lib/index.js +149 -0
  335. package/node_modules/egg-errors/package.json +49 -0
  336. package/node_modules/egg-logger/LICENSE +21 -0
  337. package/node_modules/egg-logger/README.md +128 -0
  338. package/node_modules/egg-logger/README.zh-CN.md +125 -0
  339. package/node_modules/egg-logger/index.d.ts +233 -0
  340. package/node_modules/egg-logger/index.js +18 -0
  341. package/node_modules/egg-logger/lib/egg/console_logger.js +36 -0
  342. package/node_modules/egg-logger/lib/egg/context_logger.js +43 -0
  343. package/node_modules/egg-logger/lib/egg/custom_logger.js +10 -0
  344. package/node_modules/egg-logger/lib/egg/error_logger.js +31 -0
  345. package/node_modules/egg-logger/lib/egg/logger.js +128 -0
  346. package/node_modules/egg-logger/lib/egg/loggers.js +163 -0
  347. package/node_modules/egg-logger/lib/level.js +34 -0
  348. package/node_modules/egg-logger/lib/logger.js +170 -0
  349. package/node_modules/egg-logger/lib/transports/console.js +52 -0
  350. package/node_modules/egg-logger/lib/transports/file.js +134 -0
  351. package/node_modules/egg-logger/lib/transports/file_buffer.js +113 -0
  352. package/node_modules/egg-logger/lib/transports/transport.js +129 -0
  353. package/node_modules/egg-logger/lib/utils.js +296 -0
  354. package/node_modules/egg-logger/package.json +54 -0
  355. package/node_modules/escape-html/LICENSE +24 -0
  356. package/node_modules/escape-html/Readme.md +43 -0
  357. package/node_modules/escape-html/index.js +78 -0
  358. package/node_modules/escape-html/package.json +24 -0
  359. package/node_modules/extend-shallow/LICENSE +21 -0
  360. package/node_modules/extend-shallow/README.md +61 -0
  361. package/node_modules/extend-shallow/index.js +33 -0
  362. package/node_modules/extend-shallow/package.json +56 -0
  363. package/node_modules/has-flag/index.d.ts +39 -0
  364. package/node_modules/has-flag/index.js +8 -0
  365. package/node_modules/has-flag/license +9 -0
  366. package/node_modules/has-flag/package.json +46 -0
  367. package/node_modules/has-flag/readme.md +89 -0
  368. package/node_modules/heartbeats/.eslintrc +151 -0
  369. package/node_modules/heartbeats/.npmignore +28 -0
  370. package/node_modules/heartbeats/.travis.yml +10 -0
  371. package/node_modules/heartbeats/LICENSE +21 -0
  372. package/node_modules/heartbeats/README.md +323 -0
  373. package/node_modules/heartbeats/lib/beatevent.js +35 -0
  374. package/node_modules/heartbeats/lib/heart.js +178 -0
  375. package/node_modules/heartbeats/lib/pulse.js +39 -0
  376. package/node_modules/heartbeats/main.js +34 -0
  377. package/node_modules/heartbeats/package.json +39 -0
  378. package/node_modules/heartbeats/test/benchmark.js +138 -0
  379. package/node_modules/heartbeats/test/spawn.js +16 -0
  380. package/node_modules/heartbeats/test/test.js +158 -0
  381. package/node_modules/httpx/README.md +96 -0
  382. package/node_modules/httpx/lib/index.d.ts +31 -0
  383. package/node_modules/httpx/lib/index.js +396 -0
  384. package/node_modules/httpx/package.json +36 -0
  385. package/node_modules/iconv-lite/.github/dependabot.yml +11 -0
  386. package/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
  387. package/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
  388. package/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
  389. package/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
  390. package/node_modules/iconv-lite/.idea/modules.xml +8 -0
  391. package/node_modules/iconv-lite/.idea/vcs.xml +6 -0
  392. package/node_modules/iconv-lite/Changelog.md +212 -0
  393. package/node_modules/iconv-lite/LICENSE +21 -0
  394. package/node_modules/iconv-lite/README.md +130 -0
  395. package/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
  396. package/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
  397. package/node_modules/iconv-lite/encodings/index.js +23 -0
  398. package/node_modules/iconv-lite/encodings/internal.js +198 -0
  399. package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  400. package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  401. package/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
  402. package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  403. package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  404. package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  405. package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  406. package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  407. package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  408. package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  409. package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  410. package/node_modules/iconv-lite/encodings/utf16.js +197 -0
  411. package/node_modules/iconv-lite/encodings/utf32.js +319 -0
  412. package/node_modules/iconv-lite/encodings/utf7.js +290 -0
  413. package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  414. package/node_modules/iconv-lite/lib/index.d.ts +41 -0
  415. package/node_modules/iconv-lite/lib/index.js +180 -0
  416. package/node_modules/iconv-lite/lib/streams.js +109 -0
  417. package/node_modules/iconv-lite/package.json +44 -0
  418. package/node_modules/ip/README.md +90 -0
  419. package/node_modules/ip/lib/ip.js +496 -0
  420. package/node_modules/ip/package.json +25 -0
  421. package/node_modules/is-class-hotfix/.editorconfig +23 -0
  422. package/node_modules/is-class-hotfix/.gitattributes +2 -0
  423. package/node_modules/is-class-hotfix/CHANGELOG.md +7 -0
  424. package/node_modules/is-class-hotfix/LICENSE.md +21 -0
  425. package/node_modules/is-class-hotfix/README.md +35 -0
  426. package/node_modules/is-class-hotfix/bower.json +24 -0
  427. package/node_modules/is-class-hotfix/is-class.js +28 -0
  428. package/node_modules/is-class-hotfix/package.json +31 -0
  429. package/node_modules/is-class-hotfix/test/babel-class.js +27 -0
  430. package/node_modules/is-class-hotfix/test/is-class.js +31 -0
  431. package/node_modules/is-extendable/LICENSE +21 -0
  432. package/node_modules/is-extendable/README.md +72 -0
  433. package/node_modules/is-extendable/index.js +13 -0
  434. package/node_modules/is-extendable/package.json +51 -0
  435. package/node_modules/is-type-of/LICENSE +21 -0
  436. package/node_modules/is-type-of/README.md +105 -0
  437. package/node_modules/is-type-of/index.d.ts +65 -0
  438. package/node_modules/is-type-of/index.js +125 -0
  439. package/node_modules/is-type-of/package.json +45 -0
  440. package/node_modules/isstream/.jshintrc +59 -0
  441. package/node_modules/isstream/.npmignore +1 -0
  442. package/node_modules/isstream/.travis.yml +12 -0
  443. package/node_modules/isstream/LICENSE.md +11 -0
  444. package/node_modules/isstream/README.md +66 -0
  445. package/node_modules/isstream/isstream.js +27 -0
  446. package/node_modules/isstream/package.json +33 -0
  447. package/node_modules/isstream/test.js +168 -0
  448. package/node_modules/json-stringify-safe/.npmignore +1 -0
  449. package/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
  450. package/node_modules/json-stringify-safe/LICENSE +15 -0
  451. package/node_modules/json-stringify-safe/Makefile +35 -0
  452. package/node_modules/json-stringify-safe/README.md +52 -0
  453. package/node_modules/json-stringify-safe/package.json +31 -0
  454. package/node_modules/json-stringify-safe/stringify.js +27 -0
  455. package/node_modules/json-stringify-safe/test/mocha.opts +2 -0
  456. package/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
  457. package/node_modules/kitx/LICENSE +21 -0
  458. package/node_modules/kitx/README.md +35 -0
  459. package/node_modules/kitx/lib/index.d.ts +45 -0
  460. package/node_modules/kitx/lib/index.js +289 -0
  461. package/node_modules/kitx/package.json +41 -0
  462. package/node_modules/long/LICENSE +202 -0
  463. package/node_modules/long/README.md +246 -0
  464. package/node_modules/long/dist/long.js +2 -0
  465. package/node_modules/long/dist/long.js.map +1 -0
  466. package/node_modules/long/index.js +1 -0
  467. package/node_modules/long/package.json +34 -0
  468. package/node_modules/long/src/long.js +1323 -0
  469. package/node_modules/ms/index.js +162 -0
  470. package/node_modules/ms/license.md +21 -0
  471. package/node_modules/ms/package.json +38 -0
  472. package/node_modules/ms/readme.md +59 -0
  473. package/node_modules/p-timeout/index.d.ts +113 -0
  474. package/node_modules/p-timeout/index.js +71 -0
  475. package/node_modules/p-timeout/license +9 -0
  476. package/node_modules/p-timeout/package.json +44 -0
  477. package/node_modules/p-timeout/readme.md +117 -0
  478. package/node_modules/safer-buffer/LICENSE +21 -0
  479. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  480. package/node_modules/safer-buffer/Readme.md +156 -0
  481. package/node_modules/safer-buffer/dangerous.js +58 -0
  482. package/node_modules/safer-buffer/package.json +34 -0
  483. package/node_modules/safer-buffer/safer.js +77 -0
  484. package/node_modules/safer-buffer/tests.js +406 -0
  485. package/node_modules/sdk-base/LICENSE +21 -0
  486. package/node_modules/sdk-base/README.md +165 -0
  487. package/node_modules/sdk-base/index.d.ts +29 -0
  488. package/node_modules/sdk-base/index.js +251 -0
  489. package/node_modules/sdk-base/package.json +54 -0
  490. package/node_modules/serialize-json/LICENSE +21 -0
  491. package/node_modules/serialize-json/README.md +74 -0
  492. package/node_modules/serialize-json/lib/decoder.js +190 -0
  493. package/node_modules/serialize-json/lib/encoder.js +200 -0
  494. package/node_modules/serialize-json/lib/index.js +15 -0
  495. package/node_modules/serialize-json/package.json +53 -0
  496. package/node_modules/supports-color/browser.js +5 -0
  497. package/node_modules/supports-color/index.js +135 -0
  498. package/node_modules/supports-color/license +9 -0
  499. package/node_modules/supports-color/package.json +53 -0
  500. package/node_modules/supports-color/readme.md +76 -0
  501. package/node_modules/tcp-base/LICENSE +21 -0
  502. package/node_modules/tcp-base/README.md +134 -0
  503. package/node_modules/tcp-base/lib/base.js +456 -0
  504. package/node_modules/tcp-base/package.json +44 -0
  505. package/node_modules/undici-types/LICENSE +21 -0
  506. package/node_modules/undici-types/README.md +6 -0
  507. package/node_modules/undici-types/agent.d.ts +31 -0
  508. package/node_modules/undici-types/api.d.ts +43 -0
  509. package/node_modules/undici-types/balanced-pool.d.ts +29 -0
  510. package/node_modules/undici-types/cache.d.ts +36 -0
  511. package/node_modules/undici-types/client.d.ts +108 -0
  512. package/node_modules/undici-types/connector.d.ts +34 -0
  513. package/node_modules/undici-types/content-type.d.ts +21 -0
  514. package/node_modules/undici-types/cookies.d.ts +28 -0
  515. package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  516. package/node_modules/undici-types/dispatcher.d.ts +256 -0
  517. package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  518. package/node_modules/undici-types/errors.d.ts +149 -0
  519. package/node_modules/undici-types/eventsource.d.ts +61 -0
  520. package/node_modules/undici-types/fetch.d.ts +209 -0
  521. package/node_modules/undici-types/file.d.ts +39 -0
  522. package/node_modules/undici-types/filereader.d.ts +54 -0
  523. package/node_modules/undici-types/formdata.d.ts +108 -0
  524. package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  525. package/node_modules/undici-types/global-origin.d.ts +7 -0
  526. package/node_modules/undici-types/handlers.d.ts +15 -0
  527. package/node_modules/undici-types/header.d.ts +4 -0
  528. package/node_modules/undici-types/index.d.ts +71 -0
  529. package/node_modules/undici-types/interceptors.d.ts +17 -0
  530. package/node_modules/undici-types/mock-agent.d.ts +50 -0
  531. package/node_modules/undici-types/mock-client.d.ts +25 -0
  532. package/node_modules/undici-types/mock-errors.d.ts +12 -0
  533. package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  534. package/node_modules/undici-types/mock-pool.d.ts +25 -0
  535. package/node_modules/undici-types/package.json +55 -0
  536. package/node_modules/undici-types/patch.d.ts +33 -0
  537. package/node_modules/undici-types/pool-stats.d.ts +19 -0
  538. package/node_modules/undici-types/pool.d.ts +39 -0
  539. package/node_modules/undici-types/proxy-agent.d.ts +28 -0
  540. package/node_modules/undici-types/readable.d.ts +65 -0
  541. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  542. package/node_modules/undici-types/retry-handler.d.ts +116 -0
  543. package/node_modules/undici-types/util.d.ts +18 -0
  544. package/node_modules/undici-types/webidl.d.ts +228 -0
  545. package/node_modules/undici-types/websocket.d.ts +150 -0
  546. package/node_modules/unescape/LICENSE +21 -0
  547. package/node_modules/unescape/README.md +134 -0
  548. package/node_modules/unescape/index.js +103 -0
  549. package/node_modules/unescape/package.json +67 -0
  550. package/node_modules/utility/LICENSE.txt +21 -0
  551. package/node_modules/utility/README.md +370 -0
  552. package/node_modules/utility/dist/commonjs/array.d.ts +11 -0
  553. package/node_modules/utility/dist/commonjs/array.js +46 -0
  554. package/node_modules/utility/dist/commonjs/crypto.d.ts +86 -0
  555. package/node_modules/utility/dist/commonjs/crypto.js +159 -0
  556. package/node_modules/utility/dist/commonjs/date.d.ts +63 -0
  557. package/node_modules/utility/dist/commonjs/date.js +219 -0
  558. package/node_modules/utility/dist/commonjs/fs.d.ts +6 -0
  559. package/node_modules/utility/dist/commonjs/fs.js +20 -0
  560. package/node_modules/utility/dist/commonjs/function.d.ts +12 -0
  561. package/node_modules/utility/dist/commonjs/function.js +35 -0
  562. package/node_modules/utility/dist/commonjs/index.d.ts +12 -0
  563. package/node_modules/utility/dist/commonjs/index.js +29 -0
  564. package/node_modules/utility/dist/commonjs/json.d.ts +14 -0
  565. package/node_modules/utility/dist/commonjs/json.js +41 -0
  566. package/node_modules/utility/dist/commonjs/number.d.ts +24 -0
  567. package/node_modules/utility/dist/commonjs/number.js +66 -0
  568. package/node_modules/utility/dist/commonjs/object.d.ts +20 -0
  569. package/node_modules/utility/dist/commonjs/object.js +73 -0
  570. package/node_modules/utility/dist/commonjs/optimize.d.ts +21 -0
  571. package/node_modules/utility/dist/commonjs/optimize.js +60 -0
  572. package/node_modules/utility/dist/commonjs/package.json +3 -0
  573. package/node_modules/utility/dist/commonjs/string.d.ts +29 -0
  574. package/node_modules/utility/dist/commonjs/string.js +126 -0
  575. package/node_modules/utility/dist/commonjs/timeout.d.ts +6 -0
  576. package/node_modules/utility/dist/commonjs/timeout.js +34 -0
  577. package/node_modules/utility/dist/commonjs/web.d.ts +29 -0
  578. package/node_modules/utility/dist/commonjs/web.js +61 -0
  579. package/node_modules/utility/dist/esm/array.d.ts +11 -0
  580. package/node_modules/utility/dist/esm/array.js +42 -0
  581. package/node_modules/utility/dist/esm/crypto.d.ts +86 -0
  582. package/node_modules/utility/dist/esm/crypto.js +146 -0
  583. package/node_modules/utility/dist/esm/date.d.ts +63 -0
  584. package/node_modules/utility/dist/esm/date.js +204 -0
  585. package/node_modules/utility/dist/esm/fs.d.ts +6 -0
  586. package/node_modules/utility/dist/esm/fs.js +17 -0
  587. package/node_modules/utility/dist/esm/function.d.ts +12 -0
  588. package/node_modules/utility/dist/esm/function.js +28 -0
  589. package/node_modules/utility/dist/esm/index.d.ts +12 -0
  590. package/node_modules/utility/dist/esm/index.js +13 -0
  591. package/node_modules/utility/dist/esm/json.d.ts +14 -0
  592. package/node_modules/utility/dist/esm/json.js +34 -0
  593. package/node_modules/utility/dist/esm/number.d.ts +24 -0
  594. package/node_modules/utility/dist/esm/number.js +60 -0
  595. package/node_modules/utility/dist/esm/object.d.ts +20 -0
  596. package/node_modules/utility/dist/esm/object.js +67 -0
  597. package/node_modules/utility/dist/esm/optimize.d.ts +21 -0
  598. package/node_modules/utility/dist/esm/optimize.js +54 -0
  599. package/node_modules/utility/dist/esm/package.json +3 -0
  600. package/node_modules/utility/dist/esm/string.d.ts +29 -0
  601. package/node_modules/utility/dist/esm/string.js +118 -0
  602. package/node_modules/utility/dist/esm/timeout.d.ts +6 -0
  603. package/node_modules/utility/dist/esm/timeout.js +28 -0
  604. package/node_modules/utility/dist/esm/web.d.ts +29 -0
  605. package/node_modules/utility/dist/esm/web.js +52 -0
  606. package/node_modules/utility/dist/package.json +4 -0
  607. package/node_modules/utility/package.json +85 -0
  608. package/node_modules/utility/src/array.ts +44 -0
  609. package/node_modules/utility/src/crypto.ts +160 -0
  610. package/node_modules/utility/src/date.ts +232 -0
  611. package/node_modules/utility/src/fs.ts +17 -0
  612. package/node_modules/utility/src/function.ts +30 -0
  613. package/node_modules/utility/src/index.ts +12 -0
  614. package/node_modules/utility/src/json.ts +48 -0
  615. package/node_modules/utility/src/number.ts +63 -0
  616. package/node_modules/utility/src/object.ts +72 -0
  617. package/node_modules/utility/src/optimize.ts +62 -0
  618. package/node_modules/utility/src/string.ts +132 -0
  619. package/node_modules/utility/src/timeout.ts +37 -0
  620. package/node_modules/utility/src/web.ts +53 -0
  621. package/node_modules/ylru/LICENSE +25 -0
  622. package/node_modules/ylru/README.md +120 -0
  623. package/node_modules/ylru/dist/commonjs/index.d.ts +21 -0
  624. package/node_modules/ylru/dist/commonjs/index.js +112 -0
  625. package/node_modules/ylru/dist/commonjs/package.json +3 -0
  626. package/node_modules/ylru/dist/esm/index.d.ts +21 -0
  627. package/node_modules/ylru/dist/esm/index.js +108 -0
  628. package/node_modules/ylru/dist/esm/package.json +3 -0
  629. package/node_modules/ylru/package.json +71 -0
  630. package/node_modules/ylru/src/index.ts +124 -0
  631. package/package.json +2 -2
  632. package/node_modules/@ali/cli-skills/dist/_chunks/libs/abort-controller.mjs +0 -424
  633. package/node_modules/@ali/cli-skills/dist/_chunks/libs/archiver.mjs +0 -19586
@@ -10,9 +10,9 @@ import "./_chunks/libs/extend-shallow.mjs";
10
10
  import "./_chunks/libs/esprima.mjs";
11
11
  import { t as xdgConfig } from "./_chunks/libs/xdg-basedir.mjs";
12
12
  import { execSync, spawn } from "child_process";
13
- import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
13
+ import { createWriteStream, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
14
14
  import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "path";
15
- import { homedir, platform, tmpdir } from "os";
15
+ import { homedir, platform as platform$1, tmpdir } from "os";
16
16
  import { createHash } from "crypto";
17
17
  import { URL as URL$1, fileURLToPath } from "url";
18
18
  import * as readline from "readline";
@@ -552,12 +552,12 @@ async function getSkillLastCommitAuthor(projectId, filePath, token) {
552
552
  const ENV_URLS = {
553
553
  local: "http://localhost:3000/api/skills",
554
554
  daily: "https://next-ai-base.fn.taobao.net/api/skills",
555
- pre: "https://next-ai-base.pre-fn.alibaba-inc.com/api/skills",
556
- prod: "https://next-ai-base.fn.alibaba-inc.com/api/skills"
555
+ pre: "https://pre-ali-skills.alibaba-inc.com/api/skills",
556
+ prod: "https://ali-skills.alibaba-inc.com/api/skills"
557
557
  };
558
558
  function resolveSkillsApiBaseUrl() {
559
559
  const env = process.env.SKILLS_API_URL?.trim();
560
- if (!env) return ENV_URLS.pre;
560
+ if (!env) return ENV_URLS.prod;
561
561
  if (env in ENV_URLS) return ENV_URLS[env];
562
562
  return env.replace(/\/+$/, "");
563
563
  }
@@ -1383,7 +1383,7 @@ async function createSymlink(target, linkPath) {
1383
1383
  }
1384
1384
  const linkDir = dirname(linkPath);
1385
1385
  await mkdir(linkDir, { recursive: true });
1386
- await symlink(relative(await resolveParentSymlinks(linkDir), target), linkPath, platform() === "win32" ? "junction" : void 0);
1386
+ await symlink(relative(await resolveParentSymlinks(linkDir), target), linkPath, platform$1() === "win32" ? "junction" : void 0);
1387
1387
  return true;
1388
1388
  } catch {
1389
1389
  return false;
@@ -2205,7 +2205,7 @@ function logSkillParseFailures(failures) {
2205
2205
  if (f.hint) M.message(import_picocolors.default.yellow(` 提示: ${f.hint}`));
2206
2206
  }
2207
2207
  }
2208
- var version$1 = "2.0.21";
2208
+ var version$1 = "2.0.22";
2209
2209
  const isCancelled$1 = (value) => typeof value === "symbol";
2210
2210
  function redactSensitiveText(text) {
2211
2211
  return text.replace(/(https?:\/\/)([^/\s:@]+)(?::([^@/\s]*))?@/gi, "$1").replace(/([?&](?:private_token|access_token|token|api_key|access_key|secret|password)=)[^&\s]+/gi, "$1***");
@@ -3393,8 +3393,7 @@ const DIM$5 = "\x1B[38;5;102m";
3393
3393
  const TEXT$4 = "\x1B[38;5;145m";
3394
3394
  const CYAN$1 = "\x1B[36m";
3395
3395
  const YELLOW$5 = "\x1B[33m";
3396
- const SKILLS_API_URL = process.env.SKILLS_API_URL;
3397
- const SEARCH_ENDPOINT = SKILLS_API_URL ? `${SKILLS_API_URL.replace(/\/+$/, "")}/search` : "https://next-ai-base.pre-fn.alibaba-inc.com/api/skills/search";
3396
+ const SEARCH_ENDPOINT = `${SKILLS_API_BASE_URL}/search`;
3398
3397
  function formatInstalls(count) {
3399
3398
  if (!count || count <= 0) return "";
3400
3399
  if (count >= 1e6) return `${(count / 1e6).toFixed(1).replace(/\.0$/, "")}M installs`;
@@ -4297,7 +4296,7 @@ function detectRepoInfo() {
4297
4296
  }
4298
4297
  }
4299
4298
  async function zipSkillDirectory(skillPath, outputPath) {
4300
- const archive = (await import("./_chunks/libs/archiver.mjs").then((n) => /* @__PURE__ */ __toESM(n.t(), 1))).default("zip", { zlib: { level: 9 } });
4299
+ const archive = (await import("archiver")).default("zip", { zlib: { level: 9 } });
4301
4300
  const output = createWriteStream(outputPath);
4302
4301
  return new Promise((resolve, reject) => {
4303
4302
  output.on("close", resolve);
@@ -4546,19 +4545,15 @@ function safeWriteFile(path, data) {
4546
4545
  }
4547
4546
  function readConfig() {
4548
4547
  try {
4549
- if (!existsSync(CONFIG_FILE)) return {
4550
- version: 1,
4551
- gatewayUrl: getGatewayUrl(),
4552
- defaultTimeout: 3e4
4553
- };
4548
+ if (!existsSync(CONFIG_FILE)) return { version: 1 };
4554
4549
  const content = readFileSync(CONFIG_FILE, "utf-8");
4555
- return JSON.parse(content);
4556
- } catch {
4550
+ const parsed = JSON.parse(content);
4557
4551
  return {
4558
- version: 1,
4559
- gatewayUrl: getGatewayUrl(),
4560
- defaultTimeout: 3e4
4552
+ version: parsed.version ?? 1,
4553
+ platforms: parsed.platforms ?? {}
4561
4554
  };
4555
+ } catch {
4556
+ return { version: 1 };
4562
4557
  }
4563
4558
  }
4564
4559
  function saveConfig(config) {
@@ -4581,12 +4576,9 @@ function saveAuth(auth) {
4581
4576
  safeWriteFile(AUTH_FILE, JSON.stringify(data, null, 2));
4582
4577
  }
4583
4578
  function removeAuth() {
4584
- try {
4585
- if (existsSync(AUTH_FILE)) {
4586
- const { unlinkSync } = __require("fs");
4587
- unlinkSync(AUTH_FILE);
4588
- }
4589
- } catch {}
4579
+ if (!existsSync(AUTH_FILE)) return;
4580
+ unlinkSync(AUTH_FILE);
4581
+ if (existsSync(AUTH_FILE)) throw new Error(`Failed to remove auth file: ${AUTH_FILE}`);
4590
4582
  }
4591
4583
  function isAuthExpired(auth) {
4592
4584
  return Date.now() >= auth.expiresAt - 10080 * 60 * 1e3;
@@ -4595,25 +4587,101 @@ function getPrivateToken() {
4595
4587
  return readAuth()?.privateToken || null;
4596
4588
  }
4597
4589
  function getGatewayUrl() {
4598
- const envUrl = process.env.SKILLS_API_URL || process.env.ALI_GATEWAY_URL;
4599
- if (envUrl) switch (envUrl.toLowerCase()) {
4600
- case "local": return "http://localhost:3000";
4601
- case "daily": return "https://next-ai-base.pre-fn.alibaba-inc.com";
4602
- case "pre": return "https://ali-skills.pre.alibaba-inc.com";
4603
- case "prod": return "https://ali-skills.alibaba-inc.com";
4604
- default: return envUrl;
4605
- }
4606
- return "https://ali-skills.alibaba-inc.com";
4590
+ return SKILLS_API_BASE_URL.replace(/\/+$/, "").replace(/\/api\/skills$/i, "");
4607
4591
  }
4608
4592
  function getConfigFilePath() {
4609
4593
  return CONFIG_FILE;
4610
4594
  }
4595
+ function hasYuqueCredentials(data) {
4596
+ if (!data) return false;
4597
+ if (data.privateToken?.trim()) return true;
4598
+ return Object.values(data.groups ?? {}).some((g) => g.privateToken?.trim());
4599
+ }
4600
+ function getYuquePrivateTokenForRequest(config) {
4601
+ return resolveYuqueTokenAndGroup(config)?.token ?? null;
4602
+ }
4603
+ function resolveYuqueTokenAndGroup(config) {
4604
+ const yuque = config.platforms?.yuque;
4605
+ if (!yuque) return null;
4606
+ const tryGroup = process.env.ALI_SKILLS_YUQUE_GROUP?.trim() || yuque.defaultGroup?.trim();
4607
+ if (tryGroup) {
4608
+ const t = yuque.groups?.[tryGroup]?.privateToken?.trim();
4609
+ if (t) return {
4610
+ group: tryGroup,
4611
+ token: t
4612
+ };
4613
+ }
4614
+ const entries = Object.entries(yuque.groups ?? {}).filter(([, v]) => v.privateToken?.trim());
4615
+ const legacy = yuque.privateToken?.trim();
4616
+ if (entries.length === 1) {
4617
+ const [g, v] = entries[0];
4618
+ return {
4619
+ group: g,
4620
+ token: v.privateToken.trim()
4621
+ };
4622
+ }
4623
+ if (legacy && entries.length === 0) return { token: legacy };
4624
+ if (legacy) return { token: legacy };
4625
+ if (entries.length > 1) return null;
4626
+ return null;
4627
+ }
4628
+ const YUQUE_TOKEN_BASE = "https://aliyuque.antfin.com";
4629
+ function getYuqueGroupTokenDocUrl(teamSlug) {
4630
+ return `${YUQUE_TOKEN_BASE}/${encodeURIComponent(teamSlug)}/settings/tokens`;
4631
+ }
4611
4632
  function setPlatformToken(platform, data) {
4612
4633
  const config = readConfig();
4613
4634
  if (!config.platforms) config.platforms = {};
4614
4635
  config.platforms[platform] = data;
4615
4636
  saveConfig(config);
4616
4637
  }
4638
+ function setYuqueGroupAccessToken(teamSlug, token) {
4639
+ const config = readConfig();
4640
+ if (!config.platforms) config.platforms = {};
4641
+ const prev = config.platforms.yuque ?? {};
4642
+ const groups = {
4643
+ ...prev.groups ?? {},
4644
+ [teamSlug]: { privateToken: token }
4645
+ };
4646
+ config.platforms.yuque = {
4647
+ ...prev,
4648
+ groups,
4649
+ defaultGroup: teamSlug
4650
+ };
4651
+ saveConfig(config);
4652
+ }
4653
+ function setYuqueDefaultGroup(teamSlug) {
4654
+ const config = readConfig();
4655
+ const yuque = config.platforms?.yuque;
4656
+ if (!yuque?.groups?.[teamSlug]?.privateToken?.trim()) return;
4657
+ if (!config.platforms) config.platforms = {};
4658
+ config.platforms.yuque = {
4659
+ ...yuque,
4660
+ defaultGroup: teamSlug
4661
+ };
4662
+ saveConfig(config);
4663
+ }
4664
+ function removeYuqueGroup(teamSlug) {
4665
+ const config = readConfig();
4666
+ const yuque = config.platforms?.yuque;
4667
+ if (!yuque?.groups?.[teamSlug]) return;
4668
+ const groups = { ...yuque.groups };
4669
+ delete groups[teamSlug];
4670
+ const remainingKeys = Object.keys(groups);
4671
+ if (remainingKeys.length === 0) {
4672
+ if (yuque.privateToken?.trim()) config.platforms.yuque = { privateToken: yuque.privateToken };
4673
+ else delete config.platforms.yuque;
4674
+ saveConfig(config);
4675
+ return;
4676
+ }
4677
+ const defaultGroup = yuque.defaultGroup === teamSlug ? remainingKeys[0] : yuque.defaultGroup && remainingKeys.includes(yuque.defaultGroup) ? yuque.defaultGroup : remainingKeys[0];
4678
+ config.platforms.yuque = {
4679
+ ...yuque,
4680
+ groups,
4681
+ defaultGroup
4682
+ };
4683
+ saveConfig(config);
4684
+ }
4617
4685
  function removePlatformToken(platform) {
4618
4686
  const config = readConfig();
4619
4687
  if (config.platforms && config.platforms[platform]) {
@@ -4621,11 +4689,93 @@ function removePlatformToken(platform) {
4621
4689
  saveConfig(config);
4622
4690
  }
4623
4691
  }
4692
+ const PLATFORMS = {
4693
+ code: {
4694
+ name: "Code (GitLab)",
4695
+ host: "code.alibaba-inc.com",
4696
+ aliases: ["gitlab", "git"],
4697
+ authType: "private_token",
4698
+ tokenHeaderName: "PRIVATE-TOKEN",
4699
+ tokenDocUrl: "https://code.alibaba-inc.com/profile/account"
4700
+ },
4701
+ yuque: {
4702
+ name: "语雀",
4703
+ host: "aliyuque.antfin.com",
4704
+ aliases: ["yuque"],
4705
+ authType: "private_token",
4706
+ tokenHeaderName: "X-Auth-Token",
4707
+ tokenDocUrl: "https://aliyuque.antfin.com/settings/tokens"
4708
+ },
4709
+ o2: {
4710
+ name: "O2 平台",
4711
+ host: "o2.alibaba-inc.com",
4712
+ authType: "app_code+buc",
4713
+ appCode: process.env.O2_APP_CODE || "SYKcE5kklxmOS7Z2XatNn"
4714
+ },
4715
+ aone: {
4716
+ name: "Aone",
4717
+ host: "aone.alibaba-inc.com",
4718
+ authType: "buc_sso_refresh",
4719
+ ssoType: "refresh_token"
4720
+ }
4721
+ };
4722
+ function detectPlatformWithKey(hostname) {
4723
+ for (const [key, config] of Object.entries(PLATFORMS)) {
4724
+ if (config.host === hostname) return {
4725
+ key,
4726
+ config
4727
+ };
4728
+ if (config.aliases?.some((alias) => hostname.includes(alias))) return {
4729
+ key,
4730
+ config
4731
+ };
4732
+ }
4733
+ for (const [key, config] of Object.entries(PLATFORMS)) if (hostname.endsWith(config.host) || hostname === config.host) return {
4734
+ key,
4735
+ config
4736
+ };
4737
+ return null;
4738
+ }
4739
+ function getPlatform(key) {
4740
+ if (PLATFORMS[key]) return PLATFORMS[key];
4741
+ for (const [, config] of Object.entries(PLATFORMS)) if (config.aliases?.includes(key)) return config;
4742
+ return null;
4743
+ }
4744
+ function listPlatforms() {
4745
+ return Object.entries(PLATFORMS).map(([key, config]) => ({
4746
+ key,
4747
+ config
4748
+ }));
4749
+ }
4624
4750
  const DIM$3 = "\x1B[38;5;102m";
4625
4751
  const TEXT$3 = "\x1B[38;5;145m";
4626
4752
  const RESET$3 = "\x1B[0m";
4627
4753
  const GREEN$2 = "\x1B[32m";
4628
4754
  const YELLOW$3 = "\x1B[33m";
4755
+ const RED$3 = "\x1B[31m";
4756
+ const STATUS_PLATFORM_KEYS = [
4757
+ "code",
4758
+ "yuque",
4759
+ "o2"
4760
+ ];
4761
+ function isGatewayDebugEnabled() {
4762
+ const v = process.env.ALI_SKILLS_DEBUG_GATEWAY ?? process.env.DEBUG;
4763
+ if (!v) return false;
4764
+ const normalized = v.trim().toLowerCase();
4765
+ return normalized !== "" && normalized !== "0" && normalized !== "false" && normalized !== "off";
4766
+ }
4767
+ function gatewayDebugLog(message) {
4768
+ if (!isGatewayDebugEnabled()) return;
4769
+ console.log(`${DIM$3}[gateway-debug]${RESET$3} ${message}`);
4770
+ }
4771
+ function displayWidth(str) {
4772
+ let width = 0;
4773
+ for (const char of str) width += char.charCodeAt(0) > 127 ? 2 : 1;
4774
+ return width;
4775
+ }
4776
+ function printJson(payload, pretty = false) {
4777
+ console.log(JSON.stringify(payload, null, pretty ? 2 : 0));
4778
+ }
4629
4779
  function startLocalServer() {
4630
4780
  return new Promise((resolve) => {
4631
4781
  let resolveCallback;
@@ -4656,27 +4806,136 @@ function startLocalServer() {
4656
4806
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
4657
4807
  res.end(`
4658
4808
  <html>
4659
- <head><meta charset='UTF-8'><title>登录成功</title>
4809
+ <head><meta charset='UTF-8'><title>Ali Skills 登录成功</title>
4660
4810
  <style>
4661
- body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; text-align: center; padding: 50px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; min-height: 100vh; margin: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; }
4662
- .card { background: rgba(255, 255, 255, 0.95); padding: 40px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); color: #333; max-width: 400px; }
4663
- h1 { margin: 0 0 16px 0; color: #52c41a; }
4664
- .icon { font-size: 64px; margin-bottom: 16px; }
4665
- .user-info { background: #f6ffed; border: 1px solid #b7eb8f; border-radius: 8px; padding: 16px; margin: 16px 0; text-align: left; }
4666
- .user-info p { margin: 8px 0; }
4667
- .hint { color: #666; font-size: 14px; margin-top: 24px; }
4811
+ :root {
4812
+ --bg: #f7f7f8;
4813
+ --panel: #ffffff;
4814
+ --text: #4b5563;
4815
+ --muted: #9ca3af;
4816
+ --line: #e5e7eb;
4817
+ --ok: #16a34a;
4818
+ }
4819
+ * { box-sizing: border-box; }
4820
+ body {
4821
+ margin: 0;
4822
+ min-height: 100vh;
4823
+ display: flex;
4824
+ align-items: center;
4825
+ justify-content: center;
4826
+ padding: 16px;
4827
+ font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
4828
+ color: var(--text);
4829
+ background: var(--bg);
4830
+ }
4831
+ .card {
4832
+ width: 100%;
4833
+ max-width: 384px;
4834
+ background: var(--panel);
4835
+ border: 1px solid var(--line);
4836
+ border-radius: 12px;
4837
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
4838
+ padding: 24px;
4839
+ text-align: center;
4840
+ }
4841
+ .brand {
4842
+ font-size: 11px;
4843
+ letter-spacing: 0.14em;
4844
+ text-transform: uppercase;
4845
+ color: #9ca3af;
4846
+ margin-bottom: 14px;
4847
+ font-weight: 600;
4848
+ }
4849
+ .status {
4850
+ display: grid;
4851
+ grid-template-columns: 16px auto 16px;
4852
+ align-items: center;
4853
+ justify-content: center;
4854
+ column-gap: 5px;
4855
+ margin-top: 14px;
4856
+ }
4857
+ .icon {
4858
+ width: 16px;
4859
+ height: 16px;
4860
+ display: inline-flex;
4861
+ align-items: center;
4862
+ justify-content: center;
4863
+ border-radius: 999px;
4864
+ border: 1px solid #86efac;
4865
+ background: #f0fdf4;
4866
+ color: var(--ok);
4867
+ font-size: 10px;
4868
+ line-height: 1;
4869
+ }
4870
+ .title {
4871
+ margin: 0;
4872
+ color: var(--ok);
4873
+ font-size: 16px;
4874
+ font-weight: 600;
4875
+ line-height: 1.5;
4876
+ text-align: center;
4877
+ }
4878
+ .status-spacer {
4879
+ width: 16px;
4880
+ height: 16px;
4881
+ visibility: hidden;
4882
+ }
4883
+ .desc {
4884
+ margin: 10px auto 0;
4885
+ max-width: 320px;
4886
+ font-size: 12px;
4887
+ line-height: 1.7;
4888
+ color: var(--muted);
4889
+ }
4890
+ .user-info {
4891
+ background: #f9fafb;
4892
+ border: 1px solid var(--line);
4893
+ border-radius: 12px;
4894
+ padding: 14px 16px;
4895
+ margin: 16px 0 14px 0;
4896
+ text-align: left;
4897
+ }
4898
+ .row {
4899
+ display: grid;
4900
+ grid-template-columns: 52px 1fr;
4901
+ gap: 8px;
4902
+ margin: 8px 0;
4903
+ font-size: 13px;
4904
+ }
4905
+ .label { color: #6b7280; }
4906
+ .value { color: #111827; font-weight: 500; word-break: break-word; }
4907
+ .hint {
4908
+ margin: 0;
4909
+ font-size: 12px;
4910
+ color: #6b7280;
4911
+ text-align: center;
4912
+ }
4668
4913
  </style>
4669
4914
  </head>
4670
4915
  <body>
4671
4916
  <div class="card">
4672
- <div class="icon">✓</div>
4673
- <h1>登录成功</h1>
4917
+ <div class="brand">Ali Skills CLI</div>
4918
+ <div class="status">
4919
+ <span class="icon">✓</span>
4920
+ <h1 class="title">登录授权成功</h1>
4921
+ <span class="status-spacer" aria-hidden="true"></span>
4922
+ </div>
4923
+ <p class="desc">已完成 BUC 登录与 CLI 授权,身份凭证已保存到本机</p>
4674
4924
  <div class="user-info">
4675
- <p><strong>姓名:</strong> ${name}</p>
4676
- <p><strong>账号:</strong> ${account}</p>
4677
- <p><strong>工号:</strong> ${empId}</p>
4925
+ <div class="row">
4926
+ <span class="label">姓名</span>
4927
+ <span class="value">${name}</span>
4928
+ </div>
4929
+ <div class="row">
4930
+ <span class="label">账号</span>
4931
+ <span class="value">${account}</span>
4932
+ </div>
4933
+ <div class="row">
4934
+ <span class="label">工号</span>
4935
+ <span class="value">${empId}</span>
4936
+ </div>
4678
4937
  </div>
4679
- <p class="hint">您可以关闭此页面并返回 CLI</p>
4938
+ <p class="hint">你可以关闭此页面并返回终端继续使用</p>
4680
4939
  </div>
4681
4940
  </body>
4682
4941
  </html>
@@ -4715,7 +4974,8 @@ function openBrowser$2(url) {
4715
4974
  async function login() {
4716
4975
  const existingAuth = readAuth();
4717
4976
  if (existingAuth && !isAuthExpired(existingAuth)) {
4718
- console.log(`${TEXT$3}您已经登录为: ${existingAuth.name} (${existingAuth.account})${RESET$3}`);
4977
+ console.log(`${YELLOW$3}! 您已经登录为: ${existingAuth.name} (${existingAuth.account})${RESET$3}`);
4978
+ console.log();
4719
4979
  console.log(`${DIM$3}如需重新登录,请先执行: npx ali-skills logout${RESET$3}`);
4720
4980
  return;
4721
4981
  }
@@ -4735,10 +4995,12 @@ async function login() {
4735
4995
  empId,
4736
4996
  account,
4737
4997
  name,
4998
+ gatewayUrl,
4738
4999
  privateToken,
4739
5000
  ssoRefreshToken,
4740
- expiresAt: expiresAt * 1e3,
4741
- gatewayUrl
5001
+ ssoRefreshTokenFetchedAt: ssoRefreshToken ? Date.now() : void 0,
5002
+ ssoRefreshTokenLastCheckedAt: ssoRefreshToken ? Date.now() : void 0,
5003
+ expiresAt: expiresAt * 1e3
4742
5004
  });
4743
5005
  console.log();
4744
5006
  console.log(`${GREEN$2}✓ 登录成功!${RESET$3}`);
@@ -4750,19 +5012,256 @@ async function login() {
4750
5012
  throw error;
4751
5013
  }
4752
5014
  }
4753
- async function logout() {
4754
- if (!readAuth()) {
5015
+ async function logout(platformInput, yuqueGroup, clearAll) {
5016
+ if (platformInput) {
5017
+ const platform = resolvePlatformByInput(platformInput);
5018
+ if (!platform) {
5019
+ console.error(`${RED$3}不支持的平台: ${platformInput}${RESET$3}`);
5020
+ console.log(`${DIM$3}可用平台: ${STATUS_PLATFORM_KEYS.join(", ")}${RESET$3}`);
5021
+ process.exit(1);
5022
+ }
5023
+ if (platform.key === "yuque") {
5024
+ if (clearAll) {
5025
+ if (!hasYuqueCredentials(readConfig().platforms?.yuque)) {
5026
+ console.log(`${DIM$3}${platform.config.name} 未配置 Token${RESET$3}`);
5027
+ return;
5028
+ }
5029
+ removePlatformToken(platform.key);
5030
+ console.log(`${GREEN$2}✓ 已清除 ${platform.config.name} 的全部 Token 配置${RESET$3}`);
5031
+ return;
5032
+ }
5033
+ if (!yuqueGroup) {
5034
+ const yuque = readConfig().platforms?.yuque;
5035
+ const groups = Object.entries(yuque?.groups ?? {}).filter(([, e]) => e.privateToken?.trim()).map(([group]) => group);
5036
+ if (groups.length === 0) {
5037
+ if (yuque?.privateToken?.trim()) {
5038
+ removePlatformToken(platform.key);
5039
+ console.log(`${GREEN$2}✓ 已清除 ${platform.config.name} 的 Token 配置${RESET$3}`);
5040
+ return;
5041
+ }
5042
+ console.log(`${DIM$3}${platform.config.name} 未配置 Token${RESET$3}`);
5043
+ return;
5044
+ }
5045
+ const selected = await fe({
5046
+ message: "请选择要清除的语雀团队 Token(可多选)",
5047
+ options: groups.map((g) => ({
5048
+ value: g,
5049
+ label: g
5050
+ })),
5051
+ required: false
5052
+ });
5053
+ if (pD(selected)) {
5054
+ console.log(`${DIM$3}已取消${RESET$3}`);
5055
+ return;
5056
+ }
5057
+ if (selected.length === 0) {
5058
+ console.log(`${DIM$3}未选择任何团队,已取消${RESET$3}`);
5059
+ return;
5060
+ }
5061
+ for (const group of selected) removeYuqueGroup(group);
5062
+ console.log(`${GREEN$2}✓ 已清除 ${platform.config.name} 团队 Token: ${selected.join(", ")}${RESET$3}`);
5063
+ const remaining = Object.keys(readConfig().platforms?.yuque?.groups ?? {});
5064
+ if (remaining.length > 0) console.log(`${DIM$3}剩余团队: ${remaining.join(", ")}${RESET$3}`);
5065
+ console.log(`${DIM$3}如需清除全部,请执行: npx ali-skills logout yuque --all${RESET$3}`);
5066
+ return;
5067
+ }
5068
+ if (!hasYuqueCredentials(readConfig().platforms?.yuque)) {
5069
+ console.log(`${DIM$3}${platform.config.name} 未配置 Token${RESET$3}`);
5070
+ return;
5071
+ }
5072
+ const g = yuqueGroup.trim();
5073
+ if (!(readConfig().platforms?.yuque)?.groups?.[g]?.privateToken?.trim()) {
5074
+ console.log(`${DIM$3}${platform.config.name} 团队 ${g} 未配置 Group Access Token${RESET$3}`);
5075
+ return;
5076
+ }
5077
+ removeYuqueGroup(g);
5078
+ console.log(`${GREEN$2}✓ 已清除 ${platform.config.name} 团队 ${g} 的 Token${RESET$3}`);
5079
+ return;
5080
+ }
5081
+ if (platform.key === "o2") {
5082
+ const gatewayAuth = readAuth();
5083
+ const bucLoggedIn = Boolean(gatewayAuth) && !isAuthExpired(gatewayAuth);
5084
+ console.log(`${TEXT$3}${platform.config.name} 使用内置服务调用身份,无独立平台 Token${RESET$3}`);
5085
+ console.log(` BUC 登录态: ${bucLoggedIn ? `${GREEN$2}已登录${RESET$3}` : `${YELLOW$3}未登录${RESET$3}`}`);
5086
+ console.log(`${DIM$3}如需退出 BUC 登录态,请执行: npx ali-skills logout${RESET$3}`);
5087
+ return;
5088
+ }
5089
+ const token = readConfig().platforms?.[platform.key]?.privateToken;
5090
+ if (!token || !token.trim()) {
5091
+ console.log(`${DIM$3}${platform.config.name} 未配置 Private Token${RESET$3}`);
5092
+ return;
5093
+ }
5094
+ removePlatformToken(platform.key);
5095
+ console.log(`${GREEN$2}✓ 已清除 ${platform.config.name} 的 Private Token 配置${RESET$3}`);
5096
+ return;
5097
+ }
5098
+ const auth = readAuth();
5099
+ if (!auth) {
4755
5100
  console.log(`${DIM$3}您尚未登录${RESET$3}`);
4756
5101
  return;
4757
5102
  }
4758
- removeAuth();
4759
- console.log(`${GREEN$2}✓ 已登出${RESET$3}`);
5103
+ try {
5104
+ try {
5105
+ const revokeUrl = `${getGatewayUrl()}/api/gateway/revoke`;
5106
+ const revokeRes = await fetch(revokeUrl, {
5107
+ method: "POST",
5108
+ headers: { "X-Private-Token": auth.privateToken }
5109
+ });
5110
+ if (revokeRes.ok) console.log(`${GREEN$2}✓ 已撤销当前网关会话${RESET$3}`);
5111
+ else if (revokeRes.status === 404) console.log(`${DIM$3}服务端暂不支持撤销网关会话,继续本机登出${RESET$3}`);
5112
+ else console.log(`${YELLOW$3}⚠️ 撤销网关会话失败,继续本机登出${RESET$3}`);
5113
+ } catch {
5114
+ console.log(`${YELLOW$3}⚠️ 撤销网关会话失败,继续本机登出${RESET$3}`);
5115
+ }
5116
+ removeAuth();
5117
+ console.log(`${GREEN$2}✓ 已登出${RESET$3}`);
5118
+ } catch (error) {
5119
+ console.error(`${RED$3}登出失败: ${error.message}${RESET$3}`);
5120
+ process.exit(1);
5121
+ }
4760
5122
  }
4761
- async function status() {
5123
+ function resolvePlatformByInput(platformInput) {
5124
+ const canonicalize = (key) => {
5125
+ if (STATUS_PLATFORM_KEYS.includes(key)) return key;
5126
+ return null;
5127
+ };
5128
+ const getStatusPlatform = (key) => listPlatforms().find((item) => item.key === key) ?? null;
5129
+ const exact = listPlatforms().find(({ key }) => key === platformInput);
5130
+ if (exact) {
5131
+ const canonical = canonicalize(exact.key);
5132
+ return canonical ? getStatusPlatform(canonical) : null;
5133
+ }
5134
+ const byAlias = listPlatforms().find(({ config }) => config.aliases?.includes(platformInput));
5135
+ if (byAlias) {
5136
+ const canonical = canonicalize(byAlias.key);
5137
+ return canonical ? getStatusPlatform(canonical) : null;
5138
+ }
5139
+ const config = getPlatform(platformInput);
5140
+ if (!config) return null;
5141
+ const matched = listPlatforms().find(({ config: c }) => c === config);
5142
+ if (!matched) return null;
5143
+ const canonical = canonicalize(matched.key);
5144
+ return canonical ? getStatusPlatform(canonical) : null;
5145
+ }
5146
+ function printSinglePlatformStatus(platformInput, isLoggedIn) {
5147
+ const platform = resolvePlatformByInput(platformInput);
5148
+ if (!platform) {
5149
+ console.error(`${RED$3}不支持的平台: ${platformInput}${RESET$3}`);
5150
+ console.log(`${DIM$3}可用平台: ${STATUS_PLATFORM_KEYS.join(", ")}${RESET$3}`);
5151
+ process.exit(1);
5152
+ }
5153
+ const config = readConfig();
5154
+ const yuque = platform.key === "yuque" ? config.platforms?.yuque : void 0;
5155
+ const isBuiltinServiceIdentity = platform.key === "o2";
5156
+ const hasPrivateToken = platform.key === "yuque" ? hasYuqueCredentials(yuque) : isBuiltinServiceIdentity || Boolean(config.platforms?.[platform.key]?.privateToken?.trim());
5157
+ console.log(`${TEXT$3}平台状态: ${platform.config.name}${RESET$3}`);
5158
+ if (platform.key === "yuque") {
5159
+ const groupCount = yuque?.groups ? Object.keys(yuque.groups).length : 0;
5160
+ const line = groupCount > 0 ? ` Group Access Token: ${hasPrivateToken ? `${GREEN$2}已配置${RESET$3}` : `${YELLOW$3}未配置${RESET$3}`} ${DIM$3}(${groupCount} 团队)${RESET$3}` : ` Token: ${hasPrivateToken ? `${GREEN$2}已配置${RESET$3}` : `${YELLOW$3}未配置${RESET$3}`}`;
5161
+ console.log(line);
5162
+ if (yuque?.defaultGroup) console.log(`${DIM$3} 默认团队: ${yuque.defaultGroup}${RESET$3}`);
5163
+ } else if (isBuiltinServiceIdentity) console.log(` Token: ${GREEN$2}无需配置(走内置服务调用身份)${RESET$3}`);
5164
+ else console.log(` Private Token: ${hasPrivateToken ? `${GREEN$2}已配置${RESET$3}` : `${YELLOW$3}未配置${RESET$3}`}`);
5165
+ if (!hasPrivateToken && !isBuiltinServiceIdentity) console.log(`${DIM$3} 配置命令: npx ali-skills login ${platform.key}${RESET$3}`);
5166
+ if (platform.config.authType !== "private_token") console.log(` BUC 登录: ${isLoggedIn ? `${GREEN$2}已登录${RESET$3}` : `${YELLOW$3}未登录${RESET$3}`}`);
5167
+ }
5168
+ function printYuqueGroupStatus(group) {
5169
+ const yuque = readConfig().platforms?.yuque;
5170
+ const token = yuque?.groups?.[group]?.privateToken?.trim() ?? "";
5171
+ const hasToken = Boolean(token);
5172
+ const isDefault = yuque?.defaultGroup === group;
5173
+ console.log(`${TEXT$3}语雀团队状态: ${group}${RESET$3}`);
5174
+ console.log(` Group Access Token: ${hasToken ? `${GREEN$2}已配置${RESET$3}` : `${YELLOW$3}未配置${RESET$3}`}`);
5175
+ if (isDefault) console.log(` 默认团队: ${GREEN$2}是${RESET$3}`);
5176
+ else if (yuque?.defaultGroup) console.log(`${DIM$3} 当前默认团队: ${yuque.defaultGroup}${RESET$3}`);
5177
+ if (!hasToken) console.log(`${DIM$3} 配置命令: npx ali-skills login yuque ${group}${RESET$3}`);
5178
+ }
5179
+ function printAllPlatformStatuses(isLoggedIn) {
5180
+ const config = readConfig();
5181
+ const platforms = listPlatforms().filter(({ key }) => STATUS_PLATFORM_KEYS.includes(key));
5182
+ const maxKeyWidth = Math.max(...platforms.map(({ key }) => displayWidth(key)));
5183
+ const maxNameWidth = Math.max(...platforms.map(({ config: p }) => displayWidth(p.name)));
5184
+ console.log();
5185
+ console.log(`${TEXT$3}平台凭证状态:${RESET$3}`);
5186
+ for (const { key, config: platform } of platforms) {
5187
+ const yuque = key === "yuque" ? config.platforms?.yuque : void 0;
5188
+ const isBuiltinServiceIdentity = key === "o2";
5189
+ const hasPrivateToken = key === "yuque" ? hasYuqueCredentials(yuque) : isBuiltinServiceIdentity || Boolean(config.platforms?.[key]?.privateToken?.trim());
5190
+ const groupCount = key === "yuque" && yuque?.groups ? Object.keys(yuque.groups).length : 0;
5191
+ let statusText = isBuiltinServiceIdentity ? `${GREEN$2}Token 无需配置(走内置服务调用身份)${RESET$3}` : hasPrivateToken ? key === "yuque" && groupCount > 0 ? `${GREEN$2}Group Token 已配置${RESET$3} ${DIM$3}(${groupCount} 团队)${RESET$3}` : `${GREEN$2}Private Token 已配置${RESET$3}` : key === "yuque" ? `${YELLOW$3}Token 未配置${RESET$3}` : `${YELLOW$3}Private Token 未配置${RESET$3}`;
5192
+ if (platform.authType !== "private_token") statusText += isLoggedIn ? ` ${DIM$3}(BUC 已登录)${RESET$3}` : ` ${DIM$3}(BUC 未登录)${RESET$3}`;
5193
+ const keyPadding = " ".repeat(maxKeyWidth - displayWidth(key) + 2);
5194
+ const namePadding = " ".repeat(maxNameWidth - displayWidth(platform.name) + 2);
5195
+ console.log(` ${key}${keyPadding}${platform.name}${namePadding}${statusText}`);
5196
+ }
5197
+ }
5198
+ async function status(args = {}) {
5199
+ const { platform: targetPlatform, yuqueGroup, showAll = false, prettyJson = false, showPrivateToken = false } = args;
4762
5200
  const auth = readAuth();
5201
+ if (showPrivateToken && !targetPlatform) {
5202
+ if (showAll) {
5203
+ console.error(`${RED$3}--show/-s 与 --all 同用时需指定平台,例如: npx ali-skills status yuque -s --all${RESET$3}`);
5204
+ process.exit(1);
5205
+ }
5206
+ if (!auth) {
5207
+ console.error(`${RED$3}未登录网关,请执行: npx ali-skills login${RESET$3}`);
5208
+ process.exit(1);
5209
+ }
5210
+ printJson(auth, prettyJson);
5211
+ return;
5212
+ }
5213
+ if (targetPlatform && showPrivateToken) {
5214
+ const platform = resolvePlatformByInput(targetPlatform);
5215
+ if (!platform) {
5216
+ console.error(`${RED$3}不支持的平台: ${targetPlatform}${RESET$3}`);
5217
+ console.log(`${DIM$3}可用平台: ${STATUS_PLATFORM_KEYS.join(", ")}${RESET$3}`);
5218
+ process.exit(1);
5219
+ }
5220
+ if (platform.key === "yuque") {
5221
+ const yuque = readConfig().platforms?.yuque;
5222
+ if (!yuque) {
5223
+ console.error(`${RED$3}未配置语雀 Token,请执行: npx ali-skills login yuque${RESET$3}`);
5224
+ process.exit(1);
5225
+ }
5226
+ if (yuqueGroup) {
5227
+ const token = yuque.groups?.[yuqueGroup]?.privateToken?.trim();
5228
+ if (!token) {
5229
+ console.error(`${RED$3}语雀团队 ${yuqueGroup} 未配置 Group Access Token${RESET$3}`);
5230
+ console.log(`${DIM$3}可先执行: npx ali-skills login yuque ${yuqueGroup}${RESET$3}`);
5231
+ process.exit(1);
5232
+ }
5233
+ printJson({
5234
+ privateToken: token,
5235
+ group: yuqueGroup
5236
+ }, prettyJson);
5237
+ return;
5238
+ }
5239
+ printJson(yuque, prettyJson);
5240
+ return;
5241
+ }
5242
+ const token = readConfig().platforms?.[platform.key]?.privateToken?.trim() ?? "";
5243
+ if (!token) {
5244
+ console.error(`${RED$3}未配置 Private Token,请执行: npx ali-skills login ${platform.key}${RESET$3}`);
5245
+ process.exit(1);
5246
+ }
5247
+ printJson({ privateToken: token }, prettyJson);
5248
+ return;
5249
+ }
5250
+ if (targetPlatform) {
5251
+ if (targetPlatform === "yuque" && yuqueGroup) {
5252
+ printYuqueGroupStatus(yuqueGroup);
5253
+ return;
5254
+ }
5255
+ printSinglePlatformStatus(targetPlatform, Boolean(auth));
5256
+ return;
5257
+ }
4763
5258
  if (!auth) {
4764
5259
  console.log(`${DIM$3}您尚未登录${RESET$3}`);
4765
5260
  console.log(`${TEXT$3}请执行: npx ali-skills login${RESET$3}`);
5261
+ if (showAll) {
5262
+ console.log();
5263
+ printAllPlatformStatuses(false);
5264
+ }
4766
5265
  return;
4767
5266
  }
4768
5267
  const expired = isAuthExpired(auth);
@@ -4771,11 +5270,86 @@ async function status() {
4771
5270
  console.log(`${TEXT$3}登录状态:${RESET$3}`);
4772
5271
  console.log(` 用户: ${auth.name} (${auth.account})`);
4773
5272
  console.log(` 工号: ${auth.empId}`);
4774
- console.log(` 网关: ${auth.gatewayUrl}`);
5273
+ console.log(` 网关: ${getGatewayUrl()}`);
5274
+ console.log(` SSO_REFRESH_TOKEN: ${auth.ssoRefreshToken ? `${GREEN$2}已缓存${RESET$3}` : `${YELLOW$3}未缓存${RESET$3}`}`);
4775
5275
  if (expired) {
4776
5276
  console.log(` Token: ${YELLOW$3}即将过期${RESET$3}`);
4777
5277
  console.log(`${TEXT$3}建议重新登录: npx ali-skills login${RESET$3}`);
4778
5278
  } else console.log(` Token: ${GREEN$2}有效${RESET$3} (还剩 ${remainingDays} 天)`);
5279
+ if (showAll) {
5280
+ console.log();
5281
+ printAllPlatformStatuses(true);
5282
+ }
5283
+ }
5284
+ async function ensureSsoRefreshToken() {
5285
+ const auth = readAuth();
5286
+ if (!auth) throw new Error("未登录,请先执行: npx ali-skills login");
5287
+ if (auth.ssoRefreshToken) {
5288
+ saveAuth({
5289
+ ...auth,
5290
+ gatewayUrl: auth.gatewayUrl || getGatewayUrl(),
5291
+ ssoRefreshTokenLastCheckedAt: Date.now()
5292
+ });
5293
+ return auth.ssoRefreshToken;
5294
+ }
5295
+ const ssoTokenUrl = `${getGatewayUrl()}/api/gateway/sso-token`;
5296
+ try {
5297
+ const response = await fetch(ssoTokenUrl, {
5298
+ method: "POST",
5299
+ headers: { "X-Private-Token": auth.privateToken }
5300
+ });
5301
+ if (response.status === 200) {
5302
+ const data = await response.json();
5303
+ saveAuth({
5304
+ ...auth,
5305
+ gatewayUrl: auth.gatewayUrl || getGatewayUrl(),
5306
+ ssoRefreshToken: data.ssoRefreshToken,
5307
+ ssoRefreshTokenFetchedAt: Date.now(),
5308
+ ssoRefreshTokenLastCheckedAt: Date.now(),
5309
+ ssoRefreshTokenExpiresAt: data.ssoRefreshTokenExpiresAt
5310
+ });
5311
+ console.log(`${DIM$3}已从服务端获取 SSO_REFRESH_TOKEN${RESET$3}`);
5312
+ return data.ssoRefreshToken;
5313
+ }
5314
+ if (response.status === 404) {
5315
+ console.log(`${YELLOW$3}⚠️ SSO_REFRESH_TOKEN 不可用${RESET$3}`);
5316
+ console.log(`${DIM$3}提示: 请通过浏览器登录以获取 SSO_REFRESH_TOKEN${RESET$3}`);
5317
+ return null;
5318
+ }
5319
+ const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
5320
+ console.error(`${RED$3}获取 SSO_REFRESH_TOKEN 失败: ${errorData.error}${RESET$3}`);
5321
+ return null;
5322
+ } catch (error) {
5323
+ console.error(`${RED$3}获取 SSO_REFRESH_TOKEN 失败: ${error.message}${RESET$3}`);
5324
+ return null;
5325
+ }
5326
+ }
5327
+ async function ensureSsoTicket() {
5328
+ const auth = readAuth();
5329
+ if (!auth) throw new Error("未登录,请先执行: npx ali-skills login");
5330
+ const ticketUrl = `${getGatewayUrl()}/api/gateway/sso-ticket`;
5331
+ gatewayDebugLog(`request sso-ticket: ${ticketUrl}`);
5332
+ try {
5333
+ const response = await fetch(ticketUrl, {
5334
+ method: "POST",
5335
+ headers: { "X-Private-Token": auth.privateToken }
5336
+ });
5337
+ gatewayDebugLog(`sso-ticket response status: ${response.status}`);
5338
+ if (response.ok) {
5339
+ const data = await response.json();
5340
+ const ticket = data.ssoTicket || data.sso_ticket || data.data?.ssoTicket || data.data?.sso_ticket || data.data?.ticket || "";
5341
+ gatewayDebugLog(`sso-ticket success: ticket=${ticket ? "present" : "missing"}, ttl=${data.expiresInSeconds ?? "n/a"}, keys=${Object.keys(data).join(",")}`);
5342
+ return ticket || null;
5343
+ }
5344
+ const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
5345
+ gatewayDebugLog(`sso-ticket failed: code=${errorData.code ?? "n/a"}, error=${errorData.error ?? "Unknown error"}`);
5346
+ console.error(`${RED$3}获取 SSO_TICKET 失败: ${errorData.error || errorData.code || "Unknown error"}${RESET$3}`);
5347
+ return null;
5348
+ } catch (error) {
5349
+ gatewayDebugLog(`sso-ticket fetch exception: ${error.message}`);
5350
+ console.error(`${RED$3}获取 SSO_TICKET 失败: ${error.message}${RESET$3}`);
5351
+ return null;
5352
+ }
4779
5353
  }
4780
5354
  async function ensureLogin() {
4781
5355
  const auth = readAuth();
@@ -4786,81 +5360,11 @@ async function ensureLogin() {
4786
5360
  ssoRefreshToken: auth.ssoRefreshToken
4787
5361
  };
4788
5362
  }
4789
- const PLATFORMS = {
4790
- code: {
4791
- name: "Code (GitLab)",
4792
- host: "code.alibaba-inc.com",
4793
- aliases: ["gitlab", "git"],
4794
- authType: "private_token",
4795
- tokenHeaderName: "PRIVATE-TOKEN",
4796
- tokenDocUrl: "https://code.alibaba-inc.com/profile/account"
4797
- },
4798
- yuque: {
4799
- name: "语雀",
4800
- host: "aliyuque.antfin.com",
4801
- aliases: ["yuque"],
4802
- authType: "private_token",
4803
- tokenHeaderName: "X-Auth-Token",
4804
- tokenDocUrl: "https://aliyuque.antfin.com/settings/tokens"
4805
- },
4806
- o2: {
4807
- name: "O2 平台",
4808
- host: "o2.alibaba-inc.com",
4809
- authType: "app_code+buc",
4810
- appCode: process.env.O2_APP_CODE || "SYKcE5kklxmOS7Z2XatNn"
4811
- },
4812
- o2open: {
4813
- name: "O2 开放接口",
4814
- host: "open.o2.alibaba-inc.com",
4815
- authType: "app_code",
4816
- appCode: process.env.O2_APP_CODE || "cli-skills"
4817
- },
4818
- aone: {
4819
- name: "Aone",
4820
- host: "aone.alibaba-inc.com",
4821
- authType: "buc_sso_refresh",
4822
- ssoType: "refresh_token"
4823
- },
4824
- aonedevops: {
4825
- name: "Aone DevOps",
4826
- host: "devops.alibaba-inc.com",
4827
- authType: "buc_sso_refresh",
4828
- ssoType: "refresh_token"
4829
- }
4830
- };
4831
- function detectPlatformWithKey(hostname) {
4832
- for (const [key, config] of Object.entries(PLATFORMS)) {
4833
- if (config.host === hostname) return {
4834
- key,
4835
- config
4836
- };
4837
- if (config.aliases?.some((alias) => hostname.includes(alias))) return {
4838
- key,
4839
- config
4840
- };
4841
- }
4842
- for (const [key, config] of Object.entries(PLATFORMS)) if (hostname.endsWith(config.host) || hostname === config.host) return {
4843
- key,
4844
- config
4845
- };
4846
- return null;
4847
- }
4848
- function getPlatform(key) {
4849
- if (PLATFORMS[key]) return PLATFORMS[key];
4850
- for (const [, config] of Object.entries(PLATFORMS)) if (config.aliases?.includes(key)) return config;
4851
- return null;
4852
- }
4853
- function listPlatforms() {
4854
- return Object.entries(PLATFORMS).map(([key, config]) => ({
4855
- key,
4856
- config
4857
- }));
4858
- }
4859
5363
  const DIM$2 = "\x1B[38;5;102m";
4860
5364
  const TEXT$2 = "\x1B[38;5;145m";
4861
5365
  const RESET$2 = "\x1B[0m";
4862
5366
  const GREEN$1 = "\x1B[32m";
4863
- const RED$1 = "\x1B[31m";
5367
+ const RED$2 = "\x1B[31m";
4864
5368
  const YELLOW$2 = "\x1B[33m";
4865
5369
  function openBrowser$1(url) {
4866
5370
  const platform = process.platform;
@@ -4871,33 +5375,144 @@ function openBrowser$1(url) {
4871
5375
  }
4872
5376
  function detectAuthMode(platformKey, platform, hostname) {
4873
5377
  if (platform.authType === "private_token") return "private_token";
4874
- if (platformKey === "o2" || platform.authType === "app_code+buc") return "app_code+buc";
4875
- if (platform.authType === "app_code") return "app_code";
5378
+ if (platformKey === "o2") return "auto";
4876
5379
  if (hostname.endsWith(".alibaba-inc.com") || hostname === "alibaba-inc.com") return "sso_cookie";
4877
5380
  return "sso_ticket";
4878
5381
  }
4879
5382
  function getAuthModeDescription(mode) {
4880
5383
  switch (mode) {
4881
5384
  case "private_token": return "Private Token";
4882
- case "app_code": return "App Code";
4883
- case "app_code+buc": return "App Code + BUC SSO";
4884
5385
  case "sso_cookie": return "SSO Cookie (REFRESH_TOKEN)";
4885
5386
  case "sso_ticket": return "SSO Ticket";
4886
5387
  case "gateway": return "Gateway Proxy";
4887
5388
  default: return "Auto";
4888
5389
  }
4889
5390
  }
4890
- function getPlatformPrivateToken(platformKey, explicitToken) {
5391
+ const O2_CREDENTIALS_BASE64 = "eyJhY2Nlc3NLZXlJZCI6IlNZS2NFNWtrbHhtT1M3WjJYYXRObiIsImFjY2Vzc0tleVNlY3JldCI6IjQ2NGNhYTc0MmNiYTk2NzFkZjM5NzJkYzdhNWI3MmQ1Nzk5ZTc2NTQyYzRiZGFjM2M3YTk5N2QzMDM3YTIyNzAifQ==";
5392
+ function getO2Credentials() {
5393
+ const accessKeyId = process.env.O2_ACCESS_KEY_ID?.trim();
5394
+ const accessKeySecret = process.env.O2_ACCESS_KEY_SECRET?.trim();
5395
+ if (accessKeyId && accessKeySecret) return {
5396
+ accessKeyId,
5397
+ accessKeySecret
5398
+ };
5399
+ return JSON.parse(Buffer.from(O2_CREDENTIALS_BASE64, "base64").toString("utf-8"));
5400
+ }
5401
+ function getO2ApiEnv() {
5402
+ const env = process.env.O2_API_ENV?.trim();
5403
+ if (!env) return void 0;
5404
+ return env;
5405
+ }
5406
+ function searchParamsToObject(searchParams) {
5407
+ const out = {};
5408
+ searchParams.forEach((value, key) => {
5409
+ const prev = out[key];
5410
+ if (prev === void 0) {
5411
+ out[key] = value;
5412
+ return;
5413
+ }
5414
+ out[key] = Array.isArray(prev) ? [...prev, value] : [prev, value];
5415
+ });
5416
+ return out;
5417
+ }
5418
+ function parseBodyAsJsonObject(body) {
5419
+ if (!body) return {};
5420
+ const parsed = JSON.parse(body);
5421
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("O2 请求 body 仅支持 JSON 对象");
5422
+ return parsed;
5423
+ }
5424
+ async function sendO2SdkRequest(targetUrl, options, withSsoTicket) {
5425
+ const parsed = new URL(targetUrl);
5426
+ const path = parsed.pathname;
5427
+ const query = searchParamsToObject(parsed.searchParams);
5428
+ const headers = { ...options.headers ?? {} };
5429
+ if (withSsoTicket) {
5430
+ const ssoTicket = await ensureSsoTicket();
5431
+ if (!ssoTicket) throw new Error("无法获取 SSO_TICKET,请重新登录后重试");
5432
+ headers.SSO_TICKET = ssoTicket;
5433
+ }
5434
+ let O2ClientCtor;
5435
+ try {
5436
+ const mod = await import("@ali/o2-open-client");
5437
+ const defaultExport = mod.default;
5438
+ O2ClientCtor = mod.O2Client ?? (typeof defaultExport === "function" ? defaultExport : defaultExport?.O2Client);
5439
+ if (!O2ClientCtor) throw new Error("未找到 O2Client 导出");
5440
+ } catch (error) {
5441
+ throw new Error(`未安装 @ali/o2-open-client 或导入失败: ${error.message}`);
5442
+ }
5443
+ const { accessKeyId, accessKeySecret } = getO2Credentials();
5444
+ const o2Env = getO2ApiEnv();
5445
+ const client = new O2ClientCtor({
5446
+ accessKeyId,
5447
+ accessKeySecret,
5448
+ ...o2Env ? { env: o2Env } : {}
5449
+ });
5450
+ const method = options.method.toUpperCase();
5451
+ const bodyObj = parseBodyAsJsonObject(options.body);
5452
+ if (!options.quiet) {
5453
+ console.log(`${DIM$2}${method} ${parsed.toString()}${RESET$2}`);
5454
+ console.log(`${DIM$2}→ O2 SDK 直连${withSsoTicket ? " (携带 SSO_TICKET)" : ""}${RESET$2}`);
5455
+ if (o2Env) console.log(`${DIM$2}→ O2 SDK Env: ${o2Env}${RESET$2}`);
5456
+ }
5457
+ let responseData;
5458
+ switch (method) {
5459
+ case "GET":
5460
+ responseData = await client.get(path, query, headers);
5461
+ break;
5462
+ case "POST":
5463
+ responseData = await client.post(path, query, bodyObj, headers);
5464
+ break;
5465
+ case "PUT":
5466
+ responseData = await client.put(path, query, bodyObj, headers);
5467
+ break;
5468
+ case "DELETE":
5469
+ responseData = await client.delete(path, query, headers);
5470
+ break;
5471
+ default: throw new Error(`O2 SDK 暂不支持该方法: ${method}`);
5472
+ }
5473
+ const outputBody = !options.raw && options.pretty !== false ? JSON.stringify(responseData, null, 2) : JSON.stringify(responseData);
5474
+ if (options.output) {
5475
+ const { writeFileSync } = await import("fs");
5476
+ writeFileSync(options.output, outputBody);
5477
+ if (!options.quiet) console.log(`${GREEN$1}✓ 已保存到 ${options.output}${RESET$2}`);
5478
+ } else console.log(outputBody);
5479
+ }
5480
+ function tryExtractYuqueGroupFromUrl(targetUrl) {
5481
+ try {
5482
+ const u = new URL(targetUrl);
5483
+ const scope = u.searchParams.get("scope")?.trim();
5484
+ if (scope) {
5485
+ const groupFromScope = scope.split("/")[0]?.trim();
5486
+ if (groupFromScope && /^[a-zA-Z0-9_-]+$/.test(groupFromScope)) return groupFromScope;
5487
+ }
5488
+ return u.pathname.match(/^\/api\/v\d+\/repos\/([^/]+)\//i)?.[1]?.trim() || null;
5489
+ } catch {
5490
+ return null;
5491
+ }
5492
+ }
5493
+ function getPlatformPrivateToken(platformKey, explicitToken, targetUrl) {
4891
5494
  if (explicitToken) return explicitToken;
4892
5495
  const envVarName = `ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN`;
4893
5496
  const envToken = process.env[envVarName] || process.env[`${platformKey.toUpperCase()}_TOKEN`];
4894
5497
  if (envToken) return envToken;
4895
- return readConfig().platforms?.[platformKey]?.privateToken || null;
5498
+ const config = readConfig();
5499
+ if (platformKey === "yuque") {
5500
+ const groupFromPath = targetUrl ? tryExtractYuqueGroupFromUrl(targetUrl) : null;
5501
+ if (groupFromPath) {
5502
+ const byPath = config.platforms?.yuque?.groups?.[groupFromPath]?.privateToken?.trim();
5503
+ if (byPath) return byPath;
5504
+ }
5505
+ return getYuquePrivateTokenForRequest(config);
5506
+ }
5507
+ return config.platforms?.[platformKey]?.privateToken || null;
4896
5508
  }
4897
5509
  async function promptConfigureToken(platformKey, platform) {
4898
5510
  console.log();
4899
5511
  console.log(`${YELLOW$2}⚠️ ${platform.name} 需要配置 Private Token${RESET$2}`);
4900
- if (platform.tokenDocUrl) console.log(`${DIM$2}Token 获取地址: ${platform.tokenDocUrl}${RESET$2}`);
5512
+ const yuqueCfg = platformKey === "yuque" ? readConfig().platforms?.yuque : void 0;
5513
+ const yuqueTeamForDoc = platformKey === "yuque" ? yuqueCfg?.defaultGroup?.trim() || Object.keys(yuqueCfg?.groups ?? {})[0] : void 0;
5514
+ const tokenDocUrlToOpen = platformKey === "yuque" ? yuqueTeamForDoc ? getYuqueGroupTokenDocUrl(yuqueTeamForDoc) : platform.tokenDocUrl : platform.tokenDocUrl;
5515
+ if (tokenDocUrlToOpen) console.log(`${DIM$2}Token 获取地址: ${tokenDocUrlToOpen}${RESET$2}`);
4901
5516
  if (!await ye({
4902
5517
  message: "是否现在配置?",
4903
5518
  initialValue: true
@@ -4905,9 +5520,9 @@ async function promptConfigureToken(platformKey, platform) {
4905
5520
  console.log(`${DIM$2}已取消配置${RESET$2}`);
4906
5521
  return null;
4907
5522
  }
4908
- if (platform.tokenDocUrl) {
5523
+ if (tokenDocUrlToOpen) {
4909
5524
  console.log(`${TEXT$2}正在打开浏览器...${RESET$2}`);
4910
- openBrowser$1(platform.tokenDocUrl);
5525
+ openBrowser$1(tokenDocUrlToOpen);
4911
5526
  }
4912
5527
  const token = await ge({
4913
5528
  message: `请输入 ${platform.name} 的 Private Token:`,
@@ -4917,7 +5532,12 @@ async function promptConfigureToken(platformKey, platform) {
4917
5532
  console.log(`${DIM$2}已取消配置${RESET$2}`);
4918
5533
  return null;
4919
5534
  }
4920
- setPlatformToken(platformKey, { privateToken: token });
5535
+ if (platformKey === "yuque") {
5536
+ const cfg = readConfig().platforms?.yuque;
5537
+ const team = cfg?.defaultGroup?.trim() || (cfg?.groups ? Object.keys(cfg.groups).find((k) => cfg.groups?.[k]?.privateToken) : void 0);
5538
+ if (team) setYuqueGroupAccessToken(team, token);
5539
+ else setPlatformToken(platformKey, { privateToken: token });
5540
+ } else setPlatformToken(platformKey, { privateToken: token });
4921
5541
  console.log(`${GREEN$1}✓ ${platform.name} Token 已保存${RESET$2}`);
4922
5542
  return token;
4923
5543
  }
@@ -4950,7 +5570,7 @@ async function sendDirectRequest(targetUrl, platform, token, options) {
4950
5570
  clearTimeout(timeoutId);
4951
5571
  const responseBody = await response.text();
4952
5572
  if (!options.quiet) {
4953
- const statusColor = response.ok ? GREEN$1 : RED$1;
5573
+ const statusColor = response.ok ? GREEN$1 : RED$2;
4954
5574
  console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
4955
5575
  if (options.includeHeaders) {
4956
5576
  console.log();
@@ -4973,12 +5593,82 @@ async function sendDirectRequest(targetUrl, platform, token, options) {
4973
5593
  } else console.log(outputBody);
4974
5594
  if (!response.ok) process.exit(1);
4975
5595
  }
5596
+ async function sendSsoCookieDirectRequest(targetUrl, options) {
5597
+ let ssoRefreshToken = null;
5598
+ try {
5599
+ await ensureLogin();
5600
+ ssoRefreshToken = await ensureSsoRefreshToken();
5601
+ } catch (error) {
5602
+ console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
5603
+ process.exit(1);
5604
+ }
5605
+ if (!ssoRefreshToken) {
5606
+ console.error(`${RED$2}Error: 缺少 SSO_REFRESH_TOKEN,无法进行根域 cookie 直连${RESET$2}`);
5607
+ console.log(`${DIM$2}可能原因:${RESET$2}`);
5608
+ console.log(`${DIM$2} 1. 尚未通过 ali-skills 登录${RESET$2}`);
5609
+ console.log(`${DIM$2} 2. 登录时未拿到根域 token${RESET$2}`);
5610
+ console.log(`${DIM$2} 3. token 已失效${RESET$2}`);
5611
+ console.log(`${TEXT$2}建议执行: npx ali-skills login${RESET$2}`);
5612
+ process.exit(1);
5613
+ }
5614
+ const requestHeaders = {
5615
+ "User-Agent": "ali-skills-cli/1.0",
5616
+ Cookie: `SSO_REFRESH_TOKEN=${ssoRefreshToken}`
5617
+ };
5618
+ if (options.headers) Object.entries(options.headers).forEach(([key, value]) => {
5619
+ if (key.toLowerCase() !== "cookie") requestHeaders[key] = value;
5620
+ });
5621
+ let body;
5622
+ if (options.body) {
5623
+ body = options.body;
5624
+ if (!requestHeaders["Content-Type"]) requestHeaders["Content-Type"] = "application/json";
5625
+ }
5626
+ if (!options.quiet) {
5627
+ console.log(`${DIM$2}${options.method.toUpperCase()} ${targetUrl}${RESET$2}`);
5628
+ console.log(`${DIM$2}→ 直接请求 (Cookie: SSO_REFRESH_TOKEN)${RESET$2}`);
5629
+ }
5630
+ const controller = new AbortController();
5631
+ const timeout = options.timeout || 3e4;
5632
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
5633
+ const response = await fetch(targetUrl, {
5634
+ method: options.method.toUpperCase(),
5635
+ headers: requestHeaders,
5636
+ body: body || void 0,
5637
+ signal: controller.signal,
5638
+ redirect: "manual"
5639
+ });
5640
+ clearTimeout(timeoutId);
5641
+ const responseBody = await response.text();
5642
+ if (!options.quiet) {
5643
+ const statusColor = response.ok ? GREEN$1 : RED$2;
5644
+ console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
5645
+ if (response.status === 401 || response.status === 403) {
5646
+ console.log(`${YELLOW$2}根域 cookie 认证失败${RESET$2}`);
5647
+ console.log(`${DIM$2}可能原因:${RESET$2}`);
5648
+ console.log(`${DIM$2} 1. SSO_REFRESH_TOKEN 已过期或无效${RESET$2}`);
5649
+ console.log(`${DIM$2} 2. 目标服务未启用该认证链路${RESET$2}`);
5650
+ console.log(`${DIM$2} 3. 当前账号在目标系统无访问权限${RESET$2}`);
5651
+ console.log(`${TEXT$2}建议: 重新登录后重试,或联系目标系统确认登录态策略${RESET$2}`);
5652
+ }
5653
+ }
5654
+ let outputBody = responseBody;
5655
+ if (!options.raw && options.pretty !== false) try {
5656
+ const json = JSON.parse(responseBody);
5657
+ outputBody = JSON.stringify(json, null, 2);
5658
+ } catch {}
5659
+ if (options.output) {
5660
+ const { writeFileSync } = __require("fs");
5661
+ writeFileSync(options.output, outputBody);
5662
+ console.log(`${GREEN$1}✓ 已保存到 ${options.output}${RESET$2}`);
5663
+ } else console.log(outputBody);
5664
+ if (!response.ok) process.exit(1);
5665
+ }
4976
5666
  async function sendGatewayRequest(targetUrl, platformKey, options, authMode = "gateway") {
4977
5667
  let credentials;
4978
5668
  try {
4979
5669
  credentials = await ensureLogin();
4980
5670
  } catch (error) {
4981
- console.error(`${RED$1}Error: ${error.message}${RESET$2}`);
5671
+ console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
4982
5672
  process.exit(1);
4983
5673
  }
4984
5674
  const proxyUrl = `${getGatewayUrl()}/api/gateway/proxy`;
@@ -5017,7 +5707,7 @@ async function sendGatewayRequest(targetUrl, platformKey, options, authMode = "g
5017
5707
  error: "Unauthorized",
5018
5708
  code: "UNKNOWN"
5019
5709
  }))).code === "INVALID_TOKEN") {
5020
- console.error(`${RED$1}Error: Token 已失效,请重新登录${RESET$2}`);
5710
+ console.error(`${RED$2}Error: Token 已失效,请重新登录${RESET$2}`);
5021
5711
  console.log(`${TEXT$2}执行: npx ali-skills login${RESET$2}`);
5022
5712
  process.exit(1);
5023
5713
  }
@@ -5025,7 +5715,7 @@ async function sendGatewayRequest(targetUrl, platformKey, options, authMode = "g
5025
5715
  const responseBody = await response.text();
5026
5716
  const requestId = response.headers.get("X-Gateway-Request-Id");
5027
5717
  if (!options.quiet) {
5028
- const statusColor = response.ok ? GREEN$1 : RED$1;
5718
+ const statusColor = response.ok ? GREEN$1 : RED$2;
5029
5719
  console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
5030
5720
  if (requestId) console.log(`${DIM$2}Request ID: ${requestId}${RESET$2}`);
5031
5721
  if (options.includeHeaders) {
@@ -5054,12 +5744,13 @@ async function proxyRequest(targetUrl, options) {
5054
5744
  try {
5055
5745
  url = new URL(targetUrl);
5056
5746
  } catch {
5057
- console.error(`${RED$1}Error: 无效的 URL "${targetUrl}"${RESET$2}`);
5747
+ console.error(`${RED$2}Error: 无效的 URL "${targetUrl}"${RESET$2}`);
5058
5748
  process.exit(1);
5059
5749
  }
5060
5750
  const platformResult = detectPlatformWithKey(url.hostname);
5061
- if (!platformResult) {
5062
- console.error(`${RED$1}Error: 无法识别平台 "${url.hostname}"${RESET$2}`);
5751
+ const isAlibabaIncRootDomain = url.hostname.endsWith(".alibaba-inc.com") || url.hostname === "alibaba-inc.com";
5752
+ if (!platformResult && !isAlibabaIncRootDomain) {
5753
+ console.error(`${RED$2}Error: 无法识别平台 "${url.hostname}"${RESET$2}`);
5063
5754
  console.log(`${DIM$2}支持的平台:${RESET$2}`);
5064
5755
  console.log(`${DIM$2} - code.alibaba-inc.com (GitLab)${RESET$2}`);
5065
5756
  console.log(`${DIM$2} - aliyuque.antfin.com (语雀)${RESET$2}`);
@@ -5067,51 +5758,70 @@ async function proxyRequest(targetUrl, options) {
5067
5758
  console.log(`${DIM$2} - aone.alibaba-inc.com${RESET$2}`);
5068
5759
  process.exit(1);
5069
5760
  }
5070
- const { key: platformKey, config: platform } = platformResult;
5761
+ const platformKey = platformResult?.key || "alibaba-inc";
5762
+ const platform = platformResult?.config || {
5763
+ name: "Alibaba Inc Domain",
5764
+ host: "alibaba-inc.com",
5765
+ authType: "buc_sso_refresh",
5766
+ ssoType: "refresh_token"
5767
+ };
5071
5768
  if (!options.quiet) console.log(`${DIM$2}平台: ${platform.name}${RESET$2}`);
5072
5769
  const authMode = options.authMode === "auto" || !options.authMode ? detectAuthMode(platformKey, platform, url.hostname) : options.authMode;
5073
5770
  if (!options.quiet && authMode !== "auto") console.log(`${DIM$2}认证方式: ${getAuthModeDescription(authMode)}${RESET$2}`);
5074
5771
  try {
5772
+ if (platformKey === "o2") {
5773
+ if (authMode !== "auto" && authMode !== "sso_ticket") {
5774
+ console.error(`${RED$2}Error: o2 仅支持 --auth auto 或 --auth sso_ticket${RESET$2}`);
5775
+ process.exit(1);
5776
+ }
5777
+ await sendO2SdkRequest(targetUrl, options, authMode === "sso_ticket");
5778
+ return;
5779
+ }
5075
5780
  switch (authMode) {
5076
5781
  case "private_token": {
5077
- let token = getPlatformPrivateToken(platformKey, options.token);
5782
+ let token = getPlatformPrivateToken(platformKey, options.token, targetUrl);
5078
5783
  if (!token) {
5079
5784
  token = await promptConfigureToken(platformKey, platform);
5080
5785
  if (!token) {
5081
- console.error(`${RED$1}Error: ${platform.name} 需要配置 Private Token 才能访问${RESET$2}`);
5786
+ console.error(`${RED$2}Error: ${platform.name} 需要配置 Private Token 才能访问${RESET$2}`);
5082
5787
  console.log(`${DIM$2}您可以通过以下方式配置:${RESET$2}`);
5083
- console.log(` 1. 参数: --token <your_token>`);
5084
- console.log(` 2. 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5085
- console.log(` 3. 配置文件: npx ali-skills gateway config --platform ${platformKey}`);
5788
+ console.log(`${DIM$2} 【推荐】一次配置,持续使用:${RESET$2}`);
5789
+ console.log(` npx ali-skills login ${platformKey}`);
5790
+ console.log(`${DIM$2} 【临时】请求时传入:${RESET$2}`);
5791
+ console.log(` 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5792
+ console.log(` 参数: --token <your_token>`);
5086
5793
  process.exit(1);
5087
5794
  }
5088
5795
  }
5089
5796
  await sendDirectRequest(targetUrl, platform, token, options);
5090
5797
  break;
5091
5798
  }
5092
- case "app_code":
5093
- case "app_code+buc":
5094
- case "sso_cookie":
5095
5799
  case "sso_ticket":
5096
5800
  case "gateway":
5097
5801
  await sendGatewayRequest(targetUrl, platformKey, options, authMode);
5098
5802
  break;
5803
+ case "sso_cookie":
5804
+ await sendSsoCookieDirectRequest(targetUrl, options);
5805
+ break;
5099
5806
  default: if (platform.authType === "private_token") {
5100
- const token = getPlatformPrivateToken(platformKey, options.token);
5807
+ const token = getPlatformPrivateToken(platformKey, options.token, targetUrl);
5101
5808
  if (token) await sendDirectRequest(targetUrl, platform, token, options);
5102
5809
  else {
5103
- console.error(`${RED$1}Error: ${platform.name} 需要配置 Private Token${RESET$2}`);
5810
+ console.error(`${RED$2}Error: ${platform.name} 需要配置 Private Token${RESET$2}`);
5104
5811
  console.log(`${DIM$2}您可以通过以下方式配置:${RESET$2}`);
5105
- console.log(` 1. 参数: --token <your_token>`);
5106
- console.log(` 2. 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5107
- console.log(` 3. 配置文件: npx ali-skills gateway config --platform ${platformKey}`);
5812
+ console.log(`${DIM$2} 【推荐】一次配置,持续使用:${RESET$2}`);
5813
+ console.log(` npx ali-skills login ${platformKey}`);
5814
+ console.log(`${DIM$2} 【临时】请求时传入:${RESET$2}`);
5815
+ console.log(` 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5816
+ console.log(` 参数: --token <your_token>`);
5108
5817
  process.exit(1);
5109
5818
  }
5110
- } else await sendGatewayRequest(targetUrl, platformKey, options, "gateway");
5819
+ } else if (isAlibabaIncRootDomain) await sendSsoCookieDirectRequest(targetUrl, options);
5820
+ else await sendGatewayRequest(targetUrl, platformKey, options, "sso_ticket");
5111
5821
  }
5112
5822
  } catch (error) {
5113
- if (error instanceof Error) if (error.name === "AbortError") console.error(`${RED$1}Error: 请求超时${RESET$2}`);
5114
- else console.error(`${RED$1}Error: ${error.message}${RESET$2}`);
5823
+ if (error instanceof Error) if (error.name === "AbortError") console.error(`${RED$2}Error: 请求超时${RESET$2}`);
5824
+ else console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
5115
5825
  process.exit(1);
5116
5826
  }
5117
5827
  }
@@ -5127,47 +5837,43 @@ const TEXT$1 = "\x1B[38;5;145m";
5127
5837
  const RESET$1 = "\x1B[0m";
5128
5838
  const GREEN = "\x1B[32m";
5129
5839
  const YELLOW$1 = "\x1B[33m";
5130
- const RED = "\x1B[31m";
5131
- function showConfigHelp() {
5132
- console.log(`
5133
- ${TEXT$1}npx ali-skills config - 配置各平台访问凭证${RESET$1}
5134
-
5135
- ${DIM$1}Usage:${RESET$1}
5136
- npx ali-skills config <platform> 配置指定平台的 token
5137
- npx ali-skills config --list 列出已配置的平台
5138
- npx ali-skills config --remove <p> 移除指定平台的配置
5139
-
5140
- ${DIM$1}Supported Platforms:${RESET$1}`);
5141
- const platforms = listPlatforms();
5142
- const displayWidth = (str) => {
5143
- let width = 0;
5144
- for (const char of str) width += char.charCodeAt(0) > 127 ? 2 : 1;
5145
- return width;
5146
- };
5147
- const maxNameWidth = Math.max(...platforms.map(({ config }) => displayWidth(config.name)));
5148
- for (const { key, config } of platforms) {
5149
- const authType = config.authType === "private_token" ? "需配置 Token" : config.authType === "app_code" ? "内置凭证" : config.authType === "buc_sso_refresh" ? "需 BUC 登录" : "需 BUC 登录";
5150
- const namePadding = " ".repeat(15 - displayWidth(config.name) + maxNameWidth);
5151
- console.log(` ${key.padEnd(12)} ${config.name}${namePadding} ${DIM$1}${authType}${RESET$1}`);
5152
- }
5153
- console.log(`
5154
- ${DIM$1}Examples:${RESET$1}
5155
- npx ali-skills config code
5156
- npx ali-skills config yuque
5157
- npx ali-skills config --list
5158
- npx ali-skills config --remove code
5159
- `);
5840
+ const RED$1 = "\x1B[31m";
5841
+ function maskToken(token) {
5842
+ if (token.length <= 4) return "****";
5843
+ return `****${token.slice(-4)}`;
5160
5844
  }
5161
- async function prompt(question, defaultValue) {
5845
+ const AVAILABLE_PLATFORMS = listPlatforms().map(({ key }) => key).join(", ");
5846
+ async function promptLine(question) {
5162
5847
  const rl = (await import("readline")).createInterface({
5163
5848
  input: process.stdin,
5164
5849
  output: process.stdout
5165
5850
  });
5166
5851
  return new Promise((resolve) => {
5167
- const fullQuestion = defaultValue ? `${question} (默认: ${defaultValue}): ` : `${question}: `;
5168
- rl.question(fullQuestion, (answer) => {
5852
+ rl.question(question, (answer) => {
5169
5853
  rl.close();
5170
- resolve(answer.trim() || defaultValue || "");
5854
+ resolve(answer.trim());
5855
+ });
5856
+ });
5857
+ }
5858
+ async function promptSecret(question) {
5859
+ const rl = (await import("readline")).createInterface({
5860
+ input: process.stdin,
5861
+ output: process.stdout,
5862
+ terminal: true
5863
+ });
5864
+ return new Promise((resolve) => {
5865
+ const fullQuestion = `${question}: `;
5866
+ const writable = rl;
5867
+ process.stdout.write(fullQuestion);
5868
+ writable._writeToOutput = (chunk) => {
5869
+ if (chunk === "\r" || chunk === "\n" || chunk === "\r\n") return;
5870
+ const visible = chunk.replace(/\u001b\[[0-9;]*[A-Za-z]/g, "").replace(/[\u0000-\u001f\u007f]/g, "");
5871
+ if (visible.length > 0) process.stdout.write("*".repeat(visible.length));
5872
+ };
5873
+ rl.question("", (answer) => {
5874
+ process.stdout.write("\n");
5875
+ rl.close();
5876
+ resolve(answer.trim());
5171
5877
  });
5172
5878
  });
5173
5879
  }
@@ -5179,109 +5885,185 @@ async function openBrowser(url) {
5179
5885
  stdio: "ignore"
5180
5886
  });
5181
5887
  }
5182
- async function configurePlatform(platformKey) {
5888
+ async function configurePlatform(platformKey, yuqueGroupArg) {
5183
5889
  const platform = getPlatform(platformKey);
5184
5890
  if (!platform) {
5185
- console.error(`${RED}Error: 不支持的平台 "${platformKey}"${RESET$1}`);
5186
- console.log(`${DIM$1}运行 'npx ali-skills config --list' 查看支持的平台${RESET$1}`);
5891
+ console.error(`${RED$1}Error: 不支持的平台 "${platformKey}"${RESET$1}`);
5892
+ console.log(`${DIM$1}支持的平台: ${AVAILABLE_PLATFORMS}${RESET$1}`);
5893
+ console.log(`${DIM$1}示例: npx ali-skills login code${RESET$1}`);
5187
5894
  process.exit(1);
5188
5895
  }
5189
- console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
5190
- console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5191
5896
  switch (platform.authType) {
5192
5897
  case "private_token":
5193
- await configurePrivateToken(platformKey, platform);
5898
+ if (platformKey === "yuque") await configureYuque(yuqueGroupArg);
5899
+ else await configurePrivateToken(platformKey, platform);
5194
5900
  break;
5195
5901
  case "app_code":
5902
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
5903
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5196
5904
  console.log(`${GREEN}✓ ${platform.name} 使用内置凭证,无需配置${RESET$1}`);
5197
5905
  break;
5198
5906
  case "app_code+buc":
5199
- console.log(`${YELLOW$1}! ${platform.name} 需要 BUC 登录${RESET$1}`);
5200
- console.log(`${DIM$1}请运行: npx ali-skills login${RESET$1}`);
5907
+ if (platformKey === "o2") showO2LoginStatus();
5908
+ else {
5909
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
5910
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5911
+ console.log(`${YELLOW$1}! ${platform.name} 需要 BUC 登录${RESET$1}`);
5912
+ console.log(`${DIM$1}请运行: npx ali-skills login${RESET$1}`);
5913
+ }
5201
5914
  break;
5202
5915
  case "buc_sso_refresh":
5203
5916
  case "buc_sso_ticket":
5917
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
5918
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5204
5919
  console.log(`${YELLOW$1}! ${platform.name} 需要 BUC 登录${RESET$1}`);
5205
5920
  console.log(`${DIM$1}请运行: npx ali-skills login${RESET$1}`);
5206
5921
  break;
5207
5922
  default:
5208
- console.error(`${RED}Error: 未知的认证类型${RESET$1}`);
5923
+ console.error(`${RED$1}Error: 未知的认证类型${RESET$1}`);
5209
5924
  process.exit(1);
5210
5925
  }
5211
5926
  }
5927
+ function showO2LoginStatus() {
5928
+ const auth = readAuth();
5929
+ const isLoggedIn = Boolean(auth) && !isAuthExpired(auth);
5930
+ console.log(`${TEXT$1}配置 O2 平台${RESET$1}`);
5931
+ console.log(`${DIM$1}认证方式: 内置服务调用身份${RESET$1}`);
5932
+ if (isLoggedIn) {
5933
+ console.log(`${GREEN}✓ 当前 BUC 登录态有效${RESET$1}`);
5934
+ console.log(`${DIM$1}调用需 BUC 的 O2 接口时,将自动换取 SSO_TICKET${RESET$1}`);
5935
+ return;
5936
+ }
5937
+ console.log(`${YELLOW$1}! 当前未登录 BUC${RESET$1}`);
5938
+ console.log(`${DIM$1}请先执行: npx ali-skills login${RESET$1}`);
5939
+ }
5940
+ function assertValidYuqueTeamSlug(raw) {
5941
+ const slug = raw.trim();
5942
+ if (!slug) {
5943
+ console.error(`${RED$1}Error: 团队名称不能为空${RESET$1}`);
5944
+ process.exit(1);
5945
+ }
5946
+ if (slug.length > 128 || /[/\s]/.test(slug) || slug.includes("..")) {
5947
+ console.error(`${RED$1}Error: 团队名称不能包含空格、斜杠等非法字符${RESET$1}`);
5948
+ process.exit(1);
5949
+ }
5950
+ if (!/^[a-zA-Z0-9_-]+$/.test(slug)) {
5951
+ console.error(`${RED$1}Error: 团队名称仅允许字母、数字、连字符与下划线${RESET$1}`);
5952
+ process.exit(1);
5953
+ }
5954
+ return slug;
5955
+ }
5956
+ async function configureYuque(groupArg) {
5957
+ const platformName = "语雀";
5958
+ console.log(`${TEXT$1}配置 ${platformName}${RESET$1}`);
5959
+ console.log(`${DIM$1}认证方式: 团队 Group Access Token${RESET$1}`);
5960
+ console.log();
5961
+ const teamSlug = assertValidYuqueTeamSlug(groupArg ?? await promptLine(`${TEXT$1}请输入团队名称${RESET$1}(语雀 URL 中域名后的第一段,例如 ${DIM$1}fliggyfe-infra${RESET$1})\n${DIM$1}>${RESET$1} `));
5962
+ const existingGroupToken = readConfig().platforms?.yuque?.groups?.[teamSlug]?.privateToken?.trim();
5963
+ if (existingGroupToken) {
5964
+ setYuqueDefaultGroup(teamSlug);
5965
+ console.log(`${YELLOW$1}! 团队 ${teamSlug} 已配置 Group Access Token:${maskToken(existingGroupToken)}${RESET$1}`);
5966
+ console.log(`${DIM$1}如需重新配置,请先执行: npx ali-skills logout yuque ${teamSlug}${RESET$1}`);
5967
+ console.log();
5968
+ console.log(`${GREEN}✓ 已将默认分组切换为 ${teamSlug}${RESET$1}`);
5969
+ return;
5970
+ }
5971
+ const docUrl = getYuqueGroupTokenDocUrl(teamSlug);
5972
+ console.log(`${DIM$1}1. 正在打开团队 Token 页面...${RESET$1}`);
5973
+ console.log(`${DIM$1} ${docUrl}${RESET$1}`);
5974
+ await openBrowser(docUrl);
5975
+ console.log();
5976
+ console.log(`${DIM$1}2. 在浏览器中创建 Group Access Token,将完整 token 粘贴到下方${RESET$1}`);
5977
+ const token = await promptSecret("Group Access Token");
5978
+ if (!token) {
5979
+ console.error(`${RED$1}Error: Token 不能为空${RESET$1}`);
5980
+ process.exit(1);
5981
+ }
5982
+ if (/\s/.test(token)) {
5983
+ console.error(`${RED$1}Error: Token 中不能包含空格或换行,请重新粘贴${RESET$1}`);
5984
+ process.exit(1);
5985
+ }
5986
+ const tail = token.slice(-4);
5987
+ console.log(`${DIM$1}已读取 Group Access Token(长度 ${token.length},尾号 ${tail})${RESET$1}`);
5988
+ setYuqueGroupAccessToken(teamSlug, token);
5989
+ console.log();
5990
+ console.log(`${GREEN}✓ ${platformName} 团队 ${teamSlug} 的 Token 已保存${RESET$1}`);
5991
+ console.log(`${GREEN}✓ 已将默认分组切换为 ${teamSlug}${RESET$1}`);
5992
+ console.log(`${DIM$1}配置文件: ${getConfigFilePath()}${RESET$1}`);
5993
+ }
5212
5994
  async function configurePrivateToken(platformKey, platform) {
5213
5995
  if (!platform.tokenDocUrl) {
5214
- console.error(`${RED}Error: 未找到 ${platform.name} 的 token 文档地址${RESET$1}`);
5996
+ console.error(`${RED$1}Error: 未找到 ${platform.name} 的 token 文档地址${RESET$1}`);
5215
5997
  process.exit(1);
5216
5998
  }
5999
+ const existingToken = readConfig().platforms?.[platformKey]?.privateToken?.trim();
6000
+ if (existingToken) {
6001
+ const platformName = platform.name.includes("(") ? platform.name.split("(")[0]?.trim() || platform.name : platform.name;
6002
+ console.log(`${YELLOW$1}! 您已经配置了 ${platformName} 平台的 Private Token:${maskToken(existingToken)}${RESET$1}`);
6003
+ console.log();
6004
+ console.log(`${DIM$1}如需重新配置,请先执行: npx ali-skills logout ${platformKey}${RESET$1}`);
6005
+ return;
6006
+ }
6007
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
6008
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5217
6009
  console.log();
5218
6010
  console.log(`${DIM$1}1. 正在打开 ${platform.name} Token 页面...${RESET$1}`);
5219
6011
  console.log(`${DIM$1} ${platform.tokenDocUrl}${RESET$1}`);
5220
6012
  await openBrowser(platform.tokenDocUrl);
5221
6013
  console.log();
5222
- console.log(`${DIM$1}2. 请在浏览器中创建 Access Token,然后复制到这里${RESET$1}`);
5223
- const token = await prompt("Access Token");
6014
+ console.log(`${DIM$1}2. 请在浏览器中创建 Private Token,然后复制到这里${RESET$1}`);
6015
+ const token = await promptSecret("Private Token");
5224
6016
  if (!token) {
5225
- console.error(`${RED}Error: Token 不能为空${RESET$1}`);
6017
+ console.error(`${RED$1}Error: Token 不能为空${RESET$1}`);
5226
6018
  process.exit(1);
5227
6019
  }
6020
+ if (/\s/.test(token)) {
6021
+ console.error(`${RED$1}Error: Token 中不能包含空格或换行,请重新粘贴${RESET$1}`);
6022
+ process.exit(1);
6023
+ }
6024
+ const tail = token.slice(-4);
6025
+ console.log(`${DIM$1}已读取 Private Token(长度 ${token.length},尾号 ${tail})${RESET$1}`);
5228
6026
  setPlatformToken(platformKey, { privateToken: token });
5229
6027
  console.log();
5230
6028
  console.log(`${GREEN}✓ ${platform.name} Token 已保存${RESET$1}`);
5231
6029
  console.log(`${DIM$1}配置文件: ${getConfigFilePath()}${RESET$1}`);
5232
6030
  }
5233
- function listConfigured() {
5234
- const config = readConfig();
5235
- const platforms = Object.entries(config.platforms);
5236
- if (platforms.length === 0) {
5237
- console.log(`${DIM$1}尚未配置任何平台${RESET$1}`);
5238
- console.log(`${TEXT$1}运行 'npx ali-skills config <platform>' 开始配置${RESET$1}`);
5239
- return;
6031
+ async function runPlatformLogin(platformArgs) {
6032
+ if (platformArgs.length === 0) {
6033
+ console.error(`${RED$1}Error: 请指定平台${RESET$1}`);
6034
+ console.log(`${DIM$1}支持的平台: ${AVAILABLE_PLATFORMS}${RESET$1}`);
6035
+ console.log(`${DIM$1}示例: npx ali-skills login code${RESET$1}`);
6036
+ process.exit(1);
5240
6037
  }
5241
- console.log(`${TEXT$1}已配置的平台:${RESET$1}`);
5242
- for (const [key, token] of platforms) {
5243
- const name = getPlatform(key)?.name || key;
5244
- const hasToken = token.privateToken ? "✓" : "✗";
5245
- console.log(` ${hasToken} ${name} (${key})`);
6038
+ const platform = platformArgs[0];
6039
+ if (!platform) {
6040
+ console.error(`${RED$1}Error: 请指定平台${RESET$1}`);
6041
+ process.exit(1);
5246
6042
  }
5247
- }
5248
- function removePlatform(platformKey) {
5249
- const name = getPlatform(platformKey)?.name || platformKey;
5250
- removePlatformToken(platformKey);
5251
- console.log(`${GREEN}✓ 已移除 ${name} 的配置${RESET$1}`);
5252
- }
5253
- async function runConfig(args) {
5254
- if (args.length === 0) {
5255
- showConfigHelp();
5256
- return;
6043
+ if (platform.startsWith("-")) {
6044
+ console.error(`${RED$1}Error: 未知选项 "${platform}"${RESET$1}`);
6045
+ process.exit(1);
5257
6046
  }
5258
- const command = args[0];
5259
- switch (command) {
5260
- case "--help":
5261
- case "-h":
5262
- showConfigHelp();
5263
- break;
5264
- case "--list":
5265
- case "-l":
5266
- listConfigured();
5267
- break;
5268
- case "--remove":
5269
- case "-r": {
5270
- const platform = args[1];
5271
- if (!platform) {
5272
- console.error(`${RED}Error: 请指定要移除的平台${RESET$1}`);
5273
- process.exit(1);
5274
- }
5275
- removePlatform(platform);
5276
- break;
5277
- }
5278
- default: if (!command.startsWith("-")) await configurePlatform(command);
5279
- else {
5280
- console.error(`${RED}Error: 未知选项 "${command}"${RESET$1}`);
5281
- showConfigHelp();
6047
+ if (platformArgs.length > 1) {
6048
+ const invalidOption = platformArgs.slice(1).find((arg) => arg.startsWith("-"));
6049
+ if (invalidOption) {
6050
+ if (invalidOption === "--force" || invalidOption === "-f") {
6051
+ console.error(`${RED$1}Error: 不再支持 ${invalidOption}${RESET$1}`);
6052
+ console.log(`${DIM$1}请先执行: npx ali-skills logout ${platform},再重新配置${RESET$1}`);
6053
+ } else console.error(`${RED$1}Error: 未知选项 "${invalidOption}"${RESET$1}`);
5282
6054
  process.exit(1);
5283
6055
  }
5284
6056
  }
6057
+ const extraArgs = platformArgs.slice(1).filter(Boolean);
6058
+ if (platform !== "yuque" && extraArgs.length > 0) {
6059
+ console.error(`${RED$1}Error: login ${platform} 不支持额外参数${RESET$1}`);
6060
+ process.exit(1);
6061
+ }
6062
+ if (platform === "yuque" && extraArgs.length > 1) {
6063
+ console.error(`${RED$1}Error: login yuque 仅支持一个团队参数,例如: npx ali-skills login yuque fliggy${RESET$1}`);
6064
+ process.exit(1);
6065
+ }
6066
+ await configurePlatform(platform, platform === "yuque" ? extraArgs[0] : void 0);
5285
6067
  }
5286
6068
  function getUpdateComparisonStrategy(entry) {
5287
6069
  if (entry.sourceType === "internal") return {
@@ -5309,6 +6091,7 @@ const BOLD = "\x1B[1m";
5309
6091
  const DIM = "\x1B[38;5;102m";
5310
6092
  const TEXT = "\x1B[38;5;145m";
5311
6093
  const YELLOW = "\x1B[33m";
6094
+ const RED = "\x1B[31m";
5312
6095
  function isTruthyEnv(value) {
5313
6096
  if (!value) return false;
5314
6097
  const normalized = value.trim().toLowerCase();
@@ -5396,6 +6179,12 @@ ${BOLD}Project:${RESET}
5396
6179
  init [name] Initialize a skill (creates <name>/SKILL.md or ./SKILL.md)
5397
6180
  experimental_sync Sync skills from node_modules into agent directories
5398
6181
 
6182
+ ${BOLD}Gateway:${RESET}
6183
+ gateway 鉴权请求能力入口(login/logout/status/req)
6184
+ 支持 privateToken/accessKey 身份托管请求(code、yuque、o2)
6185
+ 支持基于 BUC SSO 的鉴权请求(sso_cookie / sso_ticket)
6186
+ 详细用法请执行: ali-skills gateway -h
6187
+
5399
6188
  ${BOLD}Add Options:${RESET}
5400
6189
  -g, --global Install skill globally (user-level) instead of project-level
5401
6190
  -a, --agent <agents> Specify agents to install to (use '*' for all agents)
@@ -5486,23 +6275,30 @@ Discover more skills at ${TEXT}https://ali-skills.alibaba-inc.com/${RESET}
5486
6275
  `);
5487
6276
  }
5488
6277
  function showGatewayHelp() {
6278
+ listPlatforms().map((p) => p.key).join(", ");
6279
+ const platformKeysForHelp = listPlatforms().filter((p) => p.key !== "aone").map((p) => p.key).join(", ");
5489
6280
  console.log(`
5490
6281
  ${BOLD}Gateway Commands:${RESET}
5491
- login Login to Gateway (BUC OAuth)
5492
- logout Logout from Gateway
5493
- status Show login status
5494
- request <url> Send HTTP request via Gateway proxy
5495
- req <url> Alias for request
6282
+ login [platform] Login to Gateway or configure platform token
6283
+ logout [platform] Logout BUC or clear platform token
6284
+ status [platform] [--all] Show login status, single platform, or all platform statuses
6285
+ request [platform] <url|path> Send HTTP request (supports platform + path shorthand)
6286
+ req [platform] <url|path> Alias for request, recommended
5496
6287
 
5497
- ${BOLD}Config Commands:${RESET}
5498
- config <platform> Configure platform token
5499
- config --list List configured platforms
5500
- config --remove <p> Remove platform config
6288
+ ${BOLD}Yuque Commands:${RESET}
6289
+ login yuque [group] Configure/switch specified Yuque group directly
6290
+ logout yuque [group] [--all] Choose one/many Yuque groups to clear, or clear all
6291
+ status yuque [group] [--show|-s] [--pretty] Show Yuque group/all config JSON
6292
+
6293
+ ${BOLD}Platform Values:${RESET}
6294
+ ${platformKeysForHelp}
5501
6295
 
5502
6296
  ${BOLD}Request Options:${RESET}
5503
6297
  -X, --method <method> HTTP method (default: GET)
5504
6298
  -b, --body <body> Request body (JSON string or @file)
5505
6299
  -h, --header <header> Custom header (can be used multiple times)
6300
+ --auth, --auth-mode <mode> Auth mode: auto/private_token/sso_cookie/sso_ticket
6301
+ --token <token> Explicit token for private_token mode
5506
6302
  -o, --output <file> Save response to file
5507
6303
  -i, --include-headers Include response headers in output
5508
6304
  -t, --timeout <ms> Request timeout (default: 30000)
@@ -5510,13 +6306,35 @@ ${BOLD}Request Options:${RESET}
5510
6306
  --raw Raw output without formatting
5511
6307
  -q, --quiet Quiet mode, only output response body
5512
6308
 
6309
+ ${BOLD}Environment:${RESET}
6310
+ ALI_SKILLS_YUQUE_GROUP Yuque team slug when multiple teams have tokens in config
6311
+ O2_API_ENV O2 SDK env override (default online; set pre for pre env)
6312
+ ALI_SKILLS_DEBUG_GATEWAY Enable gateway auth debug logs (1/true/on)
6313
+
5513
6314
  ${BOLD}Examples:${RESET}
5514
6315
  ${DIM}$${RESET} ali-skills login
5515
- ${DIM}$${RESET} ali-skills config code
5516
- ${DIM}$${RESET} ali-skills config yuque
5517
- ${DIM}$${RESET} ali-skills req https://o2.alibaba-inc.com/api/v2/apps
6316
+ ${DIM}$${RESET} ali-skills login code
6317
+ ${DIM}$${RESET} ali-skills login yuque
6318
+ ${DIM}$${RESET} ali-skills login yuque fliggy
6319
+ ${DIM}$${RESET} ali-skills status --all
6320
+ ${DIM}$${RESET} ali-skills status code
6321
+ ${DIM}$${RESET} ali-skills status -s
6322
+ ${DIM}$${RESET} ali-skills status -s --pretty
6323
+ ${DIM}$${RESET} ali-skills status code --show
6324
+ ${DIM}$${RESET} ali-skills status yuque --show
6325
+ ${DIM}$${RESET} ali-skills status yuque fliggy
6326
+ ${DIM}$${RESET} ali-skills status yuque fliggy --show
6327
+ ${DIM}$${RESET} ali-skills logout code
6328
+ ${DIM}$${RESET} ali-skills logout yuque
6329
+ ${DIM}$${RESET} ali-skills logout yuque my-team
6330
+ ${DIM}$${RESET} ali-skills logout yuque --all
6331
+ ${DIM}$${RESET} ali-skills req o2 /v1.0/work/apps
6332
+ ${DIM}$${RESET} ali-skills req o2 /v1.0/work/aone/issues/search -X POST -b '{"keyword":"auth"}'
6333
+ ${DIM}$${RESET} ali-skills req o2 /v1.0/work/issues/123 --auth sso_ticket
5518
6334
  ${DIM}$${RESET} ali-skills req https://code.alibaba-inc.com/api/v4/projects -X GET
5519
- ${DIM}$${RESET} ali-skills req https://aliyuque.antfin.com/api/v2/repos -o repos.json
6335
+ ${DIM}$${RESET} ali-skills req https://yuque-api.antfin-inc.com/api/v2/repos -o repos.json
6336
+ ${DIM}$${RESET} ali-skills req yuque "/api/v2/search?q=buc&type=doc"
6337
+ ${DIM}$${RESET} ali-skills req yuque "/api/v2/search?q=buc&type=doc&scope=fliggyfe-infra"
5520
6338
  ${DIM}$${RESET} ali-skills logout
5521
6339
  `);
5522
6340
  }
@@ -5553,21 +6371,30 @@ function parseRequestOptions(args) {
5553
6371
  options.includeHeaders = true;
5554
6372
  break;
5555
6373
  case "-t":
5556
- case "--timeout":
5557
- options.timeout = parseInt(args[++i], 10);
6374
+ case "--timeout": {
6375
+ const timeoutValue = args[++i];
6376
+ if (timeoutValue) options.timeout = parseInt(timeoutValue, 10);
5558
6377
  break;
6378
+ }
5559
6379
  case "--pretty":
5560
6380
  options.pretty = true;
5561
6381
  break;
5562
6382
  case "--raw":
5563
6383
  options.raw = true;
5564
6384
  break;
6385
+ case "--auth-mode":
6386
+ case "--auth":
6387
+ options.authMode = args[++i] ?? "auto";
6388
+ break;
6389
+ case "--token":
6390
+ options.token = args[++i];
6391
+ break;
5565
6392
  case "-q":
5566
6393
  case "--quiet":
5567
6394
  options.quiet = true;
5568
6395
  break;
5569
6396
  default:
5570
- if (!arg.startsWith("-") && !url) url = arg;
6397
+ if (arg && !arg.startsWith("-") && !url) url = arg;
5571
6398
  break;
5572
6399
  }
5573
6400
  }
@@ -5578,6 +6405,105 @@ function parseRequestOptions(args) {
5578
6405
  options
5579
6406
  };
5580
6407
  }
6408
+ function expandRequestShorthand(args) {
6409
+ if (args.length < 2) return args;
6410
+ const platformArg = args[0];
6411
+ const pathArg = args[1];
6412
+ if (!platformArg || !pathArg) return args;
6413
+ if (platformArg.startsWith("-") || pathArg.startsWith("-")) return args;
6414
+ if (/^https?:\/\//i.test(pathArg)) return args;
6415
+ const platform = listPlatforms().find(({ key, config }) => key === platformArg || config.aliases?.includes(platformArg));
6416
+ if (!platform) return args;
6417
+ const normalizedPath = pathArg.startsWith("/") ? pathArg : `/${pathArg}`;
6418
+ return [`https://${platform.key === "yuque" ? "yuque-api.antfin-inc.com" : platform.config.host}${normalizedPath}`, ...args.slice(2)];
6419
+ }
6420
+ function parseStatusArgs(args) {
6421
+ const showPrivateTokenFlags = new Set(["--show", "-s"]);
6422
+ const positionals = [];
6423
+ let showAll = false;
6424
+ let showPrivateToken = false;
6425
+ let prettyJson = false;
6426
+ for (const raw of args) {
6427
+ if (raw === "--all") {
6428
+ showAll = true;
6429
+ continue;
6430
+ }
6431
+ if (raw === "--pretty") {
6432
+ prettyJson = true;
6433
+ continue;
6434
+ }
6435
+ if (showPrivateTokenFlags.has(raw)) {
6436
+ showPrivateToken = true;
6437
+ continue;
6438
+ }
6439
+ if (raw.startsWith("-")) {
6440
+ console.error(`Unknown option for status: ${raw}`);
6441
+ process.exit(1);
6442
+ }
6443
+ positionals.push(raw);
6444
+ }
6445
+ if (positionals.length > 2) {
6446
+ console.error(`${YELLOW}status 参数过多,期望: [--show|-s]、[platform]、[platform] [--show|-s]、[yuque] [group] [--show|-s] 或 --all${RESET}`);
6447
+ process.exit(1);
6448
+ }
6449
+ const platform = positionals[0];
6450
+ const yuqueGroup = positionals[1];
6451
+ if (yuqueGroup) {
6452
+ if (platform !== "yuque") {
6453
+ console.error(`${RED}仅语雀支持第二个参数(group),例如: npx ali-skills status yuque fliggy --show${RESET}`);
6454
+ process.exit(1);
6455
+ }
6456
+ if (showAll) {
6457
+ console.error(`${RED}status yuque <group> 不能与 --all 同时使用${RESET}`);
6458
+ process.exit(1);
6459
+ }
6460
+ }
6461
+ return {
6462
+ platform,
6463
+ yuqueGroup,
6464
+ showAll,
6465
+ prettyJson,
6466
+ showPrivateToken
6467
+ };
6468
+ }
6469
+ function parseLogoutArgs(args) {
6470
+ if (args.length === 0) return {};
6471
+ const clearAll = args.includes("--all");
6472
+ const bad = args.find((a) => a.startsWith("-") && a !== "--all");
6473
+ if (bad) {
6474
+ console.error(`Unknown option for logout: ${bad}`);
6475
+ process.exit(1);
6476
+ }
6477
+ const [platform, maybeGroup, ...rest] = args.filter((a) => a !== "--all");
6478
+ if (!platform) return {};
6479
+ if (rest.length > 0) {
6480
+ console.error(`${YELLOW}logout 参数过多${RESET}`);
6481
+ process.exit(1);
6482
+ }
6483
+ if (clearAll && platform.toLowerCase() !== "yuque") {
6484
+ console.error(`${RED}仅语雀支持 --all,例如: npx ali-skills logout yuque --all${RESET}`);
6485
+ process.exit(1);
6486
+ }
6487
+ if (maybeGroup) {
6488
+ if (platform.toLowerCase() !== "yuque") {
6489
+ console.error(`${RED}仅语雀支持第二个参数(团队 slug),例如: npx ali-skills logout yuque my-team${RESET}`);
6490
+ process.exit(1);
6491
+ }
6492
+ if (clearAll) {
6493
+ console.error(`${RED}logout yuque <团队> 不能与 --all 同时使用${RESET}`);
6494
+ process.exit(1);
6495
+ }
6496
+ return {
6497
+ platform,
6498
+ yuqueGroup: maybeGroup,
6499
+ clearAll
6500
+ };
6501
+ }
6502
+ return {
6503
+ platform,
6504
+ clearAll
6505
+ };
6506
+ }
5581
6507
  async function runGatewayCommand(args) {
5582
6508
  if (args.length === 0) {
5583
6509
  showGatewayHelp();
@@ -5591,11 +6517,13 @@ async function runGatewayCommand(args) {
5591
6517
  console.log();
5592
6518
  await login();
5593
6519
  break;
5594
- case "logout":
5595
- await logout();
6520
+ case "logout": {
6521
+ const lo = parseLogoutArgs(rest);
6522
+ await logout(lo.platform, lo.yuqueGroup, lo.clearAll);
5596
6523
  break;
6524
+ }
5597
6525
  case "status":
5598
- await status();
6526
+ await status(parseStatusArgs(rest));
5599
6527
  break;
5600
6528
  case "token": {
5601
6529
  const token = getPrivateToken();
@@ -5608,7 +6536,7 @@ async function runGatewayCommand(args) {
5608
6536
  }
5609
6537
  case "request":
5610
6538
  case "req": {
5611
- const { url, options } = parseRequestOptions(rest);
6539
+ const { url, options } = parseRequestOptions(expandRequestShorthand(rest));
5612
6540
  if (!url) {
5613
6541
  console.error("Error: URL is required");
5614
6542
  showGatewayHelp();
@@ -6231,11 +7159,6 @@ async function main() {
6231
7159
  console.log();
6232
7160
  runInit(restArgs);
6233
7161
  break;
6234
- case "config":
6235
- showLogo();
6236
- console.log();
6237
- await runConfig(restArgs);
6238
- break;
6239
7162
  case "experimental_install":
6240
7163
  showLogo();
6241
7164
  await runInstallFromLock(restArgs);
@@ -6251,7 +7174,7 @@ async function main() {
6251
7174
  }
6252
7175
  case "remove":
6253
7176
  case "rm":
6254
- case "r":
7177
+ case "r": {
6255
7178
  if (restArgs.includes("--help") || restArgs.includes("-h")) {
6256
7179
  showRemoveHelp();
6257
7180
  break;
@@ -6259,6 +7182,7 @@ async function main() {
6259
7182
  const { skills, options: removeOptions } = parseRemoveOptions(restArgs);
6260
7183
  await removeCommand(skills, removeOptions);
6261
7184
  break;
7185
+ }
6262
7186
  case "experimental_sync": {
6263
7187
  showLogo();
6264
7188
  const { options: syncOptions } = parseSyncOptions(restArgs);
@@ -6280,17 +7204,20 @@ async function main() {
6280
7204
  await runCheck(restArgs);
6281
7205
  break;
6282
7206
  case "login":
6283
- await login();
7207
+ if (restArgs.length > 0) await runPlatformLogin(restArgs);
7208
+ else await login();
6284
7209
  break;
6285
- case "logout":
6286
- await logout();
7210
+ case "logout": {
7211
+ const lo = parseLogoutArgs(restArgs);
7212
+ await logout(lo.platform, lo.yuqueGroup, lo.clearAll);
6287
7213
  break;
7214
+ }
6288
7215
  case "status":
6289
- await status();
7216
+ await status(parseStatusArgs(restArgs));
6290
7217
  break;
6291
7218
  case "req":
6292
7219
  case "request": {
6293
- const { url, options } = parseRequestOptions(restArgs);
7220
+ const { url, options } = parseRequestOptions(expandRequestShorthand(restArgs));
6294
7221
  if (!url) {
6295
7222
  console.error("Error: URL is required");
6296
7223
  showGatewayHelp();