@jackwener/opencli 1.7.4 → 1.7.6

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 (181) hide show
  1. package/README.md +76 -51
  2. package/README.zh-CN.md +78 -62
  3. package/cli-manifest.json +4558 -2979
  4. package/clis/antigravity/serve.js +71 -25
  5. package/clis/baidu-scholar/search.js +87 -0
  6. package/clis/baidu-scholar/search.test.js +23 -0
  7. package/clis/bilibili/video.js +61 -0
  8. package/clis/bilibili/video.test.js +81 -0
  9. package/clis/deepseek/ask.js +94 -0
  10. package/clis/deepseek/ask.test.js +73 -0
  11. package/clis/deepseek/history.js +25 -0
  12. package/clis/deepseek/new.js +20 -0
  13. package/clis/deepseek/read.js +22 -0
  14. package/clis/deepseek/status.js +24 -0
  15. package/clis/deepseek/utils.js +291 -0
  16. package/clis/deepseek/utils.test.js +37 -0
  17. package/clis/eastmoney/_secid.js +78 -0
  18. package/clis/eastmoney/announcement.js +52 -0
  19. package/clis/eastmoney/convertible.js +73 -0
  20. package/clis/eastmoney/etf.js +65 -0
  21. package/clis/eastmoney/holders.js +78 -0
  22. package/clis/eastmoney/index-board.js +96 -0
  23. package/clis/eastmoney/kline.js +87 -0
  24. package/clis/eastmoney/kuaixun.js +54 -0
  25. package/clis/eastmoney/longhu.js +67 -0
  26. package/clis/eastmoney/money-flow.js +78 -0
  27. package/clis/eastmoney/northbound.js +57 -0
  28. package/clis/eastmoney/quote.js +107 -0
  29. package/clis/eastmoney/rank.js +94 -0
  30. package/clis/eastmoney/sectors.js +76 -0
  31. package/clis/google-scholar/search.js +58 -0
  32. package/clis/google-scholar/search.test.js +23 -0
  33. package/clis/gov-law/commands.test.js +39 -0
  34. package/clis/gov-law/recent.js +22 -0
  35. package/clis/gov-law/search.js +41 -0
  36. package/clis/gov-law/shared.js +51 -0
  37. package/clis/gov-policy/commands.test.js +27 -0
  38. package/clis/gov-policy/recent.js +47 -0
  39. package/clis/gov-policy/search.js +48 -0
  40. package/clis/jianyu/search.js +139 -3
  41. package/clis/jianyu/search.test.js +25 -0
  42. package/clis/jianyu/shared/procurement-detail.js +15 -0
  43. package/clis/jianyu/shared/procurement-detail.test.js +12 -0
  44. package/clis/nowcoder/companies.js +23 -0
  45. package/clis/nowcoder/creators.js +27 -0
  46. package/clis/nowcoder/detail.js +61 -0
  47. package/clis/nowcoder/experience.js +36 -0
  48. package/clis/nowcoder/hot.js +24 -0
  49. package/clis/nowcoder/jobs.js +21 -0
  50. package/clis/nowcoder/notifications.js +29 -0
  51. package/clis/nowcoder/papers.js +40 -0
  52. package/clis/nowcoder/practice.js +37 -0
  53. package/clis/nowcoder/recommend.js +30 -0
  54. package/clis/nowcoder/referral.js +39 -0
  55. package/clis/nowcoder/salary.js +40 -0
  56. package/clis/nowcoder/search.js +49 -0
  57. package/clis/nowcoder/suggest.js +33 -0
  58. package/clis/nowcoder/topics.js +27 -0
  59. package/clis/nowcoder/trending.js +25 -0
  60. package/clis/twitter/list-add.js +337 -0
  61. package/clis/twitter/list-add.test.js +15 -0
  62. package/clis/twitter/list-remove.js +297 -0
  63. package/clis/twitter/list-remove.test.js +14 -0
  64. package/clis/twitter/list-tweets.js +185 -0
  65. package/clis/twitter/list-tweets.test.js +108 -0
  66. package/clis/twitter/lists.js +134 -47
  67. package/clis/twitter/lists.test.js +105 -38
  68. package/clis/twitter/shared.js +7 -2
  69. package/clis/twitter/tweets.js +218 -0
  70. package/clis/twitter/tweets.test.js +125 -0
  71. package/clis/wanfang/search.js +66 -0
  72. package/clis/wanfang/search.test.js +23 -0
  73. package/clis/web/read.js +1 -1
  74. package/clis/weixin/download.js +3 -2
  75. package/clis/xiaohongshu/publish.js +149 -28
  76. package/clis/xiaohongshu/publish.test.js +319 -6
  77. package/clis/xiaoyuzhou/download.js +8 -4
  78. package/clis/xiaoyuzhou/download.test.js +23 -13
  79. package/clis/xiaoyuzhou/episode.js +9 -4
  80. package/clis/xiaoyuzhou/podcast-episodes.js +15 -11
  81. package/clis/xiaoyuzhou/podcast.js +9 -4
  82. package/clis/xiaoyuzhou/utils.js +0 -40
  83. package/clis/xiaoyuzhou/utils.test.js +15 -75
  84. package/clis/youtube/channel.js +35 -0
  85. package/clis/zsxq/dynamics.js +1 -1
  86. package/clis/zsxq/utils.js +6 -3
  87. package/clis/zsxq/utils.test.js +31 -0
  88. package/dist/src/browser/base-page.d.ts +14 -4
  89. package/dist/src/browser/base-page.js +35 -25
  90. package/dist/src/browser/bridge.d.ts +1 -0
  91. package/dist/src/browser/bridge.js +1 -1
  92. package/dist/src/browser/cdp.d.ts +1 -0
  93. package/dist/src/browser/cdp.js +13 -4
  94. package/dist/src/browser/compound.d.ts +59 -0
  95. package/dist/src/browser/compound.js +112 -0
  96. package/dist/src/browser/compound.test.js +175 -0
  97. package/dist/src/browser/daemon-client.d.ts +6 -4
  98. package/dist/src/browser/daemon-client.js +6 -1
  99. package/dist/src/browser/daemon-client.test.js +40 -1
  100. package/dist/src/browser/dom-snapshot.d.ts +7 -0
  101. package/dist/src/browser/dom-snapshot.js +83 -5
  102. package/dist/src/browser/dom-snapshot.test.js +65 -0
  103. package/dist/src/browser/extract.d.ts +69 -0
  104. package/dist/src/browser/extract.js +132 -0
  105. package/dist/src/browser/extract.test.js +129 -0
  106. package/dist/src/browser/find.d.ts +76 -0
  107. package/dist/src/browser/find.js +179 -0
  108. package/dist/src/browser/find.test.js +120 -0
  109. package/dist/src/browser/html-tree.d.ts +75 -0
  110. package/dist/src/browser/html-tree.js +112 -0
  111. package/dist/src/browser/html-tree.test.d.ts +1 -0
  112. package/dist/src/browser/html-tree.test.js +181 -0
  113. package/dist/src/browser/network-cache.d.ts +48 -0
  114. package/dist/src/browser/network-cache.js +66 -0
  115. package/dist/src/browser/network-cache.test.d.ts +1 -0
  116. package/dist/src/browser/network-cache.test.js +58 -0
  117. package/dist/src/browser/network-key.d.ts +22 -0
  118. package/dist/src/browser/network-key.js +66 -0
  119. package/dist/src/browser/network-key.test.d.ts +1 -0
  120. package/dist/src/browser/network-key.test.js +49 -0
  121. package/dist/src/browser/page.d.ts +14 -4
  122. package/dist/src/browser/page.js +48 -7
  123. package/dist/src/browser/page.test.js +97 -0
  124. package/dist/src/browser/shape-filter.d.ts +52 -0
  125. package/dist/src/browser/shape-filter.js +101 -0
  126. package/dist/src/browser/shape-filter.test.d.ts +1 -0
  127. package/dist/src/browser/shape-filter.test.js +101 -0
  128. package/dist/src/browser/shape.d.ts +23 -0
  129. package/dist/src/browser/shape.js +95 -0
  130. package/dist/src/browser/shape.test.d.ts +1 -0
  131. package/dist/src/browser/shape.test.js +82 -0
  132. package/dist/src/browser/target-errors.d.ts +14 -1
  133. package/dist/src/browser/target-errors.js +13 -0
  134. package/dist/src/browser/target-errors.test.js +39 -6
  135. package/dist/src/browser/target-resolver.d.ts +57 -10
  136. package/dist/src/browser/target-resolver.js +195 -75
  137. package/dist/src/browser/target-resolver.test.js +80 -5
  138. package/dist/src/cli.js +849 -267
  139. package/dist/src/cli.test.js +961 -90
  140. package/dist/src/commanderAdapter.d.ts +0 -1
  141. package/dist/src/commanderAdapter.js +2 -16
  142. package/dist/src/commanderAdapter.test.js +1 -1
  143. package/dist/src/completion-shared.js +2 -5
  144. package/dist/src/daemon.js +8 -0
  145. package/dist/src/download/article-download.d.ts +1 -0
  146. package/dist/src/download/article-download.js +3 -0
  147. package/dist/src/download/article-download.test.d.ts +1 -0
  148. package/dist/src/download/article-download.test.js +39 -0
  149. package/dist/src/execution.js +7 -2
  150. package/dist/src/execution.test.js +54 -0
  151. package/dist/src/main.js +16 -0
  152. package/dist/src/plugin.d.ts +1 -8
  153. package/dist/src/plugin.js +1 -27
  154. package/dist/src/plugin.test.js +1 -59
  155. package/dist/src/registry.d.ts +1 -0
  156. package/dist/src/registry.js +3 -2
  157. package/dist/src/registry.test.js +22 -0
  158. package/dist/src/types.d.ts +32 -8
  159. package/package.json +1 -1
  160. package/clis/twitter/lists-parser.js +0 -77
  161. package/clis/twitter/lists.d.ts +0 -5
  162. package/dist/src/cascade.d.ts +0 -46
  163. package/dist/src/cascade.js +0 -135
  164. package/dist/src/explore.d.ts +0 -99
  165. package/dist/src/explore.js +0 -402
  166. package/dist/src/generate-verified.d.ts +0 -105
  167. package/dist/src/generate-verified.js +0 -696
  168. package/dist/src/generate-verified.test.js +0 -925
  169. package/dist/src/generate.d.ts +0 -46
  170. package/dist/src/generate.js +0 -117
  171. package/dist/src/record.d.ts +0 -96
  172. package/dist/src/record.js +0 -657
  173. package/dist/src/record.test.js +0 -293
  174. package/dist/src/skill-generate.d.ts +0 -30
  175. package/dist/src/skill-generate.js +0 -75
  176. package/dist/src/skill-generate.test.js +0 -173
  177. package/dist/src/synthesize.d.ts +0 -97
  178. package/dist/src/synthesize.js +0 -208
  179. /package/dist/src/{generate-verified.test.d.ts → browser/compound.test.d.ts} +0 -0
  180. /package/dist/src/{record.test.d.ts → browser/extract.test.d.ts} +0 -0
  181. /package/dist/src/{skill-generate.test.d.ts → browser/find.test.d.ts} +0 -0
@@ -1,46 +0,0 @@
1
- /**
2
- * Generate: one-shot CLI creation from URL.
3
- *
4
- * Orchestrates the pipeline:
5
- * explore (Deep Explore) → synthesize (YAML generation + candidate ranking)
6
- */
7
- import type { IBrowserFactory } from './runtime.js';
8
- import { type SynthesizeCandidateSummary, type SynthesizeResult } from './synthesize.js';
9
- export interface GenerateCliOptions {
10
- url: string;
11
- BrowserFactory: new () => IBrowserFactory;
12
- goal?: string | null;
13
- site?: string;
14
- waitSeconds?: number;
15
- top?: number;
16
- workspace?: string;
17
- }
18
- export interface GenerateCliResult {
19
- ok: boolean;
20
- goal?: string | null;
21
- normalized_goal?: string | null;
22
- site: string;
23
- selected_candidate: SynthesizeCandidateSummary | null;
24
- selected_command: string;
25
- explore: {
26
- endpoint_count: number;
27
- api_endpoint_count: number;
28
- capability_count: number;
29
- top_strategy: string;
30
- framework: Record<string, boolean>;
31
- };
32
- synthesize: {
33
- candidate_count: number;
34
- candidates: Array<Pick<SynthesizeCandidateSummary, 'name' | 'strategy'>>;
35
- };
36
- }
37
- /**
38
- * Normalize a goal string to a standard capability name.
39
- */
40
- export declare function normalizeGoal(goal?: string | null): string | null;
41
- /**
42
- * Select the best candidate matching the user's goal.
43
- */
44
- export declare function selectCandidate(candidates: SynthesizeResult['candidates'], goal?: string | null): SynthesizeCandidateSummary | null;
45
- export declare function generateCliFromUrl(opts: GenerateCliOptions): Promise<GenerateCliResult>;
46
- export declare function renderGenerateSummary(r: GenerateCliResult): string;
@@ -1,117 +0,0 @@
1
- /**
2
- * Generate: one-shot CLI creation from URL.
3
- *
4
- * Orchestrates the pipeline:
5
- * explore (Deep Explore) → synthesize (YAML generation + candidate ranking)
6
- */
7
- import { exploreUrl } from './explore.js';
8
- import { synthesizeFromExplore } from './synthesize.js';
9
- const CAPABILITY_ALIASES = {
10
- search: ['search', '搜索', '查找', 'query', 'keyword'],
11
- hot: ['hot', '热门', '热榜', '热搜', 'popular', 'top', 'ranking'],
12
- trending: ['trending', '趋势', '流行', 'discover'],
13
- feed: ['feed', '动态', '关注', '时间线', 'timeline', 'following'],
14
- me: ['profile', 'me', '个人信息', 'myinfo', '账号'],
15
- detail: ['detail', '详情', 'video', 'article', 'view'],
16
- comments: ['comments', '评论', '回复', 'reply'],
17
- history: ['history', '历史', '记录'],
18
- favorite: ['favorite', '收藏', 'bookmark', 'collect'],
19
- };
20
- /**
21
- * Normalize a goal string to a standard capability name.
22
- */
23
- export function normalizeGoal(goal) {
24
- if (!goal)
25
- return null;
26
- const lower = goal.trim().toLowerCase();
27
- for (const [cap, aliases] of Object.entries(CAPABILITY_ALIASES)) {
28
- if (lower === cap || aliases.some(a => lower.includes(a.toLowerCase())))
29
- return cap;
30
- }
31
- return null;
32
- }
33
- /**
34
- * Select the best candidate matching the user's goal.
35
- */
36
- export function selectCandidate(candidates, goal) {
37
- if (!candidates.length)
38
- return null;
39
- if (!goal)
40
- return candidates[0];
41
- const normalized = normalizeGoal(goal);
42
- if (normalized) {
43
- const exact = candidates.find(c => c.name === normalized);
44
- if (exact)
45
- return exact;
46
- }
47
- const lower = (goal ?? '').trim().toLowerCase();
48
- const partial = candidates.find(c => {
49
- const cName = c.name?.toLowerCase() ?? '';
50
- return cName.includes(lower) || lower.includes(cName);
51
- });
52
- return partial ?? candidates[0];
53
- }
54
- export async function generateCliFromUrl(opts) {
55
- // Step 1: Deep Explore
56
- const exploreResult = await exploreUrl(opts.url, {
57
- BrowserFactory: opts.BrowserFactory,
58
- site: opts.site,
59
- goal: normalizeGoal(opts.goal) ?? opts.goal ?? undefined,
60
- waitSeconds: opts.waitSeconds ?? 3,
61
- workspace: opts.workspace,
62
- });
63
- // Step 2: Synthesize candidates
64
- const synthesizeResult = synthesizeFromExplore(exploreResult.out_dir, {
65
- top: opts.top ?? 5,
66
- });
67
- // Step 3: Select best candidate for goal
68
- const selected = selectCandidate(synthesizeResult.candidates ?? [], opts.goal);
69
- const selectedSite = synthesizeResult.site ?? exploreResult.site;
70
- const ok = exploreResult.endpoint_count > 0 && synthesizeResult.candidate_count > 0;
71
- return {
72
- ok,
73
- goal: opts.goal,
74
- normalized_goal: normalizeGoal(opts.goal),
75
- site: selectedSite,
76
- selected_candidate: selected,
77
- selected_command: selected ? `${selectedSite}/${selected.name}` : '(none)',
78
- explore: {
79
- endpoint_count: exploreResult.endpoint_count,
80
- api_endpoint_count: exploreResult.api_endpoint_count,
81
- capability_count: exploreResult.capabilities?.length ?? 0,
82
- top_strategy: exploreResult.top_strategy,
83
- framework: exploreResult.framework,
84
- },
85
- synthesize: {
86
- candidate_count: synthesizeResult.candidate_count,
87
- candidates: (synthesizeResult.candidates ?? []).map((c) => ({
88
- name: c.name,
89
- strategy: c.strategy,
90
- })),
91
- },
92
- };
93
- }
94
- export function renderGenerateSummary(r) {
95
- const lines = [
96
- `opencli generate: ${r.ok ? 'OK' : 'FAIL'}`,
97
- `Site: ${r.site}`,
98
- `Goal: ${r.goal ?? '(auto)'}`,
99
- `Selected: ${r.selected_command}`,
100
- '',
101
- `Explore:`,
102
- ` Endpoints: ${r.explore?.endpoint_count ?? 0} total, ${r.explore?.api_endpoint_count ?? 0} API`,
103
- ` Capabilities: ${r.explore?.capability_count ?? 0}`,
104
- ` Strategy: ${r.explore?.top_strategy ?? 'unknown'}`,
105
- '',
106
- `Synthesize:`,
107
- ` Candidates: ${r.synthesize?.candidate_count ?? 0}`,
108
- ];
109
- for (const c of r.synthesize?.candidates ?? []) {
110
- lines.push(` • ${c.name} (${c.strategy})`);
111
- }
112
- const fw = r.explore?.framework ?? {};
113
- const fwNames = Object.entries(fw).filter(([, v]) => v).map(([k]) => k);
114
- if (fwNames.length)
115
- lines.push(`Framework: ${fwNames.join(', ')}`);
116
- return lines.join('\n');
117
- }
@@ -1,96 +0,0 @@
1
- /**
2
- * Record mode — capture API calls from a live browser session.
3
- *
4
- * Flow:
5
- * 1. Navigate to the target URL in an automation tab
6
- * 2. Inject a full-capture fetch/XHR interceptor (records url + method + body)
7
- * 3. Poll every 2s and print newly captured requests
8
- * 4. User operates the page; press Enter to stop
9
- * 5. Analyze captured requests → infer capabilities → write YAML candidates
10
- *
11
- * Design: no new daemon endpoints, no extension changes.
12
- * Uses existing exec + navigate actions only.
13
- */
14
- import type { IPage } from './types.js';
15
- import { findArrayPath } from './analysis.js';
16
- export interface RecordedRequest {
17
- url: string;
18
- method: string;
19
- status: number | null;
20
- /** Request content type captured at record time, if available. */
21
- requestContentType: string | null;
22
- /** Response content type captured at record time, if available. */
23
- responseContentType: string | null;
24
- /** Parsed JSON request body for replayable write requests. */
25
- requestBody: unknown;
26
- /** Parsed JSON response body captured from the network call. */
27
- responseBody: unknown;
28
- contentType: string;
29
- body: unknown;
30
- capturedAt: number;
31
- }
32
- export interface RecordResult {
33
- site: string;
34
- url: string;
35
- requests: RecordedRequest[];
36
- outDir: string;
37
- candidateCount: number;
38
- candidates: Array<{
39
- name: string;
40
- path: string;
41
- strategy: string;
42
- }>;
43
- }
44
- type RecordedCandidateKind = 'read' | 'write';
45
- export interface RecordedCandidate {
46
- kind: RecordedCandidateKind;
47
- req: RecordedRequest;
48
- arrayResult: ReturnType<typeof findArrayPath> | null;
49
- }
50
- interface GeneratedRecordedCandidate {
51
- kind: RecordedCandidateKind;
52
- name: string;
53
- strategy: string;
54
- yaml: unknown;
55
- }
56
- /** Build one normalized recorded entry from captured request and response values. */
57
- export declare function createRecordedEntry(input: {
58
- url: string;
59
- method: string;
60
- requestContentType?: string | null;
61
- requestBodyText?: string | null;
62
- responseBody: unknown;
63
- responseContentType?: string | null;
64
- status?: number | null;
65
- capturedAt?: number;
66
- }): RecordedRequest;
67
- /**
68
- * Generates a full-capture interceptor that stores {url, method, status, body}
69
- * for every JSON response. No URL pattern filter — captures everything.
70
- */
71
- export declare function generateFullCaptureInterceptorJs(): string;
72
- /** Analyze recorded requests into read and write candidates, filtering out noise. */
73
- export declare function analyzeRecordedRequests(requests: RecordedRequest[]): {
74
- candidates: RecordedCandidate[];
75
- };
76
- /** Build a minimal YAML candidate for replayable JSON write requests. */
77
- export declare function buildWriteRecordedYaml(site: string, pageUrl: string, req: RecordedRequest, capName: string): {
78
- name: string;
79
- yaml: unknown;
80
- };
81
- /** Turn recorded requests into YAML-ready read and write candidates. */
82
- export declare function generateRecordedCandidates(site: string, pageUrl: string, requests: RecordedRequest[]): GeneratedRecordedCandidate[];
83
- export interface RecordOptions {
84
- BrowserFactory: new () => {
85
- connect(o?: unknown): Promise<IPage>;
86
- close(): Promise<void>;
87
- };
88
- site?: string;
89
- url: string;
90
- outDir?: string;
91
- pollMs?: number;
92
- timeoutMs?: number;
93
- }
94
- export declare function recordSession(opts: RecordOptions): Promise<RecordResult>;
95
- export declare function renderRecordSummary(result: RecordResult): string;
96
- export {};