Skip to content
Back to search

Automated Video Generator

Transform text scripts into professional videos with AI voiceovers, stock footage, and Remotion rendering. Advanced features include direct filesystem access, environment management, and whitelisted command execution.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked yesterday

Check it deeper on your machine

Its scripts were only partly scanned.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/itsPremkumar/Automated-Video-Generator with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/itsPremkumar/Automated-Video-Generator'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/itspremkumar--automated-video-generator/badge.svg)](/listings/itspremkumar--automated-video-generator)

HTML

<a href="/listings/itspremkumar--automated-video-generator"><img src="/api/listings/itspremkumar--automated-video-generator/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Choose your path:

| Path | Time | Difficulty | For | | -------------------------------------------------- | ----- | ---------- | ------------- | | [Windows Desktop App](#windows-desktop-app) | 2 min | ★☆☆ | Everyone | | [One-Click Launcher](#one-click-launcher-windows) | 3 min | ★☆☆ | Windows users | | [Manual Setup](#manual-setup) | 5 min | ★★☆ | Developers | | [Docker](#docker) | 3 min | ★★☆ | DevOps | | [npm (MCP)](#npm-mcp-server) | 1 min | ★☆☆ | AI agents |

🎬 Your first video in 2 commands

No API key required to run — Openverse + free CC sources provide stock footage out of the box. Voiceover uses the vendored Voicebox backend (Kokoro by default) with Edge-TTS fallback; **the Kokoro backend needs a one-time setup** — point `VOICEBOX_PYTHON` at a torch/kokoro venv (e.g. `C:/one/voicebox/.venv/Scripts/python.exe`) or it auto-falls back to the built-in Edge-TTS/Kokoro engine. Encoding is automatic: **Windows uses `h264_mf`** (Media Foundation, fast) and other platforms use `libx264`; `--gpu` selects AMF/NVENC/QSV when present. **For best results set `PEXELS_API_KEY`** (free): Pexels is the recommended provider and is skipped in keyless mode, so keyless runs use lower-relevance free sources.

# 1. Install (one time)
npm install

# 2. Generate (reads input/scripts/input-scripts.json, writes output/<id>/<Title>.mp4)
npm run generate

That's it. The CLI reads `input/scripts/input-scripts.json` (a sample job is pre-included) and renders an MP4 with AI voiceover + stock visuals + burned-in captions. With the bundled sample, find it at `output/pre7_productivity_tip/One Simple Trick To Beat Procrastination.mp4`.

Prefer a GUI? Run `npm run dev` and open **http://localhost:3001** — paste a script, click **Generate Video**.

<div align="center"> <br/> <em>Real Voicebox-narrated video from the pipeline. Script → voiceover + stock media → MP4, fully local.</em> </div>

🪟 Windows Desktop App

**No Node.js, Python, or terminal required.**

Download the [latest Windows installer](https://github.com/itsPremkumar/Automated-Video-Generator/releases/latest), double-click, and the app opens the web portal automatically. Everything is bundled.

📜 One-Click Launcher (Windows)

.\Start-Automated-Video-Generator.bat

Or the PowerShell version:

.\Start-Automated-Video-Generator.ps1

The launcher auto-installs Node.js and Python (via `winget`), creates `.env`, installs dependencies, and opens the portal at `http://localhost:3001`.

🛠️ Manual Setup

**Prerequisites:** Node.js 18+, Python 3.8+, npm

# 1. Clone
git clone https://github.com/itsPremkumar/Automated-Video-Generator.git
cd Automated-Video-Generator

# 2. Install Node dependencies
npm install

# 3. Install Python voice engine
pip install -r requirements.txt

# 4. Configure environment
cp .env.example .env
# Edit .env — add PEXELS_API_KEY (free, get one at pexels.com/api)
# No API key? Set OPENVERSE_ENABLED=true (it's the default)

# 5. (Optional) Local AI generation — ComfyUI, CogVideoX, Real-ESRGAN, rembg
#    Install the AI providers you want (all optional, all free, all offline):
#    pip install diffusers transformers accelerate torch        # CogVideoX (T2V)
#    pip install realesrgan basicsr                            # Real-ESRGAN (upscale)
#    pip install rembg                                         # Background removal
#    git clone https://github.com/comfyanonymous/ComfyUI.git  # ComfyUI (image/I2V)

# 6. Start the web portal
npm run dev

Open **http://localhost:3001/** — paste a script, click generate, and watch it render.

🐳 Docker

Pre-built image (built + scanned by CI, pushed to GHCR):

docker run -p 3001:3001 \
  -v "$(pwd)/input:/app/input" \
  -v "$(pwd)/output:/app/output" \

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/plugin.json · Manifest · 60 lines
  1. {
  2. "name": "Automated Video Generator",
  3. "version": "1.1.0",
  4. "description": "Transform text scripts into professional videos with AI voiceovers, stock footage, and Remotion rendering. Advanced features include direct filesystem access, environment management, and whitelisted command execution.",
  5. "icon": "video",
  6. "author": "Premkumar M (@itsPremkumar)",
  7. "repository": "https://github.com/itsPremkumar/Automated-Video-Generator",
  8. "license": "MIT",
  9. "components": {
  10. "skills": [
  11. {
  12. "name": "cli-operations",
  13. "path": ".agent/skills/cli-operations/SKILL.md"
  14. },
  15. {
  16. "name": "generate-script",
  17. "path": ".agent/skills/generate-script/SKILL.md"
  18. }
  19. ],
  20. "mcp": {
  21. "command": "npx",
  22. "args": ["-y", "tsx", "src/mcp-server.ts"],
  23. "env": ["PEXELS_API_KEY", "PIXABAY_API_KEY", "VIDEO_ORIENTATION", "VIDEO_VOICE"],
  24. "tools": [
  25. { "name": "generate_video", "description": "Generate a professional video from a text script." },
  26. { "name": "get_video_status", "description": "Check the status of a video generation job." },
  27. { "name": "list_jobs", "description": "List all recent video generation jobs." },
  28. { "name": "write_input_script", "description": "Save a video script to the input directory." },
  29. { "name": "read_input_script", "description": "Read available scripts from the input directory." },
  30. { "name": "delete_input_script", "description": "Remove a script from the input directory." },
  31. { "name": "validate_input_script", "description": "Check if a script format is valid." },
  32. { "name": "list_output_videos", "description": "List all generated videos." },
  33. { "name": "read_output_file", "description": "Read details or scene data from a completed video." },
  34. { "name": "delete_output", "description": "Delete a generated video and its assets." },
  35. { "name": "upload_asset", "description": "Upload media assets for use in videos." },
  36. { "name": "delete_asset", "description": "Remove a media asset." },
  37. { "name": "list_local_assets", "description": "List all uploaded media assets." },
  38. { "name": "run_pipeline_command", "description": "Run pipeline commands (generate, render, etc.)" },
  39. { "name": "read_env_config", "description": "View environment settings." },
  40. { "name": "update_env_config", "description": "Change environment settings." },
  41. { "name": "get_system_info", "description": "Check system and dependency status." },
  42. { "name": "health_check", "description": "Quick system health check." }
  43. ],
  44. "resources": [
  45. { "uri": "input://scripts", "name": "Input Scripts" },
  46. { "uri": "input://format", "name": "Script Format Guide" },
  47. { "uri": "output://videos", "name": "Output Videos List" },
  48. { "uri": "public://assets", "name": "Public Assets" },
  49. { "uri": "config://env", "name": "Environment Config" },
  50. { "uri": "config://pipeline", "name": "Pipeline Config" }
  51. ],
  52. "prompts": [
  53. { "name": "create-marketing-video", "description": "Workflow for marketing video creation." },
  54. { "name": "create-youtube-short", "description": "Workflow for viral YouTube Shorts." },
  55. { "name": "batch-generate", "description": "Workflow for batch video generation." },
  56. { "name": "debug-pipeline", "description": "Workflow for troubleshooting." }
  57. ]
  58. }
  59. }
  60. }
README.md · README · 643 lines
  1. <!--
  2. 🧠 Automated Video Generator
  3. SEO keywords: automated video generator, free video generator, open source video generator,
  4. ai video generator, text to video, remotion, edge tts, youtube shorts generator, tiktok
  5. video generator, faceless youtube, content automation, self hosted video generator,
  6. mcp server, model context protocol, stock media, pexels, pixabay, openverse, video pipeline,
  7. react video, nodejs video, typescript video, batch video generation, voiceover, text to speech,
  8. video creator, marketing video, explainer video, shorts automation, reels generator,
  9. open source, MIT license, programmatic video, no api key, cc images
  10. -->
  11. <!-- hero video removed per user request -->
  12. <div align="center">
  13. <h1>Automated Video Generator</h1>
  14. <p><strong>🆓 Free &bull; 🔓 Open Source &bull; 🏠 Self-Hosted &bull; 🤖 AI Text-to-Video</strong></p>
  15. <p><b>Turn any script into a narrated, stock-footage video in minutes.</b><br/>No API key. No watermark. Runs 100% on your machine.</p>
  16. </div>
  17. <br/>
  18. <div align="center">
  19. <a href="https://github.com/itsPremkumar/Automated-Video-Generator/stargazers"><img src="https://img.shields.io/github/stars/itsPremkumar/Automated-Video-Generator?style=for-the-badge&logo=github" alt="GitHub stars"></a>
  20. <a href="https://github.com/itsPremkumar/Automated-Video-Generator/blob/main/LICENSE"><img src="https://img.shields.io/github/license/itsPremkumar/Automated-Video-Generator?style=for-the-badge" alt="MIT license"></a>
  21. <a href="https://github.com/itsPremkumar/Automated-Video-Generator/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/itsPremkumar/Automated-Video-Generator/ci.yml?branch=main&style=for-the-badge&label=CI" alt="CI status"></a>
  22. <a href="https://www.npmjs.com/package/automated-video-generator"><img src="https://img.shields.io/npm/v/automated-video-generator?style=for-the-badge&color=cb0000" alt="NPM version"></a>
  23. <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/Node.js-18%2B-2f7d32?style=for-the-badge" alt="Node.js 18+"></a>
  24. <a href="https://github.com/itsPremkumar/Automated-Video-Generator/blob/main/docs/CONTRIBUTING.md"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen?style=for-the-badge" alt="Contributions welcome"></a>
  25. <a href="https://github.com/itsPremkumar/Automated-Video-Generator/releases/latest"><img src="https://img.shields.io/badge/download-Windows_.exe-blue?style=for-the-badge&logo=windows" alt="Download Windows"></a>
  26. <a href="https://github.com/sponsors/itsPremkumar"><img src="https://img.shields.io/badge/Sponsor-%E2%9D%A4-red?style=for-the-badge&logo=github" alt="GitHub Sponsors"></a>
  27. </div>
  28. <div align="center">
  29. <a href="https://star-history.com/#itsPremkumar/Automated-Video-Generator&Date"><img src="https://api.star-history.com/svg?repos=itsPremkumar/Automated-Video-Generator&type=Date&theme=dark" alt="Star History Chart" width="600"></a>
  30. </div>
  31. <br/>
  32. ---
  33. ## 📖 What is this?
  34. **Automated Video Generator** is a free, open-source, self-hosted pipeline that converts text scripts into polished MP4 videos. Give it a script — it fetches relevant stock visuals, generates natural voiceovers, synchronizes everything with Remotion, and exports a ready-to-share video.
  35. No paid plans. No watermarks. No monthly limits. Just your machine, your scripts, and full control.
  36. <br/>
  37. <div align="center">
  38. <table>
  39. <tr>
  40. <td align="center"><b>🎬 Input</b></td>
  41. <td align="center"><b>⚙️ Pipeline</b></td>
  42. <td align="center"><b>📦 Output</b></td>
  43. </tr>
  44. <tr>
  45. <td align="center">Text script<br/>or JSON job<br/>or AI prompt</td>
  46. <td align="center">Parse → Fetch media<br/>→ Generate voiceover<br/>→ Render with Remotion</td>
  47. <td align="center">MP4 video<br/>+ Thumbnail<br/>+ Scene data</td>
  48. </tr>
  49. </table>
  50. </div>
  51. <br/>
  52. ---
  53. ## ✨ Demo
  54. > A real short generated by the pipeline (no re-render, no edits) — script in, MP4 out:
  55. <div align="center">
  56. <a href="https://github.com/itsPremkumar/Automated-Video-Generator">
  57. <img src="assets/demo/demo.gif" alt="Automated Video Generator — real pipeline output playing" width="360" style="border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.25);">
  58. </a>
  59. <br/>
  60. <em>▶️ Autoplaying: a real short generated by this pipeline (no re-render, no edits) — script in, MP4 out.</em>
  61. <br/><br/>
  62. <a href="https://github.com/itsPremkumar/Automated-Video-Generator">
  63. <img src="assets/demo/demo-showcase.png" alt="Automated Video Generator - Project Logo & GitHub Repository" width="100%" style="border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.25);">
  64. </a>
  65. <br/>
  66. <em>🎙️ Voiceover powered by <b>Voicebox Kokoro Heart</b> — realistic local AI narration. ✅ 32/32 quality checks passed on every output. 🔓 Free & open source.</em>
  67. </div>
  68. <div align="center">
  69. <img src="assets/diagrams/demo-flow.svg" alt="How it works: script → pipeline → video" width="720" style="border-radius: 12px; margin-top: 12px;">
  70. <br/>
  71. <em>Script → AI voiceover + stock media → MP4. Fully local.</em>
  72. </div>
  73. <hr/>
  74. ## 🚀 Quick Start (5 minutes)
  75. Choose your path:
  76. | Path | Time | Difficulty | For |
  77. | -------------------------------------------------- | ----- | ---------- | ------------- |
  78. | [Windows Desktop App](#windows-desktop-app) | 2 min | ★☆☆ | Everyone |
  79. | [One-Click Launcher](#one-click-launcher-windows) | 3 min | ★☆☆ | Windows users |
  80. | [Manual Setup](#manual-setup) | 5 min | ★★☆ | Developers |
  81. | [Docker](#docker) | 3 min | ★★☆ | DevOps |
  82. | [npm (MCP)](#npm-mcp-server) | 1 min | ★☆☆ | AI agents |
  83. ### 🎬 Your first video in 2 commands
  84. No API key required to run — Openverse + free CC sources provide stock footage out of the box. Voiceover uses the vendored Voicebox backend (Kokoro by default) with Edge-TTS fallback; **the Kokoro backend needs a one-time setup** — point `VOICEBOX_PYTHON` at a torch/kokoro venv (e.g. `C:/one/voicebox/.venv/Scripts/python.exe`) or it auto-falls back to the built-in Edge-TTS/Kokoro engine. Encoding is automatic: **Windows uses `h264_mf`** (Media Foundation, fast) and other platforms use `libx264`; `--gpu` selects AMF/NVENC/QSV when present. **For best results set `PEXELS_API_KEY`** (free): Pexels is the recommended provider and is skipped in keyless mode, so keyless runs use lower-relevance free sources.
  85. ```bash
  86. # 1. Install (one time)
  87. npm install
  88. # 2. Generate (reads input/scripts/input-scripts.json, writes output/<id>/<Title>.mp4)
  89. npm run generate
  90. ```
  91. That's it. The CLI reads `input/scripts/input-scripts.json` (a sample job is pre-included) and renders an MP4 with AI voiceover + stock visuals + burned-in captions. With the bundled sample, find it at `output/pre7_productivity_tip/One Simple Trick To Beat Procrastination.mp4`.
  92. Prefer a GUI? Run `npm run dev` and open **http://localhost:3001** — paste a script, click **Generate Video**.
  93. <div align="center">
  94. <img src="assets/demo/demo.gif" alt="Real pipeline output — landscape render playing" width="640" style="border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.25);">
  95. <br/>
  96. <em>Real Voicebox-narrated video from the pipeline. Script → voiceover + stock media → MP4, fully local.</em>
  97. </div>
  98. ### 🪟 Windows Desktop App
  99. **No Node.js, Python, or terminal required.**
  100. Download the [latest Windows installer](https://github.com/itsPremkumar/Automated-Video-Generator/releases/latest), double-click, and the app opens the web portal automatically. Everything is bundled.
  101. ### 📜 One-Click Launcher (Windows)
  102. ```powershell
  103. .\Start-Automated-Video-Generator.bat
  104. ```
  105. Or the PowerShell version:
  106. ```powershell
  107. .\Start-Automated-Video-Generator.ps1
  108. ```
  109. The launcher auto-installs Node.js and Python (via `winget`), creates `.env`, installs dependencies, and opens the portal at `http://localhost:3001`.
  110. ### 🛠️ Manual Setup
  111. **Prerequisites:** Node.js 18+, Python 3.8+, npm
  112. ```bash
  113. # 1. Clone
  114. git clone https://github.com/itsPremkumar/Automated-Video-Generator.git
  115. cd Automated-Video-Generator
  116. # 2. Install Node dependencies
  117. npm install
  118. # 3. Install Python voice engine
  119. pip install -r requirements.txt
  120. # 4. Configure environment
  121. cp .env.example .env
  122. # Edit .env — add PEXELS_API_KEY (free, get one at pexels.com/api)
  123. # No API key? Set OPENVERSE_ENABLED=true (it's the default)
  124. # 5. (Optional) Local AI generation — ComfyUI, CogVideoX, Real-ESRGAN, rembg
  125. # Install the AI providers you want (all optional, all free, all offline):
  126. # pip install diffusers transformers accelerate torch # CogVideoX (T2V)
  127. # pip install realesrgan basicsr # Real-ESRGAN (upscale)
  128. # pip install rembg # Background removal
  129. # git clone https://github.com/comfyanonymous/ComfyUI.git # ComfyUI (image/I2V)
  130. # 6. Start the web portal
  131. npm run dev
  132. ```
  133. Open **http://localhost:3001/** — paste a script, click generate, and watch it render.
  134. ### 🐳 Docker
  135. Pre-built image (built + scanned by CI, pushed to GHCR):
  136. ```bash
  137. docker run -p 3001:3001 \
  138. -v "$(pwd)/input:/app/input" \
  139. -v "$(pwd)/output:/app/output" \
  140. ghcr.io/itspremkumar/automated-video-generator
  141. ```
  142. Or build locally (pinned `node:20-bookworm`, full `npm ci`, edge-tts in a
  143. venv to satisfy PEP 668, platform `linux/amd64`, healthcheck on `/api/health`):
  144. ```bash
  145. docker compose up --build
  146. ```
  147. ### 🚀 Production Deployment
  148. The container is self-contained: it bundles the ffmpeg/ffprobe static
  149. binaries and a Python venv with `edge-tts` for free, key-less narration.
  150. No external services are required for the default pipeline.
  151. **Environment variables (all optional — sensible free defaults):**
  152. | Var | Default | Purpose |
  153. |-----|---------|---------|
  154. | `PORT` | `3001` | Web portal / API port |
  155. | `PEXELS_API_KEY` | _(none)_ | Free stock video. Without it, falls back to Openverse / Wikimedia / Internet Archive. |
  156. | `YOUTUBE_API_KEY` | _(none)_ | YouTube metadata enrichment (optional). |
  157. | `OPENVERSE_ENABLED` | `true` | Use Openverse CC media when no API key is set. |
  158. | `TTS_PROVIDER` | `voicebox` | `voicebox` (default — vendored in-repo Kokoro/Chatterbox) or `edge-tts` (free, CPU). The pipeline auto-spawns the vendored backend. |
  159. | `VOICEBOX_ENGINE` | _(none)_ | `kokoro` or `chatterbox_turbo` — only when `TTS_PROVIDER=voicebox`. |
  160. | `VOICEBOX_PROFILE_ID` | _(none)_ | A Voicebox profile id (preset or cloned voice). |
  161. **Voicebox (in-repo vendored, default narrator).**
  162. Voicebox is **vendored in-repo** at `src/speech/` (MIT, sourced from jamiepine/voicebox).
  163. It is the **default TTS provider** — the pipeline auto-spawns it as `python -m speech.main`
  164. using the in-repo venv. Kokoro (~800 MB VRAM) is the default narrator engine.
  165. If the backend cannot start (missing venv, no GPU), the pipeline degrades gracefully
  166. back to Edge-TTS. For voice cloning, set `TTS_PROVIDER=voicebox` and provide a
  167. `VOICEBOX_PROFILE_ID`. See `docs/VOICEBOX_SETUP.md`.
  168. **Health & hardening:**
  169. - Healthcheck hits `GET /api/health` (container `HEALTHCHECK`).
  170. - No secrets are logged; output paths are sanitized against `../` traversal
  171. at the dispatch chokepoint (`src/agentic/operations/security.ts`).
  172. - CI runs `typecheck` + `test:unit` + a Gitleaks secret scan + a Docker
  173. build/push to GHCR on every push to `main`.
  174. The MCP server lets AI agents (Claude Desktop, Claude Code, Cursor, etc.) create videos autonomously — it exposes **61 tools** across 7 families, 13 resources, and 4 prompts over stdio.
  175. > 📚 See [`docs/MCP_TOOL_REFERENCE.md`](./docs/MCP_TOOL_REFERENCE.md) for the full tool-by-tool contract (auto-generated from source via `npm run gen:mcp-doc`; CI verifies it's in sync via `npm run verify:mcp-doc`).
  176. **Quick connect (read-only safe mode — default):**
  177. ```json
  178. {
  179. "mcpServers": {
  180. "automated-video-generator": {
  181. "command": "npx",
  182. "args": ["automated-video-generator"]
  183. }
  184. }
  185. }
  186. ```
  187. Or run it locally:
  188. ```bash
  189. npm install
  190. npm run mcp # starts the MCP server on stdio
  191. ```
  192. **⚠️ Safe mode (important):** By default the MCP server runs in **safe mode** — read tools (`read_input_script`, `list_output_videos`, `health_check`, etc.) work, but **all write/mutation tools are blocked** with `ForbiddenError: safe mode`. This protects your files from accidental changes by an agent.
  193. To enable write tools (`write_input_script`, `delete_*`, `upload_asset`, `update_env_config`, `run_pipeline_command`, `delete_output`), set the flag:
  194. ```bash
  195. # one-off
  196. ALLOW_UNSAFE_MCP_TOOLS=1 npm run mcp
  197. # or in your client config (env)
  198. {
  199. "mcpServers": {
  200. "automated-video-generator": {
  201. "command": "npx",
  202. "args": ["automated-video-generator"],
  203. "env": { "ALLOW_UNSAFE_MCP_TOOLS": "1" }
  204. }
  205. }
  206. }
  207. ```
  208. > Only enable `ALLOW_UNSAFE_MCP_TOOLS` for trusted agents — it grants filesystem write access to your project.
  209. **What the server provides:**
  210. - **Tools (60):** `write_input_script`, `read_input_script`, `delete_input_script`, `validate_input_script`, `upload_asset`, `delete_asset`, `list_output_videos`, `read_output_file`, `delete_output`, `generate_video`, `get_video_status`, `run_pipeline_command`, `list_jobs`, `get_batch_status`, `read_env_config`, `update_env_config`, `get_system_info`, `health_check`, `get_workspace_paths`, `list_public_files`, `list_voices`, `list_local_assets`, `search_free_video`, `download_free_video`, `agentic_plan`, `agentic_acquire`, `agentic_verify_all`, `list_pending_assets`, `get_asset_preview`, `approve_asset`, `reject_asset`, `agentic_gate`, `agentic_run`, `do_task`, `merge_videos`, `trim_video`, `crop_video`, `resize_video`, `rotate_video`, `extract_audio`, `split_video`, `add_captions`, `add_music`, `add_audio_track`, `localize_video`, `grade_video`, `slow_motion`, `speed_ramp`, `add_watermark`, `add_lower_third`, `add_progress_bar`, `derive_outputs`, `make_voiceover`, `download_image`, `download_video`, `remove_silence`, `detect_scenes`, `auto_reframe`, `reduce_noise`, `apply_brand_kit`
  211. - **Resources (9):** project overview, input scripts, input assets, input format docs, output videos, per-video detail, public tree, env/pipeline config
  212. - **Prompts (4):** `create-marketing-video`, `create-youtube-short`, `batch-generate`, `debug-pipeline`
  213. ---
  214. ## 🎯 Generate Your First Video
  215. ### CLI Batch Mode
  216. Create `input/scripts/input-scripts.json`:
  217. ```json
  218. [
  219. {
  220. "id": "my-first-video",
  221. "title": "3 Productivity Habits That Actually Work",
  222. "orientation": "portrait",
  223. "language": "english",
  224. "script": "Here are three productivity habits that will change your life. First, start your day with a clear plan..."
  225. }
  226. ]
  227. ```
  228. Run:
  229. ```bash
  230. npm run generate
  231. ```
  232. Output: `output/my-first-video/final.mp4` 🎉
  233. ### Publishing to social (opt-in)
  234. After a batch run, you can publish the rendered MP4s to TikTok, Instagram, or YouTube via [upload-post.com](https://upload-post.com). This is **opt-in** — the batch CLI only posts when `--post` is passed AND the env vars are configured:
  235. ```bash
  236. # In .env (one-time):
  237. UPLOAD_POST_ENABLED=true
  238. UPLOAD_POST_API_KEY=your_upload-post_key
  239. UPLOAD_POST_USERNAME=your_upload-post_user
  240. UPLOAD_POST_PLATFORMS=tiktok,instagram # or youtube,youtube_shorts
  241. # Then:
  242. npm run agentic:post # alias for: agentic-batch --post
  243. ```
  244. A `publish-manifest.json` is written next to each posted MP4 with the platform URL(s) and an audit trail. Failures never throw — one bad job can't kill the post step for the rest of the batch.
  245. ### Web Portal
  246. ```bash
  247. npm run dev
  248. # Open http://localhost:3001
  249. ```
  250. The portal lets you paste scripts, configure voice/language/orientation, track rendering progress live, and watch/download the result — all from your browser.
  251. ### Director Mode
  252. Use `[Visual: ...]` tags for frame-perfect scene control:
  253. ```json
  254. {
  255. "id": "director-mode-demo",
  256. "title": "My Directed Video",
  257. "script": "[Visual: a serene mountain lake at sunset, cinematic, slow pan]\nNestled in the heart of the Rockies, this view has inspired explorers for centuries."
  258. }
  259. ```
  260. ---
  261. ## 🌟 Key Features
  262. | Feature | Description |
  263. | ---------------------------- | ----------------------------------------------------------------------------------------------- |
  264. | **🎤 400+ Voices** | Multi-language TTS via Voicebox (Kokoro, default) with Edge-TTS, XTTS fallback |
  265. | **🖼️ Stock Media** | Openverse + free CC sources (no key) + Pexels/Pixabay (set `PEXELS_API_KEY`/`PIXABAY_API_KEY` for higher relevance) + Wikimedia Commons + Internet Archive |
  266. | **🎵 Background Music** | Auto-ducking with volume control |
  267. | **🔄 Batch Processing** | Generate dozens of videos from one JSON file |
  268. | **🖥️ Web Portal** | Browser-based UI for generation, preview, download |
  269. | **🤖 MCP Server** | Connect Claude Desktop / Claude Code for AI-driven video creation |
  270. | **✅ AI Media Verification** | Validates visuals match scene context via Ollama moondream or Gemini Vision |
  271. | **🪟 Desktop App** | Standalone Windows .exe with bundled runtime |
  272. | **📱 Portrait + Landscape** | YouTube Shorts, TikTok, Reels, and widescreen support |
  273. | **↩️ Resumable Rendering** | Cancel and resume without losing progress |
  274. | **🎬 Remotion Studio** | Preview and tweak video compositions |
  275. | **🤖 Local AI Generation** | ComfyUI (SD1.5/SDXL), CogVideoX (T2V), AnimateDiff (I2V), Real-ESRGAN (upscale), rembg (bg removal) |
  276. | **🧠 AI Intelligence** | Beat-sync, CLIP semantic matching, script enhancement, multi-language subs, storyboard gen |
  277. | **🔌 AI Job Queue** | Serial AI processing — runs one AI job at a time (6GB RAM safe) |
  278. ---
  279. ## 🧠 AI Visual Media Verification
  280. After fetching media from stock sources, the pipeline verifies each image/frame against the scene description using a local vision model:
  281. 1. Image → base64 (or FFmpeg extracts a video frame)
  282. 2. Sent to Ollama (`moondream`) or Gemini Vision with a JSON verdict prompt
  283. 3. Low-confidence matches (< 6/10 default) are rejected, cached, and the file is deleted
  284. 4. Pipeline falls back to the next media source automatically
  285. ```env
  286. MEDIA_VERIFICATION_ENABLED=true
  287. MEDIA_VERIFICATION_CONFIDENCE=6
  288. AI_PROVIDER=ollama
  289. ```
  290. [Full guide →](docs/MEDIA_VERIFICATION.md)
  291. ---
  292. ## 🔌 CLI Reference
  293. ```text
  294. npm run generate # Generate videos from input/scripts/input-scripts.json
  295. npm run resume # Resume an interrupted run
  296. npm run segment # Rebuild from existing scene data
  297. npm run agentic # Generate a video from a topic (agentic pipeline)
  298. npm run agentic:batch # Generate + verify multiple videos
  299. npm run agentic:perspectives # One topic → 5 editorial angles + comparison sheet
  300. npm run doctor # Pre-flight health check (ffmpeg/RAM/network/TTS)
  301. npm run dev # Start the local web portal
  302. npm run mcp # Start the MCP server
  303. npm run typecheck # TypeScript validation
  304. npm run test # Typecheck + unit tests
  305. npm run test:unit # Run unit tests
  306. npm run test:render # Run E2E render test
  307. npm run test:coverage # Run tests with coverage
  308. npm run lint # ESLint
  309. npm run format # Prettier formatting
  310. npm run remotion:studio # Open Remotion Studio for composition preview
  311. npm run remotion:render # Render using the Remotion pipeline
  312. npm run electron:dev # Run the desktop app in development mode
  313. npm run electron:build # Build the Windows desktop installer
  314. npm run electron:pack # Create unpacked release for testing
  315. npm run docker:build # Build Docker image
  316. npm run docker:run # Run Docker container
  317. npm run batch # Batch mode alias
  318. npm run agentic:upscale # Upscale an image (AI, Real-ESRGAN)
  319. npm run agentic:remove-bg # Remove background (AI, rembg)
  320. ```
  321. **AI Tool Commands:**
  322. ```bash
  323. # Upscale an image 2x-4x using Real-ESRGAN
  324. npx tsx src/adapters/cli/agentic-modular.ts upscale --input photo.jpg --output photo_4k.jpg --factor 2
  325. # Remove background using rembg
  326. npx tsx src/adapters/cli/agentic-modular.ts remove-bg --input photo.jpg --output photo_nobg.png --model u2net
  327. ```
  328. [Full CLI docs →](docs/cli-reference.md)
  329. ---
  330. ## 🏗️ Architecture
  331. <div align="center">
  332. <img src="assets/diagrams/architecture.svg" alt="Hexagonal architecture: 4 runtimes, 1 core" width="760" style="border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.15);">
  333. </div>
  334. The project follows a **hexagonal architecture** with four entry points sharing a common application core.
  335. - `src/adapters/` — HTTP controllers, CLI runner, MCP tool registrars
  336. - `src/application/` — Shared orchestration services
  337. - `src/lib/` — Core business logic (fetchers, parsers, verifiers)
  338. - `src/infrastructure/` — Persistence and filesystem
  339. - `src/shared/` — Contracts, runtime safety, logging
  340. [Full architecture docs →](docs/ARCHITECTURE.md)
  341. ---
  342. ## 🛠️ Use Cases
  343. ### YouTube Shorts / TikTok Automation
  344. Automate a daily Shorts channel. Generate 30 portrait-mode videos from a script list in one batch run.
  345. ```bash
  346. # Configure 30 scripts in input/scripts/input-scripts.json
  347. npm run generate
  348. ```
  349. [Example →](examples/youtube-shorts/)
  350. ### Faceless YouTube Channel
  351. Create documentary-style videos using stock footage, AI voiceovers, and background music — no camera or mic needed.
  352. [Example →](examples/faceless-channel/)
  353. ### Multi-Language Content
  354. Generate the same script in English, Tamil, Hindi, Spanish, French, and German — all from a single batch config.
  355. [Example →](examples/multi-language/)
  356. ### AI Agent Workflows
  357. Use the MCP server to let Claude or other AI agents create videos autonomously:
  358. ```bash
  359. # Start the MCP server
  360. npm run mcp
  361. # In Claude Code:
  362. claude mcp add automated-video-generator -- npx automated-video-generator
  363. ```
  364. [Example →](examples/mcp-agent/)
  365. ### Local Assets
  366. Use your own images and videos instead of stock media. Place files in `input/visuals/` and reference them with `[Visual: filename.mp4]` or `[Visual: filename.jpg]`.
  367. [Example →](examples/local-assets/)
  368. [Full guide →](docs/INPUT_ASSETS_GUIDE.md)
  369. ### Background Music
  370. Add background music with auto volume ducking so voiceovers stay clear:
  371. ```env
  372. BACKGROUND_MUSIC=true
  373. BACKGROUND_MUSIC_VOLUME=0.15
  374. ```
  375. [Example →](examples/background-music/)
  376. ---
  377. ## 🌐 No-API-Key Media Sources
  378. One of the project's standout features: **you can generate videos without registering for any API service**.
  379. | Source | Needs API Key? | Content | Enabled By Default |
  380. | ---------------------------------- | ---------------- | ------------------------ | ------------------ |
  381. | [Pexels](https://pexels.com/api) | ✅ Free key | Stock videos + images | When key is set |
  382. | [Pixabay](https://pixabay.com/api) | ✅ Free key | Stock videos + images | When key is set |
  383. | **Openverse** | ❌ No key needed | 600M+ CC-licensed images | ✅ Yes |
  384. | **Wikimedia Commons** | ❌ No key needed | CC-licensed videos | ✅ Yes |
  385. | **Internet Archive** | ❌ No key needed | Public domain videos | ✅ Yes |
  386. [Openverse guide →](docs/OPENVERSE.md) &nbsp;|&nbsp; [Free video guide →](docs/FREE_VIDEO.md)
  387. ---
  388. ## 🆚 How It Compares
  389. | Feature | Automated Video Generator | Commercial tools | Other OSS tools |
  390. | -------------------------- | -------------------------- | ---------------- | --------------- |
  391. | **Price** | Completely free (MIT) | $20-200/mo | Varies |
  392. | **Watermark** | None | Usually yes | Varies |
  393. | **Self-hosted** | ✅ Yes | ❌ Cloud-only | Sometimes |
  394. | **Local execution** | ✅ Full local | ❌ | Sometimes |
  395. | **API key required** | ❌ Optional | ✅ Required | Varies |
  396. | **MCP / AI agent support** | ✅ Built-in | ❌ | Rare |
  397. | **Stock media** | ✅ Multi-source integrated | ✅ | Limited |
  398. | **AI media verification** | ✅ Built-in | ❌ | ❌ |
  399. | **400+ voices** | ✅ 13+ languages | ✅ | Limited |
  400. | **Batch mode** | ✅ Built-in | ✅ | Limited |
  401. | **Desktop app** | ✅ Windows (.exe) | ✅ | Rare |
  402. [Full comparison →](docs/COMPARISON.md)
  403. ---
  404. ## 📚 Documentation
  405. | Resource | Description |
  406. | ---------------------------------------------------- | ----------------------------------------- |
  407. | [Installation Guide](docs/installation.md) | Full setup instructions for all platforms |
  408. | [Configuration Reference](docs/configuration.md) | All environment variables explained |
  409. | [CLI Reference](docs/cli-reference.md) | All CLI commands and options |
  410. | [API Reference](docs/api-reference.md) | HTTP API endpoints |
  411. | [Architecture](docs/ARCHITECTURE.md) | Codebase architecture deep-dive |
  412. | [Usage Guide](docs/usage.md) | Generating videos step by step |
  413. | [FAQ](docs/faq.md) | Frequently asked questions |
  414. | [Troubleshooting](docs/troubleshooting.md) | Common issues and solutions |
  415. | [OpenVerse Guide](docs/OPENVERSE.md) | Free CC-licensed image search |
  416. | [Free Video Guide](docs/FREE_VIDEO.md) | Free video sources |
  417. | [Media Verification](docs/MEDIA_VERIFICATION.md) | AI visual verification setup |
  418. | [Voice Cloning](docs/VOICE_CLONING_GUIDE.md) | Custom voice model setup |
  419. | [Input Assets Guide](docs/INPUT_ASSETS_GUIDE.md) | Using local images/videos |
  420. | [Production Hardening](docs/PRODUCTION_HARDENING.md) | Deployment best practices |
  421. | [Windows Installer](docs/WINDOWS_INSTALLER.md) | Desktop app builds |
  422. | [Claude MCP Setup](docs/CLAUDE_MCP_SETUP.md) | AI agent integration |
  423. | [llms.txt](llms.txt) | AI-friendly project summary |
  424. | [llms-full.txt](llms-full.txt) | Full AI-friendly documentation |
  425. ---
  426. ## 🤝 Contributing
  427. Contributions of all kinds are welcome — code, docs, bug reports, feature ideas, and community support.
  428. - [Contributing Guide](docs/CONTRIBUTING.md)
  429. - [Code of Conduct](docs/CODE_OF_CONDUCT.md)
  430. - [Security Policy](docs/SECURITY.md)
  431. - [Roadmap](docs/ROADMAP.md)
  432. - [Changelog](docs/CHANGELOG.md)
  433. ### Quick contributor workflow
  434. ```bash
  435. # Fork → Clone → Branch → Code → Test → PR
  436. git checkout -b feat/my-feature
  437. # ... make changes ...
  438. npm run typecheck && npm run test:unit && npm run lint && npm run format
  439. git push origin feat/my-feature
  440. # Open a pull request
  441. ```
  442. ---
  443. ## 🗺️ Roadmap
  444. **Current (v5.x):** Desktop app, MCP server, AI verification, GPU acceleration, free media sources, voice cloning, content gate, subtitle sidecars, batch mode presets
  445. **Short-term (v5.5-v6.0):** Plugin system, subtitle styling, template system, macOS/Linux desktop, Swagger docs
  446. **Medium-term (v6.0-v7.0):** Visual timeline editor, collaboration, advanced transitions
  447. **Long-term (v7.0+):** Cloud rendering, marketplace, storyboard AI, mobile companion
  448. [Full roadmap →](docs/ROADMAP.md)
  449. ---
  450. ## 📦 Releases
  451. The project follows [Semantic Versioning](https://semver.org/). See [releases](https://github.com/itsPremkumar/Automated-Video-Generator/releases) for download links and release notes.
  452. | Version | Status | Support |
  453. | ------- | ----------- | ----------------- |
  454. | 5.x | Active | ✅ Full support |
  455. | 4.x | Maintenance | ⚠️ Security fixes |
  456. | <4.0 | EOL | ❌ No support |
  457. ---
  458. ## 📄 License
  459. MIT © [Premkumar](https://github.com/itsPremkumar). See [LICENSE](LICENSE) for details.
  460. ---
  461. <div align="center">
  462. <p>
  463. <strong>⭐ Star this repo</strong> if it helps your projects — it helps others discover it too.<br/>
  464. <a href="https://github.com/itsPremkumar/Automated-Video-Generator">GitHub</a> &bull;
  465. <a href="https://www.npmjs.com/package/automated-video-generator">npm</a> &bull;
  466. <a href="https://itspremkumar.github.io/Automated-Video-Generator">Website</a> &bull;
  467. <a href="https://github.com/itsPremkumar/Automated-Video-Generator/discussions">Discussions</a>
  468. </p>
  469. <p>
  470. <sub>Built with ❤️ and lots of ☕ | Free forever • MIT licensed • No watermarks • No subscriptions</sub>
  471. </p>
  472. </div>
src/adapters/mcp/pipeline-commands.test.ts · Bundled script · 188 lines · 2 findings marked
  1. import { test, mock } from 'node:test';
  2. import assert from 'node:assert/strict';
  3. /**
  4. * pipeline-commands.test.ts
  5. *
  6. * Tests the security-critical allowlist-based exec() in pipeline-commands.ts.
  7. *
  8. * Node 22 mock API constraint: mock.module() for a given specifier can only be
  9. * registered ONCE per process (no mock.resetModules(); restoreAll() does NOT free
  10. * it for re-registration). So child_process + fs are registered exactly ONCE at
  11. * top-level with mutable STATE the closures read at call time. Each test mutates
  12. * STATE before calling the SUT.
  13. *
  14. * NOTE: we must NOT do `(cp as any).exec = ...` / `mock.method(cp, 'exec', ...)` —
  15. * child_process.exec is a read-only ESM namespace export. mock.module() replaces
  16. * the whole namespace, which is the supported path.
  17. */
  18. const ALLOWED = ['generate', 'resume', 'segment', 'remotion:render', 'remotion:studio'];
  19. const execState: { impl: (cmd: string, cb?: (e: any, out: string, err: string) => void) => void } = {
  20. impl: (cmd: string, cb?: (e: any, out: string, err: string) => void) => {
  21. if (typeof cb === 'function') cb(null, `mock stdout for ${cmd}`, '');
  22. },
  23. };
  24. const fsState: { existsImpl: () => boolean; readImpl: () => string; writeImpl: () => void } = {
  25. existsImpl: () => false,
  26. readImpl: () => '{}',
  27. writeImpl: () => {},
  28. };
  29. mock.module('child_process', {
  30. namedExports: {
  31. execFile: mock.fn((file: string, args: string[], _opts: any, cb?: (e: any, out: string, err: string) => void) => {
  32. // Capture as a shell-style string so the test's execState.impl
  33. // (which pushes/inspects the command) keeps working.
  34. execState.impl(`${file} ${args.join(' ')}`, cb);
  35. return {} as any;
  36. }),
  37. },
  38. });
  39. mock.module('fs', {
  40. namedExports: {
  41. existsSync: () => fsState.existsImpl(),
  42. readFileSync: () => fsState.readImpl(),
  43. writeFileSync: (_path: string, _content: string) => fsState.writeImpl(),
  44. renameSync: () => {},
  45. },
  46. });
  47. // ---------------------------------------------------------------------------
  48. // Allowlist validation — pure logic, no mocking needed (throws before exec)
  49. // ---------------------------------------------------------------------------
  50. test('runPipelineCommand: rejects command not in allowlist', async () => {
  51. const { runPipelineCommand } = await import('./pipeline-commands.js');
  52. for (const bad of ['', 'rm -rf /', 'npm run generate', 'generate --danger', 'evil', 'ls', 'sudo']) {
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 60 on GitHub
  53. await assert.rejects(
  54. () => runPipelineCommand(bad),
  55. { name: 'Error', message: /not whitelisted/ },
  56. `should reject "${bad}"`,
  57. );
  58. }
  59. });
  60. test('runPipelineCommand: error message lists all allowed commands', async () => {
  61. const { runPipelineCommand } = await import('./pipeline-commands.js');
  62. let captured: any;
  63. try {
  64. await runPipelineCommand('hack');
  65. } catch (err) {
  66. captured = err;
  67. }
  68. assert.ok(captured, 'should throw');
  69. assert.match(captured.message, /not whitelisted/);
  70. for (const cmd of ALLOWED) {
  71. assert.ok(captured.message.includes(cmd), `error message should mention "${cmd}"`);
  72. }
  73. });
  74. test('runPipelineCommand: rejects empty command', async () => {
  75. const { runPipelineCommand } = await import('./pipeline-commands.js');
  76. await assert.rejects(() => runPipelineCommand(''), { message: /not whitelisted/ });
  77. });
  78. // ---------------------------------------------------------------------------
  79. // Allowed commands — exec + fs mocked to prevent real execution
  80. // ---------------------------------------------------------------------------
  81. test('runPipelineCommand: allowed commands proceed and return correct shape', async () => {
  82. const execCalls: string[] = [];
  83. execState.impl = (cmd: string, cb?: (e: any, out: string, err: string) => void) => {
  84. execCalls.push(cmd);
  85. if (typeof cb === 'function') cb(null, 'mock stdout', '');
  86. };
  87. fsState.existsImpl = () => false;
  88. fsState.readImpl = () => '{}';
  89. fsState.writeImpl = () => {};
  90. const { runPipelineCommand } = await import('./pipeline-commands.js');
  91. for (const cmd of ALLOWED) {
  92. const result = await runPipelineCommand(cmd);
  93. assert.ok(result.jobId, `should return jobId for "${cmd}"`);
  94. assert.ok(result.jobId.startsWith('exec_'), 'jobId starts with exec_');
  95. assert.ok(result.command.includes(cmd), 'command includes the npm script');
  96. }
  97. assert.equal(execCalls.length, ALLOWED.length, 'every allowed command should have executed');
  98. });
  99. test('runPipelineCommand: allows passing arguments on allowed commands', async () => {
  100. const execCalls: string[] = [];
  101. execState.impl = (cmd: string, cb?: (e: any, out: string, err: string) => void) => {
  102. execCalls.push(cmd);
  103. if (typeof cb === 'function') cb(null, 'mock stdout', '');
  104. };
  105. fsState.existsImpl = () => false;
  106. fsState.readImpl = () => '{}';
  107. fsState.writeImpl = () => {};
  108. const { runPipelineCommand } = await import('./pipeline-commands.js');
  109. const result = await runPipelineCommand('generate', ['--batch', '--resume']);
  110. assert.ok(result.jobId);
  111. assert.ok(result.command.includes('--batch'));
  112. assert.ok(result.command.includes('--resume'));
  113. assert.ok(result.command.startsWith('npm run generate'));
  114. });
  115. test('runPipelineCommand: args with shell metacharacters do NOT bypass allowlist', async () => {
  116. const { runPipelineCommand } = await import('./pipeline-commands.js');
  117. await assert.rejects(() => runPipelineCommand('generate; rm -rf /', ['--flag']), { message: /not whitelisted/ });
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 135 on GitHub
  118. });
  119. test('runPipelineCommand: each allowed command works with no args', async () => {
  120. const execCalls: string[] = [];
  121. execState.impl = (cmd: string, cb?: (e: any, out: string, err: string) => void) => {
  122. execCalls.push(cmd);
  123. if (typeof cb === 'function') cb(null, 'output', '');
  124. };
  125. fsState.existsImpl = () => false;
  126. fsState.readImpl = () => '{}';
  127. fsState.writeImpl = () => {};
  128. const { runPipelineCommand } = await import('./pipeline-commands.js');
  129. for (const cmd of ALLOWED) {
  130. const result = await runPipelineCommand(cmd);
  131. assert.ok(result.jobId, `no-args call should succeed for "${cmd}"`);
  132. }
  133. assert.equal(execCalls.length, ALLOWED.length);
  134. });
  135. test('runPipelineCommand: returns { jobId, command } shape', async () => {
  136. execState.impl = (cmd: string, cb?: (e: any, out: string, err: string) => void) => {
  137. if (typeof cb === 'function') cb(null, 'ok', '');
  138. };
  139. fsState.existsImpl = () => false;
  140. fsState.readImpl = () => '{}';
  141. fsState.writeImpl = () => {};
  142. const { runPipelineCommand } = await import('./pipeline-commands.js');
  143. const result = await runPipelineCommand('generate');
  144. assert.equal(typeof result.jobId, 'string');
  145. assert.equal(typeof result.command, 'string');
  146. assert.ok(result.jobId.length > 0);
  147. assert.ok(result.command.length > 0);
  148. });
  149. test('runPipelineCommand: executes the correct npm run command', async () => {
  150. const execCalls: string[] = [];
  151. execState.impl = (cmd: string, cb?: (e: any, out: string, err: string) => void) => {
  152. execCalls.push(cmd);
  153. if (typeof cb === 'function') cb(null, 'done', '');
  154. };
  155. fsState.existsImpl = () => false;
  156. fsState.readImpl = () => '{}';
  157. fsState.writeImpl = () => {};
  158. const { runPipelineCommand } = await import('./pipeline-commands.js');
  159. const result = await runPipelineCommand('remotion:render', ['vid-1']);
  160. assert.equal(result.command, 'npm run remotion:render -- vid-1');
  161. });
src/adapters/mcp/pipeline-commands.ts · Bundled script · 36 lines · 1 finding marked
  1. import { execFile, ChildProcess } from 'child_process';
  2. import { jobStore } from '../../infrastructure/persistence/job-store';
  3. import { resolveProjectPath } from '../../shared/runtime/paths';
  4. const ALLOWED_COMMANDS = ['generate', 'resume', 'segment', 'remotion:render', 'remotion:studio'];
  5. export async function runPipelineCommand(command: string, args: string[] = []) {
  6. if (!ALLOWED_COMMANDS.includes(command)) {
  7. throw new Error(`Command "${command}" is not whitelisted. Allowed: ${ALLOWED_COMMANDS.join(', ')}`);
  8. }
  9. // SECURITY: pass args as an argv array to execFile so they are NEVER
  10. // interpreted by a shell. The previous `exec(\`npm run ${command} -- ${args.join(' ')}\`)`
  11. // was a command-injection/RCE: a malicious `args` value like `"; rm -rf ~`
    • Note: Quoted as data in code: Runs `rm -rf` against a root or home-directory path
    • Line 14 on GitHub
  12. // would execute. npm receives the args verbatim as script flags.
  13. const jobId = `exec_${Date.now()}_${command}`;
  14. jobStore.set(jobId, { status: 'pending', progress: 0, message: `Running command: npm run ${command}` });
  15. const child: ChildProcess = execFile(
  16. 'npm',
  17. ['run', command, '--', ...args],
  18. { cwd: resolveProjectPath() },
  19. (error, stdout, stderr) => {
  20. if (error) {
  21. jobStore.set(jobId, { status: 'failed', error: error.message, message: stderr });
  22. return;
  23. }
  24. jobStore.set(jobId, { status: 'completed', progress: 100, message: stdout, endTime: Date.now() });
  25. },
  26. );
  27. // Return the full command string for callers/audit (informational only —
  28. // the actual execution above uses argv, not a shell).
  29. const commandStr = `npm run ${command}${args.length ? ' -- ' + args.join(' ') : ''}`;
  30. return { jobId, command: commandStr };
  31. }

Version history

  • v1.1.011/14/2026

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.