yuanflow-cli 0.1.4 → 0.1.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.
- package/README.md +47 -0
- package/lib/skill-installer/repo-source.cjs +8 -9
- package/package.json +1 -1
- package/skills/yuanflow-skill/SKILL.md +67 -2
- package/skills/yuanflow-skill/yuanflow-cli/SKILL.md +68 -4
- package/skills/yuanflow-skill//344/275/234/345/223/201/344/270/213/350/275/275/347/273/274/345/220/210/345/267/245/345/205/267/SKILL.md +118 -0
- package/skills/yuanflow-skill//344/275/234/345/223/201/350/257/204/350/256/272/351/207/207/351/233/206/SKILL.md +169 -0
- package/skills/yuanflow-skill//344/275/234/345/223/201/350/257/246/346/203/205/350/216/267/345/217/226/345/267/245/345/205/267/SKILL.md +134 -0
- package/skills/yuanflow-skill//347/273/274/345/220/210/346/220/234/347/264/242/345/267/245/345/205/267/SKILL.md +112 -0
- package/skills/yuanflow-skill//347/273/274/345/220/210/347/224/250/346/210/267/346/220/234/347/264/242/345/267/245/345/205/267/SKILL.md +107 -0
- package/src/agent-protocol.js +6 -1
- package/src/cli.js +120 -0
- package/src/comment-collector.js +823 -0
- package/src/request.js +5 -5
- package/src/work-tool-definitions.js +569 -0
- package/src/work-tools.js +344 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 作品详情获取工具
|
|
3
|
+
description: Use when the user wants to fetch details, metadata, author info, text, stats, or media info for a single post, note, video, article, tweet, Weibo, YouTube post, Zhihu article, or social-media work through yuanflow-cli.
|
|
4
|
+
builtin_skill_version: 1.0.0
|
|
5
|
+
tags:
|
|
6
|
+
- 自媒体
|
|
7
|
+
- 作品详情
|
|
8
|
+
- 单作品解析
|
|
9
|
+
- 数据查询
|
|
10
|
+
emoji: 📄
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# 作品详情获取工具
|
|
14
|
+
|
|
15
|
+
本技能把用户的“查询单个作品详情、解析作品链接、获取作品元数据”需求稳定映射到 `yuanflow-cli works detail`。在 YuanFlow 主程序内,优先调用受控工具 `yuanflow_cli_call`;它会由主程序认证系统注入 `YUANCHUANG_API_TOKEN`,不要让用户粘贴 KEY,不要在回复、日志或文件里暴露 token。
|
|
16
|
+
|
|
17
|
+
## 什么时候使用
|
|
18
|
+
|
|
19
|
+
用户出现以下意图时使用:
|
|
20
|
+
|
|
21
|
+
- 查询单个作品、视频、笔记、文章、帖子、推文、微博、知乎文章的详情。
|
|
22
|
+
- 用户给出作品链接、分享链接、BV 号、视频 ID、帖子 ID、文章 ID。
|
|
23
|
+
- 用户要标题、正文、作者、发布时间、互动统计、封面、媒体信息等字段。
|
|
24
|
+
|
|
25
|
+
不要用于评论采集、批量搜索、账号搜索或下载保存;评论用 `作品评论采集`,内容搜索用 `综合搜索工具`,用户搜索用 `综合用户搜索工具`,播放/下载地址用 `作品下载综合工具`。
|
|
26
|
+
|
|
27
|
+
## 调用优先级
|
|
28
|
+
|
|
29
|
+
1. YuanFlow 主程序内:调用 `yuanflow_cli_call`,参数数组从 `works detail` 开始。
|
|
30
|
+
2. 外部 Agent 且本机有 CLI:执行 `yuanflow-cli works detail ...`。
|
|
31
|
+
3. 外部 Agent 且没有 CLI:再提示用户安装 `npm install -g yuanflow-cli`。
|
|
32
|
+
|
|
33
|
+
YuanFlow 内置调用示例:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"args": [
|
|
38
|
+
"works",
|
|
39
|
+
"detail",
|
|
40
|
+
"--platform",
|
|
41
|
+
"douyin",
|
|
42
|
+
"--target",
|
|
43
|
+
"https://v.douyin.com/xxx/",
|
|
44
|
+
"--format",
|
|
45
|
+
"agent-json"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
外部 CLI 示例:
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
yuanflow-cli works detail --platform douyin --target "https://v.douyin.com/xxx/" --format agent-json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 先查命令和 schema
|
|
57
|
+
|
|
58
|
+
不确定参数时先查,不要猜:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{"args":["commands","list"]}
|
|
62
|
+
{"args":["schema","works.douyin.detail"]}
|
|
63
|
+
{"args":["schema","works.xiaohongshu.detail"]}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
命令 key 格式是:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
works.<platform>.detail
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 平台识别
|
|
73
|
+
|
|
74
|
+
| 平台参数 | 用户常见说法 | 链接或 ID 标识 | 说明 |
|
|
75
|
+
|---|---|---|---|
|
|
76
|
+
| `douyin` | 抖音、Douyin | `douyin.com`、`iesdouyin.com`、`v.douyin.com`、`aweme_id` | 分享链接优先 |
|
|
77
|
+
| `xiaohongshu` | 小红书、XHS | `xiaohongshu.com`、`xhslink.com`、`note_id` | 可传 `--xsec-token` |
|
|
78
|
+
| `bilibili` | B站、哔哩哔哩 | `bilibili.com`、`b23.tv`、`BV` 号 | URL 优先 |
|
|
79
|
+
| `wechat_channels` | 微信视频号、视频号 | 视频号视频 ID、`exportId` | 可传 `--export-id` |
|
|
80
|
+
| `wechat_mp` | 微信公众号、公众号文章 | `mp.weixin.qq.com/s/` | 文章 URL |
|
|
81
|
+
| `tiktok` | TikTok | `tiktok.com`、`vm.tiktok.com`、`itemId` | 分享链接优先 |
|
|
82
|
+
| `instagram` | Instagram、ins | `instagram.com/p/`、`instagram.com/reel/`、shortcode、media_id | URL、code、media_id 均可 |
|
|
83
|
+
| `kuaishou` | 快手 | `kuaishou.com/short-video/`、`photo_id` | URL 优先 |
|
|
84
|
+
| `reddit` | Reddit | `reddit.com/r/.../comments/`、`t3_` 帖子 ID | 帖子详情 |
|
|
85
|
+
| `twitter` | Twitter、X | `twitter.com`、`x.com`、推文数字 ID | 推文详情 |
|
|
86
|
+
| `weibo` | 微博 | `weibo.com`、微博 `id`、`mid` | 可传 `--long-text true` |
|
|
87
|
+
| `youtube` | YouTube、油管 | `youtube.com/watch?v=`、`youtu.be/`、视频 ID、社区帖子 ID | 默认视频详情,帖子用 `--kind post` |
|
|
88
|
+
| `zhihu` | 知乎 | 专栏文章 ID、问题 ID | 文章用 `--kind article`,问题回答入口用 `--kind question` |
|
|
89
|
+
| `xigua` | 西瓜视频 | 西瓜视频链接、`item_id` | 作品详情 |
|
|
90
|
+
|
|
91
|
+
如果短链文本无法判断平台,先按域名判断;仍无法判断就追问平台。
|
|
92
|
+
|
|
93
|
+
## 参数规则
|
|
94
|
+
|
|
95
|
+
通用参数:
|
|
96
|
+
|
|
97
|
+
- `--platform`:平台标识。
|
|
98
|
+
- `--target`:作品链接、分享链接或作品 ID。
|
|
99
|
+
- `--prefer fallback`:主接口失败或用户要求备用接口时使用。
|
|
100
|
+
- `--kind`:区分同平台不同对象,例如 YouTube 的 `video` / `post`,知乎的 `article` / `question`。
|
|
101
|
+
- `--target-kind`:区分 ID 类型,例如 Instagram 的 `code` / `media_id`。
|
|
102
|
+
- `--extra`:JSON 字符串补充参数。
|
|
103
|
+
- `--format agent-json`:Agent 调用时必须加,便于稳定解析。
|
|
104
|
+
|
|
105
|
+
## 接口映射
|
|
106
|
+
|
|
107
|
+
Agent 不需要直接拼接口地址,只需要选对 `platform`、`target` 和必要参数。
|
|
108
|
+
|
|
109
|
+
| 平台 | 首选能力 | 主要参数 | 备用或特殊能力 |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| 抖音 | 分享链接取作品详情 | `share_url` | aweme_id / app v3 备用 |
|
|
112
|
+
| 小红书 | 笔记详情 | `note_id`、`xsec_token` | 暂无 |
|
|
113
|
+
| B站 | 视频 URL 取详情 | `url` | BV 号详情 |
|
|
114
|
+
| 微信视频号 | 视频详情 | `id`、`exportId` | 暂无 |
|
|
115
|
+
| 微信公众号 | 文章详情 JSON | `url` | 暂无 |
|
|
116
|
+
| TikTok | 分享链接取作品详情 | `share_url` | itemId 详情 |
|
|
117
|
+
| Instagram | URL 取帖子详情 | `post_url` | shortcode / media_id |
|
|
118
|
+
| 快手 | URL 取作品详情 | `url` | photo_id 详情 |
|
|
119
|
+
| Reddit | 帖子详情 | `post_id` | 可传 comment_id |
|
|
120
|
+
| Twitter/X | 推文详情 | `tweet_id` | 暂无 |
|
|
121
|
+
| 微博 | 微博详情 | `id` | post_id 备用 |
|
|
122
|
+
| YouTube | 视频详情 | `video_id` | 帖子详情 `--kind post` |
|
|
123
|
+
| 知乎 | 专栏文章详情 | `article_id` | 问题回答入口 `--kind question` |
|
|
124
|
+
| 西瓜视频 | 作品详情 | `item_id` | 暂无 |
|
|
125
|
+
|
|
126
|
+
## 输出要求
|
|
127
|
+
|
|
128
|
+
成功后用中文简短说明:
|
|
129
|
+
|
|
130
|
+
- 调用了哪个平台和详情能力。
|
|
131
|
+
- 提炼标题、作者、发布时间、正文/描述、互动统计、媒体信息等用户需要的字段。
|
|
132
|
+
- 如果响应字段过多,先摘要,再询问是否需要导出完整 JSON。
|
|
133
|
+
|
|
134
|
+
失败时按 `agent-json` 的 `error.code` 和 `error.message` 解释。不要展示完整 Authorization 请求头、token、cookie 或敏感账号信息。
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 综合搜索工具
|
|
3
|
+
description: Use when the user wants to search public content, posts, notes, videos, articles, or social-media results across Douyin, Xiaohongshu, Bilibili, WeChat Channels, TikTok, Instagram, Kuaishou, Reddit, Twitter/X, Weibo, YouTube, Zhihu, or Xigua.
|
|
4
|
+
builtin_skill_version: 1.0.0
|
|
5
|
+
tags:
|
|
6
|
+
- 自媒体
|
|
7
|
+
- 综合搜索
|
|
8
|
+
- 内容搜索
|
|
9
|
+
- 关键词搜索
|
|
10
|
+
emoji: 🔎
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# 综合搜索工具
|
|
14
|
+
|
|
15
|
+
本技能把用户的“按关键词搜索内容、视频、笔记、文章、帖子”需求稳定映射到 `yuanflow-cli search content`。在 YuanFlow 主程序内,优先调用受控工具 `yuanflow_cli_call`;它会由主程序认证系统注入 `YUANCHUANG_API_TOKEN`,不要让用户粘贴 KEY,不要在回复、日志或文件里暴露 token。
|
|
16
|
+
|
|
17
|
+
## 什么时候使用
|
|
18
|
+
|
|
19
|
+
用户出现以下意图时使用:
|
|
20
|
+
|
|
21
|
+
- 搜索某个平台上的内容、作品、笔记、帖子、文章、视频。
|
|
22
|
+
- 用户给出关键词,并指定抖音、小红书、B站、微信视频号、TikTok、Instagram、快手、Reddit、Twitter/X、微博、YouTube、知乎或西瓜视频。
|
|
23
|
+
- 用户要做选题、竞品素材、热点素材、内容检索。
|
|
24
|
+
|
|
25
|
+
不要用于用户搜索;用户、作者、账号、频道搜索应使用 `综合用户搜索工具`。不要用于批量抓取、绕过平台限制或未授权数据访问。
|
|
26
|
+
|
|
27
|
+
## 调用优先级
|
|
28
|
+
|
|
29
|
+
1. YuanFlow 主程序内:调用 `yuanflow_cli_call`,参数数组从 `search content` 开始。
|
|
30
|
+
2. 外部 Agent 且本机有 CLI:执行 `yuanflow-cli search content ...`。
|
|
31
|
+
3. 外部 Agent 且没有 CLI:再提示用户安装 `npm install -g yuanflow-cli`。
|
|
32
|
+
|
|
33
|
+
YuanFlow 内置调用示例:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"args": [
|
|
38
|
+
"search",
|
|
39
|
+
"content",
|
|
40
|
+
"--platform",
|
|
41
|
+
"xiaohongshu",
|
|
42
|
+
"--keyword",
|
|
43
|
+
"美妆",
|
|
44
|
+
"--page",
|
|
45
|
+
"1",
|
|
46
|
+
"--format",
|
|
47
|
+
"agent-json"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
外部 CLI 示例:
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
yuanflow-cli search content --platform xiaohongshu --keyword "美妆" --page 1 --format agent-json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 先查命令和 schema
|
|
59
|
+
|
|
60
|
+
不确定参数时先查,不要猜:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{"args":["commands","list"]}
|
|
64
|
+
{"args":["schema","search.xiaohongshu.content"]}
|
|
65
|
+
{"args":["schema","search.douyin.content"]}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
命令 key 格式是:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
search.<platform>.content
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 平台识别
|
|
75
|
+
|
|
76
|
+
| 平台参数 | 用户常见说法 | 主要搜索对象 | 常用补充参数 |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| `douyin` | 抖音、Douyin | 综合内容、视频、图文、文章 | `--cursor`、`--sort-type`、`--publish-time`、`--content-type` |
|
|
79
|
+
| `xiaohongshu` | 小红书、XHS | 笔记 | `--page`、`--sort`、`--note-type` |
|
|
80
|
+
| `bilibili` | B站、哔哩哔哩 | 综合结果、视频 | `--page`、`--page-size`、`--order` |
|
|
81
|
+
| `wechat_channels` | 微信视频号、视频号 | 视频号综合搜索 | 关键词 |
|
|
82
|
+
| `tiktok` | TikTok | 综合结果 | `--offset`、`--count`、`--sort-type` |
|
|
83
|
+
| `instagram` | Instagram、ins | 综合结果 | `--next-max-id`、`--rank-token` |
|
|
84
|
+
| `kuaishou` | 快手 | 综合结果 | `--pcursor`、`--sort-type` |
|
|
85
|
+
| `reddit` | Reddit | 帖子、社区、评论、媒体 | `--search-type`、`--sort`、`--after` |
|
|
86
|
+
| `twitter` | Twitter、X | 推文搜索时间线 | `--search-type`、`--cursor` |
|
|
87
|
+
| `weibo` | 微博 | 微博高级搜索 | `--page`、`--search-type` |
|
|
88
|
+
| `youtube` | YouTube、油管 | 综合结果 | `--continuation-token`、`--type`、`--sort-by` |
|
|
89
|
+
| `zhihu` | 知乎 | 文章搜索 | `--offset`、`--limit`、`--sort` |
|
|
90
|
+
| `xigua` | 西瓜视频 | 视频搜索 | `--offset`、`--order-type` |
|
|
91
|
+
|
|
92
|
+
## 参数规则
|
|
93
|
+
|
|
94
|
+
通用参数:
|
|
95
|
+
|
|
96
|
+
- `--platform`:平台标识。
|
|
97
|
+
- `--keyword`:搜索关键词。
|
|
98
|
+
- `--cursor`、`--offset`、`--page`、`--continuation-token`:翻页参数,必须来自上一次响应,不要编造。
|
|
99
|
+
- `--count`、`--limit`、`--page-size`:数量参数,仅平台支持时传。
|
|
100
|
+
- `--sort`、`--sort-type`、`--publish-time`、`--content-type`:筛选参数,按 schema 和平台说明传。
|
|
101
|
+
- `--extra`:JSON 字符串补充参数。
|
|
102
|
+
- `--format agent-json`:Agent 调用时必须加,便于稳定解析。
|
|
103
|
+
|
|
104
|
+
## 输出要求
|
|
105
|
+
|
|
106
|
+
成功后用中文简短说明:
|
|
107
|
+
|
|
108
|
+
- 搜索的平台、关键词和筛选条件。
|
|
109
|
+
- 如果响应里有结果数量、下一页游标、continuation token,要提示用户。
|
|
110
|
+
- 用户要求整理时,再转成表格、摘要或文件。
|
|
111
|
+
|
|
112
|
+
失败时按 `agent-json` 的 `error.code` 和 `error.message` 解释。不要展示完整 Authorization 请求头、token、cookie 或敏感账号信息。
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 综合用户搜索工具
|
|
3
|
+
description: Use when the user wants to search creators, accounts, users, channels, authors, or profiles across Douyin, Xiaohongshu, WeChat Channels, TikTok, Instagram, Kuaishou, Weibo, YouTube, or Zhihu.
|
|
4
|
+
builtin_skill_version: 1.0.0
|
|
5
|
+
tags:
|
|
6
|
+
- 自媒体
|
|
7
|
+
- 用户搜索
|
|
8
|
+
- 作者搜索
|
|
9
|
+
- 账号搜索
|
|
10
|
+
emoji: 👤
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# 综合用户搜索工具
|
|
14
|
+
|
|
15
|
+
本技能把用户的“搜索账号、作者、用户、频道、达人”需求稳定映射到 `yuanflow-cli search users`。在 YuanFlow 主程序内,优先调用受控工具 `yuanflow_cli_call`;它会由主程序认证系统注入 `YUANCHUANG_API_TOKEN`,不要让用户粘贴 KEY,不要在回复、日志或文件里暴露 token。
|
|
16
|
+
|
|
17
|
+
## 什么时候使用
|
|
18
|
+
|
|
19
|
+
用户出现以下意图时使用:
|
|
20
|
+
|
|
21
|
+
- 按关键词搜索某个平台上的账号、作者、达人、用户、频道。
|
|
22
|
+
- 查找某个品牌、昵称、抖音号、小红书号、YouTube 频道等候选账号。
|
|
23
|
+
- 做账号调研、达人筛选、用户线索查找。
|
|
24
|
+
|
|
25
|
+
不要用于搜索作品、笔记、文章、帖子或视频;内容搜索应使用 `综合搜索工具`。不要用于批量抓取、绕过平台限制或未授权数据访问。
|
|
26
|
+
|
|
27
|
+
## 调用优先级
|
|
28
|
+
|
|
29
|
+
1. YuanFlow 主程序内:调用 `yuanflow_cli_call`,参数数组从 `search users` 开始。
|
|
30
|
+
2. 外部 Agent 且本机有 CLI:执行 `yuanflow-cli search users ...`。
|
|
31
|
+
3. 外部 Agent 且没有 CLI:再提示用户安装 `npm install -g yuanflow-cli`。
|
|
32
|
+
|
|
33
|
+
YuanFlow 内置调用示例:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"args": [
|
|
38
|
+
"search",
|
|
39
|
+
"users",
|
|
40
|
+
"--platform",
|
|
41
|
+
"instagram",
|
|
42
|
+
"--keyword",
|
|
43
|
+
"nasa",
|
|
44
|
+
"--format",
|
|
45
|
+
"agent-json"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
外部 CLI 示例:
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
yuanflow-cli search users --platform instagram --keyword "nasa" --format agent-json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 先查命令和 schema
|
|
57
|
+
|
|
58
|
+
不确定参数时先查,不要猜:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{"args":["commands","list"]}
|
|
62
|
+
{"args":["schema","search.instagram.users"]}
|
|
63
|
+
{"args":["schema","search.douyin.users"]}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
命令 key 格式是:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
search.<platform>.users
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 平台识别
|
|
73
|
+
|
|
74
|
+
| 平台参数 | 用户常见说法 | 搜索对象 | 常用补充参数 |
|
|
75
|
+
|---|---|---|---|
|
|
76
|
+
| `douyin` | 抖音、Douyin | 用户、达人、账号 | `--cursor` |
|
|
77
|
+
| `xiaohongshu` | 小红书、XHS | 用户 | `--page` |
|
|
78
|
+
| `wechat_channels` | 微信视频号、视频号 | 视频号用户 | `--page` |
|
|
79
|
+
| `tiktok` | TikTok | 用户 | `--offset`、`--count` |
|
|
80
|
+
| `instagram` | Instagram、ins | 用户 | `--rank-token` |
|
|
81
|
+
| `kuaishou` | 快手 | 用户 | `--page` |
|
|
82
|
+
| `weibo` | 微博 | 用户 | `--page`、`--region`、`--auth`、`--gender` |
|
|
83
|
+
| `youtube` | YouTube、油管 | 频道 | `--continuation-token` |
|
|
84
|
+
| `zhihu` | 知乎 | 用户 | `--offset`、`--limit` |
|
|
85
|
+
|
|
86
|
+
B站、Reddit、Twitter/X 当前没有单独接入稳定用户搜索综合命令;如果用户指定这些平台,先说明当前工具不支持单独用户搜索,再建议使用 `综合搜索工具` 做内容/综合搜索,或用 `yuanflow-cli commands list` 查找可用原子接口。
|
|
87
|
+
|
|
88
|
+
## 参数规则
|
|
89
|
+
|
|
90
|
+
通用参数:
|
|
91
|
+
|
|
92
|
+
- `--platform`:平台标识。
|
|
93
|
+
- `--keyword`:用户、账号、频道或达人关键词。
|
|
94
|
+
- `--cursor`、`--offset`、`--page`、`--continuation-token`:翻页参数,必须来自上一次响应,不要编造。
|
|
95
|
+
- `--count`、`--limit`:数量参数,仅平台支持时传。
|
|
96
|
+
- `--extra`:JSON 字符串补充参数。
|
|
97
|
+
- `--format agent-json`:Agent 调用时必须加,便于稳定解析。
|
|
98
|
+
|
|
99
|
+
## 输出要求
|
|
100
|
+
|
|
101
|
+
成功后用中文简短说明:
|
|
102
|
+
|
|
103
|
+
- 搜索的平台和关键词。
|
|
104
|
+
- 返回结果中的昵称、账号 ID、主页标识、粉丝数等常用字段要按用户需求整理。
|
|
105
|
+
- 如果响应里有下一页游标或 continuation token,要提示用户。
|
|
106
|
+
|
|
107
|
+
失败时按 `agent-json` 的 `error.code` 和 `error.message` 解释。不要展示完整 Authorization 请求头、token、cookie 或敏感账号信息。
|
package/src/agent-protocol.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { listEndpoints } from './registry.js';
|
|
2
2
|
import { listShortcuts } from './shortcuts.js';
|
|
3
|
+
import { listCommentCommands } from './comment-collector.js';
|
|
4
|
+
import { listSearchCommands, listWorkCommands } from './work-tools.js';
|
|
3
5
|
|
|
4
6
|
const ERROR_MAP = [
|
|
5
7
|
{
|
|
@@ -81,7 +83,10 @@ export function getCommandName(platform, command) {
|
|
|
81
83
|
export function buildCommandRegistry() {
|
|
82
84
|
const shortcuts = listShortcuts().map((shortcut) => shortcutToCommand(shortcut));
|
|
83
85
|
const endpoints = listEndpoints().map((endpoint) => endpointToCommand(endpoint));
|
|
84
|
-
|
|
86
|
+
const commentCommands = listCommentCommands();
|
|
87
|
+
const workCommands = listWorkCommands();
|
|
88
|
+
const searchCommands = listSearchCommands();
|
|
89
|
+
return [...shortcuts, ...endpoints, ...commentCommands, ...workCommands, ...searchCommands].sort((left, right) =>
|
|
85
90
|
left.key.localeCompare(right.key),
|
|
86
91
|
);
|
|
87
92
|
}
|
package/src/cli.js
CHANGED
|
@@ -16,6 +16,13 @@ import {
|
|
|
16
16
|
isAgentJsonFormat,
|
|
17
17
|
} from './agent-protocol.js';
|
|
18
18
|
import { findShortcut, listShortcuts } from './shortcuts.js';
|
|
19
|
+
import { collectComments } from './comment-collector.js';
|
|
20
|
+
import {
|
|
21
|
+
getWorkDetail,
|
|
22
|
+
getWorkDownload,
|
|
23
|
+
searchContent,
|
|
24
|
+
searchUsers,
|
|
25
|
+
} from './work-tools.js';
|
|
19
26
|
|
|
20
27
|
export async function main(argv) {
|
|
21
28
|
const args = argv.slice(2);
|
|
@@ -46,6 +53,21 @@ export async function main(argv) {
|
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
48
55
|
|
|
56
|
+
if (command === 'comments') {
|
|
57
|
+
await handleComments(rest);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (command === 'works') {
|
|
62
|
+
await handleWorks(rest);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (command === 'search') {
|
|
67
|
+
await handleSearch(rest);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
49
71
|
if (command === 'schema') {
|
|
50
72
|
await handleSchema(rest);
|
|
51
73
|
return;
|
|
@@ -210,6 +232,99 @@ async function handleCall(args) {
|
|
|
210
232
|
});
|
|
211
233
|
}
|
|
212
234
|
|
|
235
|
+
async function handleComments(args) {
|
|
236
|
+
const { positionals, options } = parseOptions(args);
|
|
237
|
+
const [action = 'collect'] = positionals;
|
|
238
|
+
if (action !== 'collect') {
|
|
239
|
+
throw new Error('未知 comments 命令。用法:yuanflow-cli comments collect --platform douyin --target <作品链接或ID>');
|
|
240
|
+
}
|
|
241
|
+
const platform = options.named?.platform;
|
|
242
|
+
const target = options.named?.target || positionals[1];
|
|
243
|
+
if (!platform) {
|
|
244
|
+
throw new Error('缺少 --platform,例如 douyin、xiaohongshu、bilibili。');
|
|
245
|
+
}
|
|
246
|
+
if (!target) {
|
|
247
|
+
throw new Error('缺少 --target 或目标位置参数。');
|
|
248
|
+
}
|
|
249
|
+
const result = await collectComments({
|
|
250
|
+
platform,
|
|
251
|
+
action: options.named?.action || 'comments',
|
|
252
|
+
target,
|
|
253
|
+
prefer: options.named?.prefer || 'primary',
|
|
254
|
+
options,
|
|
255
|
+
});
|
|
256
|
+
await outputResult(result, options, {
|
|
257
|
+
command: 'comments collect',
|
|
258
|
+
meta: { endpoint: result.endpoint.path, kind: 'comment-collector' },
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function handleWorks(args) {
|
|
263
|
+
const { positionals, options } = parseOptions(args);
|
|
264
|
+
const [action = 'detail'] = positionals;
|
|
265
|
+
const platform = options.named?.platform;
|
|
266
|
+
const target = options.named?.target || positionals[1];
|
|
267
|
+
if (!platform) {
|
|
268
|
+
throw new Error('缺少 --platform,例如 douyin、youtube、bilibili。');
|
|
269
|
+
}
|
|
270
|
+
if (!target) {
|
|
271
|
+
throw new Error('缺少 --target 或目标位置参数。');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let result;
|
|
275
|
+
if (action === 'detail') {
|
|
276
|
+
result = await getWorkDetail({
|
|
277
|
+
platform,
|
|
278
|
+
target,
|
|
279
|
+
prefer: options.named?.prefer || 'primary',
|
|
280
|
+
kind: options.named?.kind,
|
|
281
|
+
targetKind: options.named?.['target-kind'],
|
|
282
|
+
options,
|
|
283
|
+
});
|
|
284
|
+
} else if (action === 'download') {
|
|
285
|
+
result = await getWorkDownload({
|
|
286
|
+
platform,
|
|
287
|
+
target,
|
|
288
|
+
prefer: options.named?.prefer || 'primary',
|
|
289
|
+
kind: options.named?.kind,
|
|
290
|
+
targetKind: options.named?.['target-kind'],
|
|
291
|
+
options,
|
|
292
|
+
});
|
|
293
|
+
} else {
|
|
294
|
+
throw new Error('未知 works 命令。用法:yuanflow-cli works detail|download --platform douyin --target <作品链接或ID>');
|
|
295
|
+
}
|
|
296
|
+
await outputResult(result, options, {
|
|
297
|
+
command: `works ${action}`,
|
|
298
|
+
meta: { endpoint: result.endpoint.path, kind: result.endpoint.kind || `work-${action}` },
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async function handleSearch(args) {
|
|
303
|
+
const { positionals, options } = parseOptions(args);
|
|
304
|
+
const [action = 'content'] = positionals;
|
|
305
|
+
const platform = options.named?.platform;
|
|
306
|
+
const keyword = options.named?.keyword || positionals[1];
|
|
307
|
+
if (!platform) {
|
|
308
|
+
throw new Error('缺少 --platform,例如 douyin、xiaohongshu、instagram。');
|
|
309
|
+
}
|
|
310
|
+
if (!keyword) {
|
|
311
|
+
throw new Error('缺少 --keyword 或关键词位置参数。');
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
let result;
|
|
315
|
+
if (action === 'content') {
|
|
316
|
+
result = await searchContent({ platform, keyword, options });
|
|
317
|
+
} else if (action === 'users' || action === 'user') {
|
|
318
|
+
result = await searchUsers({ platform, keyword, options });
|
|
319
|
+
} else {
|
|
320
|
+
throw new Error('未知 search 命令。用法:yuanflow-cli search content|users --platform douyin --keyword <关键词>');
|
|
321
|
+
}
|
|
322
|
+
await outputResult(result, options, {
|
|
323
|
+
command: `search ${action}`,
|
|
324
|
+
meta: { endpoint: result.endpoint.path, kind: result.endpoint.kind || `${action}-search` },
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
213
328
|
async function handleGeneratedCommand(platform, args) {
|
|
214
329
|
if (!getPlatforms().includes(platform)) {
|
|
215
330
|
throw new Error(`未知平台:${platform}。可用平台:${getPlatforms().join(', ')}`);
|
|
@@ -363,6 +478,11 @@ function printHelp() {
|
|
|
363
478
|
yuanflow-cli shortcuts douyin
|
|
364
479
|
yuanflow-cli commands list
|
|
365
480
|
yuanflow-cli schema douyin.video-detail
|
|
481
|
+
yuanflow-cli comments collect --platform douyin --target "https://v.douyin.com/xxx/" --dry-run
|
|
482
|
+
yuanflow-cli works detail --platform douyin --target "https://v.douyin.com/xxx/" --dry-run
|
|
483
|
+
yuanflow-cli works download --platform youtube --target "dQw4w9WgXcQ" --dry-run
|
|
484
|
+
yuanflow-cli search content --platform xiaohongshu --keyword "美妆" --dry-run
|
|
485
|
+
yuanflow-cli search users --platform instagram --keyword "nasa" --dry-run
|
|
366
486
|
yuanflow-cli list douyin
|
|
367
487
|
|
|
368
488
|
说明:
|