@jackwener/opencli 0.9.6 → 1.0.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 (307) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +83 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.yml +42 -0
  4. package/.github/ISSUE_TEMPLATE/new_site_adapter.yml +57 -0
  5. package/.github/dependabot.yml +27 -0
  6. package/.github/pull_request_template.md +24 -0
  7. package/.github/workflows/ci.yml +14 -8
  8. package/.github/workflows/e2e-headed.yml +6 -2
  9. package/.github/workflows/pkg-pr-new.yml +2 -2
  10. package/.github/workflows/release-please.yml +25 -0
  11. package/.github/workflows/release.yml +2 -2
  12. package/.github/workflows/security.yml +36 -0
  13. package/CDP.md +1 -1
  14. package/CDP.zh-CN.md +1 -1
  15. package/CLI-ELECTRON.md +89 -36
  16. package/CLI-EXPLORER.md +4 -4
  17. package/CONTRIBUTING.md +167 -0
  18. package/README.md +113 -89
  19. package/README.zh-CN.md +114 -91
  20. package/SKILL.md +10 -8
  21. package/TESTING.md +7 -7
  22. package/dist/browser/daemon-client.d.ts +37 -0
  23. package/dist/browser/daemon-client.js +82 -0
  24. package/dist/browser/discover.d.ts +11 -34
  25. package/dist/browser/discover.js +15 -190
  26. package/dist/browser/errors.d.ts +6 -20
  27. package/dist/browser/errors.js +24 -63
  28. package/dist/browser/index.d.ts +2 -11
  29. package/dist/browser/index.js +5 -11
  30. package/dist/browser/mcp.d.ts +9 -18
  31. package/dist/browser/mcp.js +70 -284
  32. package/dist/browser/page.d.ts +28 -6
  33. package/dist/browser/page.js +210 -85
  34. package/dist/browser.test.js +4 -202
  35. package/dist/build-manifest.d.ts +26 -0
  36. package/dist/build-manifest.js +132 -60
  37. package/dist/build-manifest.test.d.ts +1 -0
  38. package/dist/build-manifest.test.js +26 -0
  39. package/dist/cli-manifest.json +1582 -29
  40. package/dist/clis/bilibili/download.d.ts +10 -0
  41. package/dist/clis/bilibili/download.js +135 -0
  42. package/dist/clis/chatwise/ask.d.ts +1 -0
  43. package/dist/clis/chatwise/ask.js +76 -0
  44. package/dist/clis/chatwise/export.d.ts +1 -0
  45. package/dist/clis/chatwise/export.js +46 -0
  46. package/dist/clis/chatwise/history.d.ts +1 -0
  47. package/dist/clis/chatwise/history.js +43 -0
  48. package/dist/clis/chatwise/model.d.ts +1 -0
  49. package/dist/clis/chatwise/model.js +81 -0
  50. package/dist/clis/chatwise/new.d.ts +1 -0
  51. package/dist/clis/chatwise/new.js +18 -0
  52. package/dist/clis/chatwise/read.d.ts +1 -0
  53. package/dist/clis/chatwise/read.js +39 -0
  54. package/dist/clis/chatwise/screenshot.d.ts +1 -0
  55. package/dist/clis/chatwise/screenshot.js +27 -0
  56. package/dist/clis/chatwise/send.d.ts +1 -0
  57. package/dist/clis/chatwise/send.js +45 -0
  58. package/dist/clis/chatwise/status.d.ts +1 -0
  59. package/dist/clis/chatwise/status.js +22 -0
  60. package/dist/clis/discord-app/channels.d.ts +1 -0
  61. package/dist/clis/discord-app/channels.js +45 -0
  62. package/dist/clis/discord-app/members.d.ts +1 -0
  63. package/dist/clis/discord-app/members.js +38 -0
  64. package/dist/clis/discord-app/read.d.ts +1 -0
  65. package/dist/clis/discord-app/read.js +45 -0
  66. package/dist/clis/discord-app/search.d.ts +1 -0
  67. package/dist/clis/discord-app/search.js +56 -0
  68. package/dist/clis/discord-app/send.d.ts +1 -0
  69. package/dist/clis/discord-app/send.js +27 -0
  70. package/dist/clis/discord-app/servers.d.ts +1 -0
  71. package/dist/clis/discord-app/servers.js +36 -0
  72. package/dist/clis/discord-app/status.d.ts +1 -0
  73. package/dist/clis/discord-app/status.js +16 -0
  74. package/dist/clis/feishu/new.d.ts +1 -0
  75. package/dist/clis/feishu/new.js +27 -0
  76. package/dist/clis/feishu/read.d.ts +1 -0
  77. package/dist/clis/feishu/read.js +40 -0
  78. package/dist/clis/feishu/search.d.ts +1 -0
  79. package/dist/clis/feishu/search.js +30 -0
  80. package/dist/clis/feishu/send.d.ts +1 -0
  81. package/dist/clis/feishu/send.js +39 -0
  82. package/dist/clis/feishu/status.d.ts +1 -0
  83. package/dist/clis/feishu/status.js +28 -0
  84. package/dist/clis/grok/ask.d.ts +1 -0
  85. package/dist/clis/grok/ask.js +82 -0
  86. package/dist/clis/grok/debug.d.ts +1 -0
  87. package/dist/clis/grok/debug.js +45 -0
  88. package/dist/clis/jimeng/generate.yaml +84 -0
  89. package/dist/clis/jimeng/history.yaml +47 -0
  90. package/dist/clis/linux-do/categories.yaml +41 -0
  91. package/dist/clis/linux-do/category.yaml +49 -0
  92. package/dist/clis/linux-do/hot.yaml +50 -0
  93. package/dist/clis/linux-do/latest.yaml +40 -0
  94. package/dist/clis/linux-do/search.yaml +45 -0
  95. package/dist/clis/linux-do/topic.yaml +38 -0
  96. package/dist/clis/neteasemusic/like.d.ts +1 -0
  97. package/dist/clis/neteasemusic/like.js +25 -0
  98. package/dist/clis/neteasemusic/lyrics.d.ts +1 -0
  99. package/dist/clis/neteasemusic/lyrics.js +47 -0
  100. package/dist/clis/neteasemusic/next.d.ts +1 -0
  101. package/dist/clis/neteasemusic/next.js +26 -0
  102. package/dist/clis/neteasemusic/play.d.ts +1 -0
  103. package/dist/clis/neteasemusic/play.js +26 -0
  104. package/dist/clis/neteasemusic/playing.d.ts +1 -0
  105. package/dist/clis/neteasemusic/playing.js +59 -0
  106. package/dist/clis/neteasemusic/playlist.d.ts +1 -0
  107. package/dist/clis/neteasemusic/playlist.js +46 -0
  108. package/dist/clis/neteasemusic/prev.d.ts +1 -0
  109. package/dist/clis/neteasemusic/prev.js +25 -0
  110. package/dist/clis/neteasemusic/search.d.ts +1 -0
  111. package/dist/clis/neteasemusic/search.js +52 -0
  112. package/dist/clis/neteasemusic/status.d.ts +1 -0
  113. package/dist/clis/neteasemusic/status.js +16 -0
  114. package/dist/clis/neteasemusic/volume.d.ts +1 -0
  115. package/dist/clis/neteasemusic/volume.js +54 -0
  116. package/dist/clis/notion/export.d.ts +1 -0
  117. package/dist/clis/notion/export.js +31 -0
  118. package/dist/clis/notion/favorites.d.ts +1 -0
  119. package/dist/clis/notion/favorites.js +84 -0
  120. package/dist/clis/notion/new.d.ts +1 -0
  121. package/dist/clis/notion/new.js +34 -0
  122. package/dist/clis/notion/read.d.ts +1 -0
  123. package/dist/clis/notion/read.js +30 -0
  124. package/dist/clis/notion/search.d.ts +1 -0
  125. package/dist/clis/notion/search.js +46 -0
  126. package/dist/clis/notion/sidebar.d.ts +1 -0
  127. package/dist/clis/notion/sidebar.js +41 -0
  128. package/dist/clis/notion/status.d.ts +1 -0
  129. package/dist/clis/notion/status.js +16 -0
  130. package/dist/clis/notion/write.d.ts +1 -0
  131. package/dist/clis/notion/write.js +40 -0
  132. package/dist/clis/twitter/download.d.ts +8 -0
  133. package/dist/clis/twitter/download.js +204 -0
  134. package/dist/clis/wechat/chats.d.ts +1 -0
  135. package/dist/clis/wechat/chats.js +28 -0
  136. package/dist/clis/wechat/contacts.d.ts +1 -0
  137. package/dist/clis/wechat/contacts.js +28 -0
  138. package/dist/clis/wechat/read.d.ts +1 -0
  139. package/dist/clis/wechat/read.js +58 -0
  140. package/dist/clis/wechat/search.d.ts +1 -0
  141. package/dist/clis/wechat/search.js +31 -0
  142. package/dist/clis/wechat/send.d.ts +1 -0
  143. package/dist/clis/wechat/send.js +42 -0
  144. package/dist/clis/wechat/status.d.ts +1 -0
  145. package/dist/clis/wechat/status.js +29 -0
  146. package/dist/clis/xiaohongshu/creator-note-detail.d.ts +10 -0
  147. package/dist/clis/xiaohongshu/creator-note-detail.js +88 -0
  148. package/dist/clis/xiaohongshu/creator-notes.d.ts +11 -0
  149. package/dist/clis/xiaohongshu/creator-notes.js +109 -0
  150. package/dist/clis/xiaohongshu/creator-profile.d.ts +10 -0
  151. package/dist/clis/xiaohongshu/creator-profile.js +54 -0
  152. package/dist/clis/xiaohongshu/creator-stats.d.ts +10 -0
  153. package/dist/clis/xiaohongshu/creator-stats.js +74 -0
  154. package/dist/clis/xiaohongshu/download.d.ts +7 -0
  155. package/dist/clis/xiaohongshu/download.js +155 -0
  156. package/dist/clis/xiaohongshu/search.js +1 -1
  157. package/dist/clis/xiaohongshu/user-helpers.d.ts +15 -0
  158. package/dist/clis/xiaohongshu/user-helpers.js +67 -0
  159. package/dist/clis/xiaohongshu/user-helpers.test.d.ts +1 -0
  160. package/dist/clis/xiaohongshu/user-helpers.test.js +81 -0
  161. package/dist/clis/xiaohongshu/user.js +46 -29
  162. package/dist/clis/zhihu/download.d.ts +11 -0
  163. package/dist/clis/zhihu/download.js +186 -0
  164. package/dist/clis/zhihu/download.test.d.ts +1 -0
  165. package/dist/clis/zhihu/download.test.js +10 -0
  166. package/dist/daemon.d.ts +13 -0
  167. package/dist/daemon.js +187 -0
  168. package/dist/doctor.d.ts +27 -61
  169. package/dist/doctor.js +70 -601
  170. package/dist/doctor.test.js +30 -170
  171. package/dist/download/index.d.ts +79 -0
  172. package/dist/download/index.js +325 -0
  173. package/dist/download/progress.d.ts +36 -0
  174. package/dist/download/progress.js +111 -0
  175. package/dist/engine.test.js +15 -0
  176. package/dist/main.js +22 -28
  177. package/dist/pipeline/executor.test.js +1 -0
  178. package/dist/pipeline/registry.js +2 -0
  179. package/dist/pipeline/steps/browser.js +2 -2
  180. package/dist/pipeline/steps/download.d.ts +34 -0
  181. package/dist/pipeline/steps/download.js +251 -0
  182. package/dist/pipeline/steps/intercept.js +1 -2
  183. package/dist/pipeline/template.js +28 -0
  184. package/dist/setup.d.ts +6 -0
  185. package/dist/setup.js +46 -160
  186. package/dist/types.d.ts +6 -0
  187. package/extension/icons/icon-128.png +0 -0
  188. package/extension/icons/icon-16.png +0 -0
  189. package/extension/icons/icon-32.png +0 -0
  190. package/extension/icons/icon-48.png +0 -0
  191. package/extension/manifest.json +31 -0
  192. package/extension/package.json +16 -0
  193. package/extension/src/background.ts +293 -0
  194. package/extension/src/cdp.ts +125 -0
  195. package/extension/src/protocol.ts +57 -0
  196. package/extension/store-assets/screenshot-1280x800.png +0 -0
  197. package/extension/tsconfig.json +15 -0
  198. package/extension/vite.config.ts +18 -0
  199. package/package.json +8 -7
  200. package/scripts/test-site.mjs +70 -0
  201. package/src/browser/daemon-client.ts +113 -0
  202. package/src/browser/discover.ts +18 -216
  203. package/src/browser/errors.ts +30 -100
  204. package/src/browser/index.ts +6 -12
  205. package/src/browser/mcp.ts +78 -278
  206. package/src/browser/page.ts +222 -88
  207. package/src/browser.test.ts +3 -210
  208. package/src/build-manifest.test.ts +28 -0
  209. package/src/build-manifest.ts +147 -57
  210. package/src/clis/bilibili/download.ts +161 -0
  211. package/src/clis/chatgpt/README.md +1 -1
  212. package/src/clis/chatgpt/README.zh-CN.md +1 -1
  213. package/src/clis/chatwise/README.md +38 -0
  214. package/src/clis/chatwise/README.zh-CN.md +38 -0
  215. package/src/clis/chatwise/ask.ts +87 -0
  216. package/src/clis/chatwise/export.ts +51 -0
  217. package/src/clis/chatwise/history.ts +47 -0
  218. package/src/clis/chatwise/model.ts +87 -0
  219. package/src/clis/chatwise/new.ts +21 -0
  220. package/src/clis/chatwise/read.ts +42 -0
  221. package/src/clis/chatwise/screenshot.ts +33 -0
  222. package/src/clis/chatwise/send.ts +50 -0
  223. package/src/clis/chatwise/status.ts +25 -0
  224. package/src/clis/discord-app/README.md +28 -0
  225. package/src/clis/discord-app/README.zh-CN.md +28 -0
  226. package/src/clis/discord-app/channels.ts +48 -0
  227. package/src/clis/discord-app/members.ts +41 -0
  228. package/src/clis/discord-app/read.ts +49 -0
  229. package/src/clis/discord-app/search.ts +64 -0
  230. package/src/clis/discord-app/send.ts +32 -0
  231. package/src/clis/discord-app/servers.ts +39 -0
  232. package/src/clis/discord-app/status.ts +18 -0
  233. package/src/clis/feishu/README.md +20 -0
  234. package/src/clis/feishu/README.zh-CN.md +20 -0
  235. package/src/clis/feishu/new.ts +32 -0
  236. package/src/clis/feishu/read.ts +48 -0
  237. package/src/clis/feishu/search.ts +35 -0
  238. package/src/clis/feishu/send.ts +46 -0
  239. package/src/clis/feishu/status.ts +34 -0
  240. package/src/clis/grok/ask.ts +90 -0
  241. package/src/clis/grok/debug.ts +49 -0
  242. package/src/clis/jimeng/generate.yaml +84 -0
  243. package/src/clis/jimeng/history.yaml +47 -0
  244. package/src/clis/linux-do/categories.yaml +41 -0
  245. package/src/clis/linux-do/category.yaml +49 -0
  246. package/src/clis/linux-do/hot.yaml +50 -0
  247. package/src/clis/linux-do/latest.yaml +40 -0
  248. package/src/clis/linux-do/search.yaml +45 -0
  249. package/src/clis/linux-do/topic.yaml +38 -0
  250. package/src/clis/neteasemusic/README.md +31 -0
  251. package/src/clis/neteasemusic/README.zh-CN.md +31 -0
  252. package/src/clis/neteasemusic/like.ts +28 -0
  253. package/src/clis/neteasemusic/lyrics.ts +53 -0
  254. package/src/clis/neteasemusic/next.ts +30 -0
  255. package/src/clis/neteasemusic/play.ts +30 -0
  256. package/src/clis/neteasemusic/playing.ts +62 -0
  257. package/src/clis/neteasemusic/playlist.ts +51 -0
  258. package/src/clis/neteasemusic/prev.ts +29 -0
  259. package/src/clis/neteasemusic/search.ts +58 -0
  260. package/src/clis/neteasemusic/status.ts +18 -0
  261. package/src/clis/neteasemusic/volume.ts +61 -0
  262. package/src/clis/notion/README.md +29 -0
  263. package/src/clis/notion/README.zh-CN.md +29 -0
  264. package/src/clis/notion/export.ts +36 -0
  265. package/src/clis/notion/favorites.ts +87 -0
  266. package/src/clis/notion/new.ts +39 -0
  267. package/src/clis/notion/read.ts +33 -0
  268. package/src/clis/notion/search.ts +54 -0
  269. package/src/clis/notion/sidebar.ts +44 -0
  270. package/src/clis/notion/status.ts +18 -0
  271. package/src/clis/notion/write.ts +45 -0
  272. package/src/clis/twitter/download.ts +227 -0
  273. package/src/clis/wechat/README.md +28 -0
  274. package/src/clis/wechat/README.zh-CN.md +28 -0
  275. package/src/clis/wechat/chats.ts +33 -0
  276. package/src/clis/wechat/contacts.ts +33 -0
  277. package/src/clis/wechat/read.ts +72 -0
  278. package/src/clis/wechat/search.ts +36 -0
  279. package/src/clis/wechat/send.ts +49 -0
  280. package/src/clis/wechat/status.ts +35 -0
  281. package/src/clis/xiaohongshu/creator-note-detail.ts +95 -0
  282. package/src/clis/xiaohongshu/creator-notes.ts +116 -0
  283. package/src/clis/xiaohongshu/creator-profile.ts +60 -0
  284. package/src/clis/xiaohongshu/creator-stats.ts +81 -0
  285. package/src/clis/xiaohongshu/download.ts +173 -0
  286. package/src/clis/xiaohongshu/search.ts +1 -1
  287. package/src/clis/xiaohongshu/user-helpers.test.ts +106 -0
  288. package/src/clis/xiaohongshu/user-helpers.ts +85 -0
  289. package/src/clis/xiaohongshu/user.ts +52 -32
  290. package/src/clis/zhihu/download.test.ts +12 -0
  291. package/src/clis/zhihu/download.ts +223 -0
  292. package/src/daemon.ts +217 -0
  293. package/src/doctor.test.ts +32 -193
  294. package/src/doctor.ts +74 -668
  295. package/src/download/index.ts +395 -0
  296. package/src/download/progress.ts +125 -0
  297. package/src/engine.test.ts +17 -0
  298. package/src/main.ts +18 -26
  299. package/src/pipeline/executor.test.ts +1 -0
  300. package/src/pipeline/registry.ts +2 -0
  301. package/src/pipeline/steps/browser.ts +2 -2
  302. package/src/pipeline/steps/download.ts +310 -0
  303. package/src/pipeline/steps/intercept.ts +1 -2
  304. package/src/pipeline/template.ts +26 -0
  305. package/src/setup.ts +47 -183
  306. package/src/types.ts +1 -0
  307. package/tests/e2e/browser-auth.test.ts +25 -0
@@ -0,0 +1,72 @@
1
+ import { execSync, spawnSync } from 'node:child_process';
2
+ import { cli, Strategy } from '../../registry.js';
3
+ import type { IPage } from '../../types.js';
4
+
5
+ export const readCommand = cli({
6
+ site: 'wechat',
7
+ name: 'read',
8
+ description: 'Read the current chat content by selecting all and copying',
9
+ domain: 'localhost',
10
+ strategy: Strategy.PUBLIC,
11
+ browser: false,
12
+ args: [],
13
+ columns: ['Content'],
14
+ func: async (page: IPage | null) => {
15
+ try {
16
+ // Backup clipboard
17
+ let clipBackup = '';
18
+ try {
19
+ clipBackup = execSync('pbpaste', { encoding: 'utf-8' });
20
+ } catch { /* empty */ }
21
+
22
+ // Activate WeChat
23
+ execSync("osascript -e 'tell application \"WeChat\" to activate'");
24
+ execSync("osascript -e 'delay 0.3'");
25
+
26
+ // Click on the chat area first, then select all and copy
27
+ execSync(
28
+ "osascript " +
29
+ "-e 'tell application \"System Events\"' " +
30
+ "-e 'tell application process \"WeChat\"' " +
31
+ // Click in the message area (center-right of the window)
32
+ "-e 'set frontWin to front window' " +
33
+ "-e 'set winPos to position of frontWin' " +
34
+ "-e 'set winSize to size of frontWin' " +
35
+ "-e 'end tell' " +
36
+ "-e 'end tell'"
37
+ );
38
+
39
+ execSync("osascript -e 'delay 0.2'");
40
+
41
+ // Select all text in chat area and copy
42
+ execSync(
43
+ "osascript " +
44
+ "-e 'tell application \"System Events\"' " +
45
+ "-e 'keystroke \"a\" using command down' " +
46
+ "-e 'delay 0.2' " +
47
+ "-e 'keystroke \"c\" using command down' " +
48
+ "-e 'delay 0.2' " +
49
+ "-e 'end tell'"
50
+ );
51
+
52
+ const content = execSync('pbpaste', { encoding: 'utf-8' }).trim();
53
+
54
+ // Restore clipboard
55
+ if (clipBackup) {
56
+ spawnSync('pbcopy', { input: clipBackup });
57
+ }
58
+
59
+ // Press Escape to deselect
60
+ execSync(
61
+ "osascript " +
62
+ "-e 'tell application \"System Events\"' " +
63
+ "-e 'key code 53' " + // Escape
64
+ "-e 'end tell'"
65
+ );
66
+
67
+ return [{ Content: content || '(no content captured)' }];
68
+ } catch (err: any) {
69
+ return [{ Content: 'Error: ' + err.message }];
70
+ }
71
+ },
72
+ });
@@ -0,0 +1,36 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { cli, Strategy } from '../../registry.js';
3
+ import type { IPage } from '../../types.js';
4
+
5
+ export const searchCommand = cli({
6
+ site: 'wechat',
7
+ name: 'search',
8
+ description: 'Open WeChat search and type a query (find contacts or messages)',
9
+ domain: 'localhost',
10
+ strategy: Strategy.PUBLIC,
11
+ browser: false,
12
+ args: [{ name: 'query', required: true, positional: true, help: 'Search query (contact name or keyword)' }],
13
+ columns: ['Status'],
14
+ func: async (page: IPage | null, kwargs: any) => {
15
+ const query = kwargs.query as string;
16
+ try {
17
+ // Activate WeChat
18
+ execSync("osascript -e 'tell application \"WeChat\" to activate'");
19
+ execSync("osascript -e 'delay 0.3'");
20
+
21
+ // Cmd+F to open search (WeChat Mac uses Cmd+F for search)
22
+ execSync(
23
+ "osascript " +
24
+ "-e 'tell application \"System Events\"' " +
25
+ "-e 'keystroke \"f\" using command down' " +
26
+ "-e 'delay 0.5' " +
27
+ `-e 'keystroke ${JSON.stringify(query)}' ` +
28
+ "-e 'end tell'"
29
+ );
30
+
31
+ return [{ Status: `Searching for: ${query}` }];
32
+ } catch (err: any) {
33
+ return [{ Status: 'Error: ' + err.message }];
34
+ }
35
+ },
36
+ });
@@ -0,0 +1,49 @@
1
+ import { execSync, spawnSync } from 'node:child_process';
2
+ import { cli, Strategy } from '../../registry.js';
3
+ import type { IPage } from '../../types.js';
4
+
5
+ export const sendCommand = cli({
6
+ site: 'wechat',
7
+ name: 'send',
8
+ description: 'Send a message in the active WeChat conversation via clipboard paste',
9
+ domain: 'localhost',
10
+ strategy: Strategy.PUBLIC,
11
+ browser: false,
12
+ args: [{ name: 'text', required: true, positional: true, help: 'Message to send' }],
13
+ columns: ['Status'],
14
+ func: async (page: IPage | null, kwargs: any) => {
15
+ const text = kwargs.text as string;
16
+ try {
17
+ // Backup clipboard
18
+ let clipBackup = '';
19
+ try {
20
+ clipBackup = execSync('pbpaste', { encoding: 'utf-8' });
21
+ } catch { /* clipboard may be empty */ }
22
+
23
+ // Copy text to clipboard
24
+ spawnSync('pbcopy', { input: text });
25
+
26
+ // Activate WeChat and paste
27
+ execSync("osascript -e 'tell application \"WeChat\" to activate'");
28
+ execSync("osascript -e 'delay 0.5'");
29
+
30
+ execSync(
31
+ "osascript " +
32
+ "-e 'tell application \"System Events\"' " +
33
+ "-e 'keystroke \"v\" using command down' " +
34
+ "-e 'delay 0.2' " +
35
+ "-e 'keystroke return' " +
36
+ "-e 'end tell'"
37
+ );
38
+
39
+ // Restore clipboard
40
+ if (clipBackup) {
41
+ spawnSync('pbcopy', { input: clipBackup });
42
+ }
43
+
44
+ return [{ Status: 'Success' }];
45
+ } catch (err: any) {
46
+ return [{ Status: 'Error: ' + err.message }];
47
+ }
48
+ },
49
+ });
@@ -0,0 +1,35 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { cli, Strategy } from '../../registry.js';
3
+ import type { IPage } from '../../types.js';
4
+
5
+ export const statusCommand = cli({
6
+ site: 'wechat',
7
+ name: 'status',
8
+ description: 'Check if WeChat Desktop is running on macOS',
9
+ domain: 'localhost',
10
+ strategy: Strategy.PUBLIC,
11
+ browser: false,
12
+ args: [],
13
+ columns: ['Status', 'Detail'],
14
+ func: async (page: IPage | null) => {
15
+ try {
16
+ const running = execSync("osascript -e 'application \"WeChat\" is running'", { encoding: 'utf-8' }).trim();
17
+ if (running !== 'true') {
18
+ return [{ Status: 'Stopped', Detail: 'WeChat is not running' }];
19
+ }
20
+
21
+ // Get window count to check if logged in
22
+ const windowCount = execSync(
23
+ "osascript -e 'tell application \"System Events\" to count windows of application process \"WeChat\"'",
24
+ { encoding: 'utf-8' }
25
+ ).trim();
26
+
27
+ return [{
28
+ Status: 'Running',
29
+ Detail: `${windowCount} window(s) open`,
30
+ }];
31
+ } catch (err: any) {
32
+ return [{ Status: 'Error', Detail: err.message }];
33
+ }
34
+ },
35
+ });
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Xiaohongshu Creator Note Detail — per-note analytics breakdown.
3
+ *
4
+ * Uses the creator.xiaohongshu.com internal API (cookie auth).
5
+ * Returns total reads, engagement, likes, collects, comments, shares
6
+ * for a specific note, split by channel (organic vs promoted vs video).
7
+ *
8
+ * Requires: logged into creator.xiaohongshu.com in Chrome.
9
+ */
10
+
11
+ import { cli, Strategy } from '../../registry.js';
12
+
13
+ cli({
14
+ site: 'xiaohongshu',
15
+ name: 'creator-note-detail',
16
+ description: '小红书单篇笔记详细数据 (阅读/互动/点赞/收藏/评论/分享,区分自然流量/推广/视频)',
17
+ domain: 'creator.xiaohongshu.com',
18
+ strategy: Strategy.COOKIE,
19
+ browser: true,
20
+ args: [
21
+ { name: 'note_id', type: 'string', required: true, help: 'Note ID (from note URL or creator-notes command)' },
22
+ ],
23
+ columns: ['channel', 'reads', 'engagement', 'likes', 'collects', 'comments', 'shares'],
24
+ func: async (page, kwargs) => {
25
+ const noteId: string = kwargs.note_id;
26
+ const encodedNoteId = encodeURIComponent(noteId);
27
+
28
+ // Navigate for cookie context
29
+ await page.goto('https://creator.xiaohongshu.com/new/home');
30
+ await page.wait(2);
31
+
32
+ const data = await page.evaluate(`
33
+ async () => {
34
+ try {
35
+ const resp = await fetch(
36
+ '/api/galaxy/creator/data/note_detail?note_id=${encodedNoteId}',
37
+ { credentials: 'include' }
38
+ );
39
+ if (!resp.ok) return { error: 'HTTP ' + resp.status };
40
+ return await resp.json();
41
+ } catch (e) {
42
+ return { error: e.message };
43
+ }
44
+ }
45
+ `);
46
+
47
+ if (data?.error) {
48
+ throw new Error(data.error + '. Check note_id and login status.');
49
+ }
50
+ if (!data?.data) {
51
+ throw new Error('Unexpected response structure');
52
+ }
53
+
54
+ const d = data.data;
55
+
56
+ return [
57
+ {
58
+ channel: 'Total',
59
+ reads: d.total_read ?? 0,
60
+ engagement: d.total_engage ?? 0,
61
+ likes: d.total_like ?? 0,
62
+ collects: d.total_fav ?? 0,
63
+ comments: d.total_cmt ?? 0,
64
+ shares: d.total_share ?? 0,
65
+ },
66
+ {
67
+ channel: 'Organic',
68
+ reads: d.normal_read ?? 0,
69
+ engagement: d.normal_engage ?? 0,
70
+ likes: d.normal_like ?? 0,
71
+ collects: d.normal_fav ?? 0,
72
+ comments: d.normal_cmt ?? 0,
73
+ shares: d.normal_share ?? 0,
74
+ },
75
+ {
76
+ channel: 'Promoted',
77
+ reads: d.total_promo_read ?? 0,
78
+ engagement: 0,
79
+ likes: 0,
80
+ collects: 0,
81
+ comments: 0,
82
+ shares: 0,
83
+ },
84
+ {
85
+ channel: 'Video',
86
+ reads: d.video_read ?? 0,
87
+ engagement: d.video_engage ?? 0,
88
+ likes: d.video_like ?? 0,
89
+ collects: d.video_fav ?? 0,
90
+ comments: d.video_cmt ?? 0,
91
+ shares: d.video_share ?? 0,
92
+ },
93
+ ];
94
+ },
95
+ });
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Xiaohongshu Creator Note List — per-note metrics from the creator backend.
3
+ *
4
+ * Navigates to the note manager page and extracts per-note data from
5
+ * the rendered DOM. This approach bypasses the v2 API signature requirement.
6
+ *
7
+ * Returns: note title, publish date, views, likes, collects, comments.
8
+ *
9
+ * Requires: logged into creator.xiaohongshu.com in Chrome.
10
+ */
11
+
12
+ import { cli, Strategy } from '../../registry.js';
13
+
14
+ cli({
15
+ site: 'xiaohongshu',
16
+ name: 'creator-notes',
17
+ description: '小红书创作者笔记列表 + 每篇数据 (标题/日期/观看/点赞/收藏/评论)',
18
+ domain: 'creator.xiaohongshu.com',
19
+ strategy: Strategy.COOKIE,
20
+ browser: true,
21
+ args: [
22
+ { name: 'limit', type: 'int', default: 20, help: 'Number of notes to return' },
23
+ ],
24
+ columns: ['rank', 'id', 'title', 'date', 'views', 'likes', 'collects', 'comments', 'url'],
25
+ func: async (page, kwargs) => {
26
+ const limit = kwargs.limit || 20;
27
+
28
+ // Navigate to note manager
29
+ await page.goto('https://creator.xiaohongshu.com/new/note-manager');
30
+ await page.wait(4);
31
+
32
+ // Scroll to load more notes if needed
33
+ await page.autoScroll({ times: Math.ceil(limit / 10), delayMs: 1500 });
34
+
35
+ // Extract note data from rendered DOM
36
+ const notes = await page.evaluate(`
37
+ (() => {
38
+ const results = [];
39
+ // Note cards in the manager page contain title, date, and metric numbers
40
+ // Each note card has a consistent structure with the title, date line,
41
+ // and a row of 4 numbers (views, likes, collects, comments)
42
+ const cards = document.querySelectorAll('[class*="note-item"], [class*="noteItem"], [class*="card"]');
43
+
44
+ if (cards.length === 0) {
45
+ // Fallback: parse from any container with note-like content
46
+ const allText = document.body.innerText;
47
+ const notePattern = /(.+?)\\s+发布于\\s+(\\d{4}年\\d{2}月\\d{2}日\\s+\\d{2}:\\d{2})\\s*(\\d+)\\s*(\\d+)\\s*(\\d+)\\s*(\\d+)/g;
48
+ let match;
49
+ while ((match = notePattern.exec(allText)) !== null) {
50
+ results.push({
51
+ title: match[1].trim(),
52
+ date: match[2],
53
+ views: parseInt(match[3]) || 0,
54
+ likes: parseInt(match[4]) || 0,
55
+ collects: parseInt(match[5]) || 0,
56
+ comments: parseInt(match[6]) || 0,
57
+ });
58
+ }
59
+ return results;
60
+ }
61
+
62
+ cards.forEach(card => {
63
+ const text = card.innerText || '';
64
+ const linkEl = card.querySelector('a[href*="/publish/"], a[href*="/note/"], a[href*="/explore/"]');
65
+ const href = linkEl?.getAttribute('href') || '';
66
+ const idMatch = href.match(/\/(?:publish|explore|note)\/([a-zA-Z0-9]+)/);
67
+ // Try to extract structured data
68
+ const lines = text.split('\\n').map(l => l.trim()).filter(Boolean);
69
+ if (lines.length < 2) return;
70
+
71
+ const title = lines[0];
72
+ const dateLine = lines.find(l => l.includes('发布于'));
73
+ const dateMatch = dateLine?.match(/发布于\\s+(\\d{4}年\\d{2}月\\d{2}日\\s+\\d{2}:\\d{2})/);
74
+
75
+ // Remove the publish timestamp before collecting note metrics.
76
+ // Otherwise year/month/day/hour digits are picked up as views/likes/etc.
77
+ const metricText = dateLine ? text.replace(dateLine, ' ') : text;
78
+ const nums = metricText.match(/(?:^|\\s)(\\d+)(?:\\s|$)/g)?.map(n => parseInt(n.trim())) || [];
79
+
80
+ if (title && !title.includes('全部笔记')) {
81
+ results.push({
82
+ id: idMatch ? idMatch[1] : '',
83
+ title: title.replace(/\\s+/g, ' ').substring(0, 80),
84
+ date: dateMatch ? dateMatch[1] : '',
85
+ views: nums[0] || 0,
86
+ likes: nums[1] || 0,
87
+ collects: nums[2] || 0,
88
+ comments: nums[3] || 0,
89
+ url: href ? new URL(href, window.location.origin).toString() : '',
90
+ });
91
+ }
92
+ });
93
+
94
+ return results;
95
+ })()
96
+ `);
97
+
98
+ if (!Array.isArray(notes) || notes.length === 0) {
99
+ throw new Error('No notes found. Are you logged into creator.xiaohongshu.com?');
100
+ }
101
+
102
+ return notes
103
+ .slice(0, limit)
104
+ .map((n: any, i: number) => ({
105
+ rank: i + 1,
106
+ id: n.id,
107
+ title: n.title,
108
+ date: n.date,
109
+ views: n.views,
110
+ likes: n.likes,
111
+ collects: n.collects,
112
+ comments: n.comments,
113
+ url: n.url,
114
+ }));
115
+ },
116
+ });
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Xiaohongshu Creator Profile — creator account info and growth status.
3
+ *
4
+ * Uses the creator.xiaohongshu.com internal API (cookie auth).
5
+ * Returns follower/following counts, total likes+collects, and
6
+ * creator level growth info.
7
+ *
8
+ * Requires: logged into creator.xiaohongshu.com in Chrome.
9
+ */
10
+
11
+ import { cli, Strategy } from '../../registry.js';
12
+
13
+ cli({
14
+ site: 'xiaohongshu',
15
+ name: 'creator-profile',
16
+ description: '小红书创作者账号信息 (粉丝/关注/获赞/成长等级)',
17
+ domain: 'creator.xiaohongshu.com',
18
+ strategy: Strategy.COOKIE,
19
+ browser: true,
20
+ args: [],
21
+ columns: ['field', 'value'],
22
+ func: async (page, _kwargs) => {
23
+ await page.goto('https://creator.xiaohongshu.com/new/home');
24
+ await page.wait(3);
25
+
26
+ const data = await page.evaluate(`
27
+ async () => {
28
+ try {
29
+ const resp = await fetch('/api/galaxy/creator/home/personal_info', {
30
+ credentials: 'include',
31
+ });
32
+ if (!resp.ok) return { error: 'HTTP ' + resp.status };
33
+ return await resp.json();
34
+ } catch (e) {
35
+ return { error: e.message };
36
+ }
37
+ }
38
+ `);
39
+
40
+ if (data?.error) {
41
+ throw new Error(data.error + '. Are you logged into creator.xiaohongshu.com?');
42
+ }
43
+ if (!data?.data) {
44
+ throw new Error('Unexpected response structure');
45
+ }
46
+
47
+ const d = data.data;
48
+ const grow = d.grow_info || {};
49
+
50
+ return [
51
+ { field: 'Name', value: d.name ?? '' },
52
+ { field: 'Followers', value: d.fans_count ?? 0 },
53
+ { field: 'Following', value: d.follow_count ?? 0 },
54
+ { field: 'Likes & Collects', value: d.faved_count ?? 0 },
55
+ { field: 'Creator Level', value: grow.level ?? 0 },
56
+ { field: 'Level Progress', value: `${grow.fans_count ?? 0}/${grow.max_fans_count ?? 0} fans` },
57
+ { field: 'Bio', value: (d.personal_desc ?? '').replace(/\\n/g, ' | ') },
58
+ ];
59
+ },
60
+ });
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Xiaohongshu Creator Analytics — account-level metrics overview.
3
+ *
4
+ * Uses the creator.xiaohongshu.com internal API (cookie auth).
5
+ * Returns 7-day and 30-day aggregate stats: views, likes, collects,
6
+ * comments, shares, new followers, and daily trend data.
7
+ *
8
+ * Requires: logged into creator.xiaohongshu.com in Chrome.
9
+ */
10
+
11
+ import { cli, Strategy } from '../../registry.js';
12
+
13
+ cli({
14
+ site: 'xiaohongshu',
15
+ name: 'creator-stats',
16
+ description: '小红书创作者数据总览 (观看/点赞/收藏/评论/分享/涨粉,含每日趋势)',
17
+ domain: 'creator.xiaohongshu.com',
18
+ strategy: Strategy.COOKIE,
19
+ browser: true,
20
+ args: [
21
+ {
22
+ name: 'period',
23
+ type: 'string',
24
+ default: 'seven',
25
+ help: 'Stats period: seven or thirty',
26
+ choices: ['seven', 'thirty'],
27
+ },
28
+ ],
29
+ columns: ['metric', 'total', 'trend'],
30
+ func: async (page, kwargs) => {
31
+ const period: string = kwargs.period || 'seven';
32
+
33
+ // Navigate to creator center for cookie context
34
+ await page.goto('https://creator.xiaohongshu.com/new/home');
35
+ await page.wait(3);
36
+
37
+ const data = await page.evaluate(`
38
+ async () => {
39
+ try {
40
+ const resp = await fetch('/api/galaxy/creator/data/note_detail_new', {
41
+ credentials: 'include',
42
+ });
43
+ if (!resp.ok) return { error: 'HTTP ' + resp.status };
44
+ return await resp.json();
45
+ } catch (e) {
46
+ return { error: e.message };
47
+ }
48
+ }
49
+ `);
50
+
51
+ if (data?.error) {
52
+ throw new Error(data.error + '. Are you logged into creator.xiaohongshu.com?');
53
+ }
54
+ if (!data?.data) {
55
+ throw new Error('Unexpected response structure');
56
+ }
57
+
58
+ const stats = data.data[period];
59
+ if (!stats) {
60
+ throw new Error(`No data for period "${period}". Available: ${Object.keys(data.data).join(', ')}`);
61
+ }
62
+
63
+ // Format daily trend as sparkline-like summary
64
+ const formatTrend = (list: any[]): string => {
65
+ if (!list || !list.length) return '-';
66
+ return list.map((d: any) => d.count).join(' → ');
67
+ };
68
+
69
+ return [
70
+ { metric: '观看数 (views)', total: stats.view_count ?? 0, trend: formatTrend(stats.view_list) },
71
+ { metric: '平均观看时长 (avg view time ms)', total: stats.view_time_avg ?? 0, trend: formatTrend(stats.view_time_list) },
72
+ { metric: '主页访问 (home views)', total: stats.home_view_count ?? 0, trend: formatTrend(stats.home_view_list) },
73
+ { metric: '点赞数 (likes)', total: stats.like_count ?? 0, trend: formatTrend(stats.like_list) },
74
+ { metric: '收藏数 (collects)', total: stats.collect_count ?? 0, trend: formatTrend(stats.collect_list) },
75
+ { metric: '评论数 (comments)', total: stats.comment_count ?? 0, trend: formatTrend(stats.comment_list) },
76
+ { metric: '弹幕数 (danmaku)', total: stats.danmaku_count ?? 0, trend: '-' },
77
+ { metric: '分享数 (shares)', total: stats.share_count ?? 0, trend: formatTrend(stats.share_list) },
78
+ { metric: '涨粉数 (new followers)', total: stats.rise_fans_count ?? 0, trend: formatTrend(stats.rise_fans_list) },
79
+ ];
80
+ },
81
+ });