@jackwener/opencli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +26 -0
- package/.github/workflows/release.yml +40 -0
- package/README.md +67 -0
- package/SKILL.md +230 -0
- package/dist/bilibili.d.ts +13 -0
- package/dist/bilibili.js +93 -0
- package/dist/browser.d.ts +48 -0
- package/dist/browser.js +261 -0
- package/dist/clis/bilibili/favorite.d.ts +1 -0
- package/dist/clis/bilibili/favorite.js +39 -0
- package/dist/clis/bilibili/feed.d.ts +1 -0
- package/dist/clis/bilibili/feed.js +64 -0
- package/dist/clis/bilibili/history.d.ts +1 -0
- package/dist/clis/bilibili/history.js +44 -0
- package/dist/clis/bilibili/me.d.ts +1 -0
- package/dist/clis/bilibili/me.js +13 -0
- package/dist/clis/bilibili/search.d.ts +1 -0
- package/dist/clis/bilibili/search.js +24 -0
- package/dist/clis/bilibili/user-videos.d.ts +1 -0
- package/dist/clis/bilibili/user-videos.js +38 -0
- package/dist/clis/github/search.d.ts +1 -0
- package/dist/clis/github/search.js +20 -0
- package/dist/clis/index.d.ts +13 -0
- package/dist/clis/index.js +16 -0
- package/dist/clis/zhihu/search.d.ts +1 -0
- package/dist/clis/zhihu/search.js +58 -0
- package/dist/engine.d.ts +6 -0
- package/dist/engine.js +77 -0
- package/dist/explore.d.ts +17 -0
- package/dist/explore.js +603 -0
- package/dist/generate.d.ts +11 -0
- package/dist/generate.js +134 -0
- package/dist/main.d.ts +5 -0
- package/dist/main.js +117 -0
- package/dist/output.d.ts +11 -0
- package/dist/output.js +98 -0
- package/dist/pipeline.d.ts +9 -0
- package/dist/pipeline.js +315 -0
- package/dist/promote.d.ts +1 -0
- package/dist/promote.js +3 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.js +2 -0
- package/dist/registry.d.ts +50 -0
- package/dist/registry.js +42 -0
- package/dist/runtime.d.ts +12 -0
- package/dist/runtime.js +27 -0
- package/dist/scaffold.d.ts +2 -0
- package/dist/scaffold.js +2 -0
- package/dist/smoke.d.ts +2 -0
- package/dist/smoke.js +2 -0
- package/dist/snapshotFormatter.d.ts +9 -0
- package/dist/snapshotFormatter.js +41 -0
- package/dist/synthesize.d.ts +10 -0
- package/dist/synthesize.js +191 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +73 -0
- package/dist/verify.d.ts +2 -0
- package/dist/verify.js +9 -0
- package/package.json +47 -0
- package/src/bilibili.ts +111 -0
- package/src/browser.ts +260 -0
- package/src/clis/bilibili/favorite.ts +42 -0
- package/src/clis/bilibili/feed.ts +71 -0
- package/src/clis/bilibili/history.ts +48 -0
- package/src/clis/bilibili/hot.yaml +38 -0
- package/src/clis/bilibili/me.ts +14 -0
- package/src/clis/bilibili/search.ts +25 -0
- package/src/clis/bilibili/user-videos.ts +42 -0
- package/src/clis/github/search.ts +21 -0
- package/src/clis/github/trending.yaml +58 -0
- package/src/clis/hackernews/top.yaml +36 -0
- package/src/clis/index.ts +19 -0
- package/src/clis/twitter/trending.yaml +40 -0
- package/src/clis/v2ex/hot.yaml +29 -0
- package/src/clis/v2ex/latest.yaml +28 -0
- package/src/clis/zhihu/hot.yaml +28 -0
- package/src/clis/zhihu/search.ts +65 -0
- package/src/engine.ts +86 -0
- package/src/explore.ts +648 -0
- package/src/generate.ts +145 -0
- package/src/main.ts +103 -0
- package/src/output.ts +96 -0
- package/src/pipeline.ts +295 -0
- package/src/promote.ts +3 -0
- package/src/register.ts +2 -0
- package/src/registry.ts +87 -0
- package/src/runtime.ts +36 -0
- package/src/scaffold.ts +2 -0
- package/src/smoke.ts +2 -0
- package/src/snapshotFormatter.ts +51 -0
- package/src/synthesize.ts +210 -0
- package/src/validate.ts +55 -0
- package/src/verify.ts +9 -0
- package/tsconfig.json +17 -0
package/dist/engine.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI discovery: finds YAML/TS CLI definitions and registers them.
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import yaml from 'js-yaml';
|
|
7
|
+
import { Strategy, registerCommand } from './registry.js';
|
|
8
|
+
import { executePipeline } from './pipeline.js';
|
|
9
|
+
export function discoverClis(...dirs) {
|
|
10
|
+
for (const dir of dirs) {
|
|
11
|
+
if (!fs.existsSync(dir))
|
|
12
|
+
continue;
|
|
13
|
+
for (const site of fs.readdirSync(dir)) {
|
|
14
|
+
const siteDir = path.join(dir, site);
|
|
15
|
+
if (!fs.statSync(siteDir).isDirectory())
|
|
16
|
+
continue;
|
|
17
|
+
for (const file of fs.readdirSync(siteDir)) {
|
|
18
|
+
const filePath = path.join(siteDir, file);
|
|
19
|
+
if (file.endsWith('.yaml') || file.endsWith('.yml')) {
|
|
20
|
+
registerYamlCli(filePath, site);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function registerYamlCli(filePath, defaultSite) {
|
|
27
|
+
try {
|
|
28
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
29
|
+
const def = yaml.load(raw);
|
|
30
|
+
if (!def || typeof def !== 'object')
|
|
31
|
+
return;
|
|
32
|
+
const site = def.site ?? defaultSite;
|
|
33
|
+
const name = def.name ?? path.basename(filePath, path.extname(filePath));
|
|
34
|
+
const strategyStr = def.strategy ?? (def.browser === false ? 'public' : 'cookie');
|
|
35
|
+
const strategy = Strategy[strategyStr.toUpperCase()] ?? Strategy.COOKIE;
|
|
36
|
+
const browser = def.browser ?? (strategy !== Strategy.PUBLIC);
|
|
37
|
+
const args = [];
|
|
38
|
+
if (def.args && typeof def.args === 'object') {
|
|
39
|
+
for (const [argName, argDef] of Object.entries(def.args)) {
|
|
40
|
+
args.push({
|
|
41
|
+
name: argName,
|
|
42
|
+
type: argDef?.type ?? 'str',
|
|
43
|
+
default: argDef?.default,
|
|
44
|
+
required: argDef?.required ?? false,
|
|
45
|
+
help: argDef?.description ?? argDef?.help ?? '',
|
|
46
|
+
choices: argDef?.choices,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const cmd = {
|
|
51
|
+
site,
|
|
52
|
+
name,
|
|
53
|
+
description: def.description ?? '',
|
|
54
|
+
domain: def.domain,
|
|
55
|
+
strategy,
|
|
56
|
+
browser,
|
|
57
|
+
args,
|
|
58
|
+
columns: def.columns,
|
|
59
|
+
pipeline: def.pipeline,
|
|
60
|
+
timeoutSeconds: def.timeout,
|
|
61
|
+
source: filePath,
|
|
62
|
+
};
|
|
63
|
+
registerCommand(cmd);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
process.stderr.write(`Warning: failed to load ${filePath}: ${err.message}\n`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export async function executeCommand(cmd, page, kwargs, debug = false) {
|
|
70
|
+
if (cmd.func) {
|
|
71
|
+
return cmd.func(page, kwargs, debug);
|
|
72
|
+
}
|
|
73
|
+
if (cmd.pipeline) {
|
|
74
|
+
return executePipeline(page, cmd.pipeline, { args: kwargs, debug });
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`Command ${cmd.site}/${cmd.name} has no func or pipeline`);
|
|
77
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Explore: intelligent API discovery with response analysis.
|
|
3
|
+
*
|
|
4
|
+
* Unlike simple page snapshots, Deep Explore intercepts network traffic,
|
|
5
|
+
* analyzes response schemas, and automatically infers capabilities that
|
|
6
|
+
* can be turned into CLI commands.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. Navigate to target URL
|
|
10
|
+
* 2. Auto-scroll to trigger lazy loading
|
|
11
|
+
* 3. Capture network requests (with body analysis)
|
|
12
|
+
* 4. For each JSON response: detect list fields, infer columns, analyze auth
|
|
13
|
+
* 5. Detect frontend framework (Vue/React/Pinia/Next.js)
|
|
14
|
+
* 6. Generate structured capabilities.json
|
|
15
|
+
*/
|
|
16
|
+
export declare function exploreUrl(url: string, opts?: any): Promise<any>;
|
|
17
|
+
export declare function renderExploreSummary(result: any): string;
|