@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.
- package/.github/workflows/build-extension.yml +62 -0
- package/.github/workflows/ci.yml +6 -6
- package/.github/workflows/e2e-headed.yml +2 -2
- package/.github/workflows/pkg-pr-new.yml +2 -2
- package/.github/workflows/release.yml +2 -5
- package/.github/workflows/security.yml +2 -2
- package/CDP.md +1 -1
- package/CDP.zh-CN.md +1 -1
- package/README.md +15 -7
- package/README.zh-CN.md +15 -7
- package/SKILL.md +3 -5
- package/dist/browser/cdp.d.ts +27 -0
- package/dist/browser/cdp.js +295 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +4 -0
- package/dist/browser/page.js +2 -23
- package/dist/browser/utils.d.ts +10 -0
- package/dist/browser/utils.js +27 -0
- package/dist/browser.test.js +42 -1
- package/dist/chaoxing.d.ts +58 -0
- package/dist/chaoxing.js +225 -0
- package/dist/chaoxing.test.d.ts +1 -0
- package/dist/chaoxing.test.js +38 -0
- package/dist/cli-manifest.json +203 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +197 -0
- package/dist/clis/boss/chatlist.d.ts +1 -0
- package/dist/clis/boss/chatlist.js +50 -0
- package/dist/clis/boss/chatmsg.d.ts +1 -0
- package/dist/clis/boss/chatmsg.js +73 -0
- package/dist/clis/boss/send.d.ts +1 -0
- package/dist/clis/boss/send.js +176 -0
- package/dist/clis/chaoxing/assignments.d.ts +1 -0
- package/dist/clis/chaoxing/assignments.js +74 -0
- package/dist/clis/chaoxing/exams.d.ts +1 -0
- package/dist/clis/chaoxing/exams.js +74 -0
- package/dist/clis/chatgpt/ask.js +15 -14
- package/dist/clis/chatgpt/ax.d.ts +1 -0
- package/dist/clis/chatgpt/ax.js +78 -0
- package/dist/clis/chatgpt/read.js +5 -6
- package/dist/clis/twitter/post.js +9 -2
- package/dist/clis/twitter/search.js +14 -33
- package/dist/clis/xiaohongshu/download.d.ts +1 -1
- package/dist/clis/xiaohongshu/download.js +1 -1
- package/dist/engine.js +24 -13
- package/dist/explore.js +46 -101
- package/dist/main.js +4 -193
- package/dist/output.d.ts +1 -1
- package/dist/registry.d.ts +3 -3
- package/dist/scripts/framework.d.ts +4 -0
- package/dist/scripts/framework.js +21 -0
- package/dist/scripts/interact.d.ts +4 -0
- package/dist/scripts/interact.js +20 -0
- package/dist/scripts/store.d.ts +9 -0
- package/dist/scripts/store.js +44 -0
- package/dist/synthesize.js +1 -1
- package/extension/dist/background.js +338 -430
- package/extension/manifest.json +2 -2
- package/extension/src/background.ts +2 -2
- package/package.json +1 -1
- package/src/browser/cdp.ts +295 -0
- package/src/browser/index.ts +4 -0
- package/src/browser/page.ts +2 -24
- package/src/browser/utils.ts +27 -0
- package/src/browser.test.ts +46 -0
- package/src/chaoxing.test.ts +45 -0
- package/src/chaoxing.ts +268 -0
- package/src/cli.ts +185 -0
- package/src/clis/antigravity/SKILL.md +5 -0
- package/src/clis/boss/chatlist.ts +50 -0
- package/src/clis/boss/chatmsg.ts +70 -0
- package/src/clis/boss/send.ts +193 -0
- package/src/clis/chaoxing/README.md +36 -0
- package/src/clis/chaoxing/README.zh-CN.md +35 -0
- package/src/clis/chaoxing/assignments.ts +88 -0
- package/src/clis/chaoxing/exams.ts +88 -0
- package/src/clis/chatgpt/ask.ts +14 -15
- package/src/clis/chatgpt/ax.ts +81 -0
- package/src/clis/chatgpt/read.ts +5 -7
- package/src/clis/twitter/post.ts +9 -2
- package/src/clis/twitter/search.ts +15 -33
- package/src/clis/xiaohongshu/download.ts +1 -1
- package/src/engine.ts +20 -13
- package/src/explore.ts +51 -100
- package/src/main.ts +4 -180
- package/src/output.ts +12 -12
- package/src/registry.ts +3 -3
- package/src/scripts/framework.ts +20 -0
- package/src/scripts/interact.ts +22 -0
- package/src/scripts/store.ts +40 -0
- package/src/synthesize.ts +1 -1
package/src/output.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface RenderOptions {
|
|
|
14
14
|
source?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function render(data:
|
|
17
|
+
export function render(data: unknown, opts: RenderOptions = {}): void {
|
|
18
18
|
const fmt = opts.fmt ?? 'table';
|
|
19
19
|
if (data === null || data === undefined) {
|
|
20
20
|
console.log(data);
|
|
@@ -29,8 +29,8 @@ export function render(data: any, opts: RenderOptions = {}): void {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function renderTable(data:
|
|
33
|
-
const rows
|
|
32
|
+
function renderTable(data: unknown, opts: RenderOptions): void {
|
|
33
|
+
const rows = Array.isArray(data) ? data : [data as Record<string, unknown>];
|
|
34
34
|
if (!rows.length) { console.log(chalk.dim('(no data)')); return; }
|
|
35
35
|
const columns = opts.columns ?? Object.keys(rows[0]);
|
|
36
36
|
|
|
@@ -44,7 +44,7 @@ function renderTable(data: any, opts: RenderOptions): void {
|
|
|
44
44
|
|
|
45
45
|
for (const row of rows) {
|
|
46
46
|
table.push(columns.map(c => {
|
|
47
|
-
const v = row[c];
|
|
47
|
+
const v = (row as Record<string, unknown>)[c];
|
|
48
48
|
return v === null || v === undefined ? '' : String(v);
|
|
49
49
|
}));
|
|
50
50
|
}
|
|
@@ -59,36 +59,36 @@ function renderTable(data: any, opts: RenderOptions): void {
|
|
|
59
59
|
console.log(chalk.dim(footer.join(' · ')));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function renderJson(data:
|
|
62
|
+
function renderJson(data: unknown): void {
|
|
63
63
|
console.log(JSON.stringify(data, null, 2));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function renderMarkdown(data:
|
|
67
|
-
const rows
|
|
66
|
+
function renderMarkdown(data: unknown, opts: RenderOptions): void {
|
|
67
|
+
const rows = Array.isArray(data) ? data : [data as Record<string, unknown>];
|
|
68
68
|
if (!rows.length) return;
|
|
69
69
|
const columns = opts.columns ?? Object.keys(rows[0]);
|
|
70
70
|
console.log('| ' + columns.join(' | ') + ' |');
|
|
71
71
|
console.log('| ' + columns.map(() => '---').join(' | ') + ' |');
|
|
72
72
|
for (const row of rows) {
|
|
73
|
-
console.log('| ' + columns.map(c => String(row[c] ?? '')).join(' | ') + ' |');
|
|
73
|
+
console.log('| ' + columns.map(c => String((row as Record<string, unknown>)[c] ?? '')).join(' | ') + ' |');
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function renderCsv(data:
|
|
78
|
-
const rows
|
|
77
|
+
function renderCsv(data: unknown, opts: RenderOptions): void {
|
|
78
|
+
const rows = Array.isArray(data) ? data : [data as Record<string, unknown>];
|
|
79
79
|
if (!rows.length) return;
|
|
80
80
|
const columns = opts.columns ?? Object.keys(rows[0]);
|
|
81
81
|
console.log(columns.join(','));
|
|
82
82
|
for (const row of rows) {
|
|
83
83
|
console.log(columns.map(c => {
|
|
84
|
-
const v = String(row[c] ?? '');
|
|
84
|
+
const v = String((row as Record<string, unknown>)[c] ?? '');
|
|
85
85
|
return v.includes(',') || v.includes('"') || v.includes('\n')
|
|
86
86
|
? `"${v.replace(/"/g, '""')}"` : v;
|
|
87
87
|
}).join(','));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function renderYaml(data:
|
|
91
|
+
function renderYaml(data: unknown): void {
|
|
92
92
|
console.log(yaml.dump(data, { sortKeys: false, lineWidth: 120, noRefs: true }));
|
|
93
93
|
}
|
|
94
94
|
|
package/src/registry.ts
CHANGED
|
@@ -15,7 +15,7 @@ export enum Strategy {
|
|
|
15
15
|
export interface Arg {
|
|
16
16
|
name: string;
|
|
17
17
|
type?: string;
|
|
18
|
-
default?:
|
|
18
|
+
default?: unknown;
|
|
19
19
|
required?: boolean;
|
|
20
20
|
positional?: boolean;
|
|
21
21
|
help?: string;
|
|
@@ -31,8 +31,8 @@ export interface CliCommand {
|
|
|
31
31
|
browser?: boolean;
|
|
32
32
|
args: Arg[];
|
|
33
33
|
columns?: string[];
|
|
34
|
-
func?: (page: IPage, kwargs: Record<string, any>, debug?: boolean) => Promise<
|
|
35
|
-
pipeline?:
|
|
34
|
+
func?: (page: IPage, kwargs: Record<string, any>, debug?: boolean) => Promise<unknown>;
|
|
35
|
+
pipeline?: Record<string, unknown>[];
|
|
36
36
|
timeoutSeconds?: number;
|
|
37
37
|
source?: string;
|
|
38
38
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injected script for detecting frontend frameworks (Vue, React, Next, Nuxt, etc.)
|
|
3
|
+
*/
|
|
4
|
+
export function detectFramework() {
|
|
5
|
+
const r: Record<string, boolean> = {};
|
|
6
|
+
try {
|
|
7
|
+
const app = document.querySelector('#app') as any;
|
|
8
|
+
r.vue3 = !!(app && app.__vue_app__);
|
|
9
|
+
r.vue2 = !!(app && app.__vue__);
|
|
10
|
+
r.react = !!(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ || !!document.querySelector('[data-reactroot]');
|
|
11
|
+
r.nextjs = !!(window as any).__NEXT_DATA__;
|
|
12
|
+
r.nuxt = !!(window as any).__NUXT__;
|
|
13
|
+
if (r.vue3 && app.__vue_app__) {
|
|
14
|
+
const gp = app.__vue_app__.config?.globalProperties;
|
|
15
|
+
r.pinia = !!(gp && gp.$pinia);
|
|
16
|
+
r.vuex = !!(gp && gp.$store);
|
|
17
|
+
}
|
|
18
|
+
} catch {}
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injected script for interactive fuzzing (clicking elements to trigger lazy loading)
|
|
3
|
+
*/
|
|
4
|
+
export async function interactFuzz() {
|
|
5
|
+
const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
|
|
6
|
+
const clickables = Array.from(document.querySelectorAll(
|
|
7
|
+
'button, [role="button"], [role="tab"], .tab, .btn, a[href="javascript:void(0)"], a[href="#"]'
|
|
8
|
+
)).slice(0, 15); // limit to a small number to avoid endless loops
|
|
9
|
+
|
|
10
|
+
let clicked = 0;
|
|
11
|
+
for (const el of clickables) {
|
|
12
|
+
try {
|
|
13
|
+
const rect = el.getBoundingClientRect();
|
|
14
|
+
if (rect.width > 0 && rect.height > 0) {
|
|
15
|
+
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
|
|
16
|
+
clicked++;
|
|
17
|
+
await sleep(300); // give it time to trigger network
|
|
18
|
+
}
|
|
19
|
+
} catch {}
|
|
20
|
+
}
|
|
21
|
+
return clicked;
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injected script for discovering Pinia or Vuex stores and their actions/state representations
|
|
3
|
+
*/
|
|
4
|
+
export function discoverStores() {
|
|
5
|
+
const stores: Array<{ type: string; id: string; actions: string[]; stateKeys: string[] }> = [];
|
|
6
|
+
try {
|
|
7
|
+
const app = document.querySelector('#app') as any;
|
|
8
|
+
if (!app?.__vue_app__) return stores;
|
|
9
|
+
const gp = app.__vue_app__.config?.globalProperties;
|
|
10
|
+
|
|
11
|
+
// Pinia stores
|
|
12
|
+
const pinia = gp?.$pinia;
|
|
13
|
+
if (pinia?._s) {
|
|
14
|
+
pinia._s.forEach((store: any, id: string) => {
|
|
15
|
+
const actions: string[] = [];
|
|
16
|
+
const stateKeys: string[] = [];
|
|
17
|
+
for (const k in store) {
|
|
18
|
+
try {
|
|
19
|
+
if (k.startsWith('$') || k.startsWith('_')) continue;
|
|
20
|
+
if (typeof store[k] === 'function') actions.push(k);
|
|
21
|
+
else stateKeys.push(k);
|
|
22
|
+
} catch {}
|
|
23
|
+
}
|
|
24
|
+
stores.push({ type: 'pinia', id, actions: actions.slice(0, 20), stateKeys: stateKeys.slice(0, 15) });
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Vuex store modules
|
|
29
|
+
const vuex = gp?.$store;
|
|
30
|
+
if (vuex?._modules?.root?._children) {
|
|
31
|
+
const children = vuex._modules.root._children;
|
|
32
|
+
for (const [modName, mod] of Object.entries<any>(children)) {
|
|
33
|
+
const actions = Object.keys(mod._rawModule?.actions ?? {}).slice(0, 20);
|
|
34
|
+
const stateKeys = Object.keys(mod.state ?? {}).slice(0, 15);
|
|
35
|
+
stores.push({ type: 'vuex', id: modName, actions, stateKeys });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch {}
|
|
39
|
+
return stores;
|
|
40
|
+
}
|
package/src/synthesize.ts
CHANGED
|
@@ -116,7 +116,7 @@ function buildEvaluateScript(url: string, itemPath: string, endpoint: any): stri
|
|
|
116
116
|
|
|
117
117
|
return [
|
|
118
118
|
'(async () => {',
|
|
119
|
-
` const res = await fetch(
|
|
119
|
+
` const res = await fetch(${JSON.stringify(url)}, {`,
|
|
120
120
|
` credentials: 'include'`,
|
|
121
121
|
' });',
|
|
122
122
|
' const data = await res.json();',
|