@sovovs/bycli 1.8.0 → 2.1.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 (539) hide show
  1. package/cli-manifest.json +0 -61
  2. package/clis/twitter/search.js +3 -3
  3. package/dist/src/adapter-shadow.js +2 -2
  4. package/dist/src/browser/analyze.d.ts +10 -99
  5. package/dist/src/browser/analyze.js +10 -226
  6. package/dist/src/browser/cdp.js +67 -7
  7. package/dist/src/browser/daemon-client.d.ts +2 -0
  8. package/dist/src/browser/daemon-client.js +1 -1
  9. package/dist/src/browser/extension-capabilities.d.ts +13 -0
  10. package/dist/src/browser/extension-capabilities.js +22 -0
  11. package/dist/src/browser/extension-capabilities.test.d.ts +1 -0
  12. package/dist/src/browser/extension-version-metadata.test.d.ts +1 -0
  13. package/dist/src/browser/navigation-guard.d.ts +78 -0
  14. package/dist/src/browser/navigation-guard.js +142 -0
  15. package/dist/src/browser/navigation-guard.test.d.ts +1 -0
  16. package/dist/src/browser/page.d.ts +1 -0
  17. package/dist/src/browser/page.js +20 -1
  18. package/dist/src/browser/url-policy.d.ts +89 -0
  19. package/dist/src/browser/url-policy.js +311 -0
  20. package/dist/src/browser/url-policy.test.d.ts +1 -0
  21. package/dist/src/browser/verify-fixture.js +2 -2
  22. package/dist/src/build-manifest.js +4 -2
  23. package/dist/src/capabilityRouting.d.ts +3 -2
  24. package/dist/src/capabilityRouting.js +10 -2
  25. package/dist/src/cli.js +11 -14
  26. package/dist/src/commanderAdapter.js +5 -5
  27. package/dist/src/config-paths.d.ts +19 -0
  28. package/dist/src/config-paths.js +31 -0
  29. package/dist/src/daemon.js +256 -0
  30. package/dist/src/discovery.d.ts +10 -3
  31. package/dist/src/discovery.js +20 -10
  32. package/dist/src/discovery.test.d.ts +1 -0
  33. package/dist/src/execution.d.ts +5 -0
  34. package/dist/src/execution.js +272 -48
  35. package/dist/src/help.js +8 -8
  36. package/dist/src/main.js +18 -2
  37. package/dist/src/manifest-schema.d.ts +9 -0
  38. package/dist/src/manifest-schema.js +162 -0
  39. package/dist/src/manifest-schema.test.d.ts +1 -0
  40. package/dist/src/manifest-types.d.ts +1 -1
  41. package/dist/src/observation/redaction.js +10 -4
  42. package/dist/src/plugin.js +11 -8
  43. package/dist/src/recorder/highlevel/analyze.d.ts +29 -0
  44. package/dist/src/recorder/highlevel/analyze.js +91 -0
  45. package/dist/src/recorder/highlevel/init.d.ts +125 -0
  46. package/dist/src/recorder/highlevel/init.js +279 -0
  47. package/dist/src/recorder/highlevel/init.test.d.ts +1 -0
  48. package/dist/src/recorder/highlevel/verify.d.ts +73 -0
  49. package/dist/src/recorder/highlevel/verify.js +74 -0
  50. package/dist/src/recorder/http/analyze-runner.d.ts +28 -0
  51. package/dist/src/recorder/http/analyze-runner.js +78 -0
  52. package/dist/src/recorder/http/analyze-runner.test.d.ts +1 -0
  53. package/dist/src/recorder/http/handlers.d.ts +51 -0
  54. package/dist/src/recorder/http/handlers.js +219 -0
  55. package/dist/src/recorder/http/wrapper-config.d.ts +20 -0
  56. package/dist/src/recorder/http/wrapper-config.js +82 -0
  57. package/dist/src/recorder/http/wrapper-envelope.d.ts +31 -0
  58. package/dist/src/recorder/http/wrapper-envelope.js +51 -0
  59. package/dist/src/recorder/http/wrapper-gates.d.ts +16 -0
  60. package/dist/src/recorder/http/wrapper-gates.js +28 -0
  61. package/dist/src/recorder/http/wrapper-metrics.d.ts +1 -0
  62. package/dist/src/recorder/http/wrapper-metrics.js +5 -0
  63. package/dist/src/recorder/http/wrapper-registry.d.ts +50 -0
  64. package/dist/src/recorder/http/wrapper-registry.js +98 -0
  65. package/dist/src/recorder/http/wrapper-server.d.ts +59 -0
  66. package/dist/src/recorder/http/wrapper-server.js +240 -0
  67. package/dist/src/recorder/http/wrapper.test.d.ts +1 -0
  68. package/dist/src/recorder/observability/logger.d.ts +5 -0
  69. package/dist/src/recorder/observability/logger.js +13 -0
  70. package/dist/src/recorder/runner/config.d.ts +34 -0
  71. package/dist/src/recorder/runner/config.js +84 -0
  72. package/dist/src/recorder/runner/config.test.d.ts +1 -0
  73. package/dist/src/recorder/runner/reap.d.ts +79 -0
  74. package/dist/src/recorder/runner/reap.js +230 -0
  75. package/dist/src/recorder/runner/reap.test.d.ts +1 -0
  76. package/dist/src/recorder/runner/runner-port.d.ts +95 -0
  77. package/dist/src/recorder/runner/runner-port.js +518 -0
  78. package/dist/src/recorder/runner/runner-port.test.d.ts +1 -0
  79. package/dist/src/recorder/runner/session-keys.d.ts +28 -0
  80. package/dist/src/recorder/runner/session-keys.js +72 -0
  81. package/dist/src/recorder/runner/session-keys.test.d.ts +1 -0
  82. package/dist/src/recorder/runner/verify-runner-main.d.ts +96 -0
  83. package/dist/src/recorder/runner/verify-runner-main.js +292 -0
  84. package/dist/src/recorder/runner/verify-runner-main.test.d.ts +1 -0
  85. package/dist/src/registry-api.d.ts +1 -1
  86. package/dist/src/registry-api.types.test.d.ts +1 -0
  87. package/dist/src/registry-transaction.d.ts +42 -0
  88. package/dist/src/registry-transaction.js +194 -0
  89. package/dist/src/registry-transaction.test.d.ts +1 -0
  90. package/dist/src/registry.d.ts +58 -16
  91. package/dist/src/registry.js +131 -15
  92. package/dist/src/serialization.d.ts +1 -1
  93. package/dist/src/serialization.js +3 -3
  94. package/dist/src/types.d.ts +2 -0
  95. package/package.json +8 -5
  96. package/scripts/m1-daemon-navigate-drive.mjs +138 -0
  97. package/scripts/m1-extension-spike.mjs +237 -0
  98. package/scripts/m1-live-spike.mjs +156 -0
  99. package/scripts/m6b-connect-back-spike.sh +31 -0
  100. package/clis/12306/utils.test.js +0 -331
  101. package/clis/1688/assets.test.js +0 -39
  102. package/clis/1688/download.test.js +0 -31
  103. package/clis/1688/item.test.js +0 -67
  104. package/clis/1688/search.test.js +0 -75
  105. package/clis/1688/shared.test.js +0 -57
  106. package/clis/1688/store.test.js +0 -62
  107. package/clis/36kr/article.test.js +0 -46
  108. package/clis/36kr/hot.test.js +0 -15
  109. package/clis/36kr/news.test.js +0 -85
  110. package/clis/51job/utils.test.js +0 -69
  111. package/clis/_atlassian/shared.test.js +0 -170
  112. package/clis/aibase/news.test.js +0 -59
  113. package/clis/amazon/bestsellers.test.js +0 -29
  114. package/clis/amazon/discussion.test.js +0 -124
  115. package/clis/amazon/offer.test.js +0 -29
  116. package/clis/amazon/product.test.js +0 -24
  117. package/clis/amazon/rankings.test.js +0 -41
  118. package/clis/amazon/search.test.js +0 -22
  119. package/clis/amazon/shared.test.js +0 -44
  120. package/clis/apple-podcasts/commands.test.js +0 -119
  121. package/clis/apple-podcasts/utils.test.js +0 -57
  122. package/clis/arxiv/arxiv.test.js +0 -112
  123. package/clis/baidu-scholar/search.test.js +0 -23
  124. package/clis/barchart/greeks.test.js +0 -138
  125. package/clis/bilibili/comment.test.js +0 -153
  126. package/clis/bilibili/comments.test.js +0 -142
  127. package/clis/bilibili/dynamic.test.js +0 -68
  128. package/clis/bilibili/hot.test.js +0 -17
  129. package/clis/bilibili/subtitle.test.js +0 -196
  130. package/clis/bilibili/summary.test.js +0 -210
  131. package/clis/bilibili/utils.test.js +0 -61
  132. package/clis/bilibili/video.test.js +0 -132
  133. package/clis/binance/commands.test.js +0 -70
  134. package/clis/bloomberg/utils.test.js +0 -129
  135. package/clis/booking/booking.test.js +0 -356
  136. package/clis/boss/chatlist.test.js +0 -211
  137. package/clis/boss/chatmsg.test.js +0 -230
  138. package/clis/boss/search.test.js +0 -78
  139. package/clis/boss/utils.test.js +0 -34
  140. package/clis/brave/search.test.js +0 -76
  141. package/clis/chaoxing/utils.test.js +0 -45
  142. package/clis/chatgpt/commands.test.js +0 -45
  143. package/clis/chatgpt/envelope.test.js +0 -108
  144. package/clis/chatgpt/image.test.js +0 -188
  145. package/clis/chatgpt/utils.test.js +0 -330
  146. package/clis/chatgpt-app/ax.test.js +0 -35
  147. package/clis/chatwise/composer.test.js +0 -186
  148. package/clis/chess/analyze.test.js +0 -79
  149. package/clis/chess/game.test.js +0 -178
  150. package/clis/chess/games.test.js +0 -164
  151. package/clis/chess/stats.test.js +0 -79
  152. package/clis/chess/utils.test.js +0 -230
  153. package/clis/claude/ask.test.js +0 -338
  154. package/clis/claude/commands.test.js +0 -118
  155. package/clis/claude/utils.test.js +0 -148
  156. package/clis/cnki/search.test.js +0 -18
  157. package/clis/codex/sidebar.test.js +0 -329
  158. package/clis/coingecko/coingecko.test.js +0 -109
  159. package/clis/confluence/commands.test.js +0 -195
  160. package/clis/coupang/coupang.test.js +0 -159
  161. package/clis/coupang/utils.test.js +0 -62
  162. package/clis/ctrip/ctrip.test.js +0 -719
  163. package/clis/dblp/dblp.test.js +0 -397
  164. package/clis/deepseek/ask.test.js +0 -312
  165. package/clis/deepseek/detail.test.js +0 -81
  166. package/clis/deepseek/send.test.js +0 -107
  167. package/clis/deepseek/utils.test.js +0 -370
  168. package/clis/defillama/defillama.test.js +0 -99
  169. package/clis/devto/devto.test.js +0 -236
  170. package/clis/dianping/dianping.test.js +0 -578
  171. package/clis/douban/download.test.js +0 -170
  172. package/clis/douban/movie-hot.test.js +0 -14
  173. package/clis/douban/search.test.js +0 -11
  174. package/clis/douban/subject.test.js +0 -11
  175. package/clis/douban/utils.test.js +0 -438
  176. package/clis/doubao/detail.test.js +0 -42
  177. package/clis/doubao/history.test.js +0 -37
  178. package/clis/doubao/utils.test.js +0 -344
  179. package/clis/douyin/_shared/browser-fetch.test.js +0 -64
  180. package/clis/douyin/_shared/creation-id.test.js +0 -22
  181. package/clis/douyin/_shared/imagex-upload.test.js +0 -87
  182. package/clis/douyin/_shared/sts2.test.js +0 -27
  183. package/clis/douyin/_shared/text-extra.test.js +0 -37
  184. package/clis/douyin/_shared/timing.test.js +0 -28
  185. package/clis/douyin/_shared/tos-upload-short-read.test.js +0 -83
  186. package/clis/douyin/_shared/tos-upload.test.js +0 -229
  187. package/clis/douyin/_shared/transcode.test.js +0 -91
  188. package/clis/douyin/_shared/vod-upload.test.js +0 -38
  189. package/clis/douyin/activities.test.js +0 -55
  190. package/clis/douyin/collections.test.js +0 -45
  191. package/clis/douyin/delete.test.js +0 -100
  192. package/clis/douyin/draft.test.js +0 -335
  193. package/clis/douyin/drafts.test.js +0 -11
  194. package/clis/douyin/hashtag.test.js +0 -171
  195. package/clis/douyin/location.test.js +0 -23
  196. package/clis/douyin/profile.test.js +0 -46
  197. package/clis/douyin/publish-upload-id.test.js +0 -170
  198. package/clis/douyin/publish.test.js +0 -38
  199. package/clis/douyin/stats.test.js +0 -22
  200. package/clis/douyin/update.test.js +0 -11
  201. package/clis/douyin/user-videos.test.js +0 -151
  202. package/clis/douyin/videos.test.js +0 -54
  203. package/clis/duckduckgo/search.test.js +0 -128
  204. package/clis/duckduckgo/suggest.test.js +0 -66
  205. package/clis/eastmoney/hot-rank.test.js +0 -59
  206. package/clis/endoflife/endoflife.test.js +0 -51
  207. package/clis/facebook/feed.test.js +0 -169
  208. package/clis/facebook/marketplace.test.js +0 -91
  209. package/clis/facebook/notifications.test.js +0 -458
  210. package/clis/facebook/search.test.js +0 -55
  211. package/clis/flathub/flathub.test.js +0 -90
  212. package/clis/flomo/memos.test.js +0 -144
  213. package/clis/gemini/ask.test.js +0 -100
  214. package/clis/gemini/deep-research-result.test.js +0 -155
  215. package/clis/gemini/deep-research.test.js +0 -181
  216. package/clis/gemini/reply-state.test.js +0 -671
  217. package/clis/gemini/utils.test.js +0 -198
  218. package/clis/geogebra/geogebra.test.js +0 -175
  219. package/clis/gitee/search.test.js +0 -65
  220. package/clis/gitee/user.test.js +0 -63
  221. package/clis/google/utils.test.js +0 -75
  222. package/clis/google-scholar/cite.test.js +0 -47
  223. package/clis/google-scholar/profile.test.js +0 -49
  224. package/clis/google-scholar/search.test.js +0 -71
  225. package/clis/goproxy/goproxy.test.js +0 -103
  226. package/clis/gov-law/commands.test.js +0 -39
  227. package/clis/gov-policy/gov-policy.test.js +0 -224
  228. package/clis/grok/ask.test.js +0 -29
  229. package/clis/grok/utils.test.js +0 -103
  230. package/clis/hackernews/hackernews.test.js +0 -132
  231. package/clis/hf/hf.test.js +0 -16
  232. package/clis/hupu/hot.test.js +0 -224
  233. package/clis/imdb/utils.test.js +0 -88
  234. package/clis/indeed/indeed.test.js +0 -375
  235. package/clis/instagram/_shared/private-publish.test.js +0 -705
  236. package/clis/instagram/_shared/protocol-capture.test.js +0 -114
  237. package/clis/instagram/download.test.js +0 -118
  238. package/clis/instagram/note.test.js +0 -53
  239. package/clis/instagram/post.test.js +0 -1647
  240. package/clis/instagram/reel.test.js +0 -167
  241. package/clis/instagram/story.test.js +0 -134
  242. package/clis/jd/commands.test.js +0 -41
  243. package/clis/jd/item.test.js +0 -354
  244. package/clis/jianyu/search.test.js +0 -153
  245. package/clis/jianyu/shared/procurement-contract.test.js +0 -72
  246. package/clis/jianyu/shared/procurement-detail.test.js +0 -84
  247. package/clis/jike/read.test.js +0 -86
  248. package/clis/jira/commands.test.js +0 -287
  249. package/clis/juejin/search.js +0 -123
  250. package/clis/juejin/search.test.js +0 -98
  251. package/clis/lesswrong/frontpage.test.js +0 -37
  252. package/clis/lichess/lichess.test.js +0 -85
  253. package/clis/linkedin/connect.test.js +0 -213
  254. package/clis/linkedin/inbox.test.js +0 -152
  255. package/clis/linkedin/job-detail.test.js +0 -38
  256. package/clis/linkedin/jobs-preferences.test.js +0 -43
  257. package/clis/linkedin/people-search.test.js +0 -216
  258. package/clis/linkedin/post-analytics.test.js +0 -40
  259. package/clis/linkedin/posts.test.js +0 -40
  260. package/clis/linkedin/profile-analytics.test.js +0 -67
  261. package/clis/linkedin/profile-experience.test.js +0 -152
  262. package/clis/linkedin/profile-projects.test.js +0 -111
  263. package/clis/linkedin/profile-read.test.js +0 -77
  264. package/clis/linkedin/safe-send.test.js +0 -204
  265. package/clis/linkedin/salesnav-inbox.test.js +0 -113
  266. package/clis/linkedin/salesnav-message.test.js +0 -172
  267. package/clis/linkedin/salesnav-search.test.js +0 -76
  268. package/clis/linkedin/salesnav-thread.test.js +0 -79
  269. package/clis/linkedin/search.test.js +0 -222
  270. package/clis/linkedin/sent-invitations.test.js +0 -62
  271. package/clis/linkedin/services-read.test.js +0 -105
  272. package/clis/linkedin/thread-snapshot.test.js +0 -89
  273. package/clis/linkedin/timeline.test.js +0 -81
  274. package/clis/linkedin-learning/course.test.js +0 -114
  275. package/clis/linkedin-learning/search.test.js +0 -144
  276. package/clis/linkedin-learning/trending.test.js +0 -123
  277. package/clis/linux-do/feed.test.js +0 -153
  278. package/clis/linux-do/topic-content.test.js +0 -59
  279. package/clis/lobsters/lobsters.test.js +0 -169
  280. package/clis/notebooklm/add-source.test.js +0 -97
  281. package/clis/notebooklm/compat.test.js +0 -16
  282. package/clis/notebooklm/create.test.js +0 -58
  283. package/clis/notebooklm/generate-audio.test.js +0 -63
  284. package/clis/notebooklm/generate-slides.test.js +0 -75
  285. package/clis/notebooklm/history.test.js +0 -58
  286. package/clis/notebooklm/note-list.test.js +0 -56
  287. package/clis/notebooklm/notes-get.test.js +0 -72
  288. package/clis/notebooklm/open.test.js +0 -63
  289. package/clis/notebooklm/rpc.test.js +0 -131
  290. package/clis/notebooklm/source-fulltext.test.js +0 -106
  291. package/clis/notebooklm/source-get.test.js +0 -84
  292. package/clis/notebooklm/source-guide.test.js +0 -104
  293. package/clis/notebooklm/summary.test.js +0 -78
  294. package/clis/notebooklm/utils.test.js +0 -449
  295. package/clis/notebooklm/write-note.test.js +0 -70
  296. package/clis/nuget/nuget.test.js +0 -111
  297. package/clis/oeis/oeis.test.js +0 -88
  298. package/clis/ones/task-helpers.test.js +0 -12
  299. package/clis/ones/worklog.test.js +0 -20
  300. package/clis/openfda/openfda.test.js +0 -114
  301. package/clis/openreview/openreview.test.js +0 -427
  302. package/clis/osv/osv.test.js +0 -97
  303. package/clis/paperreview/commands.test.js +0 -243
  304. package/clis/paperreview/utils.test.js +0 -49
  305. package/clis/pixiv/download.test.js +0 -87
  306. package/clis/pixiv/illusts.test.js +0 -99
  307. package/clis/pixiv/search.test.js +0 -83
  308. package/clis/powerchina/search.test.js +0 -93
  309. package/clis/producthunt/utils.test.js +0 -64
  310. package/clis/pubmed/pubmed.test.js +0 -276
  311. package/clis/quark/utils.test.js +0 -58
  312. package/clis/qwen/utils.test.js +0 -45
  313. package/clis/reddit/extract-media.test.js +0 -149
  314. package/clis/reddit/frontpage.test.js +0 -34
  315. package/clis/reddit/home.test.js +0 -170
  316. package/clis/reddit/hot.test.js +0 -32
  317. package/clis/reddit/popular.test.js +0 -26
  318. package/clis/reddit/read.test.js +0 -335
  319. package/clis/reddit/reply.test.js +0 -89
  320. package/clis/reddit/search.test.js +0 -26
  321. package/clis/reddit/subreddit-info.test.js +0 -163
  322. package/clis/reddit/subreddit.test.js +0 -31
  323. package/clis/reddit/subscribed.test.js +0 -168
  324. package/clis/reddit/whoami.test.js +0 -105
  325. package/clis/rednote/navigation.test.js +0 -26
  326. package/clis/rednote/rednote.test.js +0 -222
  327. package/clis/rest-countries/rest-countries.test.js +0 -83
  328. package/clis/reuters/reuters.test.js +0 -299
  329. package/clis/rfc/rfc.test.js +0 -74
  330. package/clis/sinafinance/stock.test.js +0 -59
  331. package/clis/spotify/utils.test.js +0 -67
  332. package/clis/stackoverflow/stackoverflow.test.js +0 -404
  333. package/clis/steam/steam.test.js +0 -46
  334. package/clis/substack/utils.test.js +0 -44
  335. package/clis/suno/commands.test.js +0 -188
  336. package/clis/suno/download.test.js +0 -151
  337. package/clis/suno/generate.test.js +0 -252
  338. package/clis/suno/utils.test.js +0 -329
  339. package/clis/taobao/commands.test.js +0 -41
  340. package/clis/tdx/hot-rank.test.js +0 -59
  341. package/clis/ths/hot-rank.test.js +0 -64
  342. package/clis/tieba/commands.test.js +0 -79
  343. package/clis/tieba/utils.test.js +0 -290
  344. package/clis/tiktok/creator-videos.test.js +0 -113
  345. package/clis/tiktok/refactor.test.js +0 -389
  346. package/clis/tiktok/write-refactor.test.js +0 -370
  347. package/clis/toutiao/toutiao.test.js +0 -378
  348. package/clis/tvmaze/tvmaze.test.js +0 -93
  349. package/clis/twitter/bookmark-folder.test.js +0 -395
  350. package/clis/twitter/bookmark-folders.test.js +0 -152
  351. package/clis/twitter/bookmark.test.js +0 -74
  352. package/clis/twitter/bookmarks.test.js +0 -205
  353. package/clis/twitter/delete.test.js +0 -85
  354. package/clis/twitter/device-follow.test.js +0 -287
  355. package/clis/twitter/download.test.js +0 -457
  356. package/clis/twitter/followers.test.js +0 -62
  357. package/clis/twitter/following.test.js +0 -338
  358. package/clis/twitter/hide-reply.test.js +0 -76
  359. package/clis/twitter/like.test.js +0 -73
  360. package/clis/twitter/likes.test.js +0 -220
  361. package/clis/twitter/list-add.test.js +0 -133
  362. package/clis/twitter/list-create.test.js +0 -169
  363. package/clis/twitter/list-remove.test.js +0 -110
  364. package/clis/twitter/list-tweets.test.js +0 -196
  365. package/clis/twitter/lists.test.js +0 -253
  366. package/clis/twitter/post.test.js +0 -258
  367. package/clis/twitter/profile.test.js +0 -39
  368. package/clis/twitter/quote.test.js +0 -194
  369. package/clis/twitter/reply.test.js +0 -237
  370. package/clis/twitter/retweet.test.js +0 -73
  371. package/clis/twitter/search.test.js +0 -349
  372. package/clis/twitter/shared.test.js +0 -794
  373. package/clis/twitter/thread.test.js +0 -58
  374. package/clis/twitter/timeline.test.js +0 -104
  375. package/clis/twitter/trending.test.js +0 -15
  376. package/clis/twitter/tweets.test.js +0 -362
  377. package/clis/twitter/unbookmark.test.js +0 -73
  378. package/clis/twitter/unlike.test.js +0 -75
  379. package/clis/twitter/unretweet.test.js +0 -73
  380. package/clis/twitter/utils.test.js +0 -169
  381. package/clis/uisdc/news.test.js +0 -66
  382. package/clis/uiverse/_shared.test.js +0 -62
  383. package/clis/uiverse/navigation.test.js +0 -12
  384. package/clis/upwork/upwork.test.js +0 -566
  385. package/clis/wanfang/search.test.js +0 -23
  386. package/clis/web/read.test.js +0 -392
  387. package/clis/weibo/delete.test.js +0 -94
  388. package/clis/weibo/envelope.test.js +0 -85
  389. package/clis/weibo/favorites.test.js +0 -114
  390. package/clis/weibo/publish.test.js +0 -192
  391. package/clis/weibo/user-posts.test.js +0 -92
  392. package/clis/weibo/utils.test.js +0 -36
  393. package/clis/weixin/drafts.test.js +0 -69
  394. package/clis/weixin/search.test.js +0 -227
  395. package/clis/weread/ai-outline.test.js +0 -83
  396. package/clis/weread/book-search.test.js +0 -242
  397. package/clis/weread/commands.test.js +0 -398
  398. package/clis/weread/private-api-regression.test.js +0 -369
  399. package/clis/weread/search-regression.test.js +0 -494
  400. package/clis/weread/utils.test.js +0 -128
  401. package/clis/weread-official/commands.test.js +0 -385
  402. package/clis/weread-official/utils.test.js +0 -242
  403. package/clis/wikidata/wikidata.test.js +0 -83
  404. package/clis/wikipedia/trending.test.js +0 -57
  405. package/clis/wttr/wttr.test.js +0 -84
  406. package/clis/xianyu/chat.test.js +0 -84
  407. package/clis/xianyu/im.test.js +0 -253
  408. package/clis/xianyu/item.test.js +0 -56
  409. package/clis/xianyu/publish.test.js +0 -220
  410. package/clis/xianyu/search.test.js +0 -17
  411. package/clis/xiaoe/xiaoe.test.js +0 -486
  412. package/clis/xiaohongshu/comments.test.js +0 -258
  413. package/clis/xiaohongshu/creator-note-detail.test.js +0 -451
  414. package/clis/xiaohongshu/creator-notes-summary.test.js +0 -94
  415. package/clis/xiaohongshu/creator-notes.test.js +0 -281
  416. package/clis/xiaohongshu/creator-stats.test.js +0 -24
  417. package/clis/xiaohongshu/delete-note.test.js +0 -172
  418. package/clis/xiaohongshu/download.test.js +0 -316
  419. package/clis/xiaohongshu/navigation.test.js +0 -34
  420. package/clis/xiaohongshu/note.test.js +0 -249
  421. package/clis/xiaohongshu/publish.test.js +0 -608
  422. package/clis/xiaohongshu/search.test.js +0 -325
  423. package/clis/xiaohongshu/user-helpers.test.js +0 -160
  424. package/clis/xiaoyuzhou/auth.test.js +0 -124
  425. package/clis/xiaoyuzhou/download.test.js +0 -135
  426. package/clis/xiaoyuzhou/podcast-episodes.test.js +0 -78
  427. package/clis/xiaoyuzhou/transcript.test.js +0 -195
  428. package/clis/xiaoyuzhou/utils.test.js +0 -39
  429. package/clis/xueqiu/comments.test.js +0 -696
  430. package/clis/xueqiu/danjuan-utils.test.js +0 -41
  431. package/clis/xueqiu/utils.test.js +0 -26
  432. package/clis/yahoo/search.test.js +0 -94
  433. package/clis/youdao/note.test.js +0 -99
  434. package/clis/youtube/channel.test.js +0 -59
  435. package/clis/youtube/feed.test.js +0 -131
  436. package/clis/youtube/transcript-group.test.js +0 -99
  437. package/clis/youtube/transcript.test.js +0 -296
  438. package/clis/youtube/utils.test.js +0 -84
  439. package/clis/yuanbao/ask.test.js +0 -124
  440. package/clis/yuanbao/new.test.js +0 -30
  441. package/clis/yuanbao/shared.test.js +0 -80
  442. package/clis/zhihu/answer-comments.test.js +0 -287
  443. package/clis/zhihu/answer-detail.test.js +0 -338
  444. package/clis/zhihu/answer.test.js +0 -54
  445. package/clis/zhihu/collection.test.js +0 -337
  446. package/clis/zhihu/collections.test.js +0 -182
  447. package/clis/zhihu/comment.test.js +0 -50
  448. package/clis/zhihu/download.test.js +0 -12
  449. package/clis/zhihu/favorite.test.js +0 -59
  450. package/clis/zhihu/follow.test.js +0 -42
  451. package/clis/zhihu/like.test.js +0 -41
  452. package/clis/zhihu/question.test.js +0 -251
  453. package/clis/zhihu/recommend.test.js +0 -143
  454. package/clis/zhihu/search.test.js +0 -198
  455. package/clis/zhihu/target.test.js +0 -77
  456. package/clis/zhihu/text.test.js +0 -24
  457. package/clis/zhihu/write-shared.test.js +0 -176
  458. package/clis/zlibrary/commands.test.js +0 -65
  459. package/clis/zsxq/search.test.js +0 -24
  460. package/clis/zsxq/topic.test.js +0 -30
  461. package/clis/zsxq/topics.test.js +0 -24
  462. package/clis/zsxq/utils.test.js +0 -31
  463. package/dist/src/adapter-shadow.test.js +0 -49
  464. package/dist/src/adapter-source.test.js +0 -29
  465. package/dist/src/browser/analyze.test.js +0 -166
  466. package/dist/src/browser/article-extract.e2e.test.js +0 -105
  467. package/dist/src/browser/article-extract.test.js +0 -94
  468. package/dist/src/browser/ax-snapshot.test.js +0 -91
  469. package/dist/src/browser/base-page.test.js +0 -758
  470. package/dist/src/browser/cdp-click-fixture.test.js +0 -87
  471. package/dist/src/browser/cdp.test.js +0 -79
  472. package/dist/src/browser/compound.test.js +0 -175
  473. package/dist/src/browser/daemon-client.test.js +0 -199
  474. package/dist/src/browser/dom-helpers.test.js +0 -106
  475. package/dist/src/browser/dom-snapshot.test.js +0 -313
  476. package/dist/src/browser/errors.test.js +0 -60
  477. package/dist/src/browser/extract.test.js +0 -129
  478. package/dist/src/browser/find.test.js +0 -180
  479. package/dist/src/browser/html-tree.test.js +0 -181
  480. package/dist/src/browser/network-cache.test.js +0 -58
  481. package/dist/src/browser/network-key.test.js +0 -49
  482. package/dist/src/browser/page.test.js +0 -378
  483. package/dist/src/browser/shape-filter.test.js +0 -101
  484. package/dist/src/browser/shape.test.js +0 -82
  485. package/dist/src/browser/stealth.test.js +0 -134
  486. package/dist/src/browser/target-errors.test.js +0 -94
  487. package/dist/src/browser/target-resolver.test.js +0 -118
  488. package/dist/src/browser/utils.test.js +0 -29
  489. package/dist/src/browser/verify-fixture.test.js +0 -219
  490. package/dist/src/browser.test.js +0 -232
  491. package/dist/src/build-manifest.test.js +0 -341
  492. package/dist/src/capabilityRouting.test.js +0 -63
  493. package/dist/src/cli-argv-preprocess.test.js +0 -209
  494. package/dist/src/cli.test.js +0 -2803
  495. package/dist/src/commanderAdapter.test.js +0 -352
  496. package/dist/src/commands/daemon.test.js +0 -219
  497. package/dist/src/completion.test.js +0 -24
  498. package/dist/src/convention-audit.test.js +0 -247
  499. package/dist/src/daemon.test.js +0 -60
  500. package/dist/src/doctor.test.js +0 -263
  501. package/dist/src/download/article-download.test.js +0 -235
  502. package/dist/src/download/index.test.js +0 -140
  503. package/dist/src/download/media-download.test.js +0 -112
  504. package/dist/src/download/progress.test.js +0 -36
  505. package/dist/src/electron-apps.test.js +0 -49
  506. package/dist/src/engine.test.js +0 -312
  507. package/dist/src/errors.test.js +0 -109
  508. package/dist/src/execution.test.js +0 -623
  509. package/dist/src/extension-manifest-regression.test.js +0 -12
  510. package/dist/src/external.test.js +0 -146
  511. package/dist/src/help.test.js +0 -58
  512. package/dist/src/hooks.test.js +0 -92
  513. package/dist/src/interceptor.test.js +0 -81
  514. package/dist/src/launcher.test.js +0 -138
  515. package/dist/src/node-network.test.js +0 -55
  516. package/dist/src/observation/artifact.test.js +0 -121
  517. package/dist/src/observation/manager.test.js +0 -13
  518. package/dist/src/observation/redaction.test.js +0 -32
  519. package/dist/src/observation/retention.test.js +0 -118
  520. package/dist/src/observation/ring-buffer.test.js +0 -22
  521. package/dist/src/output.test.js +0 -53
  522. package/dist/src/package-exports.test.js +0 -112
  523. package/dist/src/pipeline/executor.test.js +0 -182
  524. package/dist/src/pipeline/steps/download.test.js +0 -102
  525. package/dist/src/pipeline/steps/fetch.test.js +0 -117
  526. package/dist/src/pipeline/template.test.js +0 -175
  527. package/dist/src/pipeline/transform.test.js +0 -133
  528. package/dist/src/plugin-manifest.test.js +0 -179
  529. package/dist/src/plugin-scaffold.test.js +0 -83
  530. package/dist/src/plugin.test.js +0 -1324
  531. package/dist/src/registry.test.js +0 -209
  532. package/dist/src/runtime-detect.test.js +0 -39
  533. package/dist/src/serialization.test.js +0 -78
  534. package/dist/src/snapshotFormatter.test.js +0 -521
  535. package/dist/src/tui.test.js +0 -19
  536. package/dist/src/update-check.test.js +0 -116
  537. package/dist/src/utils.test.js +0 -155
  538. package/dist/src/validate.test.js +0 -90
  539. package/dist/src/weixin-download.test.js +0 -45
@@ -1,608 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as os from 'node:os';
3
- import * as path from 'node:path';
4
- import { describe, expect, it, vi } from 'vitest';
5
- import { getRegistry } from '@sovovs/bycli/registry';
6
- import './publish.js';
7
- function createPageMock(evaluateResults, overrides = {}) {
8
- const evaluate = vi.fn();
9
- for (const result of evaluateResults) {
10
- evaluate.mockResolvedValueOnce(result);
11
- }
12
- return {
13
- goto: vi.fn().mockResolvedValue(undefined),
14
- evaluate,
15
- snapshot: vi.fn().mockResolvedValue(undefined),
16
- click: vi.fn().mockResolvedValue(undefined),
17
- typeText: vi.fn().mockResolvedValue(undefined),
18
- pressKey: vi.fn().mockResolvedValue(undefined),
19
- scrollTo: vi.fn().mockResolvedValue(undefined),
20
- getFormState: vi.fn().mockResolvedValue({ forms: [], orphanFields: [] }),
21
- wait: vi.fn().mockResolvedValue(undefined),
22
- tabs: vi.fn().mockResolvedValue([]),
23
- selectTab: vi.fn().mockResolvedValue(undefined),
24
- networkRequests: vi.fn().mockResolvedValue([]),
25
- consoleMessages: vi.fn().mockResolvedValue([]),
26
- scroll: vi.fn().mockResolvedValue(undefined),
27
- autoScroll: vi.fn().mockResolvedValue(undefined),
28
- installInterceptor: vi.fn().mockResolvedValue(undefined),
29
- getInterceptedRequests: vi.fn().mockResolvedValue([]),
30
- getCookies: vi.fn().mockResolvedValue([]),
31
- screenshot: vi.fn().mockResolvedValue(''),
32
- waitForCapture: vi.fn().mockResolvedValue(undefined),
33
- ...overrides,
34
- };
35
- }
36
- function createConditionalPageMock(evaluateImpl, overrides = {}) {
37
- const page = createPageMock([], overrides);
38
- page.evaluate.mockImplementation(async (js) => evaluateImpl(String(js)));
39
- return page;
40
- }
41
- describe('xiaohongshu publish', () => {
42
- it('uses native insertText for contenteditable title fields when available', async () => {
43
- const cmd = getRegistry().get('xiaohongshu/publish');
44
- expect(cmd?.func).toBeTypeOf('function');
45
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
46
- const imagePath = path.join(tempDir, 'demo.jpg');
47
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
48
- const insertText = vi.fn().mockResolvedValue(undefined);
49
- const page = createConditionalPageMock((code) => {
50
- if (code.includes('location.href'))
51
- return 'https://creator.xiaohongshu.com/publish/publish?from=menu_left';
52
- if (code.includes("const targets = ['上传图文', '图文', '图片']"))
53
- return { ok: true, target: '上传图文', text: '上传图文' };
54
- if (code.includes('hasTitleInput') && code.includes('hasVideoSurface'))
55
- return { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false };
56
- if (code.includes('const images =') && code.includes('dt.items.add(new File'))
57
- return { ok: true, count: 1 };
58
- if (code.includes('[class*="upload"][class*="progress"]'))
59
- return false;
60
- if (code.includes('const sels =') && code.includes('for (const sel of sels)'))
61
- return true;
62
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"locate"')) {
63
- return code.includes('[contenteditable="true"][placeholder*="标题"]')
64
- ? { ok: true, sel: '[contenteditable="true"][placeholder*="标题"]', kind: 'contenteditable' }
65
- : { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' };
66
- }
67
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"prepare"'))
68
- return { ok: true };
69
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"verify"')) {
70
- return code.includes('[contenteditable="true"][placeholder*="标题"]')
71
- ? { ok: true, actual: '标题走原生输入' }
72
- : { ok: true, actual: '正文也走原生输入' };
73
- }
74
- if (code.includes('(function(selectors, text)')) {
75
- return code.includes('[contenteditable="true"][placeholder*="标题"]')
76
- ? { ok: true, sel: '[contenteditable="true"][placeholder*="标题"]', kind: 'contenteditable', actual: '标题走原生输入' }
77
- : { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable', actual: '正文也走原生输入' };
78
- }
79
- if (code.includes('xhs-publish-btn'))
80
- return { ok: true, via: 'click', text: '发布' };
81
- if (code.includes('labels.some'))
82
- return false;
83
- if (code.includes('for (const el of document.querySelectorAll'))
84
- return '发布成功';
85
- throw new Error(`Unhandled evaluate call: ${code.slice(0, 120)}`);
86
- }, {
87
- insertText,
88
- });
89
- const result = await cmd.func(page, {
90
- title: '标题走原生输入',
91
- content: '正文也走原生输入',
92
- images: imagePath,
93
- topics: '',
94
- draft: false,
95
- });
96
- expect(insertText).toHaveBeenNthCalledWith(1, '标题走原生输入');
97
- expect(insertText).toHaveBeenNthCalledWith(2, '正文也走原生输入');
98
- expect(result).toEqual([
99
- {
100
- status: '✅ 发布成功',
101
- detail: '"标题走原生输入" · 1张图片 · 发布成功',
102
- },
103
- ]);
104
- });
105
- it('aborts when the title does not stick after filling', async () => {
106
- const cmd = getRegistry().get('xiaohongshu/publish');
107
- expect(cmd?.func).toBeTypeOf('function');
108
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
109
- const imagePath = path.join(tempDir, 'demo.jpg');
110
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
111
- const insertText = vi.fn().mockResolvedValue(undefined);
112
- const page = createConditionalPageMock((code) => {
113
- if (code.includes('location.href'))
114
- return 'https://creator.xiaohongshu.com/publish/publish?from=menu_left';
115
- if (code.includes("const targets = ['上传图文', '图文', '图片']"))
116
- return { ok: true, target: '上传图文', text: '上传图文' };
117
- if (code.includes('hasTitleInput') && code.includes('hasVideoSurface'))
118
- return { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false };
119
- if (code.includes('const images =') && code.includes('dt.items.add(new File'))
120
- return { ok: true, count: 1 };
121
- if (code.includes('[class*="upload"][class*="progress"]'))
122
- return false;
123
- if (code.includes('const sels =') && code.includes('for (const sel of sels)'))
124
- return true;
125
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"locate"'))
126
- return { ok: true, sel: '[contenteditable="true"][placeholder*="标题"]', kind: 'contenteditable' };
127
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"prepare"'))
128
- return { ok: true };
129
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"verify"'))
130
- return { ok: false, actual: '' };
131
- if (code.includes('(function(selectors, text)'))
132
- return { ok: true, sel: '[contenteditable="true"][placeholder*="标题"]', kind: 'contenteditable', actual: '' };
133
- if (code.includes('xhs-publish-btn'))
134
- return { ok: true, via: 'click', text: '发布' };
135
- if (code.includes('labels.some'))
136
- return false;
137
- if (code.includes('for (const el of document.querySelectorAll'))
138
- return '发布成功';
139
- throw new Error(`Unhandled evaluate call: ${code.slice(0, 120)}`);
140
- }, {
141
- insertText,
142
- });
143
- await expect(cmd.func(page, {
144
- title: '标题没写进去',
145
- content: '正文',
146
- images: imagePath,
147
- topics: '',
148
- draft: false,
149
- })).rejects.toThrow('Failed to set title');
150
- expect(insertText).toHaveBeenCalledWith('标题没写进去');
151
- });
152
- it('falls back to in-page insertion when contenteditable native insertText fails', async () => {
153
- const cmd = getRegistry().get('xiaohongshu/publish');
154
- expect(cmd?.func).toBeTypeOf('function');
155
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
156
- const imagePath = path.join(tempDir, 'demo.jpg');
157
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
158
- const insertText = vi.fn().mockRejectedValue(new Error('insertText returned no inserted flag'));
159
- const page = createConditionalPageMock((code) => {
160
- if (code.includes('location.href'))
161
- return 'https://creator.xiaohongshu.com/publish/publish?from=menu_left';
162
- if (code.includes("const targets = ['上传图文', '图文', '图片']"))
163
- return { ok: true, target: '上传图文', text: '上传图文' };
164
- if (code.includes('hasTitleInput') && code.includes('hasVideoSurface'))
165
- return { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false };
166
- if (code.includes('const images =') && code.includes('dt.items.add(new File'))
167
- return { ok: true, count: 1 };
168
- if (code.includes('[class*="upload"][class*="progress"]'))
169
- return false;
170
- if (code.includes('const sels =') && code.includes('for (const sel of sels)'))
171
- return true;
172
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"locate"')) {
173
- return code.includes('[contenteditable="true"][placeholder*="标题"]')
174
- ? { ok: true, sel: '[contenteditable="true"][placeholder*="标题"]', kind: 'contenteditable' }
175
- : { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' };
176
- }
177
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"prepare"'))
178
- return { ok: true };
179
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"apply"')) {
180
- return code.includes('[contenteditable="true"][placeholder*="标题"]')
181
- ? { ok: true, actual: '原生失败后回退' }
182
- : { ok: true, actual: '正文也回退' };
183
- }
184
- if (code.includes('xhs-publish-btn'))
185
- return { ok: true, via: 'click', text: '发布' };
186
- if (code.includes('labels.some'))
187
- return false;
188
- if (code.includes('for (const el of document.querySelectorAll'))
189
- return '发布成功';
190
- throw new Error(`Unhandled evaluate call: ${code.slice(0, 120)}`);
191
- }, {
192
- insertText,
193
- });
194
- const result = await cmd.func(page, {
195
- title: '原生失败后回退',
196
- content: '正文也回退',
197
- images: imagePath,
198
- topics: '',
199
- draft: false,
200
- });
201
- expect(insertText).toHaveBeenCalledWith('原生失败后回退');
202
- expect(result).toEqual([
203
- {
204
- status: '✅ 发布成功',
205
- detail: '"原生失败后回退" · 1张图片 · 发布成功',
206
- },
207
- ]);
208
- });
209
- it('aborts when an input title does not stick after filling', async () => {
210
- const cmd = getRegistry().get('xiaohongshu/publish');
211
- expect(cmd?.func).toBeTypeOf('function');
212
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
213
- const imagePath = path.join(tempDir, 'demo.jpg');
214
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
215
- const page = createConditionalPageMock((code) => {
216
- if (code.includes('location.href'))
217
- return 'https://creator.xiaohongshu.com/publish/publish?from=menu_left';
218
- if (code.includes("const targets = ['上传图文', '图文', '图片']"))
219
- return { ok: true, target: '上传图文', text: '上传图文' };
220
- if (code.includes('hasTitleInput') && code.includes('hasVideoSurface'))
221
- return { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false };
222
- if (code.includes('const images =') && code.includes('dt.items.add(new File'))
223
- return { ok: true, count: 1 };
224
- if (code.includes('[class*="upload"][class*="progress"]'))
225
- return false;
226
- if (code.includes('const sels =') && code.includes('for (const sel of sels)'))
227
- return true;
228
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"locate"'))
229
- return code.includes('input[maxlength')
230
- ? { ok: true, sel: 'input[maxlength="20"]', kind: 'input' }
231
- : { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' };
232
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"apply"'))
233
- return code.includes('input[maxlength')
234
- ? { ok: false, actual: '' }
235
- : { ok: true, actual: '正文' };
236
- if (code.includes('xhs-publish-btn'))
237
- return { ok: true, via: 'click', text: '发布' };
238
- if (code.includes('labels.some'))
239
- return false;
240
- if (code.includes('for (const el of document.querySelectorAll'))
241
- return '发布成功';
242
- throw new Error(`Unhandled evaluate call: ${code.slice(0, 120)}`);
243
- });
244
- await expect(cmd.func(page, {
245
- title: '输入框标题没写进去',
246
- content: '正文',
247
- images: imagePath,
248
- topics: '',
249
- draft: false,
250
- })).rejects.toThrow('Failed to set title');
251
- });
252
- it('prefers CDP setFileInput upload when the page supports it', async () => {
253
- const cmd = getRegistry().get('xiaohongshu/publish');
254
- expect(cmd?.func).toBeTypeOf('function');
255
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
256
- const imagePath = path.join(tempDir, 'demo.jpg');
257
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
258
- const setFileInput = vi.fn().mockResolvedValue(undefined);
259
- const page = createPageMock([
260
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
261
- { ok: true, target: '上传图文', text: '上传图文' },
262
- { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
263
- 'input[type="file"][accept*="image"],input[type="file"][accept*=".jpg"],input[type="file"][accept*=".jpeg"],input[type="file"][accept*=".png"],input[type="file"][accept*=".gif"],input[type="file"][accept*=".webp"]',
264
- false,
265
- true,
266
- { ok: true, sel: 'input[maxlength="20"]', kind: 'input' },
267
- { ok: true, actual: 'CDP上传优先' },
268
- { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' },
269
- { ok: true, actual: '优先走 setFileInput 主路径' },
270
- { ok: true, via: 'click', text: '发布' },
271
- 'https://creator.xiaohongshu.com/publish/success',
272
- '发布成功',
273
- ], {
274
- setFileInput,
275
- });
276
- const result = await cmd.func(page, {
277
- title: 'CDP上传优先',
278
- content: '优先走 setFileInput 主路径',
279
- images: imagePath,
280
- topics: '',
281
- draft: false,
282
- });
283
- expect(setFileInput).toHaveBeenCalledWith([imagePath], expect.stringContaining('input[type="file"][accept*="image"]'));
284
- const evaluateCalls = page.evaluate.mock.calls.map((args) => String(args[0]));
285
- expect(evaluateCalls.some((code) => code.includes('atob(img.base64)'))).toBe(false);
286
- expect(result).toEqual([
287
- {
288
- status: '✅ 发布成功',
289
- detail: '"CDP上传优先" · 1张图片 · 发布成功',
290
- },
291
- ]);
292
- });
293
- it('falls back to DataTransfer upload when CDP file injection is blocked by Chrome', async () => {
294
- const cmd = getRegistry().get('xiaohongshu/publish');
295
- expect(cmd?.func).toBeTypeOf('function');
296
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
297
- const imagePath = path.join(tempDir, 'demo.jpg');
298
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
299
- const setFileInput = vi.fn().mockRejectedValue(new Error('Chrome Not allowed'));
300
- const page = createPageMock([
301
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left&target=image',
302
- { ok: true, target: '上传图文', text: '上传图文' },
303
- { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
304
- 'input[type="file"][accept*="image"],input[type="file"][accept*=".jpg"],input[type="file"][accept*=".jpeg"],input[type="file"][accept*=".png"],input[type="file"][accept*=".gif"],input[type="file"][accept*=".webp"]',
305
- { ok: true, count: 1 },
306
- false,
307
- true,
308
- { ok: true, sel: 'input[maxlength="20"]', kind: 'input' },
309
- { ok: true, actual: 'CDP被拒后回退' },
310
- { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' },
311
- { ok: true, actual: 'DataTransfer fallback path' },
312
- { ok: true, via: 'click', text: '发布' },
313
- 'https://creator.xiaohongshu.com/publish/success',
314
- '发布成功',
315
- ], {
316
- setFileInput,
317
- });
318
- const result = await cmd.func(page, {
319
- title: 'CDP被拒后回退',
320
- content: 'DataTransfer fallback path',
321
- images: imagePath,
322
- topics: '',
323
- draft: false,
324
- });
325
- const evaluateCalls = page.evaluate.mock.calls.map((args) => String(args[0]));
326
- expect(setFileInput).toHaveBeenCalledWith([imagePath], expect.stringContaining('input[type="file"][accept*="image"]'));
327
- expect(evaluateCalls.some((code) => code.includes('dt.items.add(new File'))).toBe(true);
328
- expect(result).toEqual([
329
- {
330
- status: '✅ 发布成功',
331
- detail: '"CDP被拒后回退" · 1张图片 · 发布成功',
332
- },
333
- ]);
334
- });
335
- it('fails fast when only a generic file input exists on the page', async () => {
336
- const cmd = getRegistry().get('xiaohongshu/publish');
337
- expect(cmd?.func).toBeTypeOf('function');
338
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
339
- const imagePath = path.join(tempDir, 'demo.jpg');
340
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
341
- const setFileInput = vi.fn().mockResolvedValue(undefined);
342
- const page = createPageMock([
343
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
344
- { ok: true, target: '上传图文', text: '上传图文' },
345
- { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
346
- null,
347
- ], {
348
- setFileInput,
349
- });
350
- await expect(cmd.func(page, {
351
- title: '不要走泛化上传',
352
- content: 'generic file input 应该直接报错',
353
- images: imagePath,
354
- topics: '',
355
- draft: false,
356
- })).rejects.toThrow('Image injection failed: No file input found on page');
357
- expect(setFileInput).not.toHaveBeenCalled();
358
- expect(page.screenshot).toHaveBeenCalledWith({ path: '/tmp/xhs_publish_upload_debug.png' });
359
- });
360
- it('selects the image-text tab and publishes successfully', async () => {
361
- const cmd = getRegistry().get('xiaohongshu/publish');
362
- expect(cmd?.func).toBeTypeOf('function');
363
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
364
- const imagePath = path.join(tempDir, 'demo.jpg');
365
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
366
- const page = createPageMock([
367
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
368
- { ok: true, target: '上传图文', text: '上传图文' },
369
- { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
370
- { ok: true, count: 1 },
371
- false,
372
- true, // waitForEditForm: editor appeared
373
- { ok: true, sel: 'input[maxlength="20"]', kind: 'input' },
374
- { ok: true, actual: 'DeepSeek别乱问' },
375
- { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' },
376
- { ok: true, actual: '一篇真实一点的小红书正文' },
377
- { ok: true, via: 'click', text: '发布' },
378
- 'https://creator.xiaohongshu.com/publish/success',
379
- '发布成功',
380
- ]);
381
- const result = await cmd.func(page, {
382
- title: 'DeepSeek别乱问',
383
- content: '一篇真实一点的小红书正文',
384
- images: imagePath,
385
- topics: '',
386
- draft: false,
387
- });
388
- const evaluateCalls = page.evaluate.mock.calls.map((args) => String(args[0]));
389
- const tabSelectCode = evaluateCalls.find((code) => code.includes("const targets = ['上传图文', '图文', '图片']"));
390
- expect(tabSelectCode).toBeTruthy();
391
- expect(tabSelectCode.indexOf('if (text === target)')).toBeLessThan(tabSelectCode.indexOf('text.startsWith(target)'));
392
- expect(evaluateCalls.some((code) => code.includes("No image file input found on page"))).toBe(true);
393
- expect(page.goto).toHaveBeenCalledWith(expect.stringContaining('target=image'));
394
- expect(result).toEqual([
395
- {
396
- status: '✅ 发布成功',
397
- detail: '"DeepSeek别乱问" · 1张图片 · 发布成功',
398
- },
399
- ]);
400
- });
401
- it('uses the shadow-DOM method-invoke path when xhs-publish-btn handler succeeds', async () => {
402
- // Mirrors the previous "selects the image-text tab and publishes successfully"
403
- // mock sequence but returns `via: 'method', name: '_onPublish'` for the publish
404
- // trigger evaluate, exercising the shadow-DOM web-component handler path
405
- // (the primary #1606 fix). Without this case the fix's main path is uncovered.
406
- const cmd = getRegistry().get('xiaohongshu/publish');
407
- expect(cmd?.func).toBeTypeOf('function');
408
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
409
- const imagePath = path.join(tempDir, 'demo.jpg');
410
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
411
- const page = createPageMock([
412
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
413
- { ok: true, target: '上传图文', text: '上传图文' },
414
- { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
415
- { ok: true, count: 1 },
416
- false,
417
- true, // waitForEditForm: editor appeared
418
- { ok: true, sel: 'input[maxlength="20"]', kind: 'input' },
419
- { ok: true, actual: 'shadow-dom-test' },
420
- { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' },
421
- { ok: true, actual: '走 method-invoke 路径' },
422
- { ok: true, via: 'method', name: '_onPublish' }, // shadow-DOM handler success
423
- 'https://creator.xiaohongshu.com/publish/success',
424
- '发布成功',
425
- ]);
426
- const result = await cmd.func(page, {
427
- title: 'shadow-dom-test',
428
- content: '走 method-invoke 路径',
429
- images: imagePath,
430
- topics: '',
431
- draft: false,
432
- });
433
- expect(result).toEqual([
434
- {
435
- status: '✅ 发布成功',
436
- detail: '"shadow-dom-test" · 1张图片 · 发布成功',
437
- },
438
- ]);
439
- // The publish-trigger evaluate must have been the shadow-DOM probe (contains
440
- // 'xhs-publish-btn'), not the legacy `button.click()` fallback alone.
441
- const evaluateCalls = page.evaluate.mock.calls.map((args) => String(args[0]));
442
- expect(evaluateCalls.some((code) => code.includes('xhs-publish-btn'))).toBe(true);
443
- });
444
- it('fails early with a clear error when still on the video page', async () => {
445
- const cmd = getRegistry().get('xiaohongshu/publish');
446
- expect(cmd?.func).toBeTypeOf('function');
447
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
448
- const imagePath = path.join(tempDir, 'demo.jpg');
449
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
450
- const page = createPageMock([
451
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
452
- { ok: false, visibleTexts: ['上传视频', '上传图文'] },
453
- { state: 'video_surface', hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
454
- { state: 'video_surface', hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
455
- { state: 'video_surface', hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
456
- { state: 'video_surface', hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
457
- ]);
458
- await expect(cmd.func(page, {
459
- title: 'DeepSeek别乱问',
460
- content: '一篇真实一点的小红书正文',
461
- images: imagePath,
462
- topics: '',
463
- draft: false,
464
- })).rejects.toThrow('Still on the video publish page after trying to select 图文');
465
- expect(page.screenshot).toHaveBeenCalledWith({ path: '/tmp/xhs_publish_tab_debug.png' });
466
- });
467
- it('waits for the image-text surface to appear after clicking the tab', async () => {
468
- const cmd = getRegistry().get('xiaohongshu/publish');
469
- expect(cmd?.func).toBeTypeOf('function');
470
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
471
- const imagePath = path.join(tempDir, 'demo.jpg');
472
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
473
- const page = createPageMock([
474
- 'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
475
- { ok: true, target: '上传图文', text: '上传图文' },
476
- { state: 'video_surface', hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
477
- { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
478
- { ok: true, count: 1 }, // injectImages
479
- false, // waitForUploads: no progress indicator
480
- true, // waitForEditForm: editor appeared
481
- { ok: true, sel: 'input[maxlength="20"]', kind: 'input' },
482
- { ok: true, actual: '延迟切换也能过' },
483
- { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' },
484
- { ok: true, actual: '图文页切换慢一点也继续等' },
485
- { ok: true, via: 'click', text: '发布' },
486
- 'https://creator.xiaohongshu.com/publish/success',
487
- '发布成功',
488
- ]);
489
- const result = await cmd.func(page, {
490
- title: '延迟切换也能过',
491
- content: '图文页切换慢一点也继续等',
492
- images: imagePath,
493
- topics: '',
494
- draft: false,
495
- });
496
- expect(page.wait.mock.calls).toContainEqual([{ time: 0.5 }]);
497
- expect(result).toEqual([
498
- {
499
- status: '✅ 发布成功',
500
- detail: '"延迟切换也能过" · 1张图片 · 发布成功',
501
- },
502
- ]);
503
- });
504
- it('treats 保存成功 on the draft list as a successful draft save', async () => {
505
- const cmd = getRegistry().get('xiaohongshu/publish');
506
- expect(cmd?.func).toBeTypeOf('function');
507
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
508
- const imagePath = path.join(tempDir, 'demo.jpg');
509
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
510
- const page = createConditionalPageMock((code) => {
511
- if (code.includes('location.href'))
512
- return 'https://creator.xiaohongshu.com/publish/publish?from=menu_left&target=image';
513
- if (code.includes("const targets = ['上传图文', '图文', '图片']"))
514
- return { ok: true, target: '上传图文', text: '上传图文' };
515
- if (code.includes('hasTitleInput') && code.includes('hasVideoSurface'))
516
- return { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false };
517
- if (code.includes('const images =') && code.includes('dt.items.add(new File'))
518
- return { ok: true, count: 1 };
519
- if (code.includes('[class*="upload"][class*="progress"]'))
520
- return false;
521
- if (code.includes('const sels =') && code.includes('for (const sel of sels)'))
522
- return true;
523
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"locate"')) {
524
- return code.includes('[contenteditable="true"][class*="content"]')
525
- ? { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' }
526
- : { ok: true, sel: 'input[placeholder*="标题"]', kind: 'input' };
527
- }
528
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"apply"')) {
529
- return code.includes('[contenteditable="true"][class*="content"]')
530
- ? { ok: true, actual: '停留在发布页也算成功' }
531
- : { ok: true, actual: '草稿成功提示' };
532
- }
533
- if (code.includes('xhs-publish-btn'))
534
- return { ok: true, via: 'click', text: '发布' };
535
- if (code.includes('labels.some'))
536
- return false;
537
- if (code.includes('for (const el of document.querySelectorAll')) {
538
- return code.includes('保存成功') ? '保存成功' : '';
539
- }
540
- throw new Error(`Unhandled evaluate call: ${code.slice(0, 120)}`);
541
- });
542
- const result = await cmd.func(page, {
543
- title: '草稿成功提示',
544
- content: '停留在发布页也算成功',
545
- images: imagePath,
546
- topics: '',
547
- draft: true,
548
- });
549
- expect(result).toEqual([
550
- {
551
- status: '✅ 暂存成功',
552
- detail: '"草稿成功提示" · 1张图片 · 保存成功',
553
- },
554
- ]);
555
- });
556
- it('does not treat 保存成功 alone as a publish success signal', async () => {
557
- const cmd = getRegistry().get('xiaohongshu/publish');
558
- expect(cmd?.func).toBeTypeOf('function');
559
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bycli-xhs-publish-'));
560
- const imagePath = path.join(tempDir, 'demo.jpg');
561
- fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
562
- const page = createConditionalPageMock((code) => {
563
- if (code.includes('location.href'))
564
- return 'https://creator.xiaohongshu.com/publish/publish?from=menu_left&target=image';
565
- if (code.includes("const targets = ['上传图文', '图文', '图片']"))
566
- return { ok: true, target: '上传图文', text: '上传图文' };
567
- if (code.includes('hasTitleInput') && code.includes('hasVideoSurface'))
568
- return { state: 'editor_ready', hasTitleInput: true, hasImageInput: true, hasVideoSurface: false };
569
- if (code.includes('const images =') && code.includes('dt.items.add(new File'))
570
- return { ok: true, count: 1 };
571
- if (code.includes('[class*="upload"][class*="progress"]'))
572
- return false;
573
- if (code.includes('const sels =') && code.includes('for (const sel of sels)'))
574
- return true;
575
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"locate"')) {
576
- return code.includes('[contenteditable="true"][class*="content"]')
577
- ? { ok: true, sel: '[contenteditable="true"][class*="content"]', kind: 'contenteditable' }
578
- : { ok: true, sel: 'input[placeholder*="标题"]', kind: 'input' };
579
- }
580
- if (code.includes('__bycli_xhs_fill_phase') && code.includes('"apply"')) {
581
- return code.includes('[contenteditable="true"][class*="content"]')
582
- ? { ok: true, actual: '发布提示不该复用草稿成功' }
583
- : { ok: true, actual: '发布成功提示' };
584
- }
585
- if (code.includes('xhs-publish-btn'))
586
- return { ok: true, via: 'click', text: '发布' };
587
- if (code.includes('labels.some'))
588
- return false;
589
- if (code.includes('for (const el of document.querySelectorAll')) {
590
- return code.includes('保存成功') ? '保存成功' : '';
591
- }
592
- throw new Error(`Unhandled evaluate call: ${code.slice(0, 120)}`);
593
- });
594
- const result = await cmd.func(page, {
595
- title: '发布成功提示',
596
- content: '发布提示不该复用草稿成功',
597
- images: imagePath,
598
- topics: '',
599
- draft: false,
600
- });
601
- expect(result).toEqual([
602
- {
603
- status: '⚠️ 操作完成,请在浏览器中确认',
604
- detail: '"发布成功提示" · 1张图片 · https://creator.xiaohongshu.com/publish/publish?from=menu_left&target=image',
605
- },
606
- ]);
607
- });
608
- });