@jackwener/opencli 1.0.1 → 1.0.3

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 (91) hide show
  1. package/.github/workflows/build-extension.yml +62 -0
  2. package/.github/workflows/ci.yml +6 -6
  3. package/.github/workflows/e2e-headed.yml +2 -2
  4. package/.github/workflows/pkg-pr-new.yml +2 -2
  5. package/.github/workflows/release.yml +2 -5
  6. package/.github/workflows/security.yml +2 -2
  7. package/CDP.md +1 -1
  8. package/CDP.zh-CN.md +1 -1
  9. package/README.md +15 -7
  10. package/README.zh-CN.md +15 -7
  11. package/SKILL.md +3 -5
  12. package/dist/browser/cdp.d.ts +27 -0
  13. package/dist/browser/cdp.js +295 -0
  14. package/dist/browser/index.d.ts +3 -0
  15. package/dist/browser/index.js +4 -0
  16. package/dist/browser/page.js +2 -23
  17. package/dist/browser/utils.d.ts +10 -0
  18. package/dist/browser/utils.js +27 -0
  19. package/dist/browser.test.js +42 -1
  20. package/dist/chaoxing.d.ts +58 -0
  21. package/dist/chaoxing.js +225 -0
  22. package/dist/chaoxing.test.d.ts +1 -0
  23. package/dist/chaoxing.test.js +38 -0
  24. package/dist/cli-manifest.json +203 -0
  25. package/dist/cli.d.ts +1 -0
  26. package/dist/cli.js +197 -0
  27. package/dist/clis/boss/chatlist.d.ts +1 -0
  28. package/dist/clis/boss/chatlist.js +50 -0
  29. package/dist/clis/boss/chatmsg.d.ts +1 -0
  30. package/dist/clis/boss/chatmsg.js +73 -0
  31. package/dist/clis/boss/send.d.ts +1 -0
  32. package/dist/clis/boss/send.js +176 -0
  33. package/dist/clis/chaoxing/assignments.d.ts +1 -0
  34. package/dist/clis/chaoxing/assignments.js +74 -0
  35. package/dist/clis/chaoxing/exams.d.ts +1 -0
  36. package/dist/clis/chaoxing/exams.js +74 -0
  37. package/dist/clis/chatgpt/ask.js +15 -14
  38. package/dist/clis/chatgpt/ax.d.ts +1 -0
  39. package/dist/clis/chatgpt/ax.js +78 -0
  40. package/dist/clis/chatgpt/read.js +5 -6
  41. package/dist/clis/twitter/post.js +9 -2
  42. package/dist/clis/twitter/search.js +14 -33
  43. package/dist/clis/xiaohongshu/download.d.ts +1 -1
  44. package/dist/clis/xiaohongshu/download.js +1 -1
  45. package/dist/engine.js +24 -13
  46. package/dist/explore.js +46 -101
  47. package/dist/main.js +4 -193
  48. package/dist/output.d.ts +1 -1
  49. package/dist/registry.d.ts +3 -3
  50. package/dist/scripts/framework.d.ts +4 -0
  51. package/dist/scripts/framework.js +21 -0
  52. package/dist/scripts/interact.d.ts +4 -0
  53. package/dist/scripts/interact.js +20 -0
  54. package/dist/scripts/store.d.ts +9 -0
  55. package/dist/scripts/store.js +44 -0
  56. package/dist/synthesize.js +1 -1
  57. package/extension/dist/background.js +338 -430
  58. package/extension/manifest.json +2 -2
  59. package/extension/src/background.ts +2 -2
  60. package/package.json +1 -1
  61. package/src/browser/cdp.ts +295 -0
  62. package/src/browser/index.ts +4 -0
  63. package/src/browser/page.ts +2 -24
  64. package/src/browser/utils.ts +27 -0
  65. package/src/browser.test.ts +46 -0
  66. package/src/chaoxing.test.ts +45 -0
  67. package/src/chaoxing.ts +268 -0
  68. package/src/cli.ts +185 -0
  69. package/src/clis/antigravity/SKILL.md +5 -0
  70. package/src/clis/boss/chatlist.ts +50 -0
  71. package/src/clis/boss/chatmsg.ts +70 -0
  72. package/src/clis/boss/send.ts +193 -0
  73. package/src/clis/chaoxing/README.md +36 -0
  74. package/src/clis/chaoxing/README.zh-CN.md +35 -0
  75. package/src/clis/chaoxing/assignments.ts +88 -0
  76. package/src/clis/chaoxing/exams.ts +88 -0
  77. package/src/clis/chatgpt/ask.ts +14 -15
  78. package/src/clis/chatgpt/ax.ts +81 -0
  79. package/src/clis/chatgpt/read.ts +5 -7
  80. package/src/clis/twitter/post.ts +9 -2
  81. package/src/clis/twitter/search.ts +15 -33
  82. package/src/clis/xiaohongshu/download.ts +1 -1
  83. package/src/engine.ts +20 -13
  84. package/src/explore.ts +51 -100
  85. package/src/main.ts +4 -180
  86. package/src/output.ts +12 -12
  87. package/src/registry.ts +3 -3
  88. package/src/scripts/framework.ts +20 -0
  89. package/src/scripts/interact.ts +22 -0
  90. package/src/scripts/store.ts +40 -0
  91. package/src/synthesize.ts +1 -1
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { formatSnapshot } from '../snapshotFormatter.js';
13
13
  import { sendCommand } from './daemon-client.js';
14
+ import { wrapForEval } from './utils.js';
14
15
  /**
15
16
  * Page — implements IPage by talking to the daemon via HTTP.
16
17
  */
@@ -257,26 +258,4 @@ export class Page {
257
258
  return result || [];
258
259
  }
259
260
  }
260
- // ─── Helpers ─────────────────────────────────────────────────────────
261
- /**
262
- * Wrap JS code for CDP Runtime.evaluate:
263
- * - Already an IIFE `(...)()` → send as-is
264
- * - Arrow/function literal → wrap as IIFE `(code)()`
265
- * - `new Promise(...)` or raw expression → send as-is (expression)
266
- */
267
- function wrapForEval(js) {
268
- const code = js.trim();
269
- if (!code)
270
- return 'undefined';
271
- // Already an IIFE: `(async () => { ... })()` or `(function() {...})()`
272
- if (/^\([\s\S]*\)\s*\(.*\)\s*$/.test(code))
273
- return code;
274
- // Arrow function: `() => ...` or `async () => ...`
275
- if (/^(async\s+)?(\([^)]*\)|[A-Za-z_]\w*)\s*=>/.test(code))
276
- return `(${code})()`;
277
- // Function declaration: `function ...` or `async function ...`
278
- if (/^(async\s+)?function[\s(]/.test(code))
279
- return `(${code})()`;
280
- // Everything else: bare expression, `new Promise(...)`, etc. → evaluate directly
281
- return code;
282
- }
261
+ // (End of file)
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utility functions for browser operations
3
+ */
4
+ /**
5
+ * Wrap JS code for CDP Runtime.evaluate:
6
+ * - Already an IIFE `(...)()` → send as-is
7
+ * - Arrow/function literal → wrap as IIFE `(code)()`
8
+ * - `new Promise(...)` or raw expression → send as-is (expression)
9
+ */
10
+ export declare function wrapForEval(js: string): string;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Utility functions for browser operations
3
+ */
4
+ /**
5
+ * Wrap JS code for CDP Runtime.evaluate:
6
+ * - Already an IIFE `(...)()` → send as-is
7
+ * - Arrow/function literal → wrap as IIFE `(code)()`
8
+ * - `new Promise(...)` or raw expression → send as-is (expression)
9
+ */
10
+ export function wrapForEval(js) {
11
+ if (typeof js !== 'string')
12
+ return 'undefined';
13
+ const code = js.trim();
14
+ if (!code)
15
+ return 'undefined';
16
+ // Already an IIFE: `(async () => { ... })()` or `(function() {...})()`
17
+ if (/^\([\s\S]*\)\s*\(.*\)\s*$/.test(code))
18
+ return code;
19
+ // Arrow function: `() => ...` or `async () => ...`
20
+ if (/^(async\s+)?(\([^)]*\)|[A-Za-z_]\w*)\s*=>/.test(code))
21
+ return `(${code})()`;
22
+ // Function declaration: `function ...` or `async function ...`
23
+ if (/^(async\s+)?function[\s(]/.test(code))
24
+ return `(${code})()`;
25
+ // Everything else: bare expression, `new Promise(...)`, etc. → evaluate directly
26
+ return code;
27
+ }
@@ -1,4 +1,4 @@
1
- import { describe, it, expect } from 'vitest';
1
+ import { describe, it, expect, vi } from 'vitest';
2
2
  import { BrowserBridge, __test__ } from './browser/index.js';
3
3
  describe('browser helpers', () => {
4
4
  it('extracts tab entries from string snapshots', () => {
@@ -30,6 +30,47 @@ describe('browser helpers', () => {
30
30
  it('times out slow promises', async () => {
31
31
  await expect(__test__.withTimeoutMs(new Promise(() => { }), 10, 'timeout')).rejects.toThrow('timeout');
32
32
  });
33
+ it('prefers the real Electron app target over DevTools and blank pages', () => {
34
+ const target = __test__.selectCDPTarget([
35
+ {
36
+ type: 'page',
37
+ title: 'DevTools - localhost:9224',
38
+ url: 'devtools://devtools/bundled/inspector.html',
39
+ webSocketDebuggerUrl: 'ws://127.0.0.1:9224/devtools',
40
+ },
41
+ {
42
+ type: 'page',
43
+ title: '',
44
+ url: 'about:blank',
45
+ webSocketDebuggerUrl: 'ws://127.0.0.1:9224/blank',
46
+ },
47
+ {
48
+ type: 'app',
49
+ title: 'Antigravity',
50
+ url: 'http://localhost:3000/',
51
+ webSocketDebuggerUrl: 'ws://127.0.0.1:9224/app',
52
+ },
53
+ ]);
54
+ expect(target?.webSocketDebuggerUrl).toBe('ws://127.0.0.1:9224/app');
55
+ });
56
+ it('honors OPENCLI_CDP_TARGET when multiple inspectable targets exist', () => {
57
+ vi.stubEnv('OPENCLI_CDP_TARGET', 'codex');
58
+ const target = __test__.selectCDPTarget([
59
+ {
60
+ type: 'app',
61
+ title: 'Cursor',
62
+ url: 'http://localhost:3000/cursor',
63
+ webSocketDebuggerUrl: 'ws://127.0.0.1:9226/cursor',
64
+ },
65
+ {
66
+ type: 'app',
67
+ title: 'OpenAI Codex',
68
+ url: 'http://localhost:3000/codex',
69
+ webSocketDebuggerUrl: 'ws://127.0.0.1:9226/codex',
70
+ },
71
+ ]);
72
+ expect(target?.webSocketDebuggerUrl).toBe('ws://127.0.0.1:9226/codex');
73
+ });
33
74
  });
34
75
  describe('BrowserBridge state', () => {
35
76
  it('transitions to closed after close()', async () => {
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Chaoxing (学习通) shared helpers.
3
+ *
4
+ * Flow: initSession → getCourses → enterCourse → getTabIframeUrl → navigate → parse DOM
5
+ * Chaoxing has no flat "list all assignments" API; data is behind session-gated
6
+ * course pages loaded as iframes.
7
+ */
8
+ import type { IPage } from './types.js';
9
+ /** Sleep for given milliseconds (anti-scraping delay). */
10
+ export declare function sleep(ms: number): Promise<void>;
11
+ /** Execute a credentialed fetch in the browser context, returning JSON or text. */
12
+ export declare function fetchChaoxing(page: IPage, url: string): Promise<any>;
13
+ /** Format a timestamp (seconds or milliseconds or date string) to YYYY-MM-DD HH:mm. */
14
+ export declare function formatTimestamp(ts: unknown): string;
15
+ /** Map numeric work status to Chinese label. */
16
+ export declare function workStatusLabel(status: unknown): string;
17
+ export interface ChaoxingCourse {
18
+ courseId: string;
19
+ classId: string;
20
+ cpi: string;
21
+ title: string;
22
+ }
23
+ /** Fetch enrolled course list via backclazzdata JSON API. */
24
+ export declare function getCourses(page: IPage): Promise<ChaoxingCourse[]>;
25
+ /** Navigate to the interaction page to establish a Chaoxing session. */
26
+ export declare function initSession(page: IPage): Promise<void>;
27
+ /**
28
+ * Enter a course via stucoursemiddle redirect (establishes course session + enc).
29
+ * After this call the browser is on the course page.
30
+ */
31
+ export declare function enterCourse(page: IPage, course: ChaoxingCourse): Promise<void>;
32
+ /**
33
+ * On the course page, click a tab (作业 / 考试) and return the iframe src
34
+ * that gets loaded. Returns empty string if the tab is not found.
35
+ */
36
+ export declare function getTabIframeUrl(page: IPage, tabName: string): Promise<string>;
37
+ export interface AssignmentRow {
38
+ course: string;
39
+ title: string;
40
+ deadline: string;
41
+ status: string;
42
+ score: string;
43
+ }
44
+ /**
45
+ * Parse assignments from the current page DOM (the 作业列表 page).
46
+ * The page uses `.ulDiv li` items with status/deadline/score info.
47
+ */
48
+ export declare function parseAssignmentsFromDom(page: IPage, courseName: string): Promise<AssignmentRow[]>;
49
+ export interface ExamRow {
50
+ course: string;
51
+ title: string;
52
+ start: string;
53
+ end: string;
54
+ status: string;
55
+ score: string;
56
+ }
57
+ /** Parse exams from the current page DOM (the 考试列表 page). */
58
+ export declare function parseExamsFromDom(page: IPage, courseName: string): Promise<ExamRow[]>;
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Chaoxing (学习通) shared helpers.
3
+ *
4
+ * Flow: initSession → getCourses → enterCourse → getTabIframeUrl → navigate → parse DOM
5
+ * Chaoxing has no flat "list all assignments" API; data is behind session-gated
6
+ * course pages loaded as iframes.
7
+ */
8
+ // ── Utilities ────────────────────────────────────────────────────────
9
+ /** Sleep for given milliseconds (anti-scraping delay). */
10
+ export function sleep(ms) {
11
+ return new Promise(resolve => setTimeout(resolve, ms));
12
+ }
13
+ /** Execute a credentialed fetch in the browser context, returning JSON or text. */
14
+ export async function fetchChaoxing(page, url) {
15
+ const urlJs = JSON.stringify(url);
16
+ return page.evaluate(`
17
+ async () => {
18
+ const res = await fetch(${urlJs}, { credentials: "include" });
19
+ const text = await res.text();
20
+ try { return JSON.parse(text); } catch {}
21
+ return text;
22
+ }
23
+ `);
24
+ }
25
+ /** Format a timestamp (seconds or milliseconds or date string) to YYYY-MM-DD HH:mm. */
26
+ export function formatTimestamp(ts) {
27
+ if (ts == null || ts === '' || ts === 0)
28
+ return '';
29
+ if (typeof ts === 'string' && !/^\d+$/.test(ts.trim()))
30
+ return ts.trim();
31
+ const num = Number(ts);
32
+ if (Number.isNaN(num) || num <= 0)
33
+ return String(ts);
34
+ const millis = num > 1e12 ? num : num * 1000;
35
+ const d = new Date(millis);
36
+ if (Number.isNaN(d.getTime()))
37
+ return String(ts);
38
+ const yyyy = d.getFullYear();
39
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
40
+ const dd = String(d.getDate()).padStart(2, '0');
41
+ const hh = String(d.getHours()).padStart(2, '0');
42
+ const mi = String(d.getMinutes()).padStart(2, '0');
43
+ return `${yyyy}-${mm}-${dd} ${hh}:${mi}`;
44
+ }
45
+ /** Map numeric work status to Chinese label. */
46
+ export function workStatusLabel(status) {
47
+ if (status == null || status === '')
48
+ return '未知';
49
+ const s = Number(status);
50
+ if (s === 0)
51
+ return '未交';
52
+ if (s === 1)
53
+ return '已交';
54
+ if (s === 2)
55
+ return '已批阅';
56
+ const str = String(status).trim();
57
+ return str || '未知';
58
+ }
59
+ /** Fetch enrolled course list via backclazzdata JSON API. */
60
+ export async function getCourses(page) {
61
+ const resp = await fetchChaoxing(page, 'https://mooc1-api.chaoxing.com/mycourse/backclazzdata?view=json&rss=1');
62
+ if (!resp || typeof resp !== 'object')
63
+ return [];
64
+ const channelList = resp.channelList ?? [];
65
+ const courses = [];
66
+ for (const channel of channelList) {
67
+ const content = channel?.content;
68
+ if (!content)
69
+ continue;
70
+ const courseData = content.course?.data;
71
+ if (!Array.isArray(courseData))
72
+ continue;
73
+ for (const c of courseData) {
74
+ courses.push({
75
+ courseId: String(c.id ?? ''),
76
+ classId: String(content.id ?? ''),
77
+ cpi: String(channel.cpi ?? ''),
78
+ title: String(c.name ?? ''),
79
+ });
80
+ }
81
+ }
82
+ return courses;
83
+ }
84
+ // ── Session & course entry ───────────────────────────────────────────
85
+ /** Navigate to the interaction page to establish a Chaoxing session. */
86
+ export async function initSession(page) {
87
+ await page.goto('https://mooc2-ans.chaoxing.com/mooc2-ans/visit/interaction');
88
+ await page.wait(3);
89
+ }
90
+ /**
91
+ * Enter a course via stucoursemiddle redirect (establishes course session + enc).
92
+ * After this call the browser is on the course page.
93
+ */
94
+ export async function enterCourse(page, course) {
95
+ const url = `https://mooc1.chaoxing.com/visit/stucoursemiddle` +
96
+ `?courseid=${course.courseId}&clazzid=${course.classId}&cpi=${course.cpi}&ismooc2=1&v=2`;
97
+ await page.goto(url);
98
+ await page.wait(3);
99
+ }
100
+ /**
101
+ * On the course page, click a tab (作业 / 考试) and return the iframe src
102
+ * that gets loaded. Returns empty string if the tab is not found.
103
+ */
104
+ export async function getTabIframeUrl(page, tabName) {
105
+ const nameJs = JSON.stringify(tabName);
106
+ const result = await page.evaluate(`
107
+ async () => {
108
+ const tabs = document.querySelectorAll('a[data-url]');
109
+ let target = null;
110
+ for (const tab of tabs) {
111
+ if ((tab.innerText || '').trim() === ${nameJs}) { target = tab; break; }
112
+ }
113
+ if (!target) return '';
114
+ target.click();
115
+ await new Promise(r => setTimeout(r, 2000));
116
+ const iframe = document.getElementById('frame_content-hd') || document.querySelector('iframe');
117
+ return iframe?.src || '';
118
+ }
119
+ `);
120
+ return typeof result === 'string' ? result : '';
121
+ }
122
+ /**
123
+ * Parse assignments from the current page DOM (the 作业列表 page).
124
+ * The page uses `.ulDiv li` items with status/deadline/score info.
125
+ */
126
+ export async function parseAssignmentsFromDom(page, courseName) {
127
+ const raw = await page.evaluate(`
128
+ (() => {
129
+ const items = [];
130
+ // Each assignment is a li or div block; try multiple selectors
131
+ const blocks = document.querySelectorAll('.ulDiv li, .work-list-item, .listContent > div, ul > li');
132
+ for (const block of blocks) {
133
+ const text = (block.innerText || '').trim();
134
+ if (!text || text.length < 3) continue;
135
+ // Skip filter buttons and headers
136
+ if (/^(全部|已完成|未完成|筛选)$/.test(text)) continue;
137
+ items.push(text);
138
+ }
139
+ // Fallback: split body text by common patterns
140
+ if (items.length === 0) {
141
+ const body = (document.body?.innerText || '').trim();
142
+ return [body];
143
+ }
144
+ return items;
145
+ })()
146
+ `) ?? [];
147
+ const rows = [];
148
+ for (const text of raw) {
149
+ if (typeof text !== 'string' || text.length < 3)
150
+ continue;
151
+ // Skip noise
152
+ if (/^(全部|已完成|未完成|筛选|暂无|提交的作业将经过)/.test(text))
153
+ continue;
154
+ const lines = text.split('\n').map((l) => l.trim()).filter(Boolean);
155
+ if (!lines.length)
156
+ continue;
157
+ // First meaningful line is the title
158
+ const title = lines[0].replace(/\s+/g, ' ').trim();
159
+ if (!title || /^(全部|已完成|未完成|筛选)$/.test(title))
160
+ continue;
161
+ // Extract status: 未交 / 待批阅 / 已完成 / 已批阅
162
+ const statusMatch = text.match(/(未交|待批阅|已完成|已批阅)/);
163
+ const status = statusMatch?.[1] ?? '';
164
+ // Extract deadline: "剩余XXX" or date pattern
165
+ const remainMatch = text.match(/(剩余[\d天小时分钟秒]+)/);
166
+ const dateMatch = text.match(/(\d{4}[-/.]\d{1,2}[-/.]\d{1,2}(?:\s+\d{1,2}:\d{2})?)/);
167
+ const deadline = remainMatch?.[1] ?? dateMatch?.[1] ?? '';
168
+ // Extract score (exclude "分钟")
169
+ const scoreMatch = text.match(/(\d+(?:\.\d+)?)\s*分(?!钟)/);
170
+ const score = scoreMatch?.[1] ?? '';
171
+ rows.push({ course: courseName, title, deadline, status, score });
172
+ }
173
+ return rows;
174
+ }
175
+ /** Parse exams from the current page DOM (the 考试列表 page). */
176
+ export async function parseExamsFromDom(page, courseName) {
177
+ const raw = await page.evaluate(`
178
+ (() => {
179
+ const items = [];
180
+ const blocks = document.querySelectorAll('.ulDiv li, .exam-list-item, .listContent > div, ul > li');
181
+ for (const block of blocks) {
182
+ const text = (block.innerText || '').trim();
183
+ if (!text || text.length < 3) continue;
184
+ if (/^(全部|已完成|未完成|筛选|暂无)$/.test(text)) continue;
185
+ items.push(text);
186
+ }
187
+ if (items.length === 0) {
188
+ const body = (document.body?.innerText || '').trim();
189
+ return [body];
190
+ }
191
+ return items;
192
+ })()
193
+ `) ?? [];
194
+ // Check for "暂无考试"
195
+ if (raw.length === 1 && typeof raw[0] === 'string' && raw[0].includes('暂无考试')) {
196
+ return [];
197
+ }
198
+ const rows = [];
199
+ for (const text of raw) {
200
+ if (typeof text !== 'string' || text.length < 3)
201
+ continue;
202
+ if (/^(全部|已完成|未完成|筛选|暂无)/.test(text))
203
+ continue;
204
+ const lines = text.split('\n').map((l) => l.trim()).filter(Boolean);
205
+ if (!lines.length)
206
+ continue;
207
+ const title = lines[0].replace(/\s+/g, ' ').trim();
208
+ if (!title || /^(全部|已完成|未完成|筛选)$/.test(title))
209
+ continue;
210
+ // Extract dates
211
+ const dates = text.match(/\d{4}[-/.]\d{1,2}[-/.]\d{1,2}\s+\d{1,2}:\d{2}/g) ?? [];
212
+ const start = dates[0] ?? '';
213
+ const end = dates[1] ?? '';
214
+ // Status
215
+ const statusMatch = text.match(/(未开始|进行中|已结束|已完成|未交|待批阅)/);
216
+ let status = statusMatch?.[1] ?? '';
217
+ if (!status && text.includes('剩余'))
218
+ status = '进行中';
219
+ // Score (exclude "分钟")
220
+ const scoreMatch = text.match(/(\d+(?:\.\d+)?)\s*分(?!钟)/);
221
+ const score = scoreMatch?.[1] ?? '';
222
+ rows.push({ course: courseName, title, start, end, status, score });
223
+ }
224
+ return rows;
225
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { formatTimestamp, workStatusLabel } from './chaoxing.js';
3
+ describe('formatTimestamp', () => {
4
+ it('formats millisecond timestamp', () => {
5
+ // 2026-01-15 08:30 UTC+8
6
+ const ts = new Date('2026-01-15T00:30:00Z').getTime();
7
+ const result = formatTimestamp(ts);
8
+ expect(result).toMatch(/2026-01-15/);
9
+ });
10
+ it('formats second timestamp', () => {
11
+ const ts = Math.floor(new Date('2026-06-01T12:00:00Z').getTime() / 1000);
12
+ const result = formatTimestamp(ts);
13
+ expect(result).toMatch(/2026-06-01/);
14
+ });
15
+ it('returns empty for null/undefined/0', () => {
16
+ expect(formatTimestamp(null)).toBe('');
17
+ expect(formatTimestamp(undefined)).toBe('');
18
+ expect(formatTimestamp(0)).toBe('');
19
+ expect(formatTimestamp('')).toBe('');
20
+ });
21
+ it('passes through readable date strings', () => {
22
+ expect(formatTimestamp('2026-03-20 23:59')).toBe('2026-03-20 23:59');
23
+ });
24
+ });
25
+ describe('workStatusLabel', () => {
26
+ it('maps numeric status codes', () => {
27
+ expect(workStatusLabel(0)).toBe('未交');
28
+ expect(workStatusLabel(1)).toBe('已交');
29
+ expect(workStatusLabel(2)).toBe('已批阅');
30
+ });
31
+ it('passes through string status', () => {
32
+ expect(workStatusLabel('已交')).toBe('已交');
33
+ });
34
+ it('returns 未知 for empty/null', () => {
35
+ expect(workStatusLabel(null)).toBe('未知');
36
+ expect(workStatusLabel('')).toBe('未知');
37
+ });
38
+ });
@@ -853,6 +853,78 @@
853
853
  "url"
854
854
  ]
855
855
  },
856
+ {
857
+ "site": "boss",
858
+ "name": "chatlist",
859
+ "description": "BOSS直聘查看聊天列表(招聘端)",
860
+ "strategy": "cookie",
861
+ "browser": true,
862
+ "args": [
863
+ {
864
+ "name": "page",
865
+ "type": "int",
866
+ "default": 1,
867
+ "required": false,
868
+ "help": "Page number"
869
+ },
870
+ {
871
+ "name": "limit",
872
+ "type": "int",
873
+ "default": 20,
874
+ "required": false,
875
+ "help": "Number of results"
876
+ },
877
+ {
878
+ "name": "job_id",
879
+ "type": "str",
880
+ "default": "0",
881
+ "required": false,
882
+ "help": "Filter by job ID (0=all)"
883
+ }
884
+ ],
885
+ "type": "ts",
886
+ "modulePath": "boss/chatlist.js",
887
+ "domain": "www.zhipin.com",
888
+ "columns": [
889
+ "name",
890
+ "job",
891
+ "last_msg",
892
+ "last_time",
893
+ "uid",
894
+ "security_id"
895
+ ]
896
+ },
897
+ {
898
+ "site": "boss",
899
+ "name": "chatmsg",
900
+ "description": "BOSS直聘查看与候选人的聊天消息",
901
+ "strategy": "cookie",
902
+ "browser": true,
903
+ "args": [
904
+ {
905
+ "name": "uid",
906
+ "type": "str",
907
+ "required": true,
908
+ "help": "Encrypted UID (from chatlist)"
909
+ },
910
+ {
911
+ "name": "page",
912
+ "type": "int",
913
+ "default": 1,
914
+ "required": false,
915
+ "help": "Page number"
916
+ }
917
+ ],
918
+ "type": "ts",
919
+ "modulePath": "boss/chatmsg.js",
920
+ "domain": "www.zhipin.com",
921
+ "columns": [
922
+ "from",
923
+ "type",
924
+ "text",
925
+ "time"
926
+ ]
927
+ },
856
928
  {
857
929
  "site": "boss",
858
930
  "name": "detail",
@@ -970,6 +1042,127 @@
970
1042
  "url"
971
1043
  ]
972
1044
  },
1045
+ {
1046
+ "site": "boss",
1047
+ "name": "send",
1048
+ "description": "BOSS直聘发送聊天消息",
1049
+ "strategy": "cookie",
1050
+ "browser": true,
1051
+ "args": [
1052
+ {
1053
+ "name": "uid",
1054
+ "type": "str",
1055
+ "required": true,
1056
+ "help": "Encrypted UID of the candidate (from chatlist)"
1057
+ },
1058
+ {
1059
+ "name": "text",
1060
+ "type": "str",
1061
+ "required": true,
1062
+ "help": "Message text to send"
1063
+ }
1064
+ ],
1065
+ "type": "ts",
1066
+ "modulePath": "boss/send.js",
1067
+ "domain": "www.zhipin.com",
1068
+ "columns": [
1069
+ "status",
1070
+ "detail"
1071
+ ]
1072
+ },
1073
+ {
1074
+ "site": "chaoxing",
1075
+ "name": "assignments",
1076
+ "description": "学习通作业列表",
1077
+ "strategy": "cookie",
1078
+ "browser": true,
1079
+ "args": [
1080
+ {
1081
+ "name": "course",
1082
+ "type": "string",
1083
+ "required": false,
1084
+ "help": "按课程名过滤(模糊匹配)"
1085
+ },
1086
+ {
1087
+ "name": "status",
1088
+ "type": "string",
1089
+ "default": "all",
1090
+ "required": false,
1091
+ "help": "按状态过滤",
1092
+ "choices": [
1093
+ "all",
1094
+ "pending",
1095
+ "submitted",
1096
+ "graded"
1097
+ ]
1098
+ },
1099
+ {
1100
+ "name": "limit",
1101
+ "type": "int",
1102
+ "default": 20,
1103
+ "required": false,
1104
+ "help": "最大返回数量"
1105
+ }
1106
+ ],
1107
+ "type": "ts",
1108
+ "modulePath": "chaoxing/assignments.js",
1109
+ "domain": "mooc2-ans.chaoxing.com",
1110
+ "columns": [
1111
+ "rank",
1112
+ "course",
1113
+ "title",
1114
+ "deadline",
1115
+ "status",
1116
+ "score"
1117
+ ]
1118
+ },
1119
+ {
1120
+ "site": "chaoxing",
1121
+ "name": "exams",
1122
+ "description": "学习通考试列表",
1123
+ "strategy": "cookie",
1124
+ "browser": true,
1125
+ "args": [
1126
+ {
1127
+ "name": "course",
1128
+ "type": "string",
1129
+ "required": false,
1130
+ "help": "按课程名过滤(模糊匹配)"
1131
+ },
1132
+ {
1133
+ "name": "status",
1134
+ "type": "string",
1135
+ "default": "all",
1136
+ "required": false,
1137
+ "help": "按状态过滤",
1138
+ "choices": [
1139
+ "all",
1140
+ "upcoming",
1141
+ "ongoing",
1142
+ "finished"
1143
+ ]
1144
+ },
1145
+ {
1146
+ "name": "limit",
1147
+ "type": "int",
1148
+ "default": 20,
1149
+ "required": false,
1150
+ "help": "最大返回数量"
1151
+ }
1152
+ ],
1153
+ "type": "ts",
1154
+ "modulePath": "chaoxing/exams.js",
1155
+ "domain": "mooc2-ans.chaoxing.com",
1156
+ "columns": [
1157
+ "rank",
1158
+ "course",
1159
+ "title",
1160
+ "start",
1161
+ "end",
1162
+ "status",
1163
+ "score"
1164
+ ]
1165
+ },
973
1166
  {
974
1167
  "site": "chatgpt",
975
1168
  "name": "ask",
@@ -1000,6 +1193,16 @@
1000
1193
  "Text"
1001
1194
  ]
1002
1195
  },
1196
+ {
1197
+ "site": "chatgpt",
1198
+ "name": "ax",
1199
+ "description": "",
1200
+ "strategy": "cookie",
1201
+ "browser": true,
1202
+ "args": [],
1203
+ "type": "ts",
1204
+ "modulePath": "chatgpt/ax.js"
1205
+ },
1003
1206
  {
1004
1207
  "site": "chatgpt",
1005
1208
  "name": "new",
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function runCli(BUILTIN_CLIS: string, USER_CLIS: string): void;