ali-skills 0.0.21 → 0.0.23

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 +1410 -316
  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.23";
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;
@@ -4869,35 +5373,154 @@ function openBrowser$1(url) {
4869
5373
  stdio: "ignore"
4870
5374
  });
4871
5375
  }
5376
+ const REDIRECT_STATUS_CODES = new Set([
5377
+ 301,
5378
+ 302,
5379
+ 303,
5380
+ 307,
5381
+ 308
5382
+ ]);
5383
+ const MAX_REDIRECTS = 5;
4872
5384
  function detectAuthMode(platformKey, platform, hostname) {
4873
5385
  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";
5386
+ if (platformKey === "o2") return "auto";
4876
5387
  if (hostname.endsWith(".alibaba-inc.com") || hostname === "alibaba-inc.com") return "sso_cookie";
4877
5388
  return "sso_ticket";
4878
5389
  }
4879
5390
  function getAuthModeDescription(mode) {
4880
5391
  switch (mode) {
4881
5392
  case "private_token": return "Private Token";
4882
- case "app_code": return "App Code";
4883
- case "app_code+buc": return "App Code + BUC SSO";
4884
5393
  case "sso_cookie": return "SSO Cookie (REFRESH_TOKEN)";
4885
5394
  case "sso_ticket": return "SSO Ticket";
4886
5395
  case "gateway": return "Gateway Proxy";
4887
5396
  default: return "Auto";
4888
5397
  }
4889
5398
  }
4890
- function getPlatformPrivateToken(platformKey, explicitToken) {
5399
+ const O2_CREDENTIALS_BASE64 = "eyJhY2Nlc3NLZXlJZCI6IlNZS2NFNWtrbHhtT1M3WjJYYXRObiIsImFjY2Vzc0tleVNlY3JldCI6IjQ2NGNhYTc0MmNiYTk2NzFkZjM5NzJkYzdhNWI3MmQ1Nzk5ZTc2NTQyYzRiZGFjM2M3YTk5N2QzMDM3YTIyNzAifQ==";
5400
+ function getO2Credentials() {
5401
+ const accessKeyId = process.env.O2_ACCESS_KEY_ID?.trim();
5402
+ const accessKeySecret = process.env.O2_ACCESS_KEY_SECRET?.trim();
5403
+ if (accessKeyId && accessKeySecret) return {
5404
+ accessKeyId,
5405
+ accessKeySecret
5406
+ };
5407
+ return JSON.parse(Buffer.from(O2_CREDENTIALS_BASE64, "base64").toString("utf-8"));
5408
+ }
5409
+ function getO2ApiEnv() {
5410
+ const env = process.env.O2_API_ENV?.trim();
5411
+ if (!env) return void 0;
5412
+ return env;
5413
+ }
5414
+ function searchParamsToObject(searchParams) {
5415
+ const out = {};
5416
+ searchParams.forEach((value, key) => {
5417
+ const prev = out[key];
5418
+ if (prev === void 0) {
5419
+ out[key] = value;
5420
+ return;
5421
+ }
5422
+ out[key] = Array.isArray(prev) ? [...prev, value] : [prev, value];
5423
+ });
5424
+ return out;
5425
+ }
5426
+ function parseBodyAsJsonObject(body) {
5427
+ if (!body) return {};
5428
+ const parsed = JSON.parse(body);
5429
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("O2 请求 body 仅支持 JSON 对象");
5430
+ return parsed;
5431
+ }
5432
+ async function sendO2SdkRequest(targetUrl, options, withSsoTicket) {
5433
+ const parsed = new URL(targetUrl);
5434
+ const path = parsed.pathname;
5435
+ const query = searchParamsToObject(parsed.searchParams);
5436
+ const headers = { ...options.headers ?? {} };
5437
+ if (withSsoTicket) {
5438
+ const ssoTicket = await ensureSsoTicket();
5439
+ if (!ssoTicket) throw new Error("无法获取 SSO_TICKET,请重新登录后重试");
5440
+ headers.SSO_TICKET = ssoTicket;
5441
+ }
5442
+ let O2ClientCtor;
5443
+ try {
5444
+ const mod = await import("@ali/o2-open-client");
5445
+ const defaultExport = mod.default;
5446
+ O2ClientCtor = mod.O2Client ?? (typeof defaultExport === "function" ? defaultExport : defaultExport?.O2Client);
5447
+ if (!O2ClientCtor) throw new Error("未找到 O2Client 导出");
5448
+ } catch (error) {
5449
+ throw new Error(`未安装 @ali/o2-open-client 或导入失败: ${error.message}`);
5450
+ }
5451
+ const { accessKeyId, accessKeySecret } = getO2Credentials();
5452
+ const o2Env = getO2ApiEnv();
5453
+ const client = new O2ClientCtor({
5454
+ accessKeyId,
5455
+ accessKeySecret,
5456
+ ...o2Env ? { env: o2Env } : {}
5457
+ });
5458
+ const method = options.method.toUpperCase();
5459
+ const bodyObj = parseBodyAsJsonObject(options.body);
5460
+ if (!options.quiet) {
5461
+ console.log(`${DIM$2}${method} ${parsed.toString()}${RESET$2}`);
5462
+ console.log(`${DIM$2}→ O2 SDK 直连${withSsoTicket ? " (携带 SSO_TICKET)" : ""}${RESET$2}`);
5463
+ if (o2Env) console.log(`${DIM$2}→ O2 SDK Env: ${o2Env}${RESET$2}`);
5464
+ }
5465
+ let responseData;
5466
+ switch (method) {
5467
+ case "GET":
5468
+ responseData = await client.get(path, query, headers);
5469
+ break;
5470
+ case "POST":
5471
+ responseData = await client.post(path, query, bodyObj, headers);
5472
+ break;
5473
+ case "PUT":
5474
+ responseData = await client.put(path, query, bodyObj, headers);
5475
+ break;
5476
+ case "DELETE":
5477
+ responseData = await client.delete(path, query, headers);
5478
+ break;
5479
+ default: throw new Error(`O2 SDK 暂不支持该方法: ${method}`);
5480
+ }
5481
+ const outputBody = !options.raw && options.pretty !== false ? JSON.stringify(responseData, null, 2) : JSON.stringify(responseData);
5482
+ if (options.output) {
5483
+ const { writeFileSync } = await import("fs");
5484
+ writeFileSync(options.output, outputBody);
5485
+ if (!options.quiet) console.log(`${GREEN$1}✓ 已保存到 ${options.output}${RESET$2}`);
5486
+ } else console.log(outputBody);
5487
+ }
5488
+ function tryExtractYuqueGroupFromUrl(targetUrl) {
5489
+ try {
5490
+ const u = new URL(targetUrl);
5491
+ const scope = u.searchParams.get("scope")?.trim();
5492
+ if (scope) {
5493
+ const groupFromScope = scope.split("/")[0]?.trim();
5494
+ if (groupFromScope && /^[a-zA-Z0-9_-]+$/.test(groupFromScope)) return groupFromScope;
5495
+ }
5496
+ return u.pathname.match(/^\/api\/v\d+\/repos\/([^/]+)\//i)?.[1]?.trim() || null;
5497
+ } catch {
5498
+ return null;
5499
+ }
5500
+ }
5501
+ function getPlatformPrivateToken(platformKey, explicitToken, targetUrl) {
4891
5502
  if (explicitToken) return explicitToken;
4892
5503
  const envVarName = `ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN`;
4893
5504
  const envToken = process.env[envVarName] || process.env[`${platformKey.toUpperCase()}_TOKEN`];
4894
5505
  if (envToken) return envToken;
4895
- return readConfig().platforms?.[platformKey]?.privateToken || null;
5506
+ const config = readConfig();
5507
+ if (platformKey === "yuque") {
5508
+ const groupFromPath = targetUrl ? tryExtractYuqueGroupFromUrl(targetUrl) : null;
5509
+ if (groupFromPath) {
5510
+ const byPath = config.platforms?.yuque?.groups?.[groupFromPath]?.privateToken?.trim();
5511
+ if (byPath) return byPath;
5512
+ }
5513
+ return getYuquePrivateTokenForRequest(config);
5514
+ }
5515
+ return config.platforms?.[platformKey]?.privateToken || null;
4896
5516
  }
4897
5517
  async function promptConfigureToken(platformKey, platform) {
4898
5518
  console.log();
4899
5519
  console.log(`${YELLOW$2}⚠️ ${platform.name} 需要配置 Private Token${RESET$2}`);
4900
- if (platform.tokenDocUrl) console.log(`${DIM$2}Token 获取地址: ${platform.tokenDocUrl}${RESET$2}`);
5520
+ const yuqueCfg = platformKey === "yuque" ? readConfig().platforms?.yuque : void 0;
5521
+ const yuqueTeamForDoc = platformKey === "yuque" ? yuqueCfg?.defaultGroup?.trim() || Object.keys(yuqueCfg?.groups ?? {})[0] : void 0;
5522
+ const tokenDocUrlToOpen = platformKey === "yuque" ? yuqueTeamForDoc ? getYuqueGroupTokenDocUrl(yuqueTeamForDoc) : platform.tokenDocUrl : platform.tokenDocUrl;
5523
+ if (tokenDocUrlToOpen) console.log(`${DIM$2}Token 获取地址: ${tokenDocUrlToOpen}${RESET$2}`);
4901
5524
  if (!await ye({
4902
5525
  message: "是否现在配置?",
4903
5526
  initialValue: true
@@ -4905,29 +5528,156 @@ async function promptConfigureToken(platformKey, platform) {
4905
5528
  console.log(`${DIM$2}已取消配置${RESET$2}`);
4906
5529
  return null;
4907
5530
  }
4908
- if (platform.tokenDocUrl) {
4909
- console.log(`${TEXT$2}正在打开浏览器...${RESET$2}`);
4910
- openBrowser$1(platform.tokenDocUrl);
5531
+ if (tokenDocUrlToOpen) {
5532
+ console.log(`${TEXT$2}正在打开浏览器...${RESET$2}`);
5533
+ openBrowser$1(tokenDocUrlToOpen);
5534
+ }
5535
+ const token = await ge({
5536
+ message: `请输入 ${platform.name} 的 Private Token:`,
5537
+ mask: "*"
5538
+ });
5539
+ if (pD(token) || !token) {
5540
+ console.log(`${DIM$2}已取消配置${RESET$2}`);
5541
+ return null;
5542
+ }
5543
+ if (platformKey === "yuque") {
5544
+ const cfg = readConfig().platforms?.yuque;
5545
+ const team = cfg?.defaultGroup?.trim() || (cfg?.groups ? Object.keys(cfg.groups).find((k) => cfg.groups?.[k]?.privateToken) : void 0);
5546
+ if (team) setYuqueGroupAccessToken(team, token);
5547
+ else setPlatformToken(platformKey, { privateToken: token });
5548
+ } else setPlatformToken(platformKey, { privateToken: token });
5549
+ console.log(`${GREEN$1}✓ ${platform.name} Token 已保存${RESET$2}`);
5550
+ return token;
5551
+ }
5552
+ async function sendDirectRequest(targetUrl, platform, token, options) {
5553
+ const requestHeaders = {
5554
+ "User-Agent": "ali-skills-cli/1.0",
5555
+ [platform.tokenHeaderName]: token
5556
+ };
5557
+ if (options.headers) Object.entries(options.headers).forEach(([key, value]) => {
5558
+ if (key.toLowerCase() !== platform.tokenHeaderName?.toLowerCase()) requestHeaders[key] = value;
5559
+ });
5560
+ let body;
5561
+ if (options.body) {
5562
+ body = options.body;
5563
+ if (!requestHeaders["Content-Type"]) requestHeaders["Content-Type"] = "application/json";
5564
+ }
5565
+ if (!options.quiet) {
5566
+ console.log(`${DIM$2}${options.method.toUpperCase()} ${targetUrl}${RESET$2}`);
5567
+ console.log(`${DIM$2}→ 直接请求 (Header: ${platform.tokenHeaderName})${RESET$2}`);
5568
+ }
5569
+ const controller = new AbortController();
5570
+ const timeout = options.timeout || 3e4;
5571
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
5572
+ const { response, responseBody } = await fetchWithRedirects(targetUrl, options.method.toUpperCase(), requestHeaders, body, timeout, options.quiet);
5573
+ clearTimeout(timeoutId);
5574
+ if (!options.quiet) {
5575
+ const statusColor = response.ok ? GREEN$1 : RED$2;
5576
+ console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
5577
+ if (options.includeHeaders) {
5578
+ console.log();
5579
+ console.log(`${TEXT$2}Response Headers:${RESET$2}`);
5580
+ response.headers.forEach((value, key) => {
5581
+ console.log(` ${key}: ${value}`);
5582
+ });
5583
+ console.log();
5584
+ }
5585
+ }
5586
+ let outputBody = responseBody;
5587
+ if (!options.raw && options.pretty !== false) try {
5588
+ const json = JSON.parse(responseBody);
5589
+ outputBody = JSON.stringify(json, null, 2);
5590
+ } catch {}
5591
+ if (options.output) {
5592
+ const { writeFileSync } = __require("fs");
5593
+ writeFileSync(options.output, outputBody);
5594
+ console.log(`${GREEN$1}✓ 已保存到 ${options.output}${RESET$2}`);
5595
+ } else console.log(outputBody);
5596
+ if (!response.ok) process.exit(1);
5597
+ }
5598
+ async function sendSsoCookieDirectRequest(targetUrl, options) {
5599
+ let ssoRefreshToken = null;
5600
+ try {
5601
+ await ensureLogin();
5602
+ ssoRefreshToken = await ensureSsoRefreshToken();
5603
+ } catch (error) {
5604
+ console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
5605
+ process.exit(1);
5606
+ }
5607
+ if (!ssoRefreshToken) {
5608
+ console.error(`${RED$2}Error: 缺少 SSO_REFRESH_TOKEN,无法进行根域 cookie 直连${RESET$2}`);
5609
+ console.log(`${DIM$2}可能原因:${RESET$2}`);
5610
+ console.log(`${DIM$2} 1. 尚未通过 ali-skills 登录${RESET$2}`);
5611
+ console.log(`${DIM$2} 2. 登录时未拿到根域 token${RESET$2}`);
5612
+ console.log(`${DIM$2} 3. token 已失效${RESET$2}`);
5613
+ console.log(`${TEXT$2}建议执行: npx ali-skills login${RESET$2}`);
5614
+ process.exit(1);
4911
5615
  }
4912
- const token = await ge({
4913
- message: `请输入 ${platform.name} 的 Private Token:`,
4914
- mask: "*"
5616
+ const requestHeaders = {
5617
+ "User-Agent": "ali-skills-cli/1.0",
5618
+ Cookie: `SSO_REFRESH_TOKEN=${ssoRefreshToken}`
5619
+ };
5620
+ if (options.headers) Object.entries(options.headers).forEach(([key, value]) => {
5621
+ if (key.toLowerCase() !== "cookie") requestHeaders[key] = value;
4915
5622
  });
4916
- if (pD(token) || !token) {
4917
- console.log(`${DIM$2}已取消配置${RESET$2}`);
4918
- return null;
5623
+ let body;
5624
+ if (options.body) {
5625
+ body = options.body;
5626
+ if (!requestHeaders["Content-Type"]) requestHeaders["Content-Type"] = "application/json";
4919
5627
  }
4920
- setPlatformToken(platformKey, { privateToken: token });
4921
- console.log(`${GREEN$1}${platform.name} Token 已保存${RESET$2}`);
4922
- return token;
5628
+ if (!options.quiet) {
5629
+ console.log(`${DIM$2}${options.method.toUpperCase()} ${targetUrl}${RESET$2}`);
5630
+ console.log(`${DIM$2}→ 直接请求 (Cookie: SSO_REFRESH_TOKEN)${RESET$2}`);
5631
+ }
5632
+ const controller = new AbortController();
5633
+ const timeout = options.timeout || 3e4;
5634
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
5635
+ const { response, responseBody } = await fetchWithRedirects(targetUrl, options.method.toUpperCase(), requestHeaders, body, timeout, options.quiet);
5636
+ clearTimeout(timeoutId);
5637
+ if (!options.quiet) {
5638
+ const statusColor = response.ok ? GREEN$1 : RED$2;
5639
+ console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
5640
+ if (response.status === 401 || response.status === 403) {
5641
+ console.log(`${YELLOW$2}根域 cookie 认证失败${RESET$2}`);
5642
+ console.log(`${DIM$2}可能原因:${RESET$2}`);
5643
+ console.log(`${DIM$2} 1. SSO_REFRESH_TOKEN 已过期或无效${RESET$2}`);
5644
+ console.log(`${DIM$2} 2. 目标服务未启用该认证链路${RESET$2}`);
5645
+ console.log(`${DIM$2} 3. 当前账号在目标系统无访问权限${RESET$2}`);
5646
+ console.log(`${TEXT$2}建议: 重新登录后重试,或联系目标系统确认登录态策略${RESET$2}`);
5647
+ }
5648
+ }
5649
+ let outputBody = responseBody;
5650
+ if (!options.raw && options.pretty !== false) try {
5651
+ const json = JSON.parse(responseBody);
5652
+ outputBody = JSON.stringify(json, null, 2);
5653
+ } catch {}
5654
+ if (options.output) {
5655
+ const { writeFileSync } = __require("fs");
5656
+ writeFileSync(options.output, outputBody);
5657
+ console.log(`${GREEN$1}✓ 已保存到 ${options.output}${RESET$2}`);
5658
+ } else console.log(outputBody);
5659
+ if (!response.ok) process.exit(1);
4923
5660
  }
4924
- async function sendDirectRequest(targetUrl, platform, token, options) {
5661
+ async function sendSsoTicketDirectRequest(targetUrl, options) {
5662
+ let ssoTicket = null;
5663
+ try {
5664
+ await ensureLogin();
5665
+ ssoTicket = await ensureSsoTicket();
5666
+ } catch (error) {
5667
+ console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
5668
+ process.exit(1);
5669
+ }
5670
+ if (!ssoTicket) {
5671
+ console.error(`${RED$2}Error: 缺少 SSO_TICKET,无法进行直连请求${RESET$2}`);
5672
+ console.log(`${TEXT$2}建议执行: npx ali-skills login${RESET$2}`);
5673
+ process.exit(1);
5674
+ }
4925
5675
  const requestHeaders = {
4926
5676
  "User-Agent": "ali-skills-cli/1.0",
4927
- [platform.tokenHeaderName]: token
5677
+ SSO_TICKET: ssoTicket
4928
5678
  };
4929
5679
  if (options.headers) Object.entries(options.headers).forEach(([key, value]) => {
4930
- if (key.toLowerCase() !== platform.tokenHeaderName?.toLowerCase()) requestHeaders[key] = value;
5680
+ if (key.toLowerCase() !== "sso_ticket") requestHeaders[key] = value;
4931
5681
  });
4932
5682
  let body;
4933
5683
  if (options.body) {
@@ -4936,21 +5686,50 @@ async function sendDirectRequest(targetUrl, platform, token, options) {
4936
5686
  }
4937
5687
  if (!options.quiet) {
4938
5688
  console.log(`${DIM$2}${options.method.toUpperCase()} ${targetUrl}${RESET$2}`);
4939
- console.log(`${DIM$2}→ 直接请求 (Header: ${platform.tokenHeaderName})${RESET$2}`);
5689
+ console.log(`${DIM$2}→ 直接请求 (Header: SSO_TICKET)${RESET$2}`);
4940
5690
  }
4941
5691
  const controller = new AbortController();
4942
5692
  const timeout = options.timeout || 3e4;
4943
5693
  const timeoutId = setTimeout(() => controller.abort(), timeout);
4944
- const response = await fetch(targetUrl, {
4945
- method: options.method.toUpperCase(),
4946
- headers: requestHeaders,
4947
- body: body || void 0,
4948
- signal: controller.signal
5694
+ const { response, responseBody } = await fetchWithRedirects(targetUrl, options.method.toUpperCase(), requestHeaders, body, timeout, options.quiet);
5695
+ clearTimeout(timeoutId);
5696
+ if (!options.quiet) {
5697
+ const statusColor = response.ok ? GREEN$1 : RED$2;
5698
+ console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
5699
+ }
5700
+ let outputBody = responseBody;
5701
+ if (!options.raw && options.pretty !== false) try {
5702
+ const json = JSON.parse(responseBody);
5703
+ outputBody = JSON.stringify(json, null, 2);
5704
+ } catch {}
5705
+ if (options.output) {
5706
+ const { writeFileSync } = __require("fs");
5707
+ writeFileSync(options.output, outputBody);
5708
+ console.log(`${GREEN$1}✓ 已保存到 ${options.output}${RESET$2}`);
5709
+ } else console.log(outputBody);
5710
+ if (!response.ok) process.exit(1);
5711
+ }
5712
+ async function sendPlainDirectRequest(targetUrl, options) {
5713
+ const requestHeaders = { "User-Agent": "ali-skills-cli/1.0" };
5714
+ if (options.headers) Object.entries(options.headers).forEach(([key, value]) => {
5715
+ requestHeaders[key] = value;
4949
5716
  });
5717
+ let body;
5718
+ if (options.body) {
5719
+ body = options.body;
5720
+ if (!requestHeaders["Content-Type"]) requestHeaders["Content-Type"] = "application/json";
5721
+ }
5722
+ if (!options.quiet) {
5723
+ console.log(`${DIM$2}${options.method.toUpperCase()} ${targetUrl}${RESET$2}`);
5724
+ console.log(`${DIM$2}→ 直接请求 (No Auth)${RESET$2}`);
5725
+ }
5726
+ const controller = new AbortController();
5727
+ const timeout = options.timeout || 3e4;
5728
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
5729
+ const { response, responseBody } = await fetchWithRedirects(targetUrl, options.method.toUpperCase(), requestHeaders, body, timeout, options.quiet);
4950
5730
  clearTimeout(timeoutId);
4951
- const responseBody = await response.text();
4952
5731
  if (!options.quiet) {
4953
- const statusColor = response.ok ? GREEN$1 : RED$1;
5732
+ const statusColor = response.ok ? GREEN$1 : RED$2;
4954
5733
  console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
4955
5734
  if (options.includeHeaders) {
4956
5735
  console.log();
@@ -4973,12 +5752,45 @@ async function sendDirectRequest(targetUrl, platform, token, options) {
4973
5752
  } else console.log(outputBody);
4974
5753
  if (!response.ok) process.exit(1);
4975
5754
  }
5755
+ async function fetchWithRedirects(initialUrl, method, headers, body, timeout, quiet) {
5756
+ const controller = new AbortController();
5757
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
5758
+ let currentUrl = initialUrl;
5759
+ let redirects = 0;
5760
+ try {
5761
+ while (true) {
5762
+ const response = await fetch(currentUrl, {
5763
+ method,
5764
+ headers,
5765
+ body: body || void 0,
5766
+ signal: controller.signal,
5767
+ redirect: "manual"
5768
+ });
5769
+ if (!REDIRECT_STATUS_CODES.has(response.status)) return {
5770
+ response,
5771
+ responseBody: await response.text()
5772
+ };
5773
+ const location = response.headers.get("location");
5774
+ if (!location) return {
5775
+ response,
5776
+ responseBody: await response.text()
5777
+ };
5778
+ if (redirects >= MAX_REDIRECTS) throw new Error(`重定向次数超过上限(${MAX_REDIRECTS})`);
5779
+ const nextUrl = new URL(location, currentUrl).toString();
5780
+ redirects += 1;
5781
+ if (!quiet) console.log(`${DIM$2}↪ 重定向 ${redirects}: ${response.status} ${response.statusText} -> ${nextUrl}${RESET$2}`);
5782
+ currentUrl = nextUrl;
5783
+ }
5784
+ } finally {
5785
+ clearTimeout(timeoutId);
5786
+ }
5787
+ }
4976
5788
  async function sendGatewayRequest(targetUrl, platformKey, options, authMode = "gateway") {
4977
5789
  let credentials;
4978
5790
  try {
4979
5791
  credentials = await ensureLogin();
4980
5792
  } catch (error) {
4981
- console.error(`${RED$1}Error: ${error.message}${RESET$2}`);
5793
+ console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
4982
5794
  process.exit(1);
4983
5795
  }
4984
5796
  const proxyUrl = `${getGatewayUrl()}/api/gateway/proxy`;
@@ -5017,7 +5829,7 @@ async function sendGatewayRequest(targetUrl, platformKey, options, authMode = "g
5017
5829
  error: "Unauthorized",
5018
5830
  code: "UNKNOWN"
5019
5831
  }))).code === "INVALID_TOKEN") {
5020
- console.error(`${RED$1}Error: Token 已失效,请重新登录${RESET$2}`);
5832
+ console.error(`${RED$2}Error: Token 已失效,请重新登录${RESET$2}`);
5021
5833
  console.log(`${TEXT$2}执行: npx ali-skills login${RESET$2}`);
5022
5834
  process.exit(1);
5023
5835
  }
@@ -5025,7 +5837,7 @@ async function sendGatewayRequest(targetUrl, platformKey, options, authMode = "g
5025
5837
  const responseBody = await response.text();
5026
5838
  const requestId = response.headers.get("X-Gateway-Request-Id");
5027
5839
  if (!options.quiet) {
5028
- const statusColor = response.ok ? GREEN$1 : RED$1;
5840
+ const statusColor = response.ok ? GREEN$1 : RED$2;
5029
5841
  console.log(`${statusColor}${response.status} ${response.statusText}${RESET$2}`);
5030
5842
  if (requestId) console.log(`${DIM$2}Request ID: ${requestId}${RESET$2}`);
5031
5843
  if (options.includeHeaders) {
@@ -5054,64 +5866,129 @@ async function proxyRequest(targetUrl, options) {
5054
5866
  try {
5055
5867
  url = new URL(targetUrl);
5056
5868
  } catch {
5057
- console.error(`${RED$1}Error: 无效的 URL "${targetUrl}"${RESET$2}`);
5869
+ console.error(`${RED$2}Error: URL 必须是绝对地址,收到 "${targetUrl}"${RESET$2}`);
5870
+ console.log(`${DIM$2}未传 platform 时,请使用完整 URL(包含协议和域名)${RESET$2}`);
5871
+ console.log(`${DIM$2}示例:${RESET$2}`);
5872
+ console.log(`${DIM$2} npx ali-skills req "https://jarvis.alitrip.com/api/xxx" --auth sso_cookie${RESET$2}`);
5873
+ console.log(`${DIM$2} npx ali-skills req o2 /v1.0/work/apps${RESET$2}`);
5058
5874
  process.exit(1);
5059
5875
  }
5060
5876
  const platformResult = detectPlatformWithKey(url.hostname);
5061
- if (!platformResult) {
5062
- console.error(`${RED$1}Error: 无法识别平台 "${url.hostname}"${RESET$2}`);
5063
- console.log(`${DIM$2}支持的平台:${RESET$2}`);
5064
- console.log(`${DIM$2} - code.alibaba-inc.com (GitLab)${RESET$2}`);
5065
- console.log(`${DIM$2} - aliyuque.antfin.com (语雀)${RESET$2}`);
5066
- console.log(`${DIM$2} - o2.alibaba-inc.com${RESET$2}`);
5067
- console.log(`${DIM$2} - aone.alibaba-inc.com${RESET$2}`);
5068
- process.exit(1);
5069
- }
5070
- const { key: platformKey, config: platform } = platformResult;
5071
- if (!options.quiet) console.log(`${DIM$2}平台: ${platform.name}${RESET$2}`);
5072
- const authMode = options.authMode === "auto" || !options.authMode ? detectAuthMode(platformKey, platform, url.hostname) : options.authMode;
5073
- if (!options.quiet && authMode !== "auto") console.log(`${DIM$2}认证方式: ${getAuthModeDescription(authMode)}${RESET$2}`);
5877
+ const hasExplicitAuthMode = Boolean(options.authMode && options.authMode !== "auto");
5878
+ const isAlibabaIncRootDomain = url.hostname.endsWith(".alibaba-inc.com") || url.hostname === "alibaba-inc.com";
5879
+ const isKnownPlatform = Boolean(platformResult) || isAlibabaIncRootDomain;
5880
+ const platformKey = platformResult?.key || (isAlibabaIncRootDomain ? "alibaba-inc" : url.hostname);
5881
+ const platform = platformResult?.config || {
5882
+ name: isAlibabaIncRootDomain ? "Alibaba Inc Domain" : "Custom Host",
5883
+ host: isAlibabaIncRootDomain ? "alibaba-inc.com" : url.hostname,
5884
+ authType: "buc_sso_refresh",
5885
+ ssoType: "refresh_token"
5886
+ };
5074
5887
  try {
5888
+ if (!isKnownPlatform && !hasExplicitAuthMode) {
5889
+ if (!options.quiet) {
5890
+ console.log(`${DIM$2}平台: Custom Host${RESET$2}`);
5891
+ console.log(`${DIM$2}认证方式: Auto (未知平台默认直连,无鉴权)${RESET$2}`);
5892
+ }
5893
+ await sendPlainDirectRequest(targetUrl, options);
5894
+ return;
5895
+ }
5896
+ if (!options.quiet) console.log(`${DIM$2}平台: ${platform.name}${RESET$2}`);
5897
+ const authMode = options.authMode === "auto" || !options.authMode ? detectAuthMode(platformKey, platform, url.hostname) : options.authMode;
5898
+ if (!options.quiet && authMode !== "auto") console.log(`${DIM$2}认证方式: ${getAuthModeDescription(authMode)}${RESET$2}`);
5899
+ if (hasExplicitAuthMode) {
5900
+ if (platformKey === "o2") {
5901
+ if (authMode !== "auto" && authMode !== "sso_ticket") {
5902
+ console.error(`${RED$2}Error: o2 仅支持 --auth auto 或 --auth sso_ticket${RESET$2}`);
5903
+ process.exit(1);
5904
+ }
5905
+ await sendO2SdkRequest(targetUrl, options, authMode === "sso_ticket");
5906
+ return;
5907
+ }
5908
+ switch (authMode) {
5909
+ case "private_token": {
5910
+ let token = getPlatformPrivateToken(platformKey, options.token, targetUrl);
5911
+ if (!token) {
5912
+ token = await promptConfigureToken(platformKey, platform);
5913
+ if (!token) {
5914
+ console.error(`${RED$2}Error: ${platform.name} 需要配置 Private Token 才能访问${RESET$2}`);
5915
+ console.log(`${DIM$2}您可以通过以下方式配置:${RESET$2}`);
5916
+ console.log(`${DIM$2} 【推荐】一次配置,持续使用:${RESET$2}`);
5917
+ console.log(` npx ali-skills login ${platformKey}`);
5918
+ console.log(`${DIM$2} 【临时】请求时传入:${RESET$2}`);
5919
+ console.log(` 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5920
+ console.log(` 参数: --token <your_token>`);
5921
+ process.exit(1);
5922
+ }
5923
+ }
5924
+ await sendDirectRequest(targetUrl, platform, token, options);
5925
+ return;
5926
+ }
5927
+ case "sso_cookie":
5928
+ await sendSsoCookieDirectRequest(targetUrl, options);
5929
+ return;
5930
+ case "sso_ticket":
5931
+ await sendSsoTicketDirectRequest(targetUrl, options);
5932
+ return;
5933
+ case "gateway":
5934
+ await sendGatewayRequest(targetUrl, platformKey, options, "gateway");
5935
+ return;
5936
+ default: break;
5937
+ }
5938
+ }
5939
+ if (platformKey === "o2") {
5940
+ if (authMode !== "auto" && authMode !== "sso_ticket") {
5941
+ console.error(`${RED$2}Error: o2 仅支持 --auth auto 或 --auth sso_ticket${RESET$2}`);
5942
+ process.exit(1);
5943
+ }
5944
+ await sendO2SdkRequest(targetUrl, options, authMode === "sso_ticket");
5945
+ return;
5946
+ }
5075
5947
  switch (authMode) {
5076
5948
  case "private_token": {
5077
- let token = getPlatformPrivateToken(platformKey, options.token);
5949
+ let token = getPlatformPrivateToken(platformKey, options.token, targetUrl);
5078
5950
  if (!token) {
5079
5951
  token = await promptConfigureToken(platformKey, platform);
5080
5952
  if (!token) {
5081
- console.error(`${RED$1}Error: ${platform.name} 需要配置 Private Token 才能访问${RESET$2}`);
5953
+ console.error(`${RED$2}Error: ${platform.name} 需要配置 Private Token 才能访问${RESET$2}`);
5082
5954
  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}`);
5955
+ console.log(`${DIM$2} 【推荐】一次配置,持续使用:${RESET$2}`);
5956
+ console.log(` npx ali-skills login ${platformKey}`);
5957
+ console.log(`${DIM$2} 【临时】请求时传入:${RESET$2}`);
5958
+ console.log(` 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5959
+ console.log(` 参数: --token <your_token>`);
5086
5960
  process.exit(1);
5087
5961
  }
5088
5962
  }
5089
5963
  await sendDirectRequest(targetUrl, platform, token, options);
5090
5964
  break;
5091
5965
  }
5092
- case "app_code":
5093
- case "app_code+buc":
5094
- case "sso_cookie":
5095
5966
  case "sso_ticket":
5096
5967
  case "gateway":
5097
5968
  await sendGatewayRequest(targetUrl, platformKey, options, authMode);
5098
5969
  break;
5970
+ case "sso_cookie":
5971
+ await sendSsoCookieDirectRequest(targetUrl, options);
5972
+ break;
5099
5973
  default: if (platform.authType === "private_token") {
5100
- const token = getPlatformPrivateToken(platformKey, options.token);
5974
+ const token = getPlatformPrivateToken(platformKey, options.token, targetUrl);
5101
5975
  if (token) await sendDirectRequest(targetUrl, platform, token, options);
5102
5976
  else {
5103
- console.error(`${RED$1}Error: ${platform.name} 需要配置 Private Token${RESET$2}`);
5977
+ console.error(`${RED$2}Error: ${platform.name} 需要配置 Private Token${RESET$2}`);
5104
5978
  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}`);
5979
+ console.log(`${DIM$2} 【推荐】一次配置,持续使用:${RESET$2}`);
5980
+ console.log(` npx ali-skills login ${platformKey}`);
5981
+ console.log(`${DIM$2} 【临时】请求时传入:${RESET$2}`);
5982
+ console.log(` 环境变量: ALI_SKILLS_${platformKey.toUpperCase()}_TOKEN=<your_token>`);
5983
+ console.log(` 参数: --token <your_token>`);
5108
5984
  process.exit(1);
5109
5985
  }
5110
- } else await sendGatewayRequest(targetUrl, platformKey, options, "gateway");
5986
+ } else if (isAlibabaIncRootDomain) await sendSsoCookieDirectRequest(targetUrl, options);
5987
+ else await sendGatewayRequest(targetUrl, platformKey, options, "sso_ticket");
5111
5988
  }
5112
5989
  } 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}`);
5990
+ if (error instanceof Error) if (error.name === "AbortError") console.error(`${RED$2}Error: 请求超时${RESET$2}`);
5991
+ else console.error(`${RED$2}Error: ${error.message}${RESET$2}`);
5115
5992
  process.exit(1);
5116
5993
  }
5117
5994
  }
@@ -5127,47 +6004,43 @@ const TEXT$1 = "\x1B[38;5;145m";
5127
6004
  const RESET$1 = "\x1B[0m";
5128
6005
  const GREEN = "\x1B[32m";
5129
6006
  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
- `);
6007
+ const RED$1 = "\x1B[31m";
6008
+ function maskToken(token) {
6009
+ if (token.length <= 4) return "****";
6010
+ return `****${token.slice(-4)}`;
5160
6011
  }
5161
- async function prompt(question, defaultValue) {
6012
+ const AVAILABLE_PLATFORMS = listPlatforms().map(({ key }) => key).join(", ");
6013
+ async function promptLine(question) {
5162
6014
  const rl = (await import("readline")).createInterface({
5163
6015
  input: process.stdin,
5164
6016
  output: process.stdout
5165
6017
  });
5166
6018
  return new Promise((resolve) => {
5167
- const fullQuestion = defaultValue ? `${question} (默认: ${defaultValue}): ` : `${question}: `;
5168
- rl.question(fullQuestion, (answer) => {
6019
+ rl.question(question, (answer) => {
6020
+ rl.close();
6021
+ resolve(answer.trim());
6022
+ });
6023
+ });
6024
+ }
6025
+ async function promptSecret(question) {
6026
+ const rl = (await import("readline")).createInterface({
6027
+ input: process.stdin,
6028
+ output: process.stdout,
6029
+ terminal: true
6030
+ });
6031
+ return new Promise((resolve) => {
6032
+ const fullQuestion = `${question}: `;
6033
+ const writable = rl;
6034
+ process.stdout.write(fullQuestion);
6035
+ writable._writeToOutput = (chunk) => {
6036
+ if (chunk === "\r" || chunk === "\n" || chunk === "\r\n") return;
6037
+ const visible = chunk.replace(/\u001b\[[0-9;]*[A-Za-z]/g, "").replace(/[\u0000-\u001f\u007f]/g, "");
6038
+ if (visible.length > 0) process.stdout.write("*".repeat(visible.length));
6039
+ };
6040
+ rl.question("", (answer) => {
6041
+ process.stdout.write("\n");
5169
6042
  rl.close();
5170
- resolve(answer.trim() || defaultValue || "");
6043
+ resolve(answer.trim());
5171
6044
  });
5172
6045
  });
5173
6046
  }
@@ -5179,109 +6052,185 @@ async function openBrowser(url) {
5179
6052
  stdio: "ignore"
5180
6053
  });
5181
6054
  }
5182
- async function configurePlatform(platformKey) {
6055
+ async function configurePlatform(platformKey, yuqueGroupArg) {
5183
6056
  const platform = getPlatform(platformKey);
5184
6057
  if (!platform) {
5185
- console.error(`${RED}Error: 不支持的平台 "${platformKey}"${RESET$1}`);
5186
- console.log(`${DIM$1}运行 'npx ali-skills config --list' 查看支持的平台${RESET$1}`);
6058
+ console.error(`${RED$1}Error: 不支持的平台 "${platformKey}"${RESET$1}`);
6059
+ console.log(`${DIM$1}支持的平台: ${AVAILABLE_PLATFORMS}${RESET$1}`);
6060
+ console.log(`${DIM$1}示例: npx ali-skills login code${RESET$1}`);
5187
6061
  process.exit(1);
5188
6062
  }
5189
- console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
5190
- console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5191
6063
  switch (platform.authType) {
5192
6064
  case "private_token":
5193
- await configurePrivateToken(platformKey, platform);
6065
+ if (platformKey === "yuque") await configureYuque(yuqueGroupArg);
6066
+ else await configurePrivateToken(platformKey, platform);
5194
6067
  break;
5195
6068
  case "app_code":
6069
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
6070
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5196
6071
  console.log(`${GREEN}✓ ${platform.name} 使用内置凭证,无需配置${RESET$1}`);
5197
6072
  break;
5198
6073
  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}`);
6074
+ if (platformKey === "o2") showO2LoginStatus();
6075
+ else {
6076
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
6077
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
6078
+ console.log(`${YELLOW$1}! ${platform.name} 需要 BUC 登录${RESET$1}`);
6079
+ console.log(`${DIM$1}请运行: npx ali-skills login${RESET$1}`);
6080
+ }
5201
6081
  break;
5202
6082
  case "buc_sso_refresh":
5203
6083
  case "buc_sso_ticket":
6084
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
6085
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5204
6086
  console.log(`${YELLOW$1}! ${platform.name} 需要 BUC 登录${RESET$1}`);
5205
6087
  console.log(`${DIM$1}请运行: npx ali-skills login${RESET$1}`);
5206
6088
  break;
5207
6089
  default:
5208
- console.error(`${RED}Error: 未知的认证类型${RESET$1}`);
6090
+ console.error(`${RED$1}Error: 未知的认证类型${RESET$1}`);
5209
6091
  process.exit(1);
5210
6092
  }
5211
6093
  }
6094
+ function showO2LoginStatus() {
6095
+ const auth = readAuth();
6096
+ const isLoggedIn = Boolean(auth) && !isAuthExpired(auth);
6097
+ console.log(`${TEXT$1}配置 O2 平台${RESET$1}`);
6098
+ console.log(`${DIM$1}认证方式: 内置服务调用身份${RESET$1}`);
6099
+ if (isLoggedIn) {
6100
+ console.log(`${GREEN}✓ 当前 BUC 登录态有效${RESET$1}`);
6101
+ console.log(`${DIM$1}调用需 BUC 的 O2 接口时,将自动换取 SSO_TICKET${RESET$1}`);
6102
+ return;
6103
+ }
6104
+ console.log(`${YELLOW$1}! 当前未登录 BUC${RESET$1}`);
6105
+ console.log(`${DIM$1}请先执行: npx ali-skills login${RESET$1}`);
6106
+ }
6107
+ function assertValidYuqueTeamSlug(raw) {
6108
+ const slug = raw.trim();
6109
+ if (!slug) {
6110
+ console.error(`${RED$1}Error: 团队名称不能为空${RESET$1}`);
6111
+ process.exit(1);
6112
+ }
6113
+ if (slug.length > 128 || /[/\s]/.test(slug) || slug.includes("..")) {
6114
+ console.error(`${RED$1}Error: 团队名称不能包含空格、斜杠等非法字符${RESET$1}`);
6115
+ process.exit(1);
6116
+ }
6117
+ if (!/^[a-zA-Z0-9_-]+$/.test(slug)) {
6118
+ console.error(`${RED$1}Error: 团队名称仅允许字母、数字、连字符与下划线${RESET$1}`);
6119
+ process.exit(1);
6120
+ }
6121
+ return slug;
6122
+ }
6123
+ async function configureYuque(groupArg) {
6124
+ const platformName = "语雀";
6125
+ console.log(`${TEXT$1}配置 ${platformName}${RESET$1}`);
6126
+ console.log(`${DIM$1}认证方式: 团队 Group Access Token${RESET$1}`);
6127
+ console.log();
6128
+ const teamSlug = assertValidYuqueTeamSlug(groupArg ?? await promptLine(`${TEXT$1}请输入团队名称${RESET$1}(语雀 URL 中域名后的第一段,例如 ${DIM$1}fliggyfe-infra${RESET$1})\n${DIM$1}>${RESET$1} `));
6129
+ const existingGroupToken = readConfig().platforms?.yuque?.groups?.[teamSlug]?.privateToken?.trim();
6130
+ if (existingGroupToken) {
6131
+ setYuqueDefaultGroup(teamSlug);
6132
+ console.log(`${YELLOW$1}! 团队 ${teamSlug} 已配置 Group Access Token:${maskToken(existingGroupToken)}${RESET$1}`);
6133
+ console.log(`${DIM$1}如需重新配置,请先执行: npx ali-skills logout yuque ${teamSlug}${RESET$1}`);
6134
+ console.log();
6135
+ console.log(`${GREEN}✓ 已将默认分组切换为 ${teamSlug}${RESET$1}`);
6136
+ return;
6137
+ }
6138
+ const docUrl = getYuqueGroupTokenDocUrl(teamSlug);
6139
+ console.log(`${DIM$1}1. 正在打开团队 Token 页面...${RESET$1}`);
6140
+ console.log(`${DIM$1} ${docUrl}${RESET$1}`);
6141
+ await openBrowser(docUrl);
6142
+ console.log();
6143
+ console.log(`${DIM$1}2. 在浏览器中创建 Group Access Token,将完整 token 粘贴到下方${RESET$1}`);
6144
+ const token = await promptSecret("Group Access Token");
6145
+ if (!token) {
6146
+ console.error(`${RED$1}Error: Token 不能为空${RESET$1}`);
6147
+ process.exit(1);
6148
+ }
6149
+ if (/\s/.test(token)) {
6150
+ console.error(`${RED$1}Error: Token 中不能包含空格或换行,请重新粘贴${RESET$1}`);
6151
+ process.exit(1);
6152
+ }
6153
+ const tail = token.slice(-4);
6154
+ console.log(`${DIM$1}已读取 Group Access Token(长度 ${token.length},尾号 ${tail})${RESET$1}`);
6155
+ setYuqueGroupAccessToken(teamSlug, token);
6156
+ console.log();
6157
+ console.log(`${GREEN}✓ ${platformName} 团队 ${teamSlug} 的 Token 已保存${RESET$1}`);
6158
+ console.log(`${GREEN}✓ 已将默认分组切换为 ${teamSlug}${RESET$1}`);
6159
+ console.log(`${DIM$1}配置文件: ${getConfigFilePath()}${RESET$1}`);
6160
+ }
5212
6161
  async function configurePrivateToken(platformKey, platform) {
5213
6162
  if (!platform.tokenDocUrl) {
5214
- console.error(`${RED}Error: 未找到 ${platform.name} 的 token 文档地址${RESET$1}`);
6163
+ console.error(`${RED$1}Error: 未找到 ${platform.name} 的 token 文档地址${RESET$1}`);
5215
6164
  process.exit(1);
5216
6165
  }
6166
+ const existingToken = readConfig().platforms?.[platformKey]?.privateToken?.trim();
6167
+ if (existingToken) {
6168
+ const platformName = platform.name.includes("(") ? platform.name.split("(")[0]?.trim() || platform.name : platform.name;
6169
+ console.log(`${YELLOW$1}! 您已经配置了 ${platformName} 平台的 Private Token:${maskToken(existingToken)}${RESET$1}`);
6170
+ console.log();
6171
+ console.log(`${DIM$1}如需重新配置,请先执行: npx ali-skills logout ${platformKey}${RESET$1}`);
6172
+ return;
6173
+ }
6174
+ console.log(`${TEXT$1}配置 ${platform.name}${RESET$1}`);
6175
+ console.log(`${DIM$1}认证方式: ${platform.authType}${RESET$1}`);
5217
6176
  console.log();
5218
6177
  console.log(`${DIM$1}1. 正在打开 ${platform.name} Token 页面...${RESET$1}`);
5219
6178
  console.log(`${DIM$1} ${platform.tokenDocUrl}${RESET$1}`);
5220
6179
  await openBrowser(platform.tokenDocUrl);
5221
6180
  console.log();
5222
- console.log(`${DIM$1}2. 请在浏览器中创建 Access Token,然后复制到这里${RESET$1}`);
5223
- const token = await prompt("Access Token");
6181
+ console.log(`${DIM$1}2. 请在浏览器中创建 Private Token,然后复制到这里${RESET$1}`);
6182
+ const token = await promptSecret("Private Token");
5224
6183
  if (!token) {
5225
- console.error(`${RED}Error: Token 不能为空${RESET$1}`);
6184
+ console.error(`${RED$1}Error: Token 不能为空${RESET$1}`);
5226
6185
  process.exit(1);
5227
6186
  }
6187
+ if (/\s/.test(token)) {
6188
+ console.error(`${RED$1}Error: Token 中不能包含空格或换行,请重新粘贴${RESET$1}`);
6189
+ process.exit(1);
6190
+ }
6191
+ const tail = token.slice(-4);
6192
+ console.log(`${DIM$1}已读取 Private Token(长度 ${token.length},尾号 ${tail})${RESET$1}`);
5228
6193
  setPlatformToken(platformKey, { privateToken: token });
5229
6194
  console.log();
5230
6195
  console.log(`${GREEN}✓ ${platform.name} Token 已保存${RESET$1}`);
5231
6196
  console.log(`${DIM$1}配置文件: ${getConfigFilePath()}${RESET$1}`);
5232
6197
  }
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;
6198
+ async function runPlatformLogin(platformArgs) {
6199
+ if (platformArgs.length === 0) {
6200
+ console.error(`${RED$1}Error: 请指定平台${RESET$1}`);
6201
+ console.log(`${DIM$1}支持的平台: ${AVAILABLE_PLATFORMS}${RESET$1}`);
6202
+ console.log(`${DIM$1}示例: npx ali-skills login code${RESET$1}`);
6203
+ process.exit(1);
5240
6204
  }
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})`);
6205
+ const platform = platformArgs[0];
6206
+ if (!platform) {
6207
+ console.error(`${RED$1}Error: 请指定平台${RESET$1}`);
6208
+ process.exit(1);
5246
6209
  }
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;
6210
+ if (platform.startsWith("-")) {
6211
+ console.error(`${RED$1}Error: 未知选项 "${platform}"${RESET$1}`);
6212
+ process.exit(1);
5257
6213
  }
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();
6214
+ if (platformArgs.length > 1) {
6215
+ const invalidOption = platformArgs.slice(1).find((arg) => arg.startsWith("-"));
6216
+ if (invalidOption) {
6217
+ if (invalidOption === "--force" || invalidOption === "-f") {
6218
+ console.error(`${RED$1}Error: 不再支持 ${invalidOption}${RESET$1}`);
6219
+ console.log(`${DIM$1}请先执行: npx ali-skills logout ${platform},再重新配置${RESET$1}`);
6220
+ } else console.error(`${RED$1}Error: 未知选项 "${invalidOption}"${RESET$1}`);
5282
6221
  process.exit(1);
5283
6222
  }
5284
6223
  }
6224
+ const extraArgs = platformArgs.slice(1).filter(Boolean);
6225
+ if (platform !== "yuque" && extraArgs.length > 0) {
6226
+ console.error(`${RED$1}Error: login ${platform} 不支持额外参数${RESET$1}`);
6227
+ process.exit(1);
6228
+ }
6229
+ if (platform === "yuque" && extraArgs.length > 1) {
6230
+ console.error(`${RED$1}Error: login yuque 仅支持一个团队参数,例如: npx ali-skills login yuque fliggy${RESET$1}`);
6231
+ process.exit(1);
6232
+ }
6233
+ await configurePlatform(platform, platform === "yuque" ? extraArgs[0] : void 0);
5285
6234
  }
5286
6235
  function getUpdateComparisonStrategy(entry) {
5287
6236
  if (entry.sourceType === "internal") return {
@@ -5309,6 +6258,7 @@ const BOLD = "\x1B[1m";
5309
6258
  const DIM = "\x1B[38;5;102m";
5310
6259
  const TEXT = "\x1B[38;5;145m";
5311
6260
  const YELLOW = "\x1B[33m";
6261
+ const RED = "\x1B[31m";
5312
6262
  function isTruthyEnv(value) {
5313
6263
  if (!value) return false;
5314
6264
  const normalized = value.trim().toLowerCase();
@@ -5396,6 +6346,12 @@ ${BOLD}Project:${RESET}
5396
6346
  init [name] Initialize a skill (creates <name>/SKILL.md or ./SKILL.md)
5397
6347
  experimental_sync Sync skills from node_modules into agent directories
5398
6348
 
6349
+ ${BOLD}Gateway:${RESET}
6350
+ gateway 鉴权请求能力入口(login/logout/status/req)
6351
+ 支持 privateToken/accessKey 身份托管请求(code、yuque、o2)
6352
+ 支持基于 BUC SSO 的鉴权请求(sso_cookie / sso_ticket)
6353
+ 详细用法请执行: ali-skills gateway -h
6354
+
5399
6355
  ${BOLD}Add Options:${RESET}
5400
6356
  -g, --global Install skill globally (user-level) instead of project-level
5401
6357
  -a, --agent <agents> Specify agents to install to (use '*' for all agents)
@@ -5486,23 +6442,30 @@ Discover more skills at ${TEXT}https://ali-skills.alibaba-inc.com/${RESET}
5486
6442
  `);
5487
6443
  }
5488
6444
  function showGatewayHelp() {
6445
+ listPlatforms().map((p) => p.key).join(", ");
6446
+ const platformKeysForHelp = listPlatforms().filter((p) => p.key !== "aone").map((p) => p.key).join(", ");
5489
6447
  console.log(`
5490
6448
  ${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
6449
+ login [platform] Login to Gateway or configure platform token
6450
+ logout [platform] Logout BUC or clear platform token
6451
+ status [platform] [--all] Show login status, single platform, or all platform statuses
6452
+ request [platform] <url|path> Send HTTP request (supports platform + path shorthand)
6453
+ req [platform] <url|path> Alias for request, recommended
6454
+
6455
+ ${BOLD}Yuque Commands:${RESET}
6456
+ login yuque [group] Configure/switch specified Yuque group directly
6457
+ logout yuque [group] [--all] Choose one/many Yuque groups to clear, or clear all
6458
+ status yuque [group] [--show|-s] [--pretty] Show Yuque group/all config JSON
5496
6459
 
5497
- ${BOLD}Config Commands:${RESET}
5498
- config <platform> Configure platform token
5499
- config --list List configured platforms
5500
- config --remove <p> Remove platform config
6460
+ ${BOLD}Platform Values:${RESET}
6461
+ ${platformKeysForHelp}
5501
6462
 
5502
6463
  ${BOLD}Request Options:${RESET}
5503
6464
  -X, --method <method> HTTP method (default: GET)
5504
6465
  -b, --body <body> Request body (JSON string or @file)
5505
6466
  -h, --header <header> Custom header (can be used multiple times)
6467
+ --auth, --auth-mode <mode> Auth mode: auto/private_token/sso_cookie/sso_ticket
6468
+ --token <token> Explicit token for private_token mode
5506
6469
  -o, --output <file> Save response to file
5507
6470
  -i, --include-headers Include response headers in output
5508
6471
  -t, --timeout <ms> Request timeout (default: 30000)
@@ -5510,13 +6473,35 @@ ${BOLD}Request Options:${RESET}
5510
6473
  --raw Raw output without formatting
5511
6474
  -q, --quiet Quiet mode, only output response body
5512
6475
 
6476
+ ${BOLD}Environment:${RESET}
6477
+ ALI_SKILLS_YUQUE_GROUP Yuque team slug when multiple teams have tokens in config
6478
+ O2_API_ENV O2 SDK env override (default online; set pre for pre env)
6479
+ ALI_SKILLS_DEBUG_GATEWAY Enable gateway auth debug logs (1/true/on)
6480
+
5513
6481
  ${BOLD}Examples:${RESET}
5514
6482
  ${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
6483
+ ${DIM}$${RESET} ali-skills login code
6484
+ ${DIM}$${RESET} ali-skills login yuque
6485
+ ${DIM}$${RESET} ali-skills login yuque fliggy
6486
+ ${DIM}$${RESET} ali-skills status --all
6487
+ ${DIM}$${RESET} ali-skills status code
6488
+ ${DIM}$${RESET} ali-skills status -s
6489
+ ${DIM}$${RESET} ali-skills status -s --pretty
6490
+ ${DIM}$${RESET} ali-skills status code --show
6491
+ ${DIM}$${RESET} ali-skills status yuque --show
6492
+ ${DIM}$${RESET} ali-skills status yuque fliggy
6493
+ ${DIM}$${RESET} ali-skills status yuque fliggy --show
6494
+ ${DIM}$${RESET} ali-skills logout code
6495
+ ${DIM}$${RESET} ali-skills logout yuque
6496
+ ${DIM}$${RESET} ali-skills logout yuque my-team
6497
+ ${DIM}$${RESET} ali-skills logout yuque --all
6498
+ ${DIM}$${RESET} ali-skills req o2 /v1.0/work/apps
6499
+ ${DIM}$${RESET} ali-skills req o2 /v1.0/work/aone/issues/search -X POST -b '{"keyword":"auth"}'
6500
+ ${DIM}$${RESET} ali-skills req o2 /v1.0/work/issues/123 --auth sso_ticket
5518
6501
  ${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
6502
+ ${DIM}$${RESET} ali-skills req https://yuque-api.antfin-inc.com/api/v2/repos -o repos.json
6503
+ ${DIM}$${RESET} ali-skills req yuque "/api/v2/search?q=buc&type=doc"
6504
+ ${DIM}$${RESET} ali-skills req yuque "/api/v2/search?q=buc&type=doc&scope=fliggyfe-infra"
5520
6505
  ${DIM}$${RESET} ali-skills logout
5521
6506
  `);
5522
6507
  }
@@ -5553,21 +6538,30 @@ function parseRequestOptions(args) {
5553
6538
  options.includeHeaders = true;
5554
6539
  break;
5555
6540
  case "-t":
5556
- case "--timeout":
5557
- options.timeout = parseInt(args[++i], 10);
6541
+ case "--timeout": {
6542
+ const timeoutValue = args[++i];
6543
+ if (timeoutValue) options.timeout = parseInt(timeoutValue, 10);
5558
6544
  break;
6545
+ }
5559
6546
  case "--pretty":
5560
6547
  options.pretty = true;
5561
6548
  break;
5562
6549
  case "--raw":
5563
6550
  options.raw = true;
5564
6551
  break;
6552
+ case "--auth-mode":
6553
+ case "--auth":
6554
+ options.authMode = args[++i] ?? "auto";
6555
+ break;
6556
+ case "--token":
6557
+ options.token = args[++i];
6558
+ break;
5565
6559
  case "-q":
5566
6560
  case "--quiet":
5567
6561
  options.quiet = true;
5568
6562
  break;
5569
6563
  default:
5570
- if (!arg.startsWith("-") && !url) url = arg;
6564
+ if (arg && !arg.startsWith("-") && !url) url = arg;
5571
6565
  break;
5572
6566
  }
5573
6567
  }
@@ -5578,6 +6572,105 @@ function parseRequestOptions(args) {
5578
6572
  options
5579
6573
  };
5580
6574
  }
6575
+ function expandRequestShorthand(args) {
6576
+ if (args.length < 2) return args;
6577
+ const platformArg = args[0];
6578
+ const pathArg = args[1];
6579
+ if (!platformArg || !pathArg) return args;
6580
+ if (platformArg.startsWith("-") || pathArg.startsWith("-")) return args;
6581
+ if (/^https?:\/\//i.test(pathArg)) return args;
6582
+ const platform = listPlatforms().find(({ key, config }) => key === platformArg || config.aliases?.includes(platformArg));
6583
+ if (!platform) return args;
6584
+ const normalizedPath = pathArg.startsWith("/") ? pathArg : `/${pathArg}`;
6585
+ return [`https://${platform.key === "yuque" ? "yuque-api.antfin-inc.com" : platform.config.host}${normalizedPath}`, ...args.slice(2)];
6586
+ }
6587
+ function parseStatusArgs(args) {
6588
+ const showPrivateTokenFlags = new Set(["--show", "-s"]);
6589
+ const positionals = [];
6590
+ let showAll = false;
6591
+ let showPrivateToken = false;
6592
+ let prettyJson = false;
6593
+ for (const raw of args) {
6594
+ if (raw === "--all") {
6595
+ showAll = true;
6596
+ continue;
6597
+ }
6598
+ if (raw === "--pretty") {
6599
+ prettyJson = true;
6600
+ continue;
6601
+ }
6602
+ if (showPrivateTokenFlags.has(raw)) {
6603
+ showPrivateToken = true;
6604
+ continue;
6605
+ }
6606
+ if (raw.startsWith("-")) {
6607
+ console.error(`Unknown option for status: ${raw}`);
6608
+ process.exit(1);
6609
+ }
6610
+ positionals.push(raw);
6611
+ }
6612
+ if (positionals.length > 2) {
6613
+ console.error(`${YELLOW}status 参数过多,期望: [--show|-s]、[platform]、[platform] [--show|-s]、[yuque] [group] [--show|-s] 或 --all${RESET}`);
6614
+ process.exit(1);
6615
+ }
6616
+ const platform = positionals[0];
6617
+ const yuqueGroup = positionals[1];
6618
+ if (yuqueGroup) {
6619
+ if (platform !== "yuque") {
6620
+ console.error(`${RED}仅语雀支持第二个参数(group),例如: npx ali-skills status yuque fliggy --show${RESET}`);
6621
+ process.exit(1);
6622
+ }
6623
+ if (showAll) {
6624
+ console.error(`${RED}status yuque <group> 不能与 --all 同时使用${RESET}`);
6625
+ process.exit(1);
6626
+ }
6627
+ }
6628
+ return {
6629
+ platform,
6630
+ yuqueGroup,
6631
+ showAll,
6632
+ prettyJson,
6633
+ showPrivateToken
6634
+ };
6635
+ }
6636
+ function parseLogoutArgs(args) {
6637
+ if (args.length === 0) return {};
6638
+ const clearAll = args.includes("--all");
6639
+ const bad = args.find((a) => a.startsWith("-") && a !== "--all");
6640
+ if (bad) {
6641
+ console.error(`Unknown option for logout: ${bad}`);
6642
+ process.exit(1);
6643
+ }
6644
+ const [platform, maybeGroup, ...rest] = args.filter((a) => a !== "--all");
6645
+ if (!platform) return {};
6646
+ if (rest.length > 0) {
6647
+ console.error(`${YELLOW}logout 参数过多${RESET}`);
6648
+ process.exit(1);
6649
+ }
6650
+ if (clearAll && platform.toLowerCase() !== "yuque") {
6651
+ console.error(`${RED}仅语雀支持 --all,例如: npx ali-skills logout yuque --all${RESET}`);
6652
+ process.exit(1);
6653
+ }
6654
+ if (maybeGroup) {
6655
+ if (platform.toLowerCase() !== "yuque") {
6656
+ console.error(`${RED}仅语雀支持第二个参数(团队 slug),例如: npx ali-skills logout yuque my-team${RESET}`);
6657
+ process.exit(1);
6658
+ }
6659
+ if (clearAll) {
6660
+ console.error(`${RED}logout yuque <团队> 不能与 --all 同时使用${RESET}`);
6661
+ process.exit(1);
6662
+ }
6663
+ return {
6664
+ platform,
6665
+ yuqueGroup: maybeGroup,
6666
+ clearAll
6667
+ };
6668
+ }
6669
+ return {
6670
+ platform,
6671
+ clearAll
6672
+ };
6673
+ }
5581
6674
  async function runGatewayCommand(args) {
5582
6675
  if (args.length === 0) {
5583
6676
  showGatewayHelp();
@@ -5591,11 +6684,13 @@ async function runGatewayCommand(args) {
5591
6684
  console.log();
5592
6685
  await login();
5593
6686
  break;
5594
- case "logout":
5595
- await logout();
6687
+ case "logout": {
6688
+ const lo = parseLogoutArgs(rest);
6689
+ await logout(lo.platform, lo.yuqueGroup, lo.clearAll);
5596
6690
  break;
6691
+ }
5597
6692
  case "status":
5598
- await status();
6693
+ await status(parseStatusArgs(rest));
5599
6694
  break;
5600
6695
  case "token": {
5601
6696
  const token = getPrivateToken();
@@ -5608,7 +6703,7 @@ async function runGatewayCommand(args) {
5608
6703
  }
5609
6704
  case "request":
5610
6705
  case "req": {
5611
- const { url, options } = parseRequestOptions(rest);
6706
+ const { url, options } = parseRequestOptions(expandRequestShorthand(rest));
5612
6707
  if (!url) {
5613
6708
  console.error("Error: URL is required");
5614
6709
  showGatewayHelp();
@@ -6231,11 +7326,6 @@ async function main() {
6231
7326
  console.log();
6232
7327
  runInit(restArgs);
6233
7328
  break;
6234
- case "config":
6235
- showLogo();
6236
- console.log();
6237
- await runConfig(restArgs);
6238
- break;
6239
7329
  case "experimental_install":
6240
7330
  showLogo();
6241
7331
  await runInstallFromLock(restArgs);
@@ -6251,7 +7341,7 @@ async function main() {
6251
7341
  }
6252
7342
  case "remove":
6253
7343
  case "rm":
6254
- case "r":
7344
+ case "r": {
6255
7345
  if (restArgs.includes("--help") || restArgs.includes("-h")) {
6256
7346
  showRemoveHelp();
6257
7347
  break;
@@ -6259,6 +7349,7 @@ async function main() {
6259
7349
  const { skills, options: removeOptions } = parseRemoveOptions(restArgs);
6260
7350
  await removeCommand(skills, removeOptions);
6261
7351
  break;
7352
+ }
6262
7353
  case "experimental_sync": {
6263
7354
  showLogo();
6264
7355
  const { options: syncOptions } = parseSyncOptions(restArgs);
@@ -6280,17 +7371,20 @@ async function main() {
6280
7371
  await runCheck(restArgs);
6281
7372
  break;
6282
7373
  case "login":
6283
- await login();
7374
+ if (restArgs.length > 0) await runPlatformLogin(restArgs);
7375
+ else await login();
6284
7376
  break;
6285
- case "logout":
6286
- await logout();
7377
+ case "logout": {
7378
+ const lo = parseLogoutArgs(restArgs);
7379
+ await logout(lo.platform, lo.yuqueGroup, lo.clearAll);
6287
7380
  break;
7381
+ }
6288
7382
  case "status":
6289
- await status();
7383
+ await status(parseStatusArgs(restArgs));
6290
7384
  break;
6291
7385
  case "req":
6292
7386
  case "request": {
6293
- const { url, options } = parseRequestOptions(restArgs);
7387
+ const { url, options } = parseRequestOptions(expandRequestShorthand(restArgs));
6294
7388
  if (!url) {
6295
7389
  console.error("Error: URL is required");
6296
7390
  showGatewayHelp();