@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
@@ -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(/&nbsp;/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/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]