yuanflow-cli 0.1.13 → 0.1.15
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 +24 -0
- package/package.json +1 -1
- package/skills/yuanflow-skill/README.md +4 -0
- package/skills/yuanflow-skill/SKILL.md +17 -4
- package/skills/yuanflow-skill//345/270/220/345/217/267/347/233/221/346/216/247/SKILL.md +219 -0
- package/skills/yuanflow-skill//346/234/254/345/234/260/351/237/263/350/247/206/351/242/221/350/275/254/346/226/207/345/255/227/SKILL.md +21 -14
- package/skills/yuanflow-skill//346/234/254/345/234/260/351/237/263/350/247/206/351/242/221/350/275/254/346/226/207/345/255/227/scripts/common/utils.py +8 -0
- package/skills/yuanflow-skill//346/234/254/345/234/260/351/237/263/350/247/206/351/242/221/350/275/254/346/226/207/345/255/227/scripts/transcribe_media.py +4 -2
- package/src/cli.js +9 -1
package/README.md
CHANGED
|
@@ -35,6 +35,9 @@ yuanflow-cli works detail --platform douyin --target "https://v.douyin.com/xxx/"
|
|
|
35
35
|
yuanflow-cli works download --platform douyin --target "https://v.douyin.com/xxx/" --region CN --format agent-json
|
|
36
36
|
yuanflow-cli search content --platform xiaohongshu --keyword "美妆" --format agent-json
|
|
37
37
|
yuanflow-cli search users --platform instagram --keyword "nasa" --format agent-json
|
|
38
|
+
yuanflow-cli douyin web get-sec-user-id --url "https://v.douyin.com/xxx/" --format agent-json
|
|
39
|
+
yuanflow-cli douyin user-profile <sec_user_id> --format agent-json
|
|
40
|
+
yuanflow-cli douyin user-posts <sec_user_id> --count 20 --cursor 0 --format agent-json
|
|
38
41
|
yuanflow-cli knowledge docs --format agent-json
|
|
39
42
|
yuanflow-cli knowledge entry --output-format short_video_script --domain 自媒体运营 --content-goal "写一个创业者短视频选题" --target-audience 创业者 --format agent-json
|
|
40
43
|
yuanflow-cli oss signed-url --key path/to/file.png --ttl-seconds 1800 --format agent-json
|
|
@@ -90,6 +93,27 @@ yuanflow-cli search users --platform instagram --keyword "nasa" --format agent-j
|
|
|
90
93
|
|
|
91
94
|
Agent 不确定参数时先执行 `commands list`,再用 `schema works.douyin.detail` 或 `schema search.xiaohongshu.content` 查看参数。`--dry-run` 可预览请求映射,不发起真实接口请求,也不要求 token。
|
|
92
95
|
|
|
96
|
+
### 帐号监控
|
|
97
|
+
|
|
98
|
+
`帐号监控` 随 npm 包安装到 Skill bundle,用于把帐号搜索、主页资料、主页作品、历史快照和变化对比串成稳定流程。
|
|
99
|
+
|
|
100
|
+
抖音完整链路:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
yuanflow-cli douyin web get-sec-user-id --url "https://v.douyin.com/xxx/" --format agent-json
|
|
104
|
+
yuanflow-cli search users --platform douyin --keyword "<sec_user_id>" --format agent-json
|
|
105
|
+
yuanflow-cli douyin user-profile <sec_user_id> --format agent-json
|
|
106
|
+
yuanflow-cli douyin user-posts <sec_user_id> --count 20 --cursor 0 --format agent-json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
如果主页作品数据缺少播放、点赞、评论、转发、收藏等统计,再用:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
yuanflow-cli works detail --platform douyin --target "<aweme_id 或 share_url>" --format agent-json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
快照默认保存到 YuanFlow 数据目录下的 `runtime_tools/account-monitor/snapshots`。
|
|
116
|
+
|
|
93
117
|
### 自媒体知识库
|
|
94
118
|
|
|
95
119
|
知识库能力独立于社媒 `/social` 接口,走 Yuan API 的 `/api/knowledge-base/docs` 和 `/atomic/agent-rules/navigate`:
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ YuanFlow Skill 是 `yuanflow-cli` 的 Agent Skill 仓库,用于把社媒平台
|
|
|
11
11
|
- `生图技能/`:图片生成与编辑 Skill,优先走 YuanFlow 内置 `yuanflow_image_request`。
|
|
12
12
|
- `HTML报告生成/`:单页 HTML 报告生成 Skill,内置 9 种米色留白报告模板。
|
|
13
13
|
- `本地音视频转文字/`:本地 SenseVoice 音视频转文字 Skill,首次明确使用时按需下载模型。
|
|
14
|
+
- `帐号监控/`:帐号搜索、主页资料、主页作品、历史快照、变化对比和 HTML 可视化分流 Skill。
|
|
14
15
|
|
|
15
16
|
## 适用场景
|
|
16
17
|
|
|
@@ -22,6 +23,7 @@ YuanFlow Skill 是 `yuanflow-cli` 的 Agent Skill 仓库,用于把社媒平台
|
|
|
22
23
|
- 生成图片、编辑图片,并缓存返回 URL 或 base64 图片。生成图片必填 `prompt`,可选 `size / quality / style / n / response_format`;编辑图片必须通过 multipart 上传本地图片。
|
|
23
24
|
- 把自媒体分析、数据复盘、文案方案、账号监控、知识梳理和执行计划生成可直接打开的单页 HTML 报告。
|
|
24
25
|
- 在用户明确要求本地转写时,把本地音频或视频转成文字;视频会先抽取音频,模型和缓存都保存在 Skill 自己目录下。
|
|
26
|
+
- 监控抖音、小红书、微博、知乎、Bilibili、TikTok、YouTube、Twitter/X 帐号主页,保存快照并对比历史变化;抖音链路优先使用 `get-sec-user-id -> user-profile -> user-posts -> works detail`。
|
|
25
27
|
|
|
26
28
|
## 双环境使用方式
|
|
27
29
|
|
|
@@ -87,6 +89,8 @@ yuanflow-skill list-skills
|
|
|
87
89
|
│ ├─ SKILL.md
|
|
88
90
|
│ ├─ templates/
|
|
89
91
|
│ └─ references/
|
|
92
|
+
├─ 帐号监控
|
|
93
|
+
│ └─ SKILL.md
|
|
90
94
|
├─ 本地音视频转文字
|
|
91
95
|
│ ├─ SKILL.md
|
|
92
96
|
│ └─ scripts/
|
|
@@ -23,6 +23,7 @@ description: Use when the user asks about social-media API workflows, platform d
|
|
|
23
23
|
- `生图技能/`
|
|
24
24
|
- `HTML报告生成/`
|
|
25
25
|
- `本地音视频转文字/`
|
|
26
|
+
- `帐号监控/`
|
|
26
27
|
|
|
27
28
|
## 环境判断
|
|
28
29
|
|
|
@@ -130,7 +131,19 @@ description: Use when the user asks about social-media API workflows, platform d
|
|
|
130
131
|
|
|
131
132
|
- `自媒体知识库`
|
|
132
133
|
|
|
133
|
-
### 8. 走
|
|
134
|
+
### 8. 走 `帐号监控`
|
|
135
|
+
|
|
136
|
+
遇到下面这些需求,优先进入这个子 Skill:
|
|
137
|
+
|
|
138
|
+
- 监控帐号、账号、博主、达人、频道、主页、竞品帐号或对标帐号。
|
|
139
|
+
- 用户给出抖音、小红书、微博、知乎、Bilibili、TikTok、YouTube、Twitter/X 主页链接或帐号 ID,并要求采集主页完整信息、主页作品、历史快照、变化对比。
|
|
140
|
+
- 用户要求把“账号搜索 + 主页详情 + 作品采集 + 历史快照 + 变化对比”串成完整流程。
|
|
141
|
+
|
|
142
|
+
子 Skill 名称:
|
|
143
|
+
|
|
144
|
+
- `帐号监控`
|
|
145
|
+
|
|
146
|
+
### 9. 走 `OSS文件中转工具`
|
|
134
147
|
|
|
135
148
|
遇到下面这些需求,优先进入这个子 Skill:
|
|
136
149
|
|
|
@@ -142,7 +155,7 @@ description: Use when the user asks about social-media API workflows, platform d
|
|
|
142
155
|
|
|
143
156
|
- `OSS文件中转工具`
|
|
144
157
|
|
|
145
|
-
###
|
|
158
|
+
### 10. 走 `生图技能`
|
|
146
159
|
|
|
147
160
|
遇到下面这些需求,优先进入这个子 Skill:
|
|
148
161
|
|
|
@@ -154,7 +167,7 @@ description: Use when the user asks about social-media API workflows, platform d
|
|
|
154
167
|
|
|
155
168
|
- `生图技能`
|
|
156
169
|
|
|
157
|
-
###
|
|
170
|
+
### 11. 走 `HTML报告生成`
|
|
158
171
|
|
|
159
172
|
遇到下面这些需求,优先进入这个子 Skill:
|
|
160
173
|
|
|
@@ -166,7 +179,7 @@ description: Use when the user asks about social-media API workflows, platform d
|
|
|
166
179
|
|
|
167
180
|
- `HTML报告生成`
|
|
168
181
|
|
|
169
|
-
###
|
|
182
|
+
### 12. 走 `本地音视频转文字`
|
|
170
183
|
|
|
171
184
|
只有当用户明确要求使用本地音视频转文字、本地转写、本地 ASR、离线转写或本地模型把音频/视频转成文字时,才进入这个子 Skill。
|
|
172
185
|
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 帐号监控
|
|
3
|
+
description: Use when the user wants to monitor or research a social-media account, creator, channel, blogger, competitor profile, or homepage across Douyin, Xiaohongshu, Weibo, Zhihu, Bilibili, TikTok, YouTube, or Twitter/X, including account search, profile details, homepage works, snapshots, metric comparison, and optional HTML visualization.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 帐号监控
|
|
7
|
+
|
|
8
|
+
本技能用于把“监控帐号、分析博主、采集主页、对比历史变化”的需求稳定映射到 `yuanflow-cli`。在 YuanFlow 主程序内,优先调用受控工具 `yuanflow_cli_call`;它会自动注入用户 token。不要要求用户粘贴 KEY,不要在回复、日志或文件里暴露 token。
|
|
9
|
+
|
|
10
|
+
## 固定目标
|
|
11
|
+
|
|
12
|
+
输出一次帐号监控结果时,至少完成:
|
|
13
|
+
|
|
14
|
+
1. 识别平台和帐号输入。
|
|
15
|
+
2. 获取帐号主页标识。
|
|
16
|
+
3. 获取主页资料。
|
|
17
|
+
4. 获取主页作品列表。
|
|
18
|
+
5. 判断作品列表是否已经包含播放、点赞、评论、转发、收藏等统计。
|
|
19
|
+
6. 必要时用 `作品详情获取工具` 补单作品详情。
|
|
20
|
+
7. 保存本次快照 JSON。
|
|
21
|
+
8. 给出简短中文汇总。
|
|
22
|
+
9. 结束时询问用户是否需要 HTML 可视化汇总;用户确认后再使用 `HTML报告生成`。
|
|
23
|
+
|
|
24
|
+
## 缓存路径
|
|
25
|
+
|
|
26
|
+
YuanFlow 主程序内默认保存到程序数据目录:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
<YuanFlow data dir>/runtime_tools/account-monitor/snapshots
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Windows 外部 Agent 默认保存到:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
%APPDATA%\YuanFlow\runtime_tools\account-monitor\snapshots
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
快照文件名建议:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
<platform>-<account_id>-<yyyyMMdd-HHmmss>.json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
快照内容至少包含:`platform`、`source_input`、`account_id`、`profile`、`works`、`captured_at`、`cli_commands`、`previous_snapshot`、`diff_summary`。
|
|
45
|
+
|
|
46
|
+
## 抖音完整链路
|
|
47
|
+
|
|
48
|
+
抖音是当前确认可完整执行的平台。用户给抖音主页 URL,例如 `https://v.douyin.com/LVToddG4-Ac/` 时,按下面顺序执行。
|
|
49
|
+
|
|
50
|
+
### 1. 获取 sec_user_id
|
|
51
|
+
|
|
52
|
+
YuanFlow 内置调用:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"args": [
|
|
57
|
+
"douyin",
|
|
58
|
+
"web",
|
|
59
|
+
"get-sec-user-id",
|
|
60
|
+
"--url",
|
|
61
|
+
"https://v.douyin.com/LVToddG4-Ac/",
|
|
62
|
+
"--format",
|
|
63
|
+
"agent-json"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
外部 CLI:
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
yuanflow-cli douyin web get-sec-user-id --url "https://v.douyin.com/LVToddG4-Ac/" --format agent-json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
注意:该接口当前返回的 `sec_user_id` 通常在 `data.data` 字符串里,不一定是 `data.data.sec_user_id` 对象字段。
|
|
75
|
+
|
|
76
|
+
### 2. 尝试综合用户搜索工具
|
|
77
|
+
|
|
78
|
+
保留“综合用户搜索工具”,但不要依赖它作为主页详情唯一来源。`search users` 适合关键词搜索,使用 `sec_user_id` 时可能返回空。
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"args": [
|
|
83
|
+
"search",
|
|
84
|
+
"users",
|
|
85
|
+
"--platform",
|
|
86
|
+
"douyin",
|
|
87
|
+
"--keyword",
|
|
88
|
+
"<sec_user_id>",
|
|
89
|
+
"--format",
|
|
90
|
+
"agent-json"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
如返回命中结果,优先提取:
|
|
96
|
+
|
|
97
|
+
| 字段 | 含义 |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `nick_name` | 昵称 |
|
|
100
|
+
| `avatar_url` | 头像 |
|
|
101
|
+
| `fans_cnt` | 粉丝数 |
|
|
102
|
+
| `like_cnt` | 获赞数 |
|
|
103
|
+
| `publish_cnt` | 发布作品数 |
|
|
104
|
+
| `second_tag_name` | 二级标签/分类,可能为空 |
|
|
105
|
+
| `new_like_cnt` | 新增获赞数,当前常为 `0` |
|
|
106
|
+
| `new_fans_cnt` | 新增粉丝数,当前常为 `0` |
|
|
107
|
+
| `fans_trends` | 粉丝趋势,当前可能为 `null` |
|
|
108
|
+
| `fans_incr_rate` | 粉丝增长率,当前常为 `0` |
|
|
109
|
+
|
|
110
|
+
如果没有命中或字段不足,立即用下一步确定性主页接口兜底,不要卡住。
|
|
111
|
+
|
|
112
|
+
### 3. 获取主页资料
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"args": [
|
|
117
|
+
"douyin",
|
|
118
|
+
"user-profile",
|
|
119
|
+
"<sec_user_id>",
|
|
120
|
+
"--format",
|
|
121
|
+
"agent-json"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
外部 CLI:
|
|
127
|
+
|
|
128
|
+
```powershell
|
|
129
|
+
yuanflow-cli douyin user-profile <sec_user_id> --format agent-json
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 4. 获取主页作品
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"args": [
|
|
137
|
+
"douyin",
|
|
138
|
+
"user-posts",
|
|
139
|
+
"<sec_user_id>",
|
|
140
|
+
"--count",
|
|
141
|
+
"20",
|
|
142
|
+
"--cursor",
|
|
143
|
+
"0",
|
|
144
|
+
"--format",
|
|
145
|
+
"agent-json"
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
外部 CLI:
|
|
151
|
+
|
|
152
|
+
```powershell
|
|
153
|
+
yuanflow-cli douyin user-posts <sec_user_id> --count 20 --cursor 0 --format agent-json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
作品字段重点提取:`aweme_id`、`desc`、`item_title`、`create_time`、`share_info.share_url`、`statistics.play_count`、`statistics.digg_count`、`statistics.comment_count`、`statistics.share_count`、`statistics.collect_count`。
|
|
157
|
+
|
|
158
|
+
如果作品列表已经包含上述统计字段,直接通过。若缺少关键统计或用户要求更完整单作品详情,再调用:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"args": [
|
|
163
|
+
"works",
|
|
164
|
+
"detail",
|
|
165
|
+
"--platform",
|
|
166
|
+
"douyin",
|
|
167
|
+
"--target",
|
|
168
|
+
"<aweme_id 或 share_url>",
|
|
169
|
+
"--format",
|
|
170
|
+
"agent-json"
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 平台链路矩阵
|
|
176
|
+
|
|
177
|
+
只使用下面确认存在的 CLI 命令或原子接口。不要编造接口。
|
|
178
|
+
|
|
179
|
+
| 平台 | 完整度 | 主页标识 | 主页资料 | 主页作品 | 作品详情补全 |
|
|
180
|
+
| --- | --- | --- | --- | --- | --- |
|
|
181
|
+
| 抖音 | 完整 | `douyin web get-sec-user-id --url <url>` | `douyin user-profile <sec_user_id>`;补救:`douyin web handler-user-profile --sec-user-id <sec_user_id>` | `douyin user-posts <sec_user_id> --count 20 --cursor 0` | `works detail --platform douyin --target <aweme_id/share_url>` |
|
|
182
|
+
| 小红书 | 基本完整 | `xiaohongshu app get-user-id-and-xsec-token --share-link <url>` | `xiaohongshu app get-user-info --user-id <user_id>`;补救:`xiaohongshu web-v3 fetch-user-info --user-id <user_id>` | `xiaohongshu user-notes <user_id> --cursor <cursor>`;补救:`xiaohongshu web-v3 fetch-user-notes --user-id <user_id> --num 20` | `works detail --platform xiaohongshu --target <note_id>`;有 `xsec_token` 时传 `--xsec-token` |
|
|
183
|
+
| 微博 | 部分完整 | 当前未发现稳定 URL 转 uid 命令;若用户提供 uid 可执行 | `weibo app fetch-user-info --uid <uid>`;补救:`weibo web-v2 fetch-user-info --uid <uid>` | `weibo web-v2 fetch-user-posts --uid <uid> --page 1`;补救:`weibo web fetch-user-posts --uid <uid>` | `works detail --platform weibo --target <id>` |
|
|
184
|
+
| 知乎 | 不完整 | 当前未发现稳定 URL 转 user_url_token 命令;可从用户给出的知乎主页 URL/用户名中提取 token | `zhihu web fetch-user-info --user-url-token <token>` | 当前未发现确定的用户主页内容列表命令;可用 `search content --platform zhihu --keyword <昵称/关键词>` 做补救检索 | `works detail --platform zhihu --target <article_id> --kind article`,问题回答用 `--kind question` |
|
|
185
|
+
| Bilibili | 完整 | `bilibili web fetch-get-user-id --share-link <url>`;或从 space URL 提取 uid | `bilibili user-profile <uid>` | `bilibili user-posts <uid> --page 1 --order pubdate` | `works detail --platform bilibili --target <BV号或视频URL>` |
|
|
186
|
+
| TikTok | 完整 | `tiktok web get-sec-user-id --url <url>`;用户名可用 `tiktok app v3 get-user-id-and-sec-user-id-by-username --username <username>` | `tiktok web fetch-user-profile --secUid <sec_user_id>`;补救:`tiktok app v3 handler-user-profile --sec-user-id <sec_user_id>` | `tiktok web fetch-user-post --secUid <sec_user_id> --count 20`;补救:`tiktok app v3 fetch-user-post-videos-v3 --sec-user-id <sec_user_id>` | `works detail --platform tiktok --target <itemId/share_url>` |
|
|
187
|
+
| YouTube | 完整 | `youtube web-v2 get-channel-id --channel-url <url>` | `youtube web get-channel-info --channel-id <channel_id>` | `youtube web-v2 get-channel-videos --channel-id <channel_id> --need-format true` | `works detail --platform youtube --target <video_id>` |
|
|
188
|
+
| Twitter/X | 基本完整 | 当前未发现稳定 URL 转 screen_name 命令;可从 `x.com/<screen_name>` 或 `twitter.com/<screen_name>` 解析 | `twitter web fetch-user-profile --screen-name <screen_name>` | `twitter web fetch-user-post-tweet --screen-name <screen_name>`;媒体用 `twitter web fetch-user-media --screen-name <screen_name>` | `works detail --platform twitter --target <tweet_id>` |
|
|
189
|
+
|
|
190
|
+
## 历史快照与变化对比
|
|
191
|
+
|
|
192
|
+
保存本次快照前,先在缓存目录里查找同平台、同帐号最近一个快照:
|
|
193
|
+
|
|
194
|
+
1. 如果存在历史快照,对比粉丝数、获赞数、发布数、作品数量、新增作品、单作品互动变化。
|
|
195
|
+
2. 如果不存在历史快照,说明这是首次快照,只输出当前基线。
|
|
196
|
+
3. 不要把接口返回的 `new_like_cnt/new_fans_cnt` 当作唯一变化依据;优先用本地历史快照计算差值。
|
|
197
|
+
|
|
198
|
+
## HTML 可视化
|
|
199
|
+
|
|
200
|
+
完成监控数据汇总后,必须询问:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
是否需要我把本次帐号监控数据生成 HTML 可视化汇总?
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
只有用户明确确认后,才读取并使用 `HTML报告生成` Skill。不要默认生成 HTML。
|
|
207
|
+
|
|
208
|
+
## 输出要求
|
|
209
|
+
|
|
210
|
+
最终回复保持简洁,包含:
|
|
211
|
+
|
|
212
|
+
- 平台和帐号标识。
|
|
213
|
+
- 主页资料摘要。
|
|
214
|
+
- 作品采集数量。
|
|
215
|
+
- 关键增长或变化。
|
|
216
|
+
- 快照保存路径。
|
|
217
|
+
- 是否需要 HTML 可视化汇总的问题。
|
|
218
|
+
|
|
219
|
+
失败时说明卡在哪一步、调用了什么命令、返回的 `error.code` 和 `error.message`。不要泄露 token、Authorization header、cookie 或完整隐私字段。
|
|
@@ -25,12 +25,19 @@ description: 仅当用户明确要求使用本地音视频转文字、本地转
|
|
|
25
25
|
|
|
26
26
|
本 Skill 的脚本目录为当前 Skill 目录下的 `scripts/`。
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
默认运行目录:
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
- Windows:`%APPDATA%/YuanFlow/runtime_tools/local-transcribe`
|
|
31
|
+
- 其它系统:`~/.yuanflow/runtime_tools/local-transcribe`
|
|
32
|
+
|
|
33
|
+
默认子目录:
|
|
34
|
+
|
|
35
|
+
- 模型保存目录:`<运行目录>/models`
|
|
36
|
+
- 任务缓存目录:`<运行目录>/cache`
|
|
37
|
+
- 抽取音频目录:`<运行目录>/cache/audio`
|
|
38
|
+
- 转写文本目录:`<运行目录>/cache/transcripts`
|
|
39
|
+
|
|
40
|
+
虚拟环境仍创建在当前 Skill 的 `scripts/.venv`,不要全局安装依赖。
|
|
34
41
|
|
|
35
42
|
在 YuanFlow 程序内置环境中,`skill_read` 返回的 `config.managed_skill_dir` 是当前 Skill 的真实目录。执行脚本时优先以这个目录为基准:
|
|
36
43
|
|
|
@@ -38,14 +45,14 @@ description: 仅当用户明确要求使用本地音视频转文字、本地转
|
|
|
38
45
|
cd "<config.managed_skill_dir>\scripts"
|
|
39
46
|
```
|
|
40
47
|
|
|
41
|
-
不要把模型下载到用户桌面、项目根目录或系统临时目录。不要把模型文件打包进 Skill 或 npm 包。
|
|
48
|
+
不要把模型下载到用户桌面、项目根目录或系统临时目录。不要把模型文件打包进 Skill 或 npm 包。Windows 下 FunASR/SentencePiece 对中文路径不稳定,所以不要强制把模型放到中文 Skill 安装目录下。
|
|
42
49
|
|
|
43
50
|
## 首次使用模型下载规则
|
|
44
51
|
|
|
45
52
|
开始转写前先检查模型目录是否已经存在:
|
|
46
53
|
|
|
47
|
-
-
|
|
48
|
-
-
|
|
54
|
+
- `<运行目录>/models/SenseVoiceSmall`
|
|
55
|
+
- `<运行目录>/models/fsmn-vad`
|
|
49
56
|
|
|
50
57
|
如果这两个目录都存在且不为空,直接执行后续任务。
|
|
51
58
|
|
|
@@ -54,7 +61,7 @@ cd "<config.managed_skill_dir>\scripts"
|
|
|
54
61
|
- SenseVoice:`iic/SenseVoiceSmall`
|
|
55
62
|
- VAD:`iic/speech_fsmn_vad_zh-cn-16k-common-pytorch`
|
|
56
63
|
|
|
57
|
-
下载由 `modelscope.snapshot_download()` 完成,保存到
|
|
64
|
+
下载由 `modelscope.snapshot_download()` 完成,保存到 `<运行目录>/models`。下载完成后继续转写。
|
|
58
65
|
|
|
59
66
|
## 执行流程
|
|
60
67
|
|
|
@@ -120,8 +127,8 @@ Set-Location -LiteralPath '<Skill目录>\scripts'; if (-not (Test-Path -LiteralP
|
|
|
120
127
|
| 参数 | 说明 |
|
|
121
128
|
| --- | --- |
|
|
122
129
|
| `input_path` | 音频文件、视频文件或目录。 |
|
|
123
|
-
| `--cache-root` | 缓存目录,默认
|
|
124
|
-
| `--models-root` | 模型目录,默认
|
|
130
|
+
| `--cache-root` | 缓存目录,默认 `<运行目录>/cache`。 |
|
|
131
|
+
| `--models-root` | 模型目录,默认 `<运行目录>/models`。 |
|
|
125
132
|
| `--recursive` | 输入为目录时递归扫描。 |
|
|
126
133
|
| `--device` | `auto`、`cpu`、`cuda:0` 等,默认 `auto`。 |
|
|
127
134
|
| `--language` | `zh`、`en`、`yue`、`ja`、`ko`、`auto`,默认 `auto`。 |
|
|
@@ -152,10 +159,10 @@ Set-Location -LiteralPath '<Skill目录>\scripts'; if (-not (Test-Path -LiteralP
|
|
|
152
159
|
|
|
153
160
|
只有用户明确要求删除缓存或模型文件时,才可以删除:
|
|
154
161
|
|
|
155
|
-
-
|
|
156
|
-
-
|
|
162
|
+
- 缓存目录:`<运行目录>/cache`
|
|
163
|
+
- 模型目录:`<运行目录>/models`
|
|
157
164
|
|
|
158
|
-
|
|
165
|
+
删除前必须确认目标路径位于 YuanFlow 本地转写运行目录下,不能删除其它项目目录、用户桌面目录、其它 Skill 或系统目录。
|
|
159
166
|
|
|
160
167
|
## 输出要求
|
|
161
168
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
+
import os
|
|
4
5
|
import re
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import Iterable
|
|
@@ -31,6 +32,13 @@ def ensure_dir(path: Path) -> Path:
|
|
|
31
32
|
return path
|
|
32
33
|
|
|
33
34
|
|
|
35
|
+
def default_runtime_root() -> Path:
|
|
36
|
+
appdata = os.environ.get("APPDATA")
|
|
37
|
+
if appdata:
|
|
38
|
+
return Path(appdata) / "YuanFlow" / "runtime_tools" / "local-transcribe"
|
|
39
|
+
return Path.home() / ".yuanflow" / "runtime_tools" / "local-transcribe"
|
|
40
|
+
|
|
41
|
+
|
|
34
42
|
def write_json(path: Path, data: object) -> Path:
|
|
35
43
|
ensure_parent(path)
|
|
36
44
|
path.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
from common.media import extract_audio
|
|
7
7
|
from common.sensevoice import build_model
|
|
8
8
|
from common.sensevoice import clean_transcript
|
|
9
|
+
from common.utils import default_runtime_root
|
|
9
10
|
from common.utils import ensure_dir
|
|
10
11
|
from common.utils import is_audio_file
|
|
11
12
|
from common.utils import is_video_file
|
|
@@ -15,8 +16,9 @@ from common.utils import write_text
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
DEFAULT_RUNTIME_ROOT = default_runtime_root()
|
|
20
|
+
DEFAULT_CACHE_ROOT = DEFAULT_RUNTIME_ROOT / "cache"
|
|
21
|
+
DEFAULT_MODELS_ROOT = DEFAULT_RUNTIME_ROOT / "models"
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
def prepare_audio(
|
package/src/cli.js
CHANGED
|
@@ -456,7 +456,15 @@ function buildBodyFromPositionals(endpoint, rest, options) {
|
|
|
456
456
|
return { url: rest[0] };
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
const body = {};
|
|
460
|
+
for (const item of endpoint.queryParams || []) {
|
|
461
|
+
const flagName = item.name.replace(/_/g, '-');
|
|
462
|
+
const value = options.named?.[flagName] ?? options.named?.[item.name];
|
|
463
|
+
if (value !== undefined) {
|
|
464
|
+
body[item.name] = value;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return body;
|
|
460
468
|
}
|
|
461
469
|
|
|
462
470
|
function parseOptions(args) {
|