@jackwener/opencli 1.6.9 → 1.7.0

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 (531) hide show
  1. package/README.md +128 -59
  2. package/README.zh-CN.md +134 -78
  3. package/dist/clis/_shared/common.d.ts +3 -0
  4. package/dist/clis/_shared/common.js +22 -0
  5. package/dist/clis/bilibili/hot.js +35 -0
  6. package/dist/clis/bluesky/feeds.d.ts +1 -0
  7. package/dist/clis/bluesky/feeds.js +27 -0
  8. package/dist/clis/bluesky/followers.d.ts +1 -0
  9. package/dist/clis/bluesky/followers.js +27 -0
  10. package/dist/clis/bluesky/following.d.ts +1 -0
  11. package/dist/clis/bluesky/following.js +27 -0
  12. package/dist/clis/bluesky/profile.d.ts +1 -0
  13. package/dist/clis/bluesky/profile.js +29 -0
  14. package/dist/clis/bluesky/search.d.ts +1 -0
  15. package/dist/clis/bluesky/search.js +28 -0
  16. package/dist/clis/bluesky/starter-packs.d.ts +1 -0
  17. package/dist/clis/bluesky/starter-packs.js +28 -0
  18. package/dist/clis/bluesky/thread.d.ts +1 -0
  19. package/dist/clis/bluesky/thread.js +30 -0
  20. package/dist/clis/bluesky/trending.d.ts +1 -0
  21. package/dist/clis/bluesky/trending.js +19 -0
  22. package/dist/clis/bluesky/user.d.ts +1 -0
  23. package/dist/clis/bluesky/user.js +33 -0
  24. package/dist/clis/cnki/search.d.ts +1 -0
  25. package/dist/clis/cnki/search.js +60 -0
  26. package/dist/clis/cnki/search.test.d.ts +1 -0
  27. package/dist/clis/cnki/search.test.js +18 -0
  28. package/dist/clis/devto/tag.d.ts +1 -0
  29. package/dist/clis/devto/tag.js +32 -0
  30. package/dist/clis/devto/top.d.ts +1 -0
  31. package/dist/clis/devto/top.js +26 -0
  32. package/dist/clis/devto/user.d.ts +1 -0
  33. package/dist/clis/devto/user.js +31 -0
  34. package/dist/clis/dictionary/examples.d.ts +1 -0
  35. package/dist/clis/dictionary/examples.js +27 -0
  36. package/dist/clis/dictionary/search.d.ts +1 -0
  37. package/dist/clis/dictionary/search.js +29 -0
  38. package/dist/clis/dictionary/synonyms.d.ts +1 -0
  39. package/dist/clis/dictionary/synonyms.js +27 -0
  40. package/dist/clis/douban/subject.d.ts +1 -0
  41. package/dist/clis/douban/subject.js +118 -0
  42. package/dist/clis/douban/top250.d.ts +1 -0
  43. package/dist/clis/douban/top250.js +67 -0
  44. package/dist/clis/facebook/add-friend.d.ts +1 -0
  45. package/dist/clis/facebook/add-friend.js +43 -0
  46. package/dist/clis/facebook/events.d.ts +1 -0
  47. package/dist/clis/facebook/events.js +40 -0
  48. package/dist/clis/facebook/feed.d.ts +1 -0
  49. package/dist/clis/facebook/feed.js +59 -0
  50. package/dist/clis/facebook/friends.d.ts +1 -0
  51. package/dist/clis/facebook/friends.js +38 -0
  52. package/dist/clis/facebook/groups.d.ts +1 -0
  53. package/dist/clis/facebook/groups.js +46 -0
  54. package/dist/clis/facebook/join-group.d.ts +1 -0
  55. package/dist/clis/facebook/join-group.js +44 -0
  56. package/dist/clis/facebook/memories.d.ts +1 -0
  57. package/dist/clis/facebook/memories.js +35 -0
  58. package/dist/clis/facebook/notifications.d.ts +1 -0
  59. package/dist/clis/facebook/notifications.js +36 -0
  60. package/dist/clis/facebook/profile.d.ts +1 -0
  61. package/dist/clis/facebook/profile.js +37 -0
  62. package/dist/clis/facebook/search.d.ts +1 -0
  63. package/dist/clis/facebook/search.js +38 -0
  64. package/dist/clis/facebook/search.test.d.ts +1 -1
  65. package/dist/clis/facebook/search.test.js +6 -9
  66. package/dist/clis/gitee/index.d.ts +3 -0
  67. package/dist/clis/gitee/index.js +3 -0
  68. package/dist/clis/gitee/search.d.ts +1 -0
  69. package/dist/clis/gitee/search.js +136 -0
  70. package/dist/clis/gitee/trending.d.ts +1 -0
  71. package/dist/clis/gitee/trending.js +567 -0
  72. package/dist/clis/gitee/user.d.ts +1 -0
  73. package/dist/clis/gitee/user.js +199 -0
  74. package/dist/clis/gitee/user.test.d.ts +1 -0
  75. package/dist/clis/gitee/user.test.js +63 -0
  76. package/dist/clis/hackernews/ask.d.ts +1 -0
  77. package/dist/clis/hackernews/ask.js +29 -0
  78. package/dist/clis/hackernews/best.d.ts +1 -0
  79. package/dist/clis/hackernews/best.js +29 -0
  80. package/dist/clis/hackernews/jobs.d.ts +1 -0
  81. package/dist/clis/hackernews/jobs.js +27 -0
  82. package/dist/clis/hackernews/new.d.ts +1 -0
  83. package/dist/clis/hackernews/new.js +29 -0
  84. package/dist/clis/hackernews/search.d.ts +1 -0
  85. package/dist/clis/hackernews/search.js +36 -0
  86. package/dist/clis/hackernews/show.d.ts +1 -0
  87. package/dist/clis/hackernews/show.js +29 -0
  88. package/dist/clis/hackernews/top.d.ts +1 -0
  89. package/dist/clis/hackernews/top.js +29 -0
  90. package/dist/clis/hackernews/user.d.ts +1 -0
  91. package/dist/clis/hackernews/user.js +22 -0
  92. package/dist/clis/hupu/hot.d.ts +1 -0
  93. package/dist/clis/hupu/hot.js +40 -0
  94. package/dist/clis/instagram/comment.d.ts +1 -0
  95. package/dist/clis/instagram/comment.js +47 -0
  96. package/dist/clis/instagram/explore.d.ts +1 -0
  97. package/dist/clis/instagram/explore.js +41 -0
  98. package/dist/clis/instagram/follow.d.ts +1 -0
  99. package/dist/clis/instagram/follow.js +43 -0
  100. package/dist/clis/instagram/followers.d.ts +1 -0
  101. package/dist/clis/instagram/followers.js +45 -0
  102. package/dist/clis/instagram/following.d.ts +1 -0
  103. package/dist/clis/instagram/following.js +45 -0
  104. package/dist/clis/instagram/like.d.ts +1 -0
  105. package/dist/clis/instagram/like.js +45 -0
  106. package/dist/clis/instagram/profile.d.ts +1 -0
  107. package/dist/clis/instagram/profile.js +39 -0
  108. package/dist/clis/instagram/save.d.ts +1 -0
  109. package/dist/clis/instagram/save.js +45 -0
  110. package/dist/clis/instagram/saved.d.ts +1 -0
  111. package/dist/clis/instagram/saved.js +38 -0
  112. package/dist/clis/instagram/search.d.ts +1 -0
  113. package/dist/clis/instagram/search.js +38 -0
  114. package/dist/clis/instagram/unfollow.d.ts +1 -0
  115. package/dist/clis/instagram/unfollow.js +40 -0
  116. package/dist/clis/instagram/unlike.d.ts +1 -0
  117. package/dist/clis/instagram/unlike.js +45 -0
  118. package/dist/clis/instagram/unsave.d.ts +1 -0
  119. package/dist/clis/instagram/unsave.js +45 -0
  120. package/dist/clis/instagram/user.d.ts +1 -0
  121. package/dist/clis/instagram/user.js +48 -0
  122. package/dist/clis/jd/add-cart.d.ts +1 -0
  123. package/dist/clis/jd/add-cart.js +71 -0
  124. package/dist/clis/jd/cart.d.ts +1 -0
  125. package/dist/clis/jd/cart.js +79 -0
  126. package/dist/clis/jd/commands.test.d.ts +5 -0
  127. package/dist/clis/jd/commands.test.js +64 -0
  128. package/dist/clis/jd/detail.d.ts +1 -0
  129. package/dist/clis/jd/detail.js +62 -0
  130. package/dist/clis/jd/reviews.d.ts +1 -0
  131. package/dist/clis/jd/reviews.js +54 -0
  132. package/dist/clis/jd/search.d.ts +1 -0
  133. package/dist/clis/jd/search.js +65 -0
  134. package/dist/clis/jianyu/detail.d.ts +1 -0
  135. package/dist/clis/jianyu/detail.js +20 -0
  136. package/dist/clis/jianyu/search.d.ts +41 -4
  137. package/dist/clis/jianyu/search.js +458 -96
  138. package/dist/clis/jianyu/search.test.js +105 -0
  139. package/dist/clis/jianyu/shared/china-bid-search.d.ts +12 -0
  140. package/dist/clis/jianyu/shared/china-bid-search.js +165 -0
  141. package/dist/clis/jianyu/shared/procurement-contract.d.ts +68 -0
  142. package/dist/clis/jianyu/shared/procurement-contract.js +324 -0
  143. package/dist/clis/jianyu/shared/procurement-contract.test.d.ts +1 -0
  144. package/dist/clis/jianyu/shared/procurement-contract.test.js +72 -0
  145. package/dist/clis/jianyu/shared/procurement-detail.d.ts +6 -0
  146. package/dist/clis/jianyu/shared/procurement-detail.js +92 -0
  147. package/dist/clis/jianyu/shared/procurement-detail.test.d.ts +1 -0
  148. package/dist/clis/jianyu/shared/procurement-detail.test.js +72 -0
  149. package/dist/clis/jike/post.d.ts +1 -0
  150. package/dist/clis/jike/post.js +61 -0
  151. package/dist/clis/jike/topic.d.ts +1 -0
  152. package/dist/clis/jike/topic.js +51 -0
  153. package/dist/clis/jike/user.d.ts +1 -0
  154. package/dist/clis/jike/user.js +50 -0
  155. package/dist/clis/jimeng/generate.d.ts +1 -0
  156. package/dist/clis/jimeng/generate.js +83 -0
  157. package/dist/clis/jimeng/history.d.ts +1 -0
  158. package/dist/clis/jimeng/history.js +47 -0
  159. package/dist/clis/jimeng/new.d.ts +1 -0
  160. package/dist/clis/jimeng/new.js +43 -0
  161. package/dist/clis/jimeng/workspaces.d.ts +1 -0
  162. package/dist/clis/jimeng/workspaces.js +41 -0
  163. package/dist/clis/linux-do/categories.d.ts +1 -0
  164. package/dist/clis/linux-do/categories.js +65 -0
  165. package/dist/clis/linux-do/search.d.ts +1 -0
  166. package/dist/clis/linux-do/search.js +41 -0
  167. package/dist/clis/linux-do/tags.d.ts +1 -0
  168. package/dist/clis/linux-do/tags.js +39 -0
  169. package/dist/clis/linux-do/topic-content.test.js +5 -5
  170. package/dist/clis/linux-do/topic.d.ts +1 -0
  171. package/dist/clis/linux-do/topic.js +56 -0
  172. package/dist/clis/linux-do/user-posts.d.ts +1 -0
  173. package/dist/clis/linux-do/user-posts.js +61 -0
  174. package/dist/clis/linux-do/user-topics.d.ts +1 -0
  175. package/dist/clis/linux-do/user-topics.js +48 -0
  176. package/dist/clis/lobsters/active.d.ts +1 -0
  177. package/dist/clis/lobsters/active.js +26 -0
  178. package/dist/clis/lobsters/hot.d.ts +1 -0
  179. package/dist/clis/lobsters/hot.js +26 -0
  180. package/dist/clis/lobsters/newest.d.ts +1 -0
  181. package/dist/clis/lobsters/newest.js +26 -0
  182. package/dist/clis/lobsters/tag.d.ts +1 -0
  183. package/dist/clis/lobsters/tag.js +32 -0
  184. package/dist/clis/pixiv/detail.d.ts +1 -0
  185. package/dist/clis/pixiv/detail.js +58 -0
  186. package/dist/clis/pixiv/ranking.d.ts +1 -0
  187. package/dist/clis/pixiv/ranking.js +59 -0
  188. package/dist/clis/pixiv/user.d.ts +1 -0
  189. package/dist/clis/pixiv/user.js +52 -0
  190. package/dist/clis/reddit/frontpage.d.ts +1 -0
  191. package/dist/clis/reddit/frontpage.js +31 -0
  192. package/dist/clis/reddit/hot.d.ts +1 -0
  193. package/dist/clis/reddit/hot.js +45 -0
  194. package/dist/clis/reddit/popular.d.ts +1 -0
  195. package/dist/clis/reddit/popular.js +41 -0
  196. package/dist/clis/reddit/search.d.ts +1 -0
  197. package/dist/clis/reddit/search.js +65 -0
  198. package/dist/clis/reddit/subreddit.d.ts +1 -0
  199. package/dist/clis/reddit/subreddit.js +52 -0
  200. package/dist/clis/reddit/user-comments.d.ts +1 -0
  201. package/dist/clis/reddit/user-comments.js +44 -0
  202. package/dist/clis/reddit/user-posts.d.ts +1 -0
  203. package/dist/clis/reddit/user-posts.js +42 -0
  204. package/dist/clis/reddit/user.d.ts +1 -0
  205. package/dist/clis/reddit/user.js +37 -0
  206. package/dist/clis/stackoverflow/bounties.d.ts +1 -0
  207. package/dist/clis/stackoverflow/bounties.js +27 -0
  208. package/dist/clis/stackoverflow/hot.d.ts +1 -0
  209. package/dist/clis/stackoverflow/hot.js +24 -0
  210. package/dist/clis/stackoverflow/search.d.ts +1 -0
  211. package/dist/clis/stackoverflow/search.js +27 -0
  212. package/dist/clis/stackoverflow/unanswered.d.ts +1 -0
  213. package/dist/clis/stackoverflow/unanswered.js +26 -0
  214. package/dist/clis/steam/top-sellers.d.ts +1 -0
  215. package/dist/clis/steam/top-sellers.js +25 -0
  216. package/dist/clis/taobao/add-cart.d.ts +1 -0
  217. package/dist/clis/taobao/add-cart.js +149 -0
  218. package/dist/clis/taobao/cart.d.ts +1 -0
  219. package/dist/clis/taobao/cart.js +95 -0
  220. package/dist/clis/taobao/commands.test.d.ts +5 -0
  221. package/dist/clis/taobao/commands.test.js +64 -0
  222. package/dist/clis/taobao/detail.d.ts +1 -0
  223. package/dist/clis/taobao/detail.js +70 -0
  224. package/dist/clis/taobao/reviews.d.ts +1 -0
  225. package/dist/clis/taobao/reviews.js +76 -0
  226. package/dist/clis/taobao/search.d.ts +1 -0
  227. package/dist/clis/taobao/search.js +96 -0
  228. package/dist/clis/tiktok/comment.d.ts +1 -0
  229. package/dist/clis/tiktok/comment.js +57 -0
  230. package/dist/clis/tiktok/explore.d.ts +1 -0
  231. package/dist/clis/tiktok/explore.js +35 -0
  232. package/dist/clis/tiktok/follow.d.ts +1 -0
  233. package/dist/clis/tiktok/follow.js +39 -0
  234. package/dist/clis/tiktok/following.d.ts +1 -0
  235. package/dist/clis/tiktok/following.js +42 -0
  236. package/dist/clis/tiktok/friends.d.ts +1 -0
  237. package/dist/clis/tiktok/friends.js +43 -0
  238. package/dist/clis/tiktok/like.d.ts +1 -0
  239. package/dist/clis/tiktok/like.js +33 -0
  240. package/dist/clis/tiktok/live.d.ts +1 -0
  241. package/dist/clis/tiktok/live.js +47 -0
  242. package/dist/clis/tiktok/notifications.d.ts +1 -0
  243. package/dist/clis/tiktok/notifications.js +49 -0
  244. package/dist/clis/tiktok/profile.d.ts +1 -0
  245. package/dist/clis/tiktok/profile.js +54 -0
  246. package/dist/clis/tiktok/save.d.ts +1 -0
  247. package/dist/clis/tiktok/save.js +29 -0
  248. package/dist/clis/tiktok/search.d.ts +1 -0
  249. package/dist/clis/tiktok/search.js +39 -0
  250. package/dist/clis/tiktok/unfollow.d.ts +1 -0
  251. package/dist/clis/tiktok/unfollow.js +44 -0
  252. package/dist/clis/tiktok/unlike.d.ts +1 -0
  253. package/dist/clis/tiktok/unlike.js +33 -0
  254. package/dist/clis/tiktok/unsave.d.ts +1 -0
  255. package/dist/clis/tiktok/unsave.js +31 -0
  256. package/dist/clis/tiktok/user.d.ts +1 -0
  257. package/dist/clis/tiktok/user.js +41 -0
  258. package/dist/clis/v2ex/hot.d.ts +1 -0
  259. package/dist/clis/v2ex/hot.js +25 -0
  260. package/dist/clis/v2ex/latest.d.ts +1 -0
  261. package/dist/clis/v2ex/latest.js +25 -0
  262. package/dist/clis/v2ex/member.d.ts +1 -0
  263. package/dist/clis/v2ex/member.js +27 -0
  264. package/dist/clis/v2ex/node.d.ts +1 -0
  265. package/dist/clis/v2ex/node.js +38 -0
  266. package/dist/clis/v2ex/nodes.d.ts +1 -0
  267. package/dist/clis/v2ex/nodes.js +25 -0
  268. package/dist/clis/v2ex/replies.d.ts +1 -0
  269. package/dist/clis/v2ex/replies.js +26 -0
  270. package/dist/clis/v2ex/topic.d.ts +1 -0
  271. package/dist/clis/v2ex/topic.js +30 -0
  272. package/dist/clis/v2ex/user.d.ts +1 -0
  273. package/dist/clis/v2ex/user.js +33 -0
  274. package/dist/clis/xiaoe/catalog.d.ts +1 -0
  275. package/dist/clis/xiaoe/catalog.js +161 -0
  276. package/dist/clis/xiaoe/content.d.ts +1 -0
  277. package/dist/clis/xiaoe/content.js +39 -0
  278. package/dist/clis/xiaoe/courses.d.ts +1 -0
  279. package/dist/clis/xiaoe/courses.js +69 -0
  280. package/dist/clis/xiaoe/detail.d.ts +1 -0
  281. package/dist/clis/xiaoe/detail.js +35 -0
  282. package/dist/clis/xiaoe/play-url.d.ts +1 -0
  283. package/dist/clis/xiaoe/play-url.js +120 -0
  284. package/dist/clis/xiaohongshu/feed.d.ts +1 -0
  285. package/dist/clis/xiaohongshu/feed.js +32 -0
  286. package/dist/clis/xiaohongshu/notifications.d.ts +1 -0
  287. package/dist/clis/xiaohongshu/notifications.js +38 -0
  288. package/dist/clis/xueqiu/earnings-date.d.ts +1 -0
  289. package/dist/clis/xueqiu/earnings-date.js +61 -0
  290. package/dist/clis/xueqiu/feed.d.ts +1 -0
  291. package/dist/clis/xueqiu/feed.js +48 -0
  292. package/dist/clis/xueqiu/groups.d.ts +1 -0
  293. package/dist/clis/xueqiu/groups.js +25 -0
  294. package/dist/clis/xueqiu/hot-stock.d.ts +1 -0
  295. package/dist/clis/xueqiu/hot-stock.js +44 -0
  296. package/dist/clis/xueqiu/hot.d.ts +1 -0
  297. package/dist/clis/xueqiu/hot.js +44 -0
  298. package/dist/clis/xueqiu/kline.d.ts +1 -0
  299. package/dist/clis/xueqiu/kline.js +64 -0
  300. package/dist/clis/xueqiu/search.d.ts +1 -0
  301. package/dist/clis/xueqiu/search.js +49 -0
  302. package/dist/clis/xueqiu/stock.d.ts +1 -0
  303. package/dist/clis/xueqiu/stock.js +72 -0
  304. package/dist/clis/xueqiu/watchlist.d.ts +1 -0
  305. package/dist/clis/xueqiu/watchlist.js +45 -0
  306. package/dist/clis/zhihu/hot.d.ts +1 -0
  307. package/dist/clis/zhihu/hot.js +43 -0
  308. package/dist/clis/zhihu/search.d.ts +1 -0
  309. package/dist/clis/zhihu/search.js +52 -0
  310. package/dist/src/browser/bridge.js +1 -1
  311. package/dist/src/browser/daemon-client.d.ts +16 -4
  312. package/dist/src/browser/daemon-client.js +33 -15
  313. package/dist/src/browser/daemon-client.test.js +0 -3
  314. package/dist/src/browser/dom-helpers.test.js +3 -2
  315. package/dist/src/browser/errors.d.ts +26 -1
  316. package/dist/src/browser/errors.js +40 -7
  317. package/dist/src/browser/errors.test.d.ts +1 -0
  318. package/dist/src/browser/errors.test.js +51 -0
  319. package/dist/src/browser/page.d.ts +9 -8
  320. package/dist/src/browser/page.js +33 -31
  321. package/dist/src/browser.test.js +25 -6
  322. package/dist/src/build-manifest.d.ts +5 -11
  323. package/dist/src/build-manifest.js +6 -75
  324. package/dist/src/build-manifest.test.js +1 -39
  325. package/dist/src/cascade.js +3 -2
  326. package/dist/src/cli.d.ts +3 -3
  327. package/dist/src/cli.js +71 -71
  328. package/dist/src/cli.test.js +20 -15
  329. package/dist/src/clis/binance/asks.d.ts +1 -0
  330. package/dist/src/clis/binance/asks.js +20 -0
  331. package/dist/src/clis/binance/commands.test.d.ts +3 -1
  332. package/dist/src/clis/binance/commands.test.js +10 -6
  333. package/dist/src/clis/binance/depth.d.ts +1 -0
  334. package/dist/src/clis/binance/depth.js +20 -0
  335. package/dist/src/clis/binance/gainers.d.ts +1 -0
  336. package/dist/src/clis/binance/gainers.js +21 -0
  337. package/dist/src/clis/binance/klines.d.ts +1 -0
  338. package/dist/src/clis/binance/klines.js +20 -0
  339. package/dist/src/clis/binance/losers.d.ts +1 -0
  340. package/dist/src/clis/binance/losers.js +21 -0
  341. package/dist/src/clis/binance/pairs.d.ts +1 -0
  342. package/dist/src/clis/binance/pairs.js +20 -0
  343. package/dist/src/clis/binance/price.d.ts +1 -0
  344. package/dist/src/clis/binance/price.js +17 -0
  345. package/dist/src/clis/binance/prices.d.ts +1 -0
  346. package/dist/src/clis/binance/prices.js +18 -0
  347. package/dist/src/clis/binance/ticker.d.ts +1 -0
  348. package/dist/src/clis/binance/ticker.js +20 -0
  349. package/dist/src/clis/binance/top.d.ts +1 -0
  350. package/dist/src/clis/binance/top.js +20 -0
  351. package/dist/src/clis/binance/trades.d.ts +1 -0
  352. package/dist/src/clis/binance/trades.js +19 -0
  353. package/dist/src/commands/daemon.d.ts +2 -6
  354. package/dist/src/commands/daemon.js +2 -58
  355. package/dist/src/commands/daemon.test.js +24 -120
  356. package/dist/src/completion-fast.d.ts +25 -0
  357. package/dist/src/completion-fast.js +140 -0
  358. package/dist/src/completion.d.ts +1 -0
  359. package/dist/src/completion.js +1 -0
  360. package/dist/src/constants.d.ts +0 -2
  361. package/dist/src/constants.js +0 -2
  362. package/dist/src/daemon.d.ts +1 -1
  363. package/dist/src/daemon.js +2 -15
  364. package/dist/src/diagnostic.test.js +2 -2
  365. package/dist/src/discovery.d.ts +3 -3
  366. package/dist/src/discovery.js +34 -97
  367. package/dist/src/download/index.d.ts +1 -1
  368. package/dist/src/engine.test.js +4 -19
  369. package/dist/src/execution.js +5 -1
  370. package/dist/src/generate-verified.d.ts +105 -0
  371. package/dist/src/generate-verified.js +696 -0
  372. package/dist/src/generate-verified.test.d.ts +1 -0
  373. package/dist/src/generate-verified.test.js +925 -0
  374. package/dist/src/generate.d.ts +9 -1
  375. package/dist/src/generate.js +2 -2
  376. package/dist/src/main.js +65 -12
  377. package/dist/src/pipeline/steps/download.d.ts +1 -17
  378. package/dist/src/pipeline/steps/download.js +20 -31
  379. package/dist/src/pipeline/steps/intercept.d.ts +1 -1
  380. package/dist/src/pipeline/steps/intercept.js +1 -1
  381. package/dist/src/pipeline/steps/tap.d.ts +1 -1
  382. package/dist/src/pipeline/steps/tap.js +1 -1
  383. package/dist/src/plugin-scaffold.d.ts +2 -2
  384. package/dist/src/plugin-scaffold.js +24 -21
  385. package/dist/src/plugin-scaffold.test.js +1 -1
  386. package/dist/src/plugin.d.ts +1 -1
  387. package/dist/src/plugin.js +4 -6
  388. package/dist/src/plugin.test.js +31 -31
  389. package/dist/src/record.js +26 -25
  390. package/dist/src/runtime-detect.js +3 -7
  391. package/dist/src/scripts/framework.d.ts +3 -0
  392. package/dist/src/scripts/framework.js +8 -4
  393. package/dist/src/scripts/store.d.ts +5 -1
  394. package/dist/src/scripts/store.js +5 -1
  395. package/dist/src/skill-generate.d.ts +30 -0
  396. package/dist/src/skill-generate.js +75 -0
  397. package/dist/src/skill-generate.test.d.ts +1 -0
  398. package/dist/src/skill-generate.test.js +173 -0
  399. package/dist/src/synthesize.d.ts +1 -1
  400. package/dist/src/synthesize.js +7 -8
  401. package/dist/src/types.d.ts +3 -1
  402. package/package.json +4 -3
  403. package/dist/clis/bilibili/hot.yaml +0 -38
  404. package/dist/clis/bluesky/feeds.yaml +0 -29
  405. package/dist/clis/bluesky/followers.yaml +0 -33
  406. package/dist/clis/bluesky/following.yaml +0 -33
  407. package/dist/clis/bluesky/profile.yaml +0 -27
  408. package/dist/clis/bluesky/search.yaml +0 -34
  409. package/dist/clis/bluesky/starter-packs.yaml +0 -34
  410. package/dist/clis/bluesky/thread.yaml +0 -32
  411. package/dist/clis/bluesky/trending.yaml +0 -27
  412. package/dist/clis/bluesky/user.yaml +0 -34
  413. package/dist/clis/devto/tag.yaml +0 -34
  414. package/dist/clis/devto/top.yaml +0 -29
  415. package/dist/clis/devto/user.yaml +0 -33
  416. package/dist/clis/dictionary/examples.yaml +0 -25
  417. package/dist/clis/dictionary/search.yaml +0 -27
  418. package/dist/clis/dictionary/synonyms.yaml +0 -25
  419. package/dist/clis/douban/subject.yaml +0 -107
  420. package/dist/clis/douban/top250.yaml +0 -70
  421. package/dist/clis/facebook/add-friend.yaml +0 -43
  422. package/dist/clis/facebook/events.yaml +0 -44
  423. package/dist/clis/facebook/feed.yaml +0 -63
  424. package/dist/clis/facebook/friends.yaml +0 -42
  425. package/dist/clis/facebook/groups.yaml +0 -50
  426. package/dist/clis/facebook/join-group.yaml +0 -44
  427. package/dist/clis/facebook/memories.yaml +0 -39
  428. package/dist/clis/facebook/notifications.yaml +0 -40
  429. package/dist/clis/facebook/profile.yaml +0 -37
  430. package/dist/clis/facebook/search.yaml +0 -47
  431. package/dist/clis/hackernews/ask.yaml +0 -38
  432. package/dist/clis/hackernews/best.yaml +0 -38
  433. package/dist/clis/hackernews/jobs.yaml +0 -36
  434. package/dist/clis/hackernews/new.yaml +0 -38
  435. package/dist/clis/hackernews/search.yaml +0 -44
  436. package/dist/clis/hackernews/show.yaml +0 -38
  437. package/dist/clis/hackernews/top.yaml +0 -38
  438. package/dist/clis/hackernews/user.yaml +0 -25
  439. package/dist/clis/hupu/hot.yaml +0 -43
  440. package/dist/clis/instagram/comment.yaml +0 -52
  441. package/dist/clis/instagram/explore.yaml +0 -43
  442. package/dist/clis/instagram/follow.yaml +0 -41
  443. package/dist/clis/instagram/followers.yaml +0 -51
  444. package/dist/clis/instagram/following.yaml +0 -51
  445. package/dist/clis/instagram/like.yaml +0 -46
  446. package/dist/clis/instagram/profile.yaml +0 -42
  447. package/dist/clis/instagram/save.yaml +0 -46
  448. package/dist/clis/instagram/saved.yaml +0 -40
  449. package/dist/clis/instagram/search.yaml +0 -44
  450. package/dist/clis/instagram/unfollow.yaml +0 -38
  451. package/dist/clis/instagram/unlike.yaml +0 -46
  452. package/dist/clis/instagram/unsave.yaml +0 -46
  453. package/dist/clis/instagram/user.yaml +0 -54
  454. package/dist/clis/jike/post.yaml +0 -59
  455. package/dist/clis/jike/topic.yaml +0 -53
  456. package/dist/clis/jike/user.yaml +0 -52
  457. package/dist/clis/jimeng/generate.yaml +0 -85
  458. package/dist/clis/jimeng/history.yaml +0 -46
  459. package/dist/clis/linux-do/categories.yaml +0 -70
  460. package/dist/clis/linux-do/search.yaml +0 -48
  461. package/dist/clis/linux-do/tags.yaml +0 -41
  462. package/dist/clis/linux-do/topic.yaml +0 -62
  463. package/dist/clis/linux-do/user-posts.yaml +0 -67
  464. package/dist/clis/linux-do/user-topics.yaml +0 -54
  465. package/dist/clis/lobsters/active.yaml +0 -29
  466. package/dist/clis/lobsters/hot.yaml +0 -29
  467. package/dist/clis/lobsters/newest.yaml +0 -29
  468. package/dist/clis/lobsters/tag.yaml +0 -34
  469. package/dist/clis/pixiv/detail.yaml +0 -49
  470. package/dist/clis/pixiv/ranking.yaml +0 -53
  471. package/dist/clis/pixiv/user.yaml +0 -46
  472. package/dist/clis/reddit/frontpage.yaml +0 -30
  473. package/dist/clis/reddit/hot.yaml +0 -47
  474. package/dist/clis/reddit/popular.yaml +0 -40
  475. package/dist/clis/reddit/search.yaml +0 -61
  476. package/dist/clis/reddit/subreddit.yaml +0 -50
  477. package/dist/clis/reddit/user-comments.yaml +0 -46
  478. package/dist/clis/reddit/user-posts.yaml +0 -44
  479. package/dist/clis/reddit/user.yaml +0 -40
  480. package/dist/clis/stackoverflow/bounties.yaml +0 -29
  481. package/dist/clis/stackoverflow/hot.yaml +0 -28
  482. package/dist/clis/stackoverflow/search.yaml +0 -33
  483. package/dist/clis/stackoverflow/unanswered.yaml +0 -28
  484. package/dist/clis/steam/top-sellers.yaml +0 -29
  485. package/dist/clis/tiktok/comment.yaml +0 -66
  486. package/dist/clis/tiktok/explore.yaml +0 -39
  487. package/dist/clis/tiktok/follow.yaml +0 -39
  488. package/dist/clis/tiktok/following.yaml +0 -46
  489. package/dist/clis/tiktok/friends.yaml +0 -47
  490. package/dist/clis/tiktok/like.yaml +0 -38
  491. package/dist/clis/tiktok/live.yaml +0 -51
  492. package/dist/clis/tiktok/notifications.yaml +0 -52
  493. package/dist/clis/tiktok/profile.yaml +0 -45
  494. package/dist/clis/tiktok/save.yaml +0 -34
  495. package/dist/clis/tiktok/search.yaml +0 -47
  496. package/dist/clis/tiktok/unfollow.yaml +0 -44
  497. package/dist/clis/tiktok/unlike.yaml +0 -38
  498. package/dist/clis/tiktok/unsave.yaml +0 -36
  499. package/dist/clis/tiktok/user.yaml +0 -44
  500. package/dist/clis/v2ex/hot.yaml +0 -28
  501. package/dist/clis/v2ex/latest.yaml +0 -28
  502. package/dist/clis/v2ex/member.yaml +0 -29
  503. package/dist/clis/v2ex/node.yaml +0 -34
  504. package/dist/clis/v2ex/nodes.yaml +0 -31
  505. package/dist/clis/v2ex/replies.yaml +0 -32
  506. package/dist/clis/v2ex/topic.yaml +0 -33
  507. package/dist/clis/v2ex/user.yaml +0 -34
  508. package/dist/clis/xiaoe/catalog.yaml +0 -129
  509. package/dist/clis/xiaoe/content.yaml +0 -43
  510. package/dist/clis/xiaoe/courses.yaml +0 -73
  511. package/dist/clis/xiaoe/detail.yaml +0 -39
  512. package/dist/clis/xiaoe/play-url.yaml +0 -124
  513. package/dist/clis/xiaohongshu/feed.yaml +0 -31
  514. package/dist/clis/xiaohongshu/notifications.yaml +0 -37
  515. package/dist/clis/xueqiu/earnings-date.yaml +0 -69
  516. package/dist/clis/xueqiu/feed.yaml +0 -53
  517. package/dist/clis/xueqiu/groups.yaml +0 -23
  518. package/dist/clis/xueqiu/hot-stock.yaml +0 -49
  519. package/dist/clis/xueqiu/hot.yaml +0 -46
  520. package/dist/clis/xueqiu/kline.yaml +0 -65
  521. package/dist/clis/xueqiu/search.yaml +0 -55
  522. package/dist/clis/xueqiu/stock.yaml +0 -69
  523. package/dist/clis/xueqiu/watchlist.yaml +0 -46
  524. package/dist/clis/zhihu/hot.yaml +0 -46
  525. package/dist/clis/zhihu/search.yaml +0 -59
  526. package/dist/src/daemon.test.js +0 -65
  527. package/dist/src/idle-manager.d.ts +0 -19
  528. package/dist/src/idle-manager.js +0 -54
  529. package/dist/src/yaml-schema.d.ts +0 -29
  530. package/dist/src/yaml-schema.js +0 -22
  531. /package/dist/{src/daemon.test.d.ts → clis/bilibili/hot.d.ts} +0 -0
@@ -0,0 +1,149 @@
1
+ import { AuthRequiredError } from '@jackwener/opencli/errors';
2
+ import { cli, Strategy } from '@jackwener/opencli/registry';
3
+ import { normalizeNumericId } from '../_shared/common.js';
4
+ cli({
5
+ site: 'taobao',
6
+ name: 'add-cart',
7
+ description: '淘宝加入购物车',
8
+ domain: 'item.taobao.com',
9
+ strategy: Strategy.COOKIE,
10
+ args: [
11
+ { name: 'id', positional: true, required: true, help: '商品 ID' },
12
+ { name: 'spec', help: '规格关键词(如 "180度" "红色 XL"),多个规格用空格分隔,模糊匹配' },
13
+ { name: 'dry-run', type: 'bool', default: false, help: '仅预览,不实际加入购物车' },
14
+ ],
15
+ columns: ['status', 'title', 'price', 'selected_spec', 'item_id'],
16
+ navigateBefore: false,
17
+ func: async (page, kwargs) => {
18
+ const itemId = normalizeNumericId(kwargs.id, 'id', '827563850178');
19
+ const specKeywords = kwargs.spec ? String(kwargs.spec).split(/\s+/).filter(Boolean) : [];
20
+ const dryRun = !!kwargs['dry-run'];
21
+ await page.goto('https://www.taobao.com');
22
+ await page.wait(2);
23
+ await page.evaluate(`location.href = ${JSON.stringify(`https://item.taobao.com/item.htm?id=${itemId}`)}`);
24
+ await page.wait(6);
25
+ const info = await page.evaluate(`
26
+ (() => {
27
+ const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
28
+ const titleEl = document.querySelector('[class*="mainTitle--"]');
29
+ const title = titleEl ? normalize(titleEl.textContent) : document.title.split('-')[0].trim();
30
+ const text = document.body?.innerText || '';
31
+ const priceMatch = text.match(/[¥¥]\\s*(\\d+(?:\\.\\d{1,2})?)/);
32
+ const price = priceMatch ? '¥' + priceMatch[1] : '';
33
+ return { title: title.slice(0, 80), price };
34
+ })()
35
+ `);
36
+ if (dryRun) {
37
+ return [{
38
+ status: 'dry-run',
39
+ title: info?.title || '',
40
+ price: info?.price || '',
41
+ selected_spec: specKeywords.join(' ') || '(未选择)',
42
+ item_id: itemId,
43
+ }];
44
+ }
45
+ const specArgs = JSON.stringify(specKeywords);
46
+ const selectResult = await page.evaluate(`
47
+ (() => {
48
+ const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
49
+ const keywords = ${specArgs};
50
+ const items = document.querySelectorAll('[class*="valueItem--"]');
51
+ const selected = [];
52
+
53
+ if (keywords.length === 0 && items.length > 0) {
54
+ const groups = new Map();
55
+ for (const item of items) {
56
+ const group = item.closest('[class*="skuItem--"], [class*="prop--"]') || item.parentElement;
57
+ const groupKey = group?.className?.substring(0, 30) || 'default';
58
+ if (!groups.has(groupKey)) groups.set(groupKey, []);
59
+ groups.get(groupKey).push(item);
60
+ }
61
+ for (const [, groupItems] of groups) {
62
+ const hasSelected = groupItems.some(el => el.className.includes('selected') || el.className.includes('active'));
63
+ if (hasSelected) continue;
64
+ for (const item of groupItems) {
65
+ if (!item.className.includes('disabled') && !item.className.includes('gray')) {
66
+ item.click();
67
+ selected.push(normalize(item.textContent).substring(0, 40));
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ } else {
73
+ const groups = new Map();
74
+ for (const item of items) {
75
+ const group = item.closest('[class*="skuItem--"], [class*="prop--"]') || item.parentElement;
76
+ const groupKey = group?.className?.substring(0, 30) || 'default';
77
+ if (!groups.has(groupKey)) groups.set(groupKey, []);
78
+ groups.get(groupKey).push(item);
79
+ }
80
+
81
+ for (const [, groupItems] of groups) {
82
+ let best = null;
83
+ let bestScore = 0;
84
+ for (const item of groupItems) {
85
+ if (item.className.includes('disabled')) continue;
86
+ const t = normalize(item.textContent);
87
+ const score = keywords.filter(kw => t.includes(kw)).length;
88
+ if (score > bestScore) { bestScore = score; best = item; }
89
+ }
90
+ if (best && bestScore > 0) {
91
+ best.click();
92
+ selected.push(normalize(best.textContent).substring(0, 40));
93
+ }
94
+ }
95
+ }
96
+ return selected;
97
+ })()
98
+ `);
99
+ await page.wait(1);
100
+ await page.evaluate(`
101
+ (() => {
102
+ const all = document.querySelectorAll('button, [role="button"], a, div, span');
103
+ for (const el of all) {
104
+ const t = (el.textContent || '').trim();
105
+ if ((t === '加入购物车' || t === '加入 购物车') && el.children.length < 5) {
106
+ el.click();
107
+ return 'clicked';
108
+ }
109
+ }
110
+ return 'btn_not_found';
111
+ })()
112
+ `);
113
+ const result = await page.evaluate(`
114
+ (async () => {
115
+ for (let i = 0; i < 10; i++) {
116
+ await new Promise(r => setTimeout(r, 500));
117
+ const text = document.body?.innerText || '';
118
+ if (text.includes('已加入购物车') || text.includes('商品已成功') || text.includes('去购物车结算') || text.includes('去购物车')) {
119
+ return 'success';
120
+ }
121
+ if (text.includes('请选择') || text.includes('请先选择')) {
122
+ return 'need_spec';
123
+ }
124
+ if (text.includes('请登录')) {
125
+ return 'login_required';
126
+ }
127
+ }
128
+ if (location.href.includes('cart')) return 'success';
129
+ return 'unknown';
130
+ })()
131
+ `);
132
+ if (result === 'login_required') {
133
+ throw new AuthRequiredError('taobao add-cart requires a logged-in Taobao session');
134
+ }
135
+ let status = '? 未确认';
136
+ if (result === 'success')
137
+ status = '✓ 已加入购物车';
138
+ else if (result === 'need_spec')
139
+ status = '✗ 需要选择更多规格';
140
+ const selectedSpec = Array.isArray(selectResult) ? selectResult.join(' | ') : '';
141
+ return [{
142
+ status,
143
+ title: info?.title || '',
144
+ price: info?.price || '',
145
+ selected_spec: selectedSpec || '(未选择)',
146
+ item_id: itemId,
147
+ }];
148
+ },
149
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ import { AuthRequiredError } from '@jackwener/opencli/errors';
2
+ import { cli, Strategy } from '@jackwener/opencli/registry';
3
+ import { clampInt } from '../_shared/common.js';
4
+ cli({
5
+ site: 'taobao',
6
+ name: 'cart',
7
+ description: '查看淘宝购物车',
8
+ domain: 'cart.taobao.com',
9
+ strategy: Strategy.COOKIE,
10
+ args: [
11
+ { name: 'limit', type: 'int', default: 20, help: '返回数量 (max 50)' },
12
+ ],
13
+ columns: ['index', 'title', 'price', 'spec', 'shop'],
14
+ navigateBefore: false,
15
+ func: async (page, kwargs) => {
16
+ const limit = clampInt(kwargs.limit, 20, 1, 50);
17
+ await page.goto('https://www.taobao.com');
18
+ await page.wait(2);
19
+ await page.evaluate(`location.href = 'https://cart.taobao.com/cart.htm'`);
20
+ await page.wait(6);
21
+ await page.autoScroll({ times: 3, delayMs: 1500 });
22
+ const data = await page.evaluate(`
23
+ (async () => {
24
+ const text = document.body?.innerText || '';
25
+ if (text.length < 500 || text.includes('请登录')) {
26
+ return { error: 'auth-required' };
27
+ }
28
+
29
+ const sections = text.split(/移入收藏/);
30
+ const results = [];
31
+
32
+ for (const section of sections) {
33
+ const lines = section.split('\\n').map(l => l.trim()).filter(Boolean);
34
+ if (lines.length < 3) continue;
35
+
36
+ let title = '';
37
+ let titleIdx = -1;
38
+ for (let i = 0; i < lines.length; i++) {
39
+ const l = lines[i];
40
+ if (l.length > 15 && l.length < 200 && !l.match(/^(删除|全选|全部商品|合计|结算|找同款|退货|¥|¥|\\d+$|颜色|尺码|规格|套餐|主板|运行)/)) {
41
+ if (l.length > title.length) {
42
+ title = l;
43
+ titleIdx = i;
44
+ }
45
+ }
46
+ }
47
+ if (!title) continue;
48
+
49
+ let price = '';
50
+ for (let i = 0; i < lines.length; i++) {
51
+ if (lines[i] === '¥' || lines[i] === '¥') {
52
+ let p = '';
53
+ for (let j = i + 1; j < Math.min(i + 4, lines.length); j++) {
54
+ if (lines[j].match(/^[\\d,.]+$/)) p += lines[j];
55
+ else if (lines[j] === '.') p += '.';
56
+ else break;
57
+ }
58
+ if (p) { price = '¥' + p; break; }
59
+ }
60
+ }
61
+
62
+ let spec = '';
63
+ for (const l of lines) {
64
+ if (l.match(/^(颜色分类|尺码|规格|套餐|主板|运行)[::]/)) {
65
+ spec = l.slice(0, 40);
66
+ break;
67
+ }
68
+ }
69
+
70
+ let shop = '';
71
+ if (titleIdx > 0) {
72
+ const prev = lines[titleIdx - 1];
73
+ if (prev && prev.length > 2 && prev.length < 30 && !prev.match(/^(删除|\\d|¥|¥|券|退|满|超)/)) {
74
+ shop = prev;
75
+ }
76
+ }
77
+
78
+ results.push({
79
+ index: results.length + 1,
80
+ title: title.slice(0, 80),
81
+ price,
82
+ spec,
83
+ shop,
84
+ });
85
+ if (results.length >= ${limit}) break;
86
+ }
87
+ return { results };
88
+ })()
89
+ `);
90
+ if (data?.error === 'auth-required') {
91
+ throw new AuthRequiredError('taobao cart requires a logged-in Taobao session');
92
+ }
93
+ return Array.isArray(data?.results) ? data.results : [];
94
+ },
95
+ });
@@ -0,0 +1,5 @@
1
+ import './search.js';
2
+ import './detail.js';
3
+ import './reviews.js';
4
+ import './cart.js';
5
+ import './add-cart.js';
@@ -0,0 +1,64 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { getRegistry } from '@jackwener/opencli/registry';
3
+ import './search.js';
4
+ import './detail.js';
5
+ import './reviews.js';
6
+ import './cart.js';
7
+ import './add-cart.js';
8
+ function createPageMock() {
9
+ return {
10
+ goto: vi.fn().mockResolvedValue(undefined),
11
+ evaluate: vi.fn().mockResolvedValue({ title: 'Demo', price: '¥99' }),
12
+ snapshot: vi.fn().mockResolvedValue(undefined),
13
+ click: vi.fn().mockResolvedValue(undefined),
14
+ typeText: vi.fn().mockResolvedValue(undefined),
15
+ pressKey: vi.fn().mockResolvedValue(undefined),
16
+ scrollTo: vi.fn().mockResolvedValue(undefined),
17
+ getFormState: vi.fn().mockResolvedValue({ forms: [], orphanFields: [] }),
18
+ wait: vi.fn().mockResolvedValue(undefined),
19
+ tabs: vi.fn().mockResolvedValue([]),
20
+ selectTab: vi.fn().mockResolvedValue(undefined),
21
+ networkRequests: vi.fn().mockResolvedValue([]),
22
+ consoleMessages: vi.fn().mockResolvedValue([]),
23
+ scroll: vi.fn().mockResolvedValue(undefined),
24
+ autoScroll: vi.fn().mockResolvedValue(undefined),
25
+ installInterceptor: vi.fn().mockResolvedValue(undefined),
26
+ getInterceptedRequests: vi.fn().mockResolvedValue([]),
27
+ getCookies: vi.fn().mockResolvedValue([]),
28
+ screenshot: vi.fn().mockResolvedValue(''),
29
+ waitForCapture: vi.fn().mockResolvedValue(undefined),
30
+ };
31
+ }
32
+ describe('taobao command registration', () => {
33
+ it('registers all taobao shopping commands', () => {
34
+ for (const name of ['search', 'detail', 'reviews', 'cart', 'add-cart']) {
35
+ expect(getRegistry().get(`taobao/${name}`)).toBeDefined();
36
+ }
37
+ });
38
+ });
39
+ describe('taobao command safety', () => {
40
+ it('rejects invalid numeric ids before evaluating page scripts', async () => {
41
+ const page = createPageMock();
42
+ const detail = getRegistry().get('taobao/detail');
43
+ await expect(detail.func(page, { id: 'bad-id' })).rejects.toMatchObject({
44
+ name: 'ArgumentError',
45
+ code: 'ARGUMENT',
46
+ });
47
+ expect(page.goto).not.toHaveBeenCalled();
48
+ expect(page.evaluate).not.toHaveBeenCalled();
49
+ });
50
+ it('supports dry-run for add-cart without clicking add-to-cart', async () => {
51
+ const page = createPageMock();
52
+ const addCart = getRegistry().get('taobao/add-cart');
53
+ const result = await addCart.func(page, { id: '827563850178', 'dry-run': true, spec: '红色 XL' });
54
+ expect(result).toEqual([
55
+ expect.objectContaining({
56
+ status: 'dry-run',
57
+ item_id: '827563850178',
58
+ }),
59
+ ]);
60
+ expect(page.goto).toHaveBeenCalledTimes(1);
61
+ expect(page.goto).toHaveBeenCalledWith('https://www.taobao.com');
62
+ expect(page.evaluate).toHaveBeenCalledTimes(2);
63
+ });
64
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import { cli, Strategy } from '@jackwener/opencli/registry';
2
+ import { normalizeNumericId } from '../_shared/common.js';
3
+ cli({
4
+ site: 'taobao',
5
+ name: 'detail',
6
+ description: '淘宝商品详情',
7
+ domain: 'item.taobao.com',
8
+ strategy: Strategy.COOKIE,
9
+ args: [
10
+ { name: 'id', positional: true, required: true, help: '商品 ID' },
11
+ ],
12
+ columns: ['field', 'value'],
13
+ navigateBefore: false,
14
+ func: async (page, kwargs) => {
15
+ const itemId = normalizeNumericId(kwargs.id, 'id', '827563850178');
16
+ await page.goto('https://www.taobao.com');
17
+ await page.wait(2);
18
+ await page.evaluate(`location.href = ${JSON.stringify(`https://item.taobao.com/item.htm?id=${itemId}`)}`);
19
+ await page.wait(6);
20
+ const data = await page.evaluate(`
21
+ (() => {
22
+ const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
23
+ const text = document.body?.innerText || '';
24
+ const results = [];
25
+
26
+ const titleEl = document.querySelector('[class*="mainTitle--"]');
27
+ const title = titleEl ? normalize(titleEl.textContent) : document.title.split('-')[0].replace(/^【[^】]+】/, '').trim();
28
+ results.push({ field: '商品名称', value: title.slice(0, 100) });
29
+
30
+ const pricePattern = /[¥¥]\\s*(\\d+(?:\\.\\d{1,2})?)/g;
31
+ const prices = [];
32
+ let m;
33
+ while ((m = pricePattern.exec(text)) && prices.length < 3) {
34
+ const p = parseFloat(m[1]);
35
+ if (p > 0.1 && p < 100000) prices.push(p);
36
+ }
37
+ if (prices.length > 0) {
38
+ results.push({ field: '价格', value: '¥' + Math.min(...prices) });
39
+ }
40
+
41
+ const salesMatch = text.match(/(\\d+万?\\+?)\\s*人付款/) || text.match(/月销\\s*(\\d+万?\\+?)/);
42
+ if (salesMatch) results.push({ field: '销量', value: salesMatch[0] });
43
+
44
+ const reviewMatch = text.match(/累计评价\\s*(\\d+万?\\+?)/) || text.match(/评价[((]\\s*(\\d+万?\\+?)/);
45
+ if (reviewMatch) results.push({ field: '评价数', value: reviewMatch[1] });
46
+
47
+ const ratingMatch = text.match(/(\\d+\\.\\d)\\s*(?:分|描述|物流|服务)/);
48
+ if (ratingMatch) results.push({ field: '店铺评分', value: ratingMatch[0] });
49
+
50
+ const shopMatch = text.match(/([\u4e00-\u9fa5A-Za-z0-9]{2,15}(?:旗舰店|专卖店|企业店|专营店))/);
51
+ if (shopMatch) results.push({ field: '店铺', value: shopMatch[1] });
52
+
53
+ const locMatch = text.match(/发货地[::]*\\s*([\u4e00-\u9fa5]{2,10})/) || text.match(/([\u4e00-\u9fa5]{2,4}(?:省|市))\\s*发货/);
54
+ if (locMatch) results.push({ field: '发货地', value: locMatch[1] });
55
+
56
+ if (text.includes('颜色分类')) {
57
+ const start = text.indexOf('颜色分类');
58
+ const specSection = start >= 0 ? text.substring(start, start + 200) : '';
59
+ const specs = specSection.split('\\n').filter(l => l.trim().length > 2 && l.trim().length < 50).slice(0, 5);
60
+ if (specs.length) results.push({ field: '可选规格', value: specs.join(' | ') });
61
+ }
62
+
63
+ results.push({ field: 'ID', value: ${JSON.stringify(itemId)} });
64
+ results.push({ field: '链接', value: location.href.split('&')[0] });
65
+ return results;
66
+ })()
67
+ `);
68
+ return Array.isArray(data) ? data : [];
69
+ },
70
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ import { cli, Strategy } from '@jackwener/opencli/registry';
2
+ import { clampInt, normalizeNumericId } from '../_shared/common.js';
3
+ cli({
4
+ site: 'taobao',
5
+ name: 'reviews',
6
+ description: '淘宝商品评价',
7
+ domain: 'item.taobao.com',
8
+ strategy: Strategy.COOKIE,
9
+ args: [
10
+ { name: 'id', positional: true, required: true, help: '商品 ID' },
11
+ { name: 'limit', type: 'int', default: 10, help: '返回评价数量 (max 20)' },
12
+ ],
13
+ columns: ['rank', 'user', 'content', 'date', 'spec'],
14
+ navigateBefore: false,
15
+ func: async (page, kwargs) => {
16
+ const itemId = normalizeNumericId(kwargs.id, 'id', '827563850178');
17
+ const limit = clampInt(kwargs.limit, 10, 1, 20);
18
+ await page.goto('https://www.taobao.com');
19
+ await page.wait(2);
20
+ await page.evaluate(`location.href = ${JSON.stringify(`https://item.taobao.com/item.htm?id=${itemId}`)}`);
21
+ await page.wait(6);
22
+ const data = await page.evaluate(`
23
+ (async () => {
24
+ const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
25
+ let sellerId = '';
26
+ const pageText = document.documentElement.innerHTML || '';
27
+ const sellerMatch = pageText.match(/sellerId['":\\s]+['"]?(\\d+)/) || pageText.match(/userId['":\\s]+['"]?(\\d+)/) || pageText.match(/shopId['":\\s]+['"]?(\\d+)/);
28
+ if (sellerMatch) sellerId = sellerMatch[1];
29
+
30
+ if (!sellerId) {
31
+ const shopLink = document.querySelector('a[href*="shopId="], a[href*="seller_id="], a[href*="userId="]');
32
+ const href = shopLink?.getAttribute('href') || '';
33
+ const m = href.match(/(?:shopId|seller_id|userId)=(\\d+)/);
34
+ if (m) sellerId = m[1];
35
+ }
36
+
37
+ const url = 'https://rate.tmall.com/list_detail_rate.htm?itemId=' + ${JSON.stringify(itemId)}
38
+ + (sellerId ? '&sellerId=' + sellerId : '')
39
+ + '&order=3&currentPage=1&append=0&content=1&tagId=&posi=&picture=&groupValue=&needFold=0&_ksTS=' + Date.now();
40
+
41
+ try {
42
+ const results = await new Promise((resolve) => {
43
+ const cbName = '_ocli_rate_' + Date.now();
44
+ let settled = false;
45
+ const cleanup = (value) => {
46
+ if (settled) return;
47
+ settled = true;
48
+ delete window[cbName];
49
+ script.remove();
50
+ resolve(value);
51
+ };
52
+ window[cbName] = (payload) => {
53
+ const list = payload?.rateDetail?.rateList || [];
54
+ cleanup(list.slice(0, ${limit}).map((item, i) => ({
55
+ rank: i + 1,
56
+ user: (item.displayUserNick || item.userNick || '').slice(0, 15),
57
+ content: normalize(item.rateContent || '').slice(0, 150),
58
+ date: (item.rateDate || '').slice(0, 10),
59
+ spec: normalize(item.auctionSku || '').slice(0, 40),
60
+ })));
61
+ };
62
+ const script = document.createElement('script');
63
+ script.src = url + '&callback=' + cbName;
64
+ script.onerror = () => cleanup([]);
65
+ document.head.appendChild(script);
66
+ setTimeout(() => cleanup([]), 10000);
67
+ });
68
+ if (results.length > 0) return results;
69
+ } catch {}
70
+
71
+ return [];
72
+ })()
73
+ `);
74
+ return Array.isArray(data) ? data : [];
75
+ },
76
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ import { AuthRequiredError } from '@jackwener/opencli/errors';
2
+ import { cli, Strategy } from '@jackwener/opencli/registry';
3
+ import { clampInt, requireNonEmptyQuery } from '../_shared/common.js';
4
+ cli({
5
+ site: 'taobao',
6
+ name: 'search',
7
+ description: '淘宝商品搜索',
8
+ domain: 's.taobao.com',
9
+ strategy: Strategy.COOKIE,
10
+ args: [
11
+ { name: 'query', positional: true, required: true, help: '搜索关键词' },
12
+ { name: 'sort', default: 'default', choices: ['default', 'sale', 'price'], help: '排序 (default/sale销量/price价格)' },
13
+ { name: 'limit', type: 'int', default: 10, help: '返回结果数量 (max 40)' },
14
+ ],
15
+ columns: ['rank', 'title', 'price', 'sales', 'shop', 'location', 'item_id', 'url'],
16
+ navigateBefore: false,
17
+ func: async (page, kwargs) => {
18
+ const limit = clampInt(kwargs.limit, 10, 1, 40);
19
+ const query = requireNonEmptyQuery(kwargs.query);
20
+ const sortMap = { default: '', sale: '&sort=sale-desc', price: '&sort=price-asc' };
21
+ const sortParam = sortMap[String(kwargs.sort || 'default')] || '';
22
+ await page.goto('https://www.taobao.com');
23
+ await page.wait(2);
24
+ await page.evaluate(`location.href = ${JSON.stringify(`https://s.taobao.com/search?q=${encodeURIComponent(query)}${sortParam}`)}`);
25
+ await page.wait(8);
26
+ await page.autoScroll({ times: 3, delayMs: 2000 });
27
+ const data = await page.evaluate(`
28
+ (async () => {
29
+ const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
30
+ const bodyText = document.body?.innerText || '';
31
+ if (bodyText.length < 1000 && bodyText.includes('请登录')) {
32
+ return { error: 'auth-required' };
33
+ }
34
+
35
+ for (let i = 0; i < 30; i++) {
36
+ if (document.querySelectorAll('[class*="doubleCard--"]').length > 3) break;
37
+ await new Promise(r => setTimeout(r, 500));
38
+ }
39
+
40
+ const cards = document.querySelectorAll('[class*="doubleCard--"]');
41
+ const results = [];
42
+ const seenTitles = new Set();
43
+
44
+ for (const card of cards) {
45
+ const titleEl = card.querySelector('[class*="title--"]');
46
+ const title = titleEl ? normalize(titleEl.textContent) : '';
47
+ if (!title || title.length < 3 || seenTitles.has(title)) continue;
48
+ seenTitles.add(title);
49
+
50
+ const intEl = card.querySelector('[class*="priceInt--"]');
51
+ const floatEl = card.querySelector('[class*="priceFloat--"]');
52
+ let price = '';
53
+ if (intEl) {
54
+ price = '¥' + normalize(intEl.textContent) + (floatEl ? normalize(floatEl.textContent) : '');
55
+ }
56
+
57
+ const salesEl = card.querySelector('[class*="realSales--"]');
58
+ const sales = salesEl ? normalize(salesEl.textContent) : '';
59
+
60
+ const shopEl = card.querySelector('[class*="shopName--"]');
61
+ let shop = shopEl ? normalize(shopEl.textContent) : '';
62
+ shop = shop.replace(/^\\d+年老店/, '').replace(/^回头客[\\d万]+/, '');
63
+
64
+ const locEls = card.querySelectorAll('[class*="procity--"]');
65
+ const location = Array.from(locEls).map(el => normalize(el.textContent)).join('');
66
+
67
+ let itemId = '';
68
+ let wrapper = card.parentElement;
69
+ for (let i = 0; i < 3 && wrapper; i++) {
70
+ const spmId = wrapper.getAttribute('data-spm-act-id');
71
+ if (spmId && /^\\d{10,}$/.test(spmId)) { itemId = spmId; break; }
72
+ wrapper = wrapper.parentElement;
73
+ }
74
+
75
+ results.push({
76
+ rank: results.length + 1,
77
+ title: title.slice(0, 80),
78
+ price,
79
+ sales,
80
+ shop,
81
+ location,
82
+ item_id: itemId,
83
+ url: itemId ? 'https://item.taobao.com/item.htm?id=' + itemId : '',
84
+ });
85
+ if (results.length >= ${limit}) break;
86
+ }
87
+
88
+ return { results };
89
+ })()
90
+ `);
91
+ if (data?.error === 'auth-required') {
92
+ throw new AuthRequiredError('taobao search requires a logged-in Taobao session');
93
+ }
94
+ return Array.isArray(data?.results) ? data.results : [];
95
+ },
96
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ import { cli } from '@jackwener/opencli/registry';
2
+ cli({
3
+ site: 'tiktok',
4
+ name: 'comment',
5
+ description: 'Comment on a TikTok video',
6
+ domain: 'www.tiktok.com',
7
+ args: [
8
+ { name: 'url', required: true, positional: true, help: 'TikTok video URL' },
9
+ { name: 'text', required: true, positional: true, help: 'Comment text' },
10
+ ],
11
+ columns: ['status', 'url', 'text'],
12
+ pipeline: [
13
+ { navigate: { url: '${{ args.url }}', settleMs: 6000 } },
14
+ { evaluate: `(async () => {
15
+ const url = \${{ args.url | json }};
16
+ const commentText = \${{ args.text | json }};
17
+ const wait = (ms) => new Promise(r => setTimeout(r, ms));
18
+
19
+ // Click comment icon to expand comment section
20
+ const commentIcon = document.querySelector('[data-e2e="comment-icon"]');
21
+ if (commentIcon) {
22
+ const cBtn = commentIcon.closest('button') || commentIcon.closest('[role="button"]') || commentIcon;
23
+ cBtn.click();
24
+ await wait(3000);
25
+ }
26
+
27
+ // Count existing comments for verification
28
+ const beforeCount = document.querySelectorAll('[data-e2e="comment-level-1"]').length;
29
+
30
+ // Find comment input
31
+ const input = document.querySelector('[data-e2e="comment-input"] [contenteditable="true"]') ||
32
+ document.querySelector('[contenteditable="true"]');
33
+ if (!input) throw new Error('Comment input not found - make sure you are logged in');
34
+
35
+ input.focus();
36
+ document.execCommand('insertText', false, commentText);
37
+ await wait(1000);
38
+
39
+ // Click post button
40
+ const btns = Array.from(document.querySelectorAll('[data-e2e="comment-post"], button'));
41
+ const postBtn = btns.find(function(b) {
42
+ var t = b.textContent.trim();
43
+ return t === 'Post' || t === '发布' || t === '发送';
44
+ });
45
+ if (!postBtn) throw new Error('Post button not found');
46
+ postBtn.click();
47
+ await wait(3000);
48
+
49
+ // Verify comment was posted by checking if comment count increased
50
+ const afterCount = document.querySelectorAll('[data-e2e="comment-level-1"]').length;
51
+ const posted = afterCount > beforeCount;
52
+
53
+ return [{ status: posted ? 'Commented' : 'Comment may have failed', url: url, text: commentText }];
54
+ })()
55
+ ` },
56
+ ],
57
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import { cli } from '@jackwener/opencli/registry';
2
+ cli({
3
+ site: 'tiktok',
4
+ name: 'explore',
5
+ description: 'Get trending TikTok videos from explore page',
6
+ domain: 'www.tiktok.com',
7
+ args: [
8
+ { name: 'limit', type: 'int', default: 20, help: 'Number of videos' },
9
+ ],
10
+ columns: ['rank', 'author', 'views', 'url'],
11
+ pipeline: [
12
+ { navigate: { url: 'https://www.tiktok.com/explore', settleMs: 5000 } },
13
+ { evaluate: `(() => {
14
+ const limit = \${{ args.limit }};
15
+ const links = Array.from(document.querySelectorAll('a[href*="/video/"]'));
16
+ const seen = new Set();
17
+ const results = [];
18
+ for (const a of links) {
19
+ const href = a.href;
20
+ if (seen.has(href)) continue;
21
+ seen.add(href);
22
+ const match = href.match(/@([^/]+)\\/video\\/(\\d+)/);
23
+ results.push({
24
+ rank: results.length + 1,
25
+ author: match ? match[1] : '',
26
+ views: a.textContent.trim() || '-',
27
+ url: href,
28
+ });
29
+ if (results.length >= limit) break;
30
+ }
31
+ return results;
32
+ })()
33
+ ` },
34
+ ],
35
+ });