@jackwener/opencli 0.1.0 → 0.1.1

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 (52) hide show
  1. package/CLI-CREATOR.md +594 -0
  2. package/README.md +116 -38
  3. package/README.zh-CN.md +143 -0
  4. package/SKILL.md +154 -102
  5. package/dist/browser.d.ts +1 -0
  6. package/dist/browser.js +35 -1
  7. package/dist/cascade.d.ts +45 -0
  8. package/dist/cascade.js +180 -0
  9. package/dist/clis/bilibili/hot.yaml +38 -0
  10. package/dist/clis/github/trending.yaml +58 -0
  11. package/dist/clis/hackernews/top.yaml +36 -0
  12. package/dist/clis/index.d.ts +2 -1
  13. package/dist/clis/index.js +3 -1
  14. package/dist/clis/reddit/hot.yaml +46 -0
  15. package/dist/clis/twitter/trending.yaml +40 -0
  16. package/dist/clis/v2ex/hot.yaml +25 -0
  17. package/dist/clis/v2ex/latest.yaml +25 -0
  18. package/dist/clis/v2ex/topic.yaml +27 -0
  19. package/dist/clis/xiaohongshu/feed.yaml +32 -0
  20. package/dist/clis/xiaohongshu/notifications.yaml +38 -0
  21. package/dist/clis/xiaohongshu/search.d.ts +5 -0
  22. package/dist/clis/xiaohongshu/search.js +68 -0
  23. package/dist/clis/zhihu/hot.yaml +42 -0
  24. package/dist/clis/zhihu/question.js +39 -0
  25. package/dist/clis/zhihu/search.yaml +55 -0
  26. package/dist/explore.d.ts +23 -13
  27. package/dist/explore.js +293 -422
  28. package/dist/main.js +17 -0
  29. package/dist/pipeline.js +238 -2
  30. package/dist/synthesize.d.ts +11 -8
  31. package/dist/synthesize.js +142 -118
  32. package/package.json +4 -2
  33. package/src/browser.ts +33 -1
  34. package/src/cascade.ts +217 -0
  35. package/src/clis/index.ts +4 -1
  36. package/src/clis/reddit/hot.yaml +46 -0
  37. package/src/clis/v2ex/hot.yaml +5 -9
  38. package/src/clis/v2ex/latest.yaml +5 -8
  39. package/src/clis/v2ex/topic.yaml +27 -0
  40. package/src/clis/xiaohongshu/feed.yaml +32 -0
  41. package/src/clis/xiaohongshu/notifications.yaml +38 -0
  42. package/src/clis/xiaohongshu/search.ts +71 -0
  43. package/src/clis/zhihu/hot.yaml +22 -8
  44. package/src/clis/zhihu/question.ts +45 -0
  45. package/src/clis/zhihu/search.yaml +55 -0
  46. package/src/explore.ts +303 -465
  47. package/src/main.ts +14 -0
  48. package/src/pipeline.ts +239 -2
  49. package/src/synthesize.ts +142 -137
  50. package/dist/clis/zhihu/search.js +0 -58
  51. package/src/clis/zhihu/search.ts +0 -65
  52. /package/dist/clis/zhihu/{search.d.ts → question.d.ts} +0 -0
@@ -1,58 +0,0 @@
1
- import { cli, Strategy } from '../../registry.js';
2
- import { fetchJson } from '../../bilibili.js';
3
- cli({
4
- site: 'zhihu',
5
- name: 'search',
6
- description: '搜索知乎问题和回答',
7
- domain: 'www.zhihu.com',
8
- strategy: Strategy.COOKIE,
9
- args: [
10
- { name: 'keyword', required: true, help: 'Search keyword' },
11
- { name: 'type', default: 'general', help: 'general, article, video' },
12
- { name: 'limit', type: 'int', default: 20, help: 'Number of results' },
13
- ],
14
- columns: ['rank', 'title', 'author', 'type', 'url'],
15
- func: async (page, kwargs) => {
16
- const { keyword, type = 'general', limit = 20 } = kwargs;
17
- // Navigate to zhihu to ensure cookie context
18
- await page.goto('https://www.zhihu.com');
19
- const qs = new URLSearchParams({ q: keyword, type, limit: String(limit) });
20
- const payload = await fetchJson(page, `https://www.zhihu.com/api/v4/search_v3?${qs}`);
21
- const data = payload?.data ?? [];
22
- const rows = [];
23
- for (let i = 0; i < Math.min(data.length, Number(limit)); i++) {
24
- const item = data[i];
25
- const obj = item.object ?? item;
26
- const itemType = item.type ?? obj.type ?? 'unknown';
27
- let title = '';
28
- let author = '';
29
- let url = '';
30
- if (itemType === 'search_result') {
31
- const highlight = obj.highlight ?? {};
32
- title = (highlight.title ?? obj.title ?? '').replace(/<[^>]+>/g, '');
33
- author = obj.author?.name ?? '';
34
- url = obj.url ?? '';
35
- }
36
- else if (obj.question) {
37
- title = (obj.question.title ?? obj.title ?? '').replace(/<[^>]+>/g, '');
38
- author = obj.author?.name ?? '';
39
- url = obj.question.url ? `https://www.zhihu.com/question/${obj.question.id}` : '';
40
- }
41
- else {
42
- title = (obj.title ?? obj.name ?? '').replace(/<[^>]+>/g, '');
43
- author = obj.author?.name ?? '';
44
- url = obj.url ?? '';
45
- }
46
- if (!title)
47
- continue;
48
- rows.push({
49
- rank: rows.length + 1,
50
- title: title.slice(0, 60),
51
- author,
52
- type: itemType.replace('search_result', 'result'),
53
- url,
54
- });
55
- }
56
- return rows;
57
- },
58
- });
@@ -1,65 +0,0 @@
1
- import { cli, Strategy } from '../../registry.js';
2
- import { fetchJson } from '../../bilibili.js';
3
-
4
- cli({
5
- site: 'zhihu',
6
- name: 'search',
7
- description: '搜索知乎问题和回答',
8
- domain: 'www.zhihu.com',
9
- strategy: Strategy.COOKIE,
10
- args: [
11
- { name: 'keyword', required: true, help: 'Search keyword' },
12
- { name: 'type', default: 'general', help: 'general, article, video' },
13
- { name: 'limit', type: 'int', default: 20, help: 'Number of results' },
14
- ],
15
- columns: ['rank', 'title', 'author', 'type', 'url'],
16
- func: async (page, kwargs) => {
17
- const { keyword, type = 'general', limit = 20 } = kwargs;
18
-
19
- // Navigate to zhihu to ensure cookie context
20
- await page.goto('https://www.zhihu.com');
21
-
22
- const qs = new URLSearchParams({ q: keyword, type, limit: String(limit) });
23
- const payload = await fetchJson(page, `https://www.zhihu.com/api/v4/search_v3?${qs}`);
24
-
25
- const data: any[] = payload?.data ?? [];
26
- const rows: any[] = [];
27
-
28
- for (let i = 0; i < Math.min(data.length, Number(limit)); i++) {
29
- const item = data[i];
30
- const obj = item.object ?? item;
31
- const itemType = item.type ?? obj.type ?? 'unknown';
32
-
33
- let title = '';
34
- let author = '';
35
- let url = '';
36
-
37
- if (itemType === 'search_result') {
38
- const highlight = obj.highlight ?? {};
39
- title = (highlight.title ?? obj.title ?? '').replace(/<[^>]+>/g, '');
40
- author = obj.author?.name ?? '';
41
- url = obj.url ?? '';
42
- } else if (obj.question) {
43
- title = (obj.question.title ?? obj.title ?? '').replace(/<[^>]+>/g, '');
44
- author = obj.author?.name ?? '';
45
- url = obj.question.url ? `https://www.zhihu.com/question/${obj.question.id}` : '';
46
- } else {
47
- title = (obj.title ?? obj.name ?? '').replace(/<[^>]+>/g, '');
48
- author = obj.author?.name ?? '';
49
- url = obj.url ?? '';
50
- }
51
-
52
- if (!title) continue;
53
-
54
- rows.push({
55
- rank: rows.length + 1,
56
- title: title.slice(0, 60),
57
- author,
58
- type: itemType.replace('search_result', 'result'),
59
- url,
60
- });
61
- }
62
-
63
- return rows;
64
- },
65
- });
File without changes