minimal-agent 0.1.9 → 0.2.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/README.md +405 -122
- package/dist/main.js +117 -738
- package/package.json +4 -2
- package/plugins/HOW-TO-WRITE-A-PLUGIN.md +186 -0
- package/plugins/ralph-wiggum/commands/ralph-loop.md +6 -16
- package/plugins/ralph-wiggum/plugin.ts +275 -0
- package/plugins/ralph-wiggum/src/goalState.ts +310 -0
- package/plugins/ralph-wiggum/src/sentinels.ts +24 -0
- package/plugins/ralph-wiggum/src/stopHookRunner.ts +136 -0
- package/plugins/ralph-wiggum/src/verificationGate.ts +252 -0
- package/plugins/ralph-wiggum/test/goalState.test.ts +410 -0
- package/plugins/ralph-wiggum/test/verificationGate.test.ts +122 -0
- package/plugins/workflow-runner/.claude-plugin/plugin.json +5 -0
- package/plugins/workflow-runner/commands/workflow.md +15 -0
- package/plugins/workflow-runner/commands/workflows.md +8 -0
- package/plugins/workflow-runner/plugin.ts +42 -0
- package/plugins/workflow-runner/src/expressions.ts +371 -0
- package/plugins/workflow-runner/src/index.ts +194 -0
- package/plugins/workflow-runner/src/loader.ts +193 -0
- package/plugins/workflow-runner/src/runner.ts +313 -0
- package/plugins/workflow-runner/src/stepExecutors/assert.ts +30 -0
- package/plugins/workflow-runner/src/stepExecutors/llm.ts +54 -0
- package/plugins/workflow-runner/src/stepExecutors/skill.ts +115 -0
- package/plugins/workflow-runner/src/stepExecutors/tool.ts +41 -0
- package/plugins/workflow-runner/src/types.ts +183 -0
- package/plugins/workflow-runner/src/workflowState.ts +65 -0
- package/plugins/workflow-runner/test/cli.e2e.test.ts +114 -0
- package/plugins/workflow-runner/test/e2e.test.ts +268 -0
- package/plugins/workflow-runner/test/expressions.test.ts +140 -0
- package/plugins/workflow-runner/test/fixtures/cli-e2e.yaml +27 -0
- package/plugins/workflow-runner/test/fixtures/hello-workflow.yaml +49 -0
- package/plugins/workflow-runner/test/graceful.test.ts +139 -0
- package/plugins/workflow-runner/test/loader.test.ts +216 -0
- package/plugins/workflow-runner/test/pluginRunner.isolation.test.ts +230 -0
- package/plugins/workflow-runner/test/runner.test.ts +511 -0
- package/skills/image-gen-openrouter/SKILL.md +121 -0
- package/skills/subtitle-srt/SKILL.md +134 -0
- package/skills/tts-zh/SKILL.md +137 -0
- package/skills/video-compose/SKILL.md +139 -0
- package/workflows/book-review-short.yaml +99 -0
- package/workflows/e2e-write-greet.yaml +27 -0
- package/workflows/schema.json +74 -0
- package/workflows/youtube-shorts.yaml +171 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
name: youtube-shorts
|
|
2
|
+
description: |
|
|
3
|
+
示例工作流:输入主题 → LLM 写 5 幕脚本 → OpenRouter 生图 ×5 → 中文 TTS ×5
|
|
4
|
+
→ ffmpeg 合成竖屏 mp4。
|
|
5
|
+
这是把 4 个通用 skill(image-gen-openrouter / tts-zh / subtitle-srt /
|
|
6
|
+
video-compose)组合的样例 —— 你可以在编辑器里改 inputs / 增删节点 / 换 skill
|
|
7
|
+
去做任意视频流水线(横屏长视频、广告片、教程片都行)。
|
|
8
|
+
version: "0.1"
|
|
9
|
+
|
|
10
|
+
inputs:
|
|
11
|
+
- name: topic
|
|
12
|
+
type: string
|
|
13
|
+
required: true
|
|
14
|
+
description: "视频主题(中文)"
|
|
15
|
+
- name: openrouter_key
|
|
16
|
+
type: string
|
|
17
|
+
required: false
|
|
18
|
+
description: "OpenRouter API key;不填则用 OPENROUTER_API_KEY 环境变量"
|
|
19
|
+
- name: aspect
|
|
20
|
+
type: enum
|
|
21
|
+
values: ["9:16", "16:9", "1:1", "4:5"]
|
|
22
|
+
default: "9:16"
|
|
23
|
+
description: "图片与视频宽高比"
|
|
24
|
+
- name: width
|
|
25
|
+
type: number
|
|
26
|
+
default: 1080
|
|
27
|
+
description: "视频输出宽度"
|
|
28
|
+
- name: height
|
|
29
|
+
type: number
|
|
30
|
+
default: 1920
|
|
31
|
+
description: "视频输出高度"
|
|
32
|
+
|
|
33
|
+
steps:
|
|
34
|
+
# ---------- 1. 用 LLM 写 5 幕脚本(强制 5 幕以便后续 loop 用静态数组) ----------
|
|
35
|
+
- id: write_script
|
|
36
|
+
llm: |
|
|
37
|
+
你是短视频文案策划。请为主题"${inputs.topic}"写一个 **正好 5 幕** 的竖屏短视频。
|
|
38
|
+
每一幕包含:
|
|
39
|
+
- text:一句 8-12 字的中文旁白
|
|
40
|
+
- image_prompt:一段 30-50 词的英文图片提示词,描述这一幕的画面
|
|
41
|
+
只输出一个 JSON 对象,结构严格如下,不要包裹在 ``` 里、不要任何额外解释:
|
|
42
|
+
{"scenes":[
|
|
43
|
+
{"text":"...","image_prompt":"..."},
|
|
44
|
+
...共 5 项...
|
|
45
|
+
]}
|
|
46
|
+
capture:
|
|
47
|
+
text: script_json_text
|
|
48
|
+
|
|
49
|
+
# ---------- 2. 把 LLM 输出落盘为 script.json ----------
|
|
50
|
+
- id: write_script_json
|
|
51
|
+
tool: Write
|
|
52
|
+
args:
|
|
53
|
+
file_path: "./assets/script.json"
|
|
54
|
+
content: "${script_json_text}"
|
|
55
|
+
|
|
56
|
+
# ---------- 3. 解析 script.json,拆出 prompts.txt / narrations.txt(每行一个) ----------
|
|
57
|
+
- id: parse_script
|
|
58
|
+
tool: Bash
|
|
59
|
+
args:
|
|
60
|
+
command: |
|
|
61
|
+
set -euo pipefail
|
|
62
|
+
mkdir -p ./assets ./out
|
|
63
|
+
jq -r '.scenes[].image_prompt' ./assets/script.json > ./assets/prompts.txt
|
|
64
|
+
jq -r '.scenes[].text' ./assets/script.json > ./assets/narrations.txt
|
|
65
|
+
# 把 narrations 转成 JSON 数组字符串,用于后续 subtitle-srt 调用
|
|
66
|
+
jq -c '[.scenes[].text]' ./assets/script.json > ./assets/narrations_json.txt
|
|
67
|
+
wc -l ./assets/prompts.txt ./assets/narrations.txt
|
|
68
|
+
capture:
|
|
69
|
+
content: parse_log
|
|
70
|
+
|
|
71
|
+
- id: assert_script_parsed
|
|
72
|
+
type: assert
|
|
73
|
+
condition: 'fileExists("./assets/prompts.txt") && fileExists("./assets/narrations.txt")'
|
|
74
|
+
onFail: "脚本解析失败:./assets/prompts.txt 或 ./assets/narrations.txt 不存在"
|
|
75
|
+
|
|
76
|
+
# ---------- 4. 生成 5 张配图(loop 静态数组 + 每轮先读对应一行 prompt) ----------
|
|
77
|
+
- id: gen_images
|
|
78
|
+
type: loop
|
|
79
|
+
over: "[0, 1, 2, 3, 4]"
|
|
80
|
+
as: i
|
|
81
|
+
do:
|
|
82
|
+
- id: read_prompt
|
|
83
|
+
tool: Bash
|
|
84
|
+
args:
|
|
85
|
+
command: "sed -n '$((${i}+1))p' ./assets/prompts.txt"
|
|
86
|
+
capture:
|
|
87
|
+
content: prompt_text
|
|
88
|
+
- id: gen_one_image
|
|
89
|
+
skill: image-gen-openrouter
|
|
90
|
+
input: 'prompt=${prompt_text} output=./assets/img_${i}.png aspect=${inputs.aspect} key=${inputs.openrouter_key}'
|
|
91
|
+
|
|
92
|
+
# ---------- 5. 生成 5 段 TTS 音频 ----------
|
|
93
|
+
- id: gen_audio
|
|
94
|
+
type: loop
|
|
95
|
+
over: "[0, 1, 2, 3, 4]"
|
|
96
|
+
as: i
|
|
97
|
+
do:
|
|
98
|
+
- id: read_narration
|
|
99
|
+
tool: Bash
|
|
100
|
+
args:
|
|
101
|
+
command: "sed -n '$((${i}+1))p' ./assets/narrations.txt"
|
|
102
|
+
capture:
|
|
103
|
+
content: narration_text
|
|
104
|
+
- id: gen_one_tts
|
|
105
|
+
skill: tts-zh
|
|
106
|
+
input: 'text=${narration_text} output=./assets/audio_${i}.mp3'
|
|
107
|
+
|
|
108
|
+
# ---------- 6. 探测各段音频时长,逗号串联 ----------
|
|
109
|
+
- id: probe_durations
|
|
110
|
+
tool: Bash
|
|
111
|
+
args:
|
|
112
|
+
command: |
|
|
113
|
+
set -euo pipefail
|
|
114
|
+
for f in $(ls ./assets/audio_*.mp3 | sort); do
|
|
115
|
+
ffprobe -v error -show_entries format=duration -of csv=p=0 "$f"
|
|
116
|
+
done | paste -sd, -
|
|
117
|
+
capture:
|
|
118
|
+
content: durations
|
|
119
|
+
|
|
120
|
+
# ---------- 7. 合并所有 TTS 段成一条音轨 ----------
|
|
121
|
+
- id: merge_audio
|
|
122
|
+
tool: Bash
|
|
123
|
+
args:
|
|
124
|
+
command: |
|
|
125
|
+
set -euo pipefail
|
|
126
|
+
LIST=/tmp/audio_concat.txt
|
|
127
|
+
: > "$LIST"
|
|
128
|
+
for f in $(ls ./assets/audio_*.mp3 | sort); do
|
|
129
|
+
echo "file '$(pwd)/${f}'" >> "$LIST"
|
|
130
|
+
done
|
|
131
|
+
ffmpeg -y -f concat -safe 0 -i "$LIST" -c copy ./assets/audio.mp3
|
|
132
|
+
ls -la ./assets/audio.mp3
|
|
133
|
+
|
|
134
|
+
# ---------- 8. 读 narrations_json(前面 parse_script 已写好),作 SRT 文本输入 ----------
|
|
135
|
+
- id: read_narrations_json
|
|
136
|
+
tool: Read
|
|
137
|
+
args:
|
|
138
|
+
file_path: "./assets/narrations_json.txt"
|
|
139
|
+
capture:
|
|
140
|
+
content: narrations_json
|
|
141
|
+
|
|
142
|
+
# ---------- 9. 生成 SRT 字幕 ----------
|
|
143
|
+
- id: make_srt
|
|
144
|
+
skill: subtitle-srt
|
|
145
|
+
input: 'texts=${narrations_json} durations=${durations} output=./assets/subs.srt'
|
|
146
|
+
|
|
147
|
+
# ---------- 10. 合成最终 mp4 ----------
|
|
148
|
+
- id: compose_video
|
|
149
|
+
skill: video-compose
|
|
150
|
+
input: 'images_glob=./assets/img_*.png audio=./assets/audio.mp3 srt=./assets/subs.srt output=./out/shorts.mp4 width=${inputs.width} height=${inputs.height}'
|
|
151
|
+
|
|
152
|
+
# ---------- 11. 守门 assert ----------
|
|
153
|
+
- id: verify_output
|
|
154
|
+
type: assert
|
|
155
|
+
condition: 'fileExists("./out/shorts.mp4")'
|
|
156
|
+
onFail: "最终视频 ./out/shorts.mp4 未生成,请检查 video-compose 日志"
|
|
157
|
+
|
|
158
|
+
__meta:
|
|
159
|
+
layout:
|
|
160
|
+
- { id: write_script, x: 100, y: 50 }
|
|
161
|
+
- { id: write_script_json, x: 100, y: 200 }
|
|
162
|
+
- { id: parse_script, x: 100, y: 350 }
|
|
163
|
+
- { id: assert_script_parsed, x: 100, y: 500 }
|
|
164
|
+
- { id: gen_images, x: 100, y: 650 }
|
|
165
|
+
- { id: gen_audio, x: 450, y: 650 }
|
|
166
|
+
- { id: probe_durations, x: 450, y: 850 }
|
|
167
|
+
- { id: merge_audio, x: 450, y: 1000 }
|
|
168
|
+
- { id: read_narrations_json, x: 100, y: 850 }
|
|
169
|
+
- { id: make_srt, x: 275, y: 1150 }
|
|
170
|
+
- { id: compose_video, x: 275, y: 1300 }
|
|
171
|
+
- { id: verify_output, x: 275, y: 1450 }
|