@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.
- package/CLI-CREATOR.md +594 -0
- package/README.md +116 -38
- package/README.zh-CN.md +143 -0
- package/SKILL.md +154 -102
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +35 -1
- package/dist/cascade.d.ts +45 -0
- package/dist/cascade.js +180 -0
- package/dist/clis/bilibili/hot.yaml +38 -0
- package/dist/clis/github/trending.yaml +58 -0
- package/dist/clis/hackernews/top.yaml +36 -0
- package/dist/clis/index.d.ts +2 -1
- package/dist/clis/index.js +3 -1
- package/dist/clis/reddit/hot.yaml +46 -0
- package/dist/clis/twitter/trending.yaml +40 -0
- package/dist/clis/v2ex/hot.yaml +25 -0
- package/dist/clis/v2ex/latest.yaml +25 -0
- package/dist/clis/v2ex/topic.yaml +27 -0
- package/dist/clis/xiaohongshu/feed.yaml +32 -0
- package/dist/clis/xiaohongshu/notifications.yaml +38 -0
- package/dist/clis/xiaohongshu/search.d.ts +5 -0
- package/dist/clis/xiaohongshu/search.js +68 -0
- package/dist/clis/zhihu/hot.yaml +42 -0
- package/dist/clis/zhihu/question.js +39 -0
- package/dist/clis/zhihu/search.yaml +55 -0
- package/dist/explore.d.ts +23 -13
- package/dist/explore.js +293 -422
- package/dist/main.js +17 -0
- package/dist/pipeline.js +238 -2
- package/dist/synthesize.d.ts +11 -8
- package/dist/synthesize.js +142 -118
- package/package.json +4 -2
- package/src/browser.ts +33 -1
- package/src/cascade.ts +217 -0
- package/src/clis/index.ts +4 -1
- package/src/clis/reddit/hot.yaml +46 -0
- package/src/clis/v2ex/hot.yaml +5 -9
- package/src/clis/v2ex/latest.yaml +5 -8
- package/src/clis/v2ex/topic.yaml +27 -0
- package/src/clis/xiaohongshu/feed.yaml +32 -0
- package/src/clis/xiaohongshu/notifications.yaml +38 -0
- package/src/clis/xiaohongshu/search.ts +71 -0
- package/src/clis/zhihu/hot.yaml +22 -8
- package/src/clis/zhihu/question.ts +45 -0
- package/src/clis/zhihu/search.yaml +55 -0
- package/src/explore.ts +303 -465
- package/src/main.ts +14 -0
- package/src/pipeline.ts +239 -2
- package/src/synthesize.ts +142 -137
- package/dist/clis/zhihu/search.js +0 -58
- package/src/clis/zhihu/search.ts +0 -65
- /package/dist/clis/zhihu/{search.d.ts → question.d.ts} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
site: zhihu
|
|
2
|
+
name: search
|
|
3
|
+
description: 知乎搜索
|
|
4
|
+
domain: www.zhihu.com
|
|
5
|
+
|
|
6
|
+
args:
|
|
7
|
+
keyword:
|
|
8
|
+
type: str
|
|
9
|
+
required: true
|
|
10
|
+
description: Search keyword
|
|
11
|
+
limit:
|
|
12
|
+
type: int
|
|
13
|
+
default: 10
|
|
14
|
+
description: Number of results
|
|
15
|
+
|
|
16
|
+
pipeline:
|
|
17
|
+
- navigate: https://www.zhihu.com
|
|
18
|
+
|
|
19
|
+
- evaluate: |
|
|
20
|
+
(async () => {
|
|
21
|
+
const strip = (html) => (html || '').replace(/<[^>]+>/g, '').replace(/ /g, ' ').replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&').replace(/<em>/g, '').replace(/<\/em>/g, '').trim();
|
|
22
|
+
const res = await fetch('https://www.zhihu.com/api/v4/search_v3?q=' + encodeURIComponent('${{ args.keyword }}') + '&t=general&offset=0&limit=${{ args.limit }}', {
|
|
23
|
+
credentials: 'include'
|
|
24
|
+
});
|
|
25
|
+
const d = await res.json();
|
|
26
|
+
return (d?.data || [])
|
|
27
|
+
.filter(item => item.type === 'search_result')
|
|
28
|
+
.map(item => {
|
|
29
|
+
const obj = item.object || {};
|
|
30
|
+
const q = obj.question || {};
|
|
31
|
+
return {
|
|
32
|
+
type: obj.type,
|
|
33
|
+
title: strip(obj.title || q.name || ''),
|
|
34
|
+
excerpt: strip(obj.excerpt || '').substring(0, 100),
|
|
35
|
+
author: obj.author?.name || '',
|
|
36
|
+
votes: obj.voteup_count || 0,
|
|
37
|
+
url: obj.type === 'answer'
|
|
38
|
+
? 'https://www.zhihu.com/question/' + q.id + '/answer/' + obj.id
|
|
39
|
+
: obj.type === 'article'
|
|
40
|
+
? 'https://zhuanlan.zhihu.com/p/' + obj.id
|
|
41
|
+
: 'https://www.zhihu.com/question/' + obj.id,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
})()
|
|
45
|
+
|
|
46
|
+
- map:
|
|
47
|
+
rank: ${{ index + 1 }}
|
|
48
|
+
title: ${{ item.title }}
|
|
49
|
+
type: ${{ item.type }}
|
|
50
|
+
author: ${{ item.author }}
|
|
51
|
+
votes: ${{ item.votes }}
|
|
52
|
+
|
|
53
|
+
- limit: ${{ args.limit }}
|
|
54
|
+
|
|
55
|
+
columns: [rank, title, type, author, votes]
|