minimal-agent 0.1.9 → 0.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.
Files changed (97) hide show
  1. package/README.md +383 -122
  2. package/package.json +19 -12
  3. package/plugins/HOW-TO-WRITE-A-PLUGIN.md +186 -0
  4. package/plugins/ralph-wiggum/commands/ralph-loop.md +6 -16
  5. package/plugins/ralph-wiggum/plugin.js +205 -0
  6. package/plugins/ralph-wiggum/src/goalState.js +260 -0
  7. package/plugins/ralph-wiggum/src/sentinels.js +21 -0
  8. package/plugins/ralph-wiggum/src/stopHookRunner.js +104 -0
  9. package/plugins/ralph-wiggum/src/verificationGate.js +202 -0
  10. package/plugins/workflow-runner/.claude-plugin/plugin.json +5 -0
  11. package/plugins/workflow-runner/commands/workflow.md +15 -0
  12. package/plugins/workflow-runner/commands/workflows.md +8 -0
  13. package/plugins/workflow-runner/plugin.js +36 -0
  14. package/plugins/workflow-runner/src/expressions.js +369 -0
  15. package/plugins/workflow-runner/src/index.js +174 -0
  16. package/plugins/workflow-runner/src/loader.js +183 -0
  17. package/plugins/workflow-runner/src/runner.js +290 -0
  18. package/plugins/workflow-runner/src/stepExecutors/assert.js +28 -0
  19. package/plugins/workflow-runner/src/stepExecutors/llm.js +44 -0
  20. package/plugins/workflow-runner/src/stepExecutors/skill.js +103 -0
  21. package/plugins/workflow-runner/src/stepExecutors/tool.js +35 -0
  22. package/plugins/workflow-runner/src/types.js +59 -0
  23. package/plugins/workflow-runner/src/workflowState.js +46 -0
  24. package/skills/image-gen-openrouter/SKILL.md +121 -0
  25. package/skills/subtitle-srt/SKILL.md +134 -0
  26. package/skills/tts-zh/SKILL.md +137 -0
  27. package/skills/video-compose/SKILL.md +139 -0
  28. package/src/bootstrap/cwdArg.js +22 -0
  29. package/src/bootstrap/workingDir.js +31 -0
  30. package/src/cli/configWizard.js +272 -0
  31. package/src/cli/print.js +192 -0
  32. package/src/config/configFile.js +78 -0
  33. package/src/config.js +118 -0
  34. package/src/context/compact.js +357 -0
  35. package/src/context/microCompactLite.js +151 -0
  36. package/src/context/persistContext.js +109 -0
  37. package/src/context/reactiveCompact.js +121 -0
  38. package/src/context/sessionPath.js +58 -0
  39. package/src/context/snipCompact.js +112 -0
  40. package/src/context/tokenCounter.js +66 -0
  41. package/src/llm/client.js +182 -0
  42. package/src/loop.js +230 -0
  43. package/src/main.js +116 -0
  44. package/src/plugin-sdk.js +24 -0
  45. package/src/plugins/commandRouter.js +169 -0
  46. package/src/plugins/hookEngine.js +258 -0
  47. package/src/plugins/pluginApi.js +23 -0
  48. package/src/plugins/pluginLoader.js +71 -0
  49. package/src/plugins/pluginRunner.js +65 -0
  50. package/src/plugins/transcript.js +171 -0
  51. package/src/prompts/projectInstructions.js +48 -0
  52. package/src/prompts/skillList.js +126 -0
  53. package/src/prompts/system.js +155 -0
  54. package/src/session/runTurn.js +41 -0
  55. package/src/session/sessionState.js +19 -0
  56. package/src/tools/bash/bash.js +352 -0
  57. package/src/tools/bash/semantics.js +85 -0
  58. package/src/tools/bash/warnings.js +98 -0
  59. package/src/tools/edit/edit.js +253 -0
  60. package/src/tools/edit/multi-edit.js +155 -0
  61. package/src/tools/glob/glob.js +97 -0
  62. package/src/tools/grep/grep.js +185 -0
  63. package/src/tools/grep/rgPath.js +173 -0
  64. package/src/tools/index.js +94 -0
  65. package/src/tools/read/read.js +209 -0
  66. package/src/tools/shared/fileState.js +61 -0
  67. package/src/tools/shared/fileUtils.js +281 -0
  68. package/src/tools/shared/schemas.js +16 -0
  69. package/src/tools/types.js +21 -0
  70. package/src/tools/webbrowser/browser.js +55 -0
  71. package/src/tools/webbrowser/webbrowser.js +194 -0
  72. package/src/tools/webfetch/preapproved.js +267 -0
  73. package/src/tools/webfetch/webfetch.js +317 -0
  74. package/src/tools/websearch/websearch.js +161 -0
  75. package/src/tools/write/write.js +125 -0
  76. package/src/types/turndown.d.ts +23 -0
  77. package/src/types.js +16 -0
  78. package/src/ui/App.js +37 -0
  79. package/src/ui/InputBox.js +240 -0
  80. package/src/ui/MessageList.js +28 -0
  81. package/src/ui/Root.js +70 -0
  82. package/src/ui/StatusLine.js +41 -0
  83. package/src/ui/ToolStatus.js +11 -0
  84. package/src/ui/hooks/useChat.js +234 -0
  85. package/src/ui/hooks/usePasteHandler.js +137 -0
  86. package/src/ui/hooks/useTextBuffer.js +55 -0
  87. package/src/ui/hooks/useTokenUsage.js +30 -0
  88. package/src/ui/textBuffer.js +217 -0
  89. package/src/utils/packageRoot.js +37 -0
  90. package/src/utils/resourcePaths.js +49 -0
  91. package/src/utils/zodToJson.js +29 -0
  92. package/workflows/book-review-short.yaml +99 -0
  93. package/workflows/e2e-write-greet.yaml +27 -0
  94. package/workflows/schema.json +74 -0
  95. package/workflows/youtube-shorts.yaml +171 -0
  96. package/dist/main.js +0 -5936
  97. package/plugins/ralph-wiggum/scripts/setup-ralph-loop.sh +0 -203
@@ -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 }