@ww_nero/skills 3.2.0 → 3.3.0
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/assets/ppt_prompt.txt +25 -0
- package/assets/video_prompt.txt +174 -0
- package/index.js +29 -30
- package/package.json +1 -1
- package/assets/guide.json +0 -10
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
制作PPT的完整步骤如下(可根据当前实际状态,跳过部分已经完成的环节):
|
|
2
|
+
|
|
3
|
+
1. **规划PPT内容**,存储到markdown文件中:
|
|
4
|
+
- 每页Slide的规划需要包含:内容、布局方式、插图(只有用户明确提出要求时才添加插图)
|
|
5
|
+
- 不同页面应尽可能使用不同的布局方式,避免过于单调,可适当使用图表来呈现信息,例如折线图、柱状图、饼状图等;各正文页面标题样式、背景和文字色调**必须保持一致**。
|
|
6
|
+
- 如果用户未明确提出要求,则页面默认比例为宽1280px、高720px,默认背景为弱渐变的浅灰蓝(#F2F4F7 → #FCFCFC),现代科技感、扁平化风格。
|
|
7
|
+
- 如果需要插入图片,则按照以下方式:
|
|
8
|
+
- 收集图片素材,优先使用用户提供的图片;如未提供,则使用图像生成工具生成合适的图片
|
|
9
|
+
- 将图片素材保存到`images`文件夹中,使用内容和宽高比例作为图片名称,例如`main_background_16_9.png`表示该图片是主背景图,宽高比为16:9;对于用户提供的图片素材,可调用工具解读图片内容
|
|
10
|
+
|
|
11
|
+
2. **通过SVG代码实现Slides的排版**:
|
|
12
|
+
- 如需Image,统一使用`rect`或`circle`元素进行占位(必须符合图片宽高比例),占位元素应设置合适的位置,可添加浅色填充或边框以便预览时识别
|
|
13
|
+
- 如需Icon,优先使用Emoji,其次使用纯SVG代码的方式绘制
|
|
14
|
+
- 如需Chart,如折线图、柱状图等,应使用纯SVG代码的方式绘制,而不是使用图片占位元素
|
|
15
|
+
- 每页Slide的保存在一个独立HTML文件中,例如`slide_01.html`、`slide_02.html`等。
|
|
16
|
+
|
|
17
|
+
3. **把SVG转成PPTX文件**:
|
|
18
|
+
- 参考snippet工具中提供的`svg_to_pptx`代码示例,编写临时的python脚本,把svg转化成可编辑的pptx文件,不要遗漏任何元素(例如线条、装饰等)
|
|
19
|
+
- 转化的方法是把svg代码转化成使用python创建pptx中可操作元素的代码,示例中的创建元素的工具函数均可以使用
|
|
20
|
+
- 同时对于每个slide务必创建单独的create_slide函数,例如`create_slide1`、`create_slide2`等
|
|
21
|
+
- **不要使用`BeautifulSoup`这种通用的解析元素的方式,而是逐个元素从svg代码转化为python创建元素的代码**
|
|
22
|
+
- 转换过程中,需要把图片占位元素替换成前面准备的图片素材
|
|
23
|
+
- 每个页面编写一个单独的python脚本进行转化,最后再写一个python脚本,把所有单页的pptx文件合并成一个。
|
|
24
|
+
|
|
25
|
+
**注意**:完成后**需要保留**规划文档、html页面文件和python转化脚本,方便进一步根据反馈进行修改
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
视频处理的技巧指导
|
|
2
|
+
|
|
3
|
+
本指南涵盖常见的视频处理场景,所有操作均基于 ffmpeg 命令行工具实现。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. 添加字幕
|
|
8
|
+
|
|
9
|
+
完整流程如下:
|
|
10
|
+
|
|
11
|
+
**步骤 1:提取音频**
|
|
12
|
+
```bash
|
|
13
|
+
ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**步骤 2:语音转字幕**
|
|
17
|
+
使用 ASR 工具(如 mcp__media__asr)将音频转换为 SRT 字幕文件。
|
|
18
|
+
|
|
19
|
+
**步骤 3:翻译字幕(可选)**
|
|
20
|
+
如需翻译字幕,可在此步骤对 SRT 文件内容进行语言转换。
|
|
21
|
+
|
|
22
|
+
**步骤 4:移除原有字幕(如有)**
|
|
23
|
+
```bash
|
|
24
|
+
# 查看视频流信息
|
|
25
|
+
ffprobe -i input.mp4
|
|
26
|
+
|
|
27
|
+
# 移除内嵌字幕流(保留视频和音频)
|
|
28
|
+
ffmpeg -i input.mp4 -map 0:v -map 0:a -c copy output_no_sub.mp4
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**步骤 5:烧录字幕到视频**
|
|
32
|
+
```bash
|
|
33
|
+
# 软字幕(可关闭)
|
|
34
|
+
ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text output.mp4
|
|
35
|
+
|
|
36
|
+
# 硬字幕(烧录到画面)
|
|
37
|
+
ffmpeg -i input.mp4 -vf "subtitles=subtitle.srt:force_style='FontSize=24,FontName=Microsoft YaHei'" -c:a copy output.mp4
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 2. 视频剪辑
|
|
43
|
+
|
|
44
|
+
**截取片段**
|
|
45
|
+
```bash
|
|
46
|
+
# 从第 10 秒开始,截取 30 秒
|
|
47
|
+
ffmpeg -i input.mp4 -ss 00:00:10 -t 00:00:30 -c copy output.mp4
|
|
48
|
+
|
|
49
|
+
# 精确截取(需重新编码)
|
|
50
|
+
ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:40 -c:v libx264 -c:a aac output.mp4
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**移除片段**
|
|
54
|
+
```bash
|
|
55
|
+
# 保留 0-10s 和 20s-结尾,移除中间 10-20s
|
|
56
|
+
ffmpeg -i input.mp4 -vf "select='not(between(t,10,20))',setpts=N/FRAME_RATE/TB" -af "aselect='not(between(t,10,20))',asetpts=N/SR/TB" output.mp4
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**合并视频**
|
|
60
|
+
```bash
|
|
61
|
+
# 创建文件列表 files.txt:
|
|
62
|
+
# file 'part1.mp4'
|
|
63
|
+
# file 'part2.mp4'
|
|
64
|
+
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**调整速度**
|
|
68
|
+
```bash
|
|
69
|
+
# 2 倍速
|
|
70
|
+
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -filter:a "atempo=2.0" output.mp4
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 3. 视频理解
|
|
76
|
+
|
|
77
|
+
对于视频内容理解,推荐采用 **抽帧 + 图像理解** 的方式:
|
|
78
|
+
|
|
79
|
+
**适用范围**
|
|
80
|
+
- 仅适用于短视频(小于 1 分钟)
|
|
81
|
+
- 建议每 5 秒抽取 1 帧
|
|
82
|
+
|
|
83
|
+
**抽帧命令**
|
|
84
|
+
```bash
|
|
85
|
+
# 每 5 秒抽取 1 帧
|
|
86
|
+
ffmpeg -i input.mp4 -vf "fps=1/5" frame_%03d.png
|
|
87
|
+
|
|
88
|
+
# 指定起止时间抽帧
|
|
89
|
+
ffmpeg -i input.mp4 -ss 00:00:00 -to 00:01:00 -vf "fps=1/5" frame_%03d.png
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**理解流程**
|
|
93
|
+
1. 使用上述命令抽取关键帧
|
|
94
|
+
2. 使用图像理解工具(如视觉模型)逐帧分析
|
|
95
|
+
3. 综合各帧信息得出视频内容理解
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 4. 视频生成
|
|
100
|
+
|
|
101
|
+
视频生成需要专业的 AI 视频生成工具,建议使用:
|
|
102
|
+
|
|
103
|
+
- **可灵 (Kling)** - 快手旗下视频生成工具
|
|
104
|
+
- **Sora** - OpenAI 视频生成模型
|
|
105
|
+
- **通义万相** - 阿里云视频生成工具
|
|
106
|
+
- **Runway Gen-3** - 专业视频生成平台
|
|
107
|
+
|
|
108
|
+
当前工具链不支持视频生成功能。
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 5. 视频内容编辑
|
|
113
|
+
|
|
114
|
+
**重要提示:不支持逐帧编辑**
|
|
115
|
+
|
|
116
|
+
如果需要对视频内容进行逐帧编辑(如使用图像编辑工具修改每一帧),成本极高,不建议执行。原因:
|
|
117
|
+
- 一分钟 30fps 视频有 1800 帧
|
|
118
|
+
- 逐帧编辑耗时耗力,效果难以保证一致性
|
|
119
|
+
|
|
120
|
+
**替代方案**
|
|
121
|
+
- 使用专业视频编辑软件:Adobe Premiere、DaVinci Resolve、Final Cut Pro
|
|
122
|
+
- 使用 AI 视频编辑工具:Runway、Pika Labs
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 6. 其他常用操作
|
|
127
|
+
|
|
128
|
+
**格式转换**
|
|
129
|
+
```bash
|
|
130
|
+
ffmpeg -i input.avi -c:v libx264 -c:a aac output.mp4
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**调整分辨率**
|
|
134
|
+
```bash
|
|
135
|
+
ffmpeg -i input.mp4 -vf "scale=1920:1080" -c:a copy output.mp4
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**提取视频(无音频)**
|
|
139
|
+
```bash
|
|
140
|
+
ffmpeg -i input.mp4 -an -c:v copy output.mp4
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**添加/替换音频**
|
|
144
|
+
```bash
|
|
145
|
+
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**生成 GIF**
|
|
149
|
+
```bash
|
|
150
|
+
ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos" -t 5 output.gif
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**旋转视频**
|
|
154
|
+
```bash
|
|
155
|
+
# 顺时针旋转 90 度
|
|
156
|
+
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 能力边界说明
|
|
162
|
+
|
|
163
|
+
**可以执行的操作**
|
|
164
|
+
- 所有基于 ffmpeg 的视频处理操作
|
|
165
|
+
- 结合 ASR 实现字幕生成
|
|
166
|
+
- 抽帧后进行图像分析
|
|
167
|
+
|
|
168
|
+
**无法执行的操作**
|
|
169
|
+
- 视频生成(建议使用专业工具)
|
|
170
|
+
- 逐帧内容编辑(成本过高)
|
|
171
|
+
- 复杂特效制作(建议使用 After Effects 等)
|
|
172
|
+
- 实时视频处理
|
|
173
|
+
|
|
174
|
+
如遇到无法实现的需求,建议使用更专业的视频处理工具。
|
package/index.js
CHANGED
|
@@ -82,7 +82,14 @@ const loadJson = (filename) => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const SNIPPETS = loadJson('snippets.json');
|
|
85
|
-
|
|
85
|
+
|
|
86
|
+
const loadText = (filename) => {
|
|
87
|
+
const filePath = path.join(ASSETS_ROOT, filename);
|
|
88
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const PPT_PROMPT = loadText('ppt_prompt.txt');
|
|
92
|
+
const VIDEO_PROMPT = loadText('video_prompt.txt');
|
|
86
93
|
|
|
87
94
|
const buildSnippet = (title, workingDirectory) => {
|
|
88
95
|
const entry = SNIPPETS[title];
|
|
@@ -109,19 +116,6 @@ const buildSnippet = (title, workingDirectory) => {
|
|
|
109
116
|
return lines.join('\n');
|
|
110
117
|
};
|
|
111
118
|
|
|
112
|
-
const buildGuide = (title) => {
|
|
113
|
-
const entry = GUIDES[title];
|
|
114
|
-
if (!entry) {
|
|
115
|
-
const supported = Object.keys(GUIDES).join(', ');
|
|
116
|
-
throw new Error(`title 仅支持: ${supported}`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const lines = [];
|
|
120
|
-
lines.push(`【${entry.title}】技能指导`);
|
|
121
|
-
lines.push(entry.content);
|
|
122
|
-
|
|
123
|
-
return lines.join('\n');
|
|
124
|
-
};
|
|
125
119
|
|
|
126
120
|
const listTools = () => ({
|
|
127
121
|
tools: [
|
|
@@ -133,7 +127,7 @@ const listTools = () => ({
|
|
|
133
127
|
properties: {
|
|
134
128
|
working_directory: {
|
|
135
129
|
type: 'string',
|
|
136
|
-
description: '
|
|
130
|
+
description: '工作目录的绝对路径,示例脚本文件将保存到此目录'
|
|
137
131
|
},
|
|
138
132
|
title: {
|
|
139
133
|
type: 'string',
|
|
@@ -145,24 +139,27 @@ const listTools = () => ({
|
|
|
145
139
|
}
|
|
146
140
|
},
|
|
147
141
|
{
|
|
148
|
-
name: '
|
|
149
|
-
description: '
|
|
142
|
+
name: 'make_ppt',
|
|
143
|
+
description: '制作PPT的全流程指导说明及注意事项',
|
|
150
144
|
inputSchema: {
|
|
151
145
|
type: 'object',
|
|
152
|
-
properties: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
146
|
+
properties: {},
|
|
147
|
+
required: []
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'process_video',
|
|
152
|
+
description: '视频处理的技巧指导',
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {},
|
|
156
|
+
required: []
|
|
160
157
|
}
|
|
161
158
|
}
|
|
162
159
|
]
|
|
163
160
|
});
|
|
164
161
|
|
|
165
|
-
const server = new Server({ name: 'skills', version: '3.
|
|
162
|
+
const server = new Server({ name: 'skills', version: '3.3.0' }, { capabilities: { tools: {} } });
|
|
166
163
|
|
|
167
164
|
server.setRequestHandler(ListToolsRequestSchema, async () => listTools());
|
|
168
165
|
|
|
@@ -179,10 +176,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
179
176
|
return { content: [{ type: 'text', text: result }] };
|
|
180
177
|
}
|
|
181
178
|
|
|
182
|
-
if (name === '
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
if (name === 'make_ppt') {
|
|
180
|
+
return { content: [{ type: 'text', text: PPT_PROMPT }] };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (name === 'process_video') {
|
|
184
|
+
return { content: [{ type: 'text', text: VIDEO_PROMPT }] };
|
|
186
185
|
}
|
|
187
186
|
|
|
188
187
|
return { content: [{ type: 'text', text: `未知工具: ${name}` }], isError: true };
|
package/package.json
CHANGED
package/assets/guide.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"convert_doc_types": {
|
|
3
|
-
"title": "转化文档类型",
|
|
4
|
-
"content": "执行文档类型转化任务(如 PPTX、PDF、DOCX、HTML、PNG 等格式互转)时,可参考以下方法:\n\n## 方法一:使用命令行工具(推荐用于简单场景)\n\n以下工具均已安装,可直接在终端调用:\n\n- **LibreOffice (soffice)**:支持 Office 文档互转\n - PPTX → PDF: `soffice --headless --convert-to pdf input.pptx --outdir ./output`\n - DOCX → PDF: `soffice --headless --convert-to pdf input.docx --outdir ./output`\n - XLSX → PDF: `soffice --headless --convert-to pdf input.xlsx --outdir ./output`\n\n- **Pandoc**:支持多种文档格式转换\n - Markdown → DOCX: `pandoc input.md -o output.docx`\n - Markdown → PDF(中文): `pandoc input.md -o output.pdf --pdf-engine=xelatex -V CJKmainfont=\"Microsoft YaHei\"`\n - HTML → Markdown: `pandoc input.html -o output.md`\n\n- **LaTeX (pdflatex/xelatex)**:用于高质量 PDF 生成\n - TEX → PDF: `xelatex input.tex`\n\n## 方法二:编写临时 Python 脚本(推荐用于复杂场景)\n\n参考 `snippet` 工具中提供的转化脚本示例(已验证正确性),编写临时 Python 脚本:\n\n| 转化类型 | snippet 名称 | 说明 |\n|---------|-------------|------|\n| HTML → PNG | `html_to_png` | 使用 Playwright 渲染并截图 |\n| PDF → PNG | `pdf_to_png` | 使用 pdf2image 分页转换 |\n| PPTX → PNG | `pptx_to_png` | 使用 LibreOffice + pdf2image |\n| SVG → PPTX | `svg_to_pptx` | 转化为可编辑的 PPTX 元素 |\n| STEP → STL | `step_to_stl` | 使用 pythonocc-core 转换 |\n| 合并 STL | `combine_stls` | 使用 gmsh 合并多个 STL |\n\n调用示例:使用 `snippet` 工具获取参考代码,如 `snippet({ title: \"pdf_to_png\" })`\n\n## 解读 PPTX 或 PDF 文档\n\n当用户需要解读 PPTX 或 PDF 文档内容时:\n1. 编写临时 Python 脚本,将 PPTX/PDF 转化为 PNG 图片\n2. 对生成的图片进行视觉分析或内容解读\n3. 完成后删除临时脚本和中间文件\n\n## 注意事项\n\n- 临时脚本执行完成后应删除,除非用户明确要求保留\n- Python 环境已全局安装 `playwright`、`pdf2image`、`python-pptx`、`Pillow`、`pythonocc-core`、`gmsh` 等常用库\n- 如需其他库,可使用 `pip install` 安装"
|
|
5
|
-
},
|
|
6
|
-
"make_ppt": {
|
|
7
|
-
"title": "制作PPT",
|
|
8
|
-
"content": "制作PPT的完整步骤如下(可根据当前实际状态,跳过部分已经完成的环节):\n\n1. **规划PPT内容**,存储到markdown文件中:\n - 每页Slide的规划需要包含:内容、布局方式、插图(只有用户明确提出要求时才添加插图)\n - 不同页面应尽可能使用不同的布局方式,避免过于单调,可适当使用图表来呈现信息,例如折线图、柱状图、饼状图等;各正文页面标题样式、背景和文字色调**必须保持一致**。\n - 如果用户未明确提出要求,则页面默认比例为宽1280px、高720px,默认背景为弱渐变的浅灰蓝(#F2F4F7 → #FCFCFC),现代科技感、扁平化风格。\n - 如果需要插入图片,则按照以下方式:\n - 收集图片素材,优先使用用户提供的图片;如未提供,则使用图像生成工具生成合适的图片\n - 将图片素材保存到`images`文件夹中,使用内容和宽高比例作为图片名称,例如`main_background_16_9.png`表示该图片是主背景图,宽高比为16:9;对于用户提供的图片素材,可调用工具解读图片内容\n\n2. **通过SVG代码实现Slides的排版**:\n - 如需Image,统一使用`rect`或`circle`元素进行占位(必须符合图片宽高比例),占位元素应设置合适的位置,可添加浅色填充或边框以便预览时识别\n - 如需Icon,优先使用Emoji,其次使用纯SVG代码的方式绘制\n - 如需Chart,如折线图、柱状图等,应使用纯SVG代码的方式绘制,而不是使用图片占位元素\n - 每页Slide的保存在一个独立HTML文件中,例如`slide_01.html`、`slide_02.html`等。\n\n3. **把SVG转成PPTX文件**:\n - 参考snippet工具中提供的`svg_to_pptx`代码示例,编写临时的python脚本,把svg转化成可编辑的pptx文件,不要遗漏任何元素(例如线条、装饰等)\n - 转化的方法是把svg代码转化成使用python创建pptx中可操作元素的代码,示例中的创建元素的工具函数均可以使用\n - 同时对于每个slide务必创建单独的create_slide函数,例如`create_slide1`、`create_slide2`等\n - **不要使用`BeautifulSoup`这种通用的解析元素的方式,而是逐个元素从svg代码转化为python创建元素的代码**\n - 转换过程中,需要把图片占位元素替换成前面准备的图片素材\n - 每个页面编写一个单独的python脚本进行转化,最后再写一个python脚本,把所有单页的pptx文件合并成一个。\n\n**注意**:完成后**需要保留**规划文档、html页面文件和python转化脚本,方便进一步根据反馈进行修改"
|
|
9
|
-
}
|
|
10
|
-
}
|