@jackwener/opencli 0.9.6 → 0.9.8

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 (221) 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/CLI-ELECTRON.md +89 -36
  14. package/CONTRIBUTING.md +167 -0
  15. package/README.md +98 -32
  16. package/README.zh-CN.md +99 -33
  17. package/dist/browser/discover.js +22 -7
  18. package/dist/browser.test.js +23 -0
  19. package/dist/build-manifest.d.ts +26 -0
  20. package/dist/build-manifest.js +132 -60
  21. package/dist/build-manifest.test.d.ts +1 -0
  22. package/dist/build-manifest.test.js +26 -0
  23. package/dist/cli-manifest.json +1415 -29
  24. package/dist/clis/bilibili/download.d.ts +10 -0
  25. package/dist/clis/bilibili/download.js +135 -0
  26. package/dist/clis/chatwise/ask.d.ts +1 -0
  27. package/dist/clis/chatwise/ask.js +76 -0
  28. package/dist/clis/chatwise/export.d.ts +1 -0
  29. package/dist/clis/chatwise/export.js +46 -0
  30. package/dist/clis/chatwise/history.d.ts +1 -0
  31. package/dist/clis/chatwise/history.js +43 -0
  32. package/dist/clis/chatwise/model.d.ts +1 -0
  33. package/dist/clis/chatwise/model.js +81 -0
  34. package/dist/clis/chatwise/new.d.ts +1 -0
  35. package/dist/clis/chatwise/new.js +18 -0
  36. package/dist/clis/chatwise/read.d.ts +1 -0
  37. package/dist/clis/chatwise/read.js +39 -0
  38. package/dist/clis/chatwise/screenshot.d.ts +1 -0
  39. package/dist/clis/chatwise/screenshot.js +27 -0
  40. package/dist/clis/chatwise/send.d.ts +1 -0
  41. package/dist/clis/chatwise/send.js +45 -0
  42. package/dist/clis/chatwise/status.d.ts +1 -0
  43. package/dist/clis/chatwise/status.js +22 -0
  44. package/dist/clis/discord-app/channels.d.ts +1 -0
  45. package/dist/clis/discord-app/channels.js +45 -0
  46. package/dist/clis/discord-app/members.d.ts +1 -0
  47. package/dist/clis/discord-app/members.js +38 -0
  48. package/dist/clis/discord-app/read.d.ts +1 -0
  49. package/dist/clis/discord-app/read.js +45 -0
  50. package/dist/clis/discord-app/search.d.ts +1 -0
  51. package/dist/clis/discord-app/search.js +56 -0
  52. package/dist/clis/discord-app/send.d.ts +1 -0
  53. package/dist/clis/discord-app/send.js +27 -0
  54. package/dist/clis/discord-app/servers.d.ts +1 -0
  55. package/dist/clis/discord-app/servers.js +36 -0
  56. package/dist/clis/discord-app/status.d.ts +1 -0
  57. package/dist/clis/discord-app/status.js +16 -0
  58. package/dist/clis/feishu/new.d.ts +1 -0
  59. package/dist/clis/feishu/new.js +27 -0
  60. package/dist/clis/feishu/read.d.ts +1 -0
  61. package/dist/clis/feishu/read.js +40 -0
  62. package/dist/clis/feishu/search.d.ts +1 -0
  63. package/dist/clis/feishu/search.js +30 -0
  64. package/dist/clis/feishu/send.d.ts +1 -0
  65. package/dist/clis/feishu/send.js +39 -0
  66. package/dist/clis/feishu/status.d.ts +1 -0
  67. package/dist/clis/feishu/status.js +28 -0
  68. package/dist/clis/grok/ask.d.ts +1 -0
  69. package/dist/clis/grok/ask.js +82 -0
  70. package/dist/clis/grok/debug.d.ts +1 -0
  71. package/dist/clis/grok/debug.js +45 -0
  72. package/dist/clis/jimeng/generate.yaml +84 -0
  73. package/dist/clis/jimeng/history.yaml +47 -0
  74. package/dist/clis/linux-do/categories.yaml +41 -0
  75. package/dist/clis/linux-do/category.yaml +49 -0
  76. package/dist/clis/linux-do/hot.yaml +50 -0
  77. package/dist/clis/linux-do/latest.yaml +40 -0
  78. package/dist/clis/linux-do/search.yaml +45 -0
  79. package/dist/clis/linux-do/topic.yaml +38 -0
  80. package/dist/clis/notion/export.d.ts +1 -0
  81. package/dist/clis/notion/export.js +31 -0
  82. package/dist/clis/notion/favorites.d.ts +1 -0
  83. package/dist/clis/notion/favorites.js +84 -0
  84. package/dist/clis/notion/new.d.ts +1 -0
  85. package/dist/clis/notion/new.js +34 -0
  86. package/dist/clis/notion/read.d.ts +1 -0
  87. package/dist/clis/notion/read.js +30 -0
  88. package/dist/clis/notion/search.d.ts +1 -0
  89. package/dist/clis/notion/search.js +46 -0
  90. package/dist/clis/notion/sidebar.d.ts +1 -0
  91. package/dist/clis/notion/sidebar.js +41 -0
  92. package/dist/clis/notion/status.d.ts +1 -0
  93. package/dist/clis/notion/status.js +16 -0
  94. package/dist/clis/notion/write.d.ts +1 -0
  95. package/dist/clis/notion/write.js +40 -0
  96. package/dist/clis/twitter/download.d.ts +8 -0
  97. package/dist/clis/twitter/download.js +204 -0
  98. package/dist/clis/wechat/chats.d.ts +1 -0
  99. package/dist/clis/wechat/chats.js +28 -0
  100. package/dist/clis/wechat/contacts.d.ts +1 -0
  101. package/dist/clis/wechat/contacts.js +28 -0
  102. package/dist/clis/wechat/read.d.ts +1 -0
  103. package/dist/clis/wechat/read.js +58 -0
  104. package/dist/clis/wechat/search.d.ts +1 -0
  105. package/dist/clis/wechat/search.js +31 -0
  106. package/dist/clis/wechat/send.d.ts +1 -0
  107. package/dist/clis/wechat/send.js +42 -0
  108. package/dist/clis/wechat/status.d.ts +1 -0
  109. package/dist/clis/wechat/status.js +29 -0
  110. package/dist/clis/xiaohongshu/creator-note-detail.d.ts +10 -0
  111. package/dist/clis/xiaohongshu/creator-note-detail.js +88 -0
  112. package/dist/clis/xiaohongshu/creator-notes.d.ts +11 -0
  113. package/dist/clis/xiaohongshu/creator-notes.js +109 -0
  114. package/dist/clis/xiaohongshu/creator-profile.d.ts +10 -0
  115. package/dist/clis/xiaohongshu/creator-profile.js +54 -0
  116. package/dist/clis/xiaohongshu/creator-stats.d.ts +10 -0
  117. package/dist/clis/xiaohongshu/creator-stats.js +74 -0
  118. package/dist/clis/xiaohongshu/download.d.ts +7 -0
  119. package/dist/clis/xiaohongshu/download.js +155 -0
  120. package/dist/clis/xiaohongshu/search.js +1 -1
  121. package/dist/clis/xiaohongshu/user-helpers.d.ts +15 -0
  122. package/dist/clis/xiaohongshu/user-helpers.js +67 -0
  123. package/dist/clis/xiaohongshu/user-helpers.test.d.ts +1 -0
  124. package/dist/clis/xiaohongshu/user-helpers.test.js +81 -0
  125. package/dist/clis/xiaohongshu/user.js +46 -29
  126. package/dist/clis/zhihu/download.d.ts +11 -0
  127. package/dist/clis/zhihu/download.js +186 -0
  128. package/dist/clis/zhihu/download.test.d.ts +1 -0
  129. package/dist/clis/zhihu/download.test.js +10 -0
  130. package/dist/download/index.d.ts +79 -0
  131. package/dist/download/index.js +325 -0
  132. package/dist/download/progress.d.ts +36 -0
  133. package/dist/download/progress.js +111 -0
  134. package/dist/engine.test.js +15 -0
  135. package/dist/main.js +16 -3
  136. package/dist/pipeline/registry.js +2 -0
  137. package/dist/pipeline/steps/download.d.ts +34 -0
  138. package/dist/pipeline/steps/download.js +251 -0
  139. package/dist/pipeline/template.js +28 -0
  140. package/package.json +4 -3
  141. package/scripts/test-site.mjs +70 -0
  142. package/src/browser/discover.ts +23 -7
  143. package/src/browser.test.ts +23 -0
  144. package/src/build-manifest.test.ts +28 -0
  145. package/src/build-manifest.ts +147 -57
  146. package/src/clis/bilibili/download.ts +161 -0
  147. package/src/clis/chatwise/README.md +38 -0
  148. package/src/clis/chatwise/README.zh-CN.md +38 -0
  149. package/src/clis/chatwise/ask.ts +87 -0
  150. package/src/clis/chatwise/export.ts +51 -0
  151. package/src/clis/chatwise/history.ts +47 -0
  152. package/src/clis/chatwise/model.ts +87 -0
  153. package/src/clis/chatwise/new.ts +21 -0
  154. package/src/clis/chatwise/read.ts +42 -0
  155. package/src/clis/chatwise/screenshot.ts +33 -0
  156. package/src/clis/chatwise/send.ts +50 -0
  157. package/src/clis/chatwise/status.ts +25 -0
  158. package/src/clis/discord-app/README.md +28 -0
  159. package/src/clis/discord-app/README.zh-CN.md +28 -0
  160. package/src/clis/discord-app/channels.ts +48 -0
  161. package/src/clis/discord-app/members.ts +41 -0
  162. package/src/clis/discord-app/read.ts +49 -0
  163. package/src/clis/discord-app/search.ts +64 -0
  164. package/src/clis/discord-app/send.ts +32 -0
  165. package/src/clis/discord-app/servers.ts +39 -0
  166. package/src/clis/discord-app/status.ts +18 -0
  167. package/src/clis/feishu/README.md +20 -0
  168. package/src/clis/feishu/README.zh-CN.md +20 -0
  169. package/src/clis/feishu/new.ts +32 -0
  170. package/src/clis/feishu/read.ts +48 -0
  171. package/src/clis/feishu/search.ts +35 -0
  172. package/src/clis/feishu/send.ts +46 -0
  173. package/src/clis/feishu/status.ts +34 -0
  174. package/src/clis/grok/ask.ts +90 -0
  175. package/src/clis/grok/debug.ts +49 -0
  176. package/src/clis/jimeng/generate.yaml +84 -0
  177. package/src/clis/jimeng/history.yaml +47 -0
  178. package/src/clis/linux-do/categories.yaml +41 -0
  179. package/src/clis/linux-do/category.yaml +49 -0
  180. package/src/clis/linux-do/hot.yaml +50 -0
  181. package/src/clis/linux-do/latest.yaml +40 -0
  182. package/src/clis/linux-do/search.yaml +45 -0
  183. package/src/clis/linux-do/topic.yaml +38 -0
  184. package/src/clis/notion/README.md +29 -0
  185. package/src/clis/notion/README.zh-CN.md +29 -0
  186. package/src/clis/notion/export.ts +36 -0
  187. package/src/clis/notion/favorites.ts +87 -0
  188. package/src/clis/notion/new.ts +39 -0
  189. package/src/clis/notion/read.ts +33 -0
  190. package/src/clis/notion/search.ts +54 -0
  191. package/src/clis/notion/sidebar.ts +44 -0
  192. package/src/clis/notion/status.ts +18 -0
  193. package/src/clis/notion/write.ts +45 -0
  194. package/src/clis/twitter/download.ts +227 -0
  195. package/src/clis/wechat/README.md +28 -0
  196. package/src/clis/wechat/README.zh-CN.md +28 -0
  197. package/src/clis/wechat/chats.ts +33 -0
  198. package/src/clis/wechat/contacts.ts +33 -0
  199. package/src/clis/wechat/read.ts +72 -0
  200. package/src/clis/wechat/search.ts +36 -0
  201. package/src/clis/wechat/send.ts +49 -0
  202. package/src/clis/wechat/status.ts +35 -0
  203. package/src/clis/xiaohongshu/creator-note-detail.ts +95 -0
  204. package/src/clis/xiaohongshu/creator-notes.ts +116 -0
  205. package/src/clis/xiaohongshu/creator-profile.ts +60 -0
  206. package/src/clis/xiaohongshu/creator-stats.ts +81 -0
  207. package/src/clis/xiaohongshu/download.ts +173 -0
  208. package/src/clis/xiaohongshu/search.ts +1 -1
  209. package/src/clis/xiaohongshu/user-helpers.test.ts +106 -0
  210. package/src/clis/xiaohongshu/user-helpers.ts +85 -0
  211. package/src/clis/xiaohongshu/user.ts +52 -32
  212. package/src/clis/zhihu/download.test.ts +12 -0
  213. package/src/clis/zhihu/download.ts +223 -0
  214. package/src/download/index.ts +395 -0
  215. package/src/download/progress.ts +125 -0
  216. package/src/engine.test.ts +17 -0
  217. package/src/main.ts +12 -3
  218. package/src/pipeline/registry.ts +2 -0
  219. package/src/pipeline/steps/download.ts +310 -0
  220. package/src/pipeline/template.ts +26 -0
  221. package/tests/e2e/browser-auth.test.ts +25 -0
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Bilibili download — download videos using yt-dlp.
3
+ *
4
+ * Usage:
5
+ * opencli bilibili download --bvid BV1xxx --output ./bilibili
6
+ *
7
+ * Requirements:
8
+ * - yt-dlp must be installed: pip install yt-dlp
9
+ */
10
+ export {};
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Bilibili download — download videos using yt-dlp.
3
+ *
4
+ * Usage:
5
+ * opencli bilibili download --bvid BV1xxx --output ./bilibili
6
+ *
7
+ * Requirements:
8
+ * - yt-dlp must be installed: pip install yt-dlp
9
+ */
10
+ import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
12
+ import { cli, Strategy } from '../../registry.js';
13
+ import { ytdlpDownload, checkYtdlp, sanitizeFilename, getTempDir, exportCookiesToNetscape, } from '../../download/index.js';
14
+ import { DownloadProgressTracker, formatBytes } from '../../download/progress.js';
15
+ cli({
16
+ site: 'bilibili',
17
+ name: 'download',
18
+ description: '下载B站视频(需要 yt-dlp)',
19
+ domain: 'www.bilibili.com',
20
+ strategy: Strategy.COOKIE,
21
+ args: [
22
+ { name: 'bvid', required: true, help: 'Video BV ID (e.g., BV1xxx)' },
23
+ { name: 'output', default: './bilibili-downloads', help: 'Output directory' },
24
+ { name: 'quality', default: 'best', help: 'Video quality (best, 1080p, 720p, 480p)' },
25
+ ],
26
+ columns: ['bvid', 'title', 'status', 'size'],
27
+ func: async (page, kwargs) => {
28
+ const bvid = kwargs.bvid;
29
+ const output = kwargs.output;
30
+ const quality = kwargs.quality;
31
+ // Check yt-dlp availability
32
+ if (!checkYtdlp()) {
33
+ return [{
34
+ bvid,
35
+ title: '-',
36
+ status: 'failed',
37
+ size: 'yt-dlp not installed. Run: pip install yt-dlp',
38
+ }];
39
+ }
40
+ // Navigate to video page to get title and cookies
41
+ await page.goto(`https://www.bilibili.com/video/${bvid}`);
42
+ await page.wait(3);
43
+ // Extract video info
44
+ const data = await page.evaluate(`
45
+ (() => {
46
+ const title = document.querySelector('h1.video-title, .video-title')?.textContent?.trim() || 'video';
47
+ const author = document.querySelector('.up-name, .username')?.textContent?.trim() || 'unknown';
48
+ return { title, author };
49
+ })()
50
+ `);
51
+ const title = sanitizeFilename(data?.title || 'video');
52
+ // Extract cookies for authenticated downloads
53
+ const cookieString = await page.evaluate(`(() => document.cookie)()`);
54
+ // Create output directory
55
+ fs.mkdirSync(output, { recursive: true });
56
+ // Export cookies to Netscape format for yt-dlp
57
+ let cookiesFile;
58
+ if (typeof cookieString === 'string' && cookieString) {
59
+ const tempDir = getTempDir();
60
+ fs.mkdirSync(tempDir, { recursive: true });
61
+ cookiesFile = path.join(tempDir, `bilibili_cookies_${Date.now()}.txt`);
62
+ const cookies = cookieString.split(';').map((c) => {
63
+ const [name, ...rest] = c.trim().split('=');
64
+ return {
65
+ name: name || '',
66
+ value: rest.join('=') || '',
67
+ domain: '.bilibili.com',
68
+ path: '/',
69
+ secure: true,
70
+ httpOnly: false,
71
+ };
72
+ }).filter((c) => c.name);
73
+ exportCookiesToNetscape(cookies, cookiesFile);
74
+ }
75
+ // Build yt-dlp format string based on quality
76
+ let format = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best';
77
+ if (quality === '1080p') {
78
+ format = 'bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[height<=1080]';
79
+ }
80
+ else if (quality === '720p') {
81
+ format = 'bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/best[height<=720]';
82
+ }
83
+ else if (quality === '480p') {
84
+ format = 'bestvideo[height<=480][ext=mp4]+bestaudio[ext=m4a]/best[height<=480]';
85
+ }
86
+ const destPath = path.join(output, `${bvid}_${title}.mp4`);
87
+ const tracker = new DownloadProgressTracker(1, true);
88
+ const progressBar = tracker.onFileStart(`${bvid}.mp4`, 0);
89
+ try {
90
+ const result = await ytdlpDownload(`https://www.bilibili.com/video/${bvid}`, destPath, {
91
+ cookiesFile,
92
+ format,
93
+ extraArgs: [
94
+ '--merge-output-format', 'mp4',
95
+ '--embed-thumbnail',
96
+ ],
97
+ onProgress: (percent) => {
98
+ if (progressBar)
99
+ progressBar.update(percent, 100);
100
+ },
101
+ });
102
+ if (progressBar) {
103
+ progressBar.complete(result.success, result.success ? formatBytes(result.size) : undefined);
104
+ }
105
+ tracker.onFileComplete(result.success);
106
+ tracker.finish();
107
+ // Cleanup cookies file
108
+ if (cookiesFile && fs.existsSync(cookiesFile)) {
109
+ fs.unlinkSync(cookiesFile);
110
+ }
111
+ return [{
112
+ bvid,
113
+ title: data?.title || 'video',
114
+ status: result.success ? 'success' : 'failed',
115
+ size: result.success ? formatBytes(result.size) : (result.error || 'unknown error'),
116
+ }];
117
+ }
118
+ catch (err) {
119
+ if (progressBar)
120
+ progressBar.fail(err.message);
121
+ tracker.onFileComplete(false);
122
+ tracker.finish();
123
+ // Cleanup cookies file
124
+ if (cookiesFile && fs.existsSync(cookiesFile)) {
125
+ fs.unlinkSync(cookiesFile);
126
+ }
127
+ return [{
128
+ bvid,
129
+ title: data?.title || 'video',
130
+ status: 'failed',
131
+ size: err.message,
132
+ }];
133
+ }
134
+ },
135
+ });
@@ -0,0 +1 @@
1
+ export declare const askCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,76 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const askCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'ask',
5
+ description: 'Send a prompt and wait for the AI response (send + wait + read)',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [
10
+ { name: 'text', required: true, positional: true, help: 'Prompt to send' },
11
+ { name: 'timeout', required: false, help: 'Max seconds to wait (default: 30)', default: '30' },
12
+ ],
13
+ columns: ['Role', 'Text'],
14
+ func: async (page, kwargs) => {
15
+ const text = kwargs.text;
16
+ const timeout = parseInt(kwargs.timeout, 10) || 30;
17
+ // Snapshot content length
18
+ const beforeLen = await page.evaluate(`
19
+ (function() {
20
+ const msgs = document.querySelectorAll('[data-message-id], [class*="message"], [class*="bubble"]');
21
+ return msgs.length;
22
+ })()
23
+ `);
24
+ // Send message
25
+ await page.evaluate(`
26
+ (function(text) {
27
+ let composer = document.querySelector('textarea');
28
+ if (!composer) {
29
+ const editables = Array.from(document.querySelectorAll('[contenteditable="true"]'));
30
+ composer = editables.length > 0 ? editables[editables.length - 1] : null;
31
+ }
32
+ if (!composer) throw new Error('Could not find input');
33
+ composer.focus();
34
+ if (composer.tagName === 'TEXTAREA') {
35
+ const setter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
36
+ setter.call(composer, text);
37
+ composer.dispatchEvent(new Event('input', { bubbles: true }));
38
+ } else {
39
+ document.execCommand('insertText', false, text);
40
+ }
41
+ })(${JSON.stringify(text)})
42
+ `);
43
+ await page.wait(0.5);
44
+ await page.pressKey('Enter');
45
+ // Poll for response
46
+ const pollInterval = 2;
47
+ const maxPolls = Math.ceil(timeout / pollInterval);
48
+ let response = '';
49
+ for (let i = 0; i < maxPolls; i++) {
50
+ await page.wait(pollInterval);
51
+ const result = await page.evaluate(`
52
+ (function(prevLen) {
53
+ const msgs = document.querySelectorAll('[data-message-id], [class*="message"], [class*="bubble"]');
54
+ if (msgs.length <= prevLen) return null;
55
+ const last = msgs[msgs.length - 1];
56
+ const text = last.innerText || last.textContent;
57
+ return text ? text.trim() : null;
58
+ })(${beforeLen})
59
+ `);
60
+ if (result) {
61
+ response = result;
62
+ break;
63
+ }
64
+ }
65
+ if (!response) {
66
+ return [
67
+ { Role: 'User', Text: text },
68
+ { Role: 'System', Text: `No response within ${timeout}s.` },
69
+ ];
70
+ }
71
+ return [
72
+ { Role: 'User', Text: text },
73
+ { Role: 'Assistant', Text: response },
74
+ ];
75
+ },
76
+ });
@@ -0,0 +1 @@
1
+ export declare const exportCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,46 @@
1
+ import * as fs from 'node:fs';
2
+ import { cli, Strategy } from '../../registry.js';
3
+ export const exportCommand = cli({
4
+ site: 'chatwise',
5
+ name: 'export',
6
+ description: 'Export the current ChatWise conversation to a Markdown file',
7
+ domain: 'localhost',
8
+ strategy: Strategy.UI,
9
+ browser: true,
10
+ args: [
11
+ { name: 'output', required: false, positional: true, help: 'Output file (default: /tmp/chatwise-export.md)' },
12
+ ],
13
+ columns: ['Status', 'File', 'Messages'],
14
+ func: async (page, kwargs) => {
15
+ const outputPath = kwargs.output || '/tmp/chatwise-export.md';
16
+ const md = await page.evaluate(`
17
+ (function() {
18
+ const selectors = [
19
+ '[data-message-id]',
20
+ '[class*="message"]',
21
+ '[class*="chat-item"]',
22
+ '[class*="bubble"]',
23
+ ];
24
+
25
+ for (const sel of selectors) {
26
+ const nodes = document.querySelectorAll(sel);
27
+ if (nodes.length > 0) {
28
+ return Array.from(nodes).map((n, i) => '## Message ' + (i + 1) + '\\n\\n' + (n.innerText || n.textContent).trim()).join('\\n\\n---\\n\\n');
29
+ }
30
+ }
31
+
32
+ const main = document.querySelector('main, [role="main"], [class*="chat-container"]');
33
+ if (main) return main.innerText || main.textContent;
34
+ return document.body.innerText;
35
+ })()
36
+ `);
37
+ fs.writeFileSync(outputPath, '# ChatWise Conversation Export\\n\\n' + md);
38
+ return [
39
+ {
40
+ Status: 'Success',
41
+ File: outputPath,
42
+ Messages: md.split('## Message').length - 1,
43
+ },
44
+ ];
45
+ },
46
+ });
@@ -0,0 +1 @@
1
+ export declare const historyCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,43 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const historyCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'history',
5
+ description: 'List conversation history in ChatWise sidebar',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [],
10
+ columns: ['Index', 'Title'],
11
+ func: async (page) => {
12
+ const items = await page.evaluate(`
13
+ (function() {
14
+ const results = [];
15
+ const selectors = [
16
+ '[class*="sidebar"] [class*="item"]',
17
+ '[class*="conversation-list"] a',
18
+ '[class*="chat-list"] > *',
19
+ 'nav a',
20
+ 'aside a',
21
+ '[role="listbox"] [role="option"]',
22
+ ];
23
+
24
+ for (const sel of selectors) {
25
+ const nodes = document.querySelectorAll(sel);
26
+ if (nodes.length > 0) {
27
+ nodes.forEach((n, i) => {
28
+ const text = (n.textContent || '').trim().substring(0, 100);
29
+ if (text) results.push({ Index: i + 1, Title: text });
30
+ });
31
+ break;
32
+ }
33
+ }
34
+
35
+ return results;
36
+ })()
37
+ `);
38
+ if (items.length === 0) {
39
+ return [{ Index: 0, Title: 'No history found. Ensure the sidebar is visible.' }];
40
+ }
41
+ return items;
42
+ },
43
+ });
@@ -0,0 +1 @@
1
+ export declare const modelCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,81 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const modelCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'model',
5
+ description: 'Get or switch the active AI model in ChatWise',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [
10
+ { name: 'model_name', required: false, positional: true, help: 'Model to switch to (e.g. gpt-4, claude-3)' },
11
+ ],
12
+ columns: ['Status', 'Model'],
13
+ func: async (page, kwargs) => {
14
+ const desiredModel = kwargs.model_name;
15
+ if (!desiredModel) {
16
+ // Read current model
17
+ const currentModel = await page.evaluate(`
18
+ (function() {
19
+ // ChatWise is a multi-LLM client, it typically shows the model name in a dropdown or header
20
+ const selectors = [
21
+ '[class*="model"] span',
22
+ '[class*="Model"] span',
23
+ '[data-testid*="model"]',
24
+ 'button[class*="model"]',
25
+ '[aria-label*="Model"]',
26
+ '[aria-label*="model"]',
27
+ ];
28
+
29
+ for (const sel of selectors) {
30
+ const el = document.querySelector(sel);
31
+ if (el) {
32
+ const text = (el.textContent || el.getAttribute('title') || '').trim();
33
+ if (text) return text;
34
+ }
35
+ }
36
+
37
+ return 'Unknown or Not Found';
38
+ })()
39
+ `);
40
+ return [{ Status: 'Active', Model: currentModel }];
41
+ }
42
+ else {
43
+ // Try to switch model
44
+ await page.evaluate(`
45
+ (function(target) {
46
+ const selectors = [
47
+ '[class*="model"]',
48
+ '[class*="Model"]',
49
+ 'button[class*="model"]',
50
+ ];
51
+
52
+ for (const sel of selectors) {
53
+ const el = document.querySelector(sel);
54
+ if (el) { el.click(); return; }
55
+ }
56
+ throw new Error('Could not find model selector');
57
+ })(${JSON.stringify(desiredModel)})
58
+ `);
59
+ await page.wait(0.5);
60
+ // Find and click the target model in the dropdown
61
+ const found = await page.evaluate(`
62
+ (function(target) {
63
+ const options = document.querySelectorAll('[role="option"], [role="menuitem"], [class*="dropdown-item"], li');
64
+ for (const opt of options) {
65
+ if ((opt.textContent || '').toLowerCase().includes(target.toLowerCase())) {
66
+ opt.click();
67
+ return true;
68
+ }
69
+ }
70
+ return false;
71
+ })(${JSON.stringify(desiredModel)})
72
+ `);
73
+ return [
74
+ {
75
+ Status: found ? 'Switched' : 'Dropdown opened but model not found',
76
+ Model: desiredModel,
77
+ },
78
+ ];
79
+ }
80
+ },
81
+ });
@@ -0,0 +1 @@
1
+ export declare const newCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,18 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const newCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'new',
5
+ description: 'Start a new conversation in ChatWise',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [],
10
+ columns: ['Status'],
11
+ func: async (page) => {
12
+ // ChatWise uses standard Electron shortcuts
13
+ const isMac = process.platform === 'darwin';
14
+ await page.pressKey(isMac ? 'Meta+N' : 'Control+N');
15
+ await page.wait(1);
16
+ return [{ Status: 'Success' }];
17
+ },
18
+ });
@@ -0,0 +1 @@
1
+ export declare const readCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,39 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const readCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'read',
5
+ description: 'Read the current ChatWise conversation history',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [],
10
+ columns: ['Content'],
11
+ func: async (page) => {
12
+ const content = await page.evaluate(`
13
+ (function() {
14
+ // Try common chat message selectors
15
+ const selectors = [
16
+ '[data-message-id]',
17
+ '[class*="message"]',
18
+ '[class*="chat-item"]',
19
+ '[class*="bubble"]',
20
+ '[role="log"] > *',
21
+ ];
22
+
23
+ for (const sel of selectors) {
24
+ const nodes = document.querySelectorAll(sel);
25
+ if (nodes.length > 0) {
26
+ return Array.from(nodes).map(n => (n.innerText || n.textContent).trim()).filter(Boolean).join('\\n\\n---\\n\\n');
27
+ }
28
+ }
29
+
30
+ // Fallback: main content area
31
+ const main = document.querySelector('main, [role="main"], [class*="chat-container"], [class*="conversation"]');
32
+ if (main) return main.innerText || main.textContent;
33
+
34
+ return document.body.innerText;
35
+ })()
36
+ `);
37
+ return [{ Content: content }];
38
+ },
39
+ });
@@ -0,0 +1 @@
1
+ export declare const screenshotCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,27 @@
1
+ import * as fs from 'node:fs';
2
+ import { cli, Strategy } from '../../registry.js';
3
+ export const screenshotCommand = cli({
4
+ site: 'chatwise',
5
+ name: 'screenshot',
6
+ description: 'Capture a snapshot of the current ChatWise window (DOM + Accessibility tree)',
7
+ domain: 'localhost',
8
+ strategy: Strategy.UI,
9
+ browser: true,
10
+ args: [
11
+ { name: 'output', required: false, positional: true, help: 'Output file path (default: /tmp/chatwise-snapshot)' },
12
+ ],
13
+ columns: ['Status', 'File'],
14
+ func: async (page, kwargs) => {
15
+ const basePath = kwargs.output || '/tmp/chatwise-snapshot';
16
+ const snap = await page.snapshot({ compact: true });
17
+ const html = await page.evaluate('document.documentElement.outerHTML');
18
+ const htmlPath = basePath + '-dom.html';
19
+ const snapPath = basePath + '-a11y.txt';
20
+ fs.writeFileSync(htmlPath, html);
21
+ fs.writeFileSync(snapPath, typeof snap === 'string' ? snap : JSON.stringify(snap, null, 2));
22
+ return [
23
+ { Status: 'Success', File: htmlPath },
24
+ { Status: 'Success', File: snapPath },
25
+ ];
26
+ },
27
+ });
@@ -0,0 +1 @@
1
+ export declare const sendCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,45 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const sendCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'send',
5
+ description: 'Send a message to the active ChatWise conversation',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [{ name: 'text', required: true, positional: true, help: 'Message to send' }],
10
+ columns: ['Status', 'InjectedText'],
11
+ func: async (page, kwargs) => {
12
+ const text = kwargs.text;
13
+ await page.evaluate(`
14
+ (function(text) {
15
+ // ChatWise input can be textarea or contenteditable
16
+ let composer = document.querySelector('textarea');
17
+ if (!composer) {
18
+ const editables = Array.from(document.querySelectorAll('[contenteditable="true"]'));
19
+ composer = editables.length > 0 ? editables[editables.length - 1] : null;
20
+ }
21
+
22
+ if (!composer) throw new Error('Could not find ChatWise input element');
23
+
24
+ composer.focus();
25
+
26
+ if (composer.tagName === 'TEXTAREA') {
27
+ // For textarea, set value and dispatch input event
28
+ const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
29
+ nativeInputValueSetter.call(composer, text);
30
+ composer.dispatchEvent(new Event('input', { bubbles: true }));
31
+ } else {
32
+ document.execCommand('insertText', false, text);
33
+ }
34
+ })(${JSON.stringify(text)})
35
+ `);
36
+ await page.wait(0.5);
37
+ await page.pressKey('Enter');
38
+ return [
39
+ {
40
+ Status: 'Success',
41
+ InjectedText: text,
42
+ },
43
+ ];
44
+ },
45
+ });
@@ -0,0 +1 @@
1
+ export declare const statusCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,22 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const statusCommand = cli({
3
+ site: 'chatwise',
4
+ name: 'status',
5
+ description: 'Check active CDP connection to ChatWise Desktop',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [],
10
+ columns: ['Status', 'Url', 'Title'],
11
+ func: async (page) => {
12
+ const url = await page.evaluate('window.location.href');
13
+ const title = await page.evaluate('document.title');
14
+ return [
15
+ {
16
+ Status: 'Connected',
17
+ Url: url,
18
+ Title: title,
19
+ },
20
+ ];
21
+ },
22
+ });
@@ -0,0 +1 @@
1
+ export declare const channelsCommand: import("../../registry.js").CliCommand;
@@ -0,0 +1,45 @@
1
+ import { cli, Strategy } from '../../registry.js';
2
+ export const channelsCommand = cli({
3
+ site: 'discord-app',
4
+ name: 'channels',
5
+ description: 'List channels in the current Discord server',
6
+ domain: 'localhost',
7
+ strategy: Strategy.UI,
8
+ browser: true,
9
+ args: [],
10
+ columns: ['Index', 'Channel', 'Type'],
11
+ func: async (page) => {
12
+ const channels = await page.evaluate(`
13
+ (function() {
14
+ const results = [];
15
+ // Discord channel list items
16
+ const items = document.querySelectorAll('[data-list-item-id*="channels___"], [class*="containerDefault_"]');
17
+
18
+ items.forEach((item, i) => {
19
+ const nameEl = item.querySelector('[class*="name_"], [class*="channelName"]');
20
+ const name = nameEl ? nameEl.textContent.trim() : (item.textContent || '').trim().substring(0, 50);
21
+
22
+ if (!name || name.length < 1) return;
23
+
24
+ // Detect channel type from icon or aria-label
25
+ const iconEl = item.querySelector('[class*="icon"]');
26
+ let type = 'Text';
27
+ if (iconEl) {
28
+ const cls = iconEl.className || '';
29
+ if (cls.includes('voice') || cls.includes('speaker')) type = 'Voice';
30
+ else if (cls.includes('forum')) type = 'Forum';
31
+ else if (cls.includes('announcement')) type = 'Announcement';
32
+ }
33
+
34
+ results.push({ Index: i + 1, Channel: name, Type: type });
35
+ });
36
+
37
+ return results;
38
+ })()
39
+ `);
40
+ if (channels.length === 0) {
41
+ return [{ Index: 0, Channel: 'No channels found', Type: '—' }];
42
+ }
43
+ return channels;
44
+ },
45
+ });
@@ -0,0 +1 @@
1
+ export declare const membersCommand: import("../../registry.js").CliCommand;