π¬ Open-source, self-hosted AI agent that runs a YouTube channel end to end: researches topics, writes scripts, generates narration, visuals and video, optimizes SEO, and publishes after your approval, then learns from analytics. Works with Gemini, OpenAI, OpenRouter, DeepSeek and more.
JavaScript ai-agentsautomationcontent-automationcontent-creationcontent-strategygoogle-geminijavascriptnodejsopenaiself-hostedseo-optimizationsocial-media-automationthumbnail-generatorvideo-generationyoutube-apiyoutube-automationyoutube-botyoutube-channelyoutube-shortsyoutube-uploader
docs: lead the README with dashboard screenshots and move reference tables to docs/ (#86)
Haithum Abdelfattahe973d515aef9
diff --git a/.gitignore b/.gitignoreindex a88abfe..ac4abd4 100644--- a/.gitignore+++ b/.gitignore@@ -70,6 +70,7 @@ build/*.gif!examples/*.png!examples/*.jpg+!assets/screenshots/*.png!assets/youtube-automation-agent.jpg# Backup filesdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex e37fc38..da458d6 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -22,6 +22,52 @@ npm run lintYou don't need API keys to work on most of the codebase β the test suite and the simulation fallbacks run without them. For end-to-end runs, `npm run setup` walks you through credentials (any one AI provider is enough).+## Project structure++```+youtube-automation-agent/+βββ agents/ # one file per pipeline agent (strategy, script, thumbnail, SEO, production, publishing, analytics)+βββ dashboard/ # web dashboard served by index.js+βββ database/ # SQLite schema and access layer+βββ schedules/ # cron-based automation+βββ scripts/ # maintenance scripts (growth snapshot, README screenshots)+βββ utils/ # AI text, media, and video providers; operator, readiness, engagement, and other services+βββ config/ # credential files (examples are committed)+βββ data/ # generated content and the local database+βββ docs/ # feature guide, API reference, providers, troubleshooting, design notes+βββ examples/ # verified real output from the community+βββ index.js # Express server and agent startup+βββ walkthrough.js # guided setup (npm run walkthrough)+βββ setup.js # classic setup (npm run setup)+βββ test.js # system test suite (npm test)+```++## Extending++### Add a text provider++Any provider with an OpenAI-compatible chat completions API can be added as a preset in `utils/ai-text-service.js`:++```javascript+deepseek: {+ name: 'DeepSeek',+ baseURL: 'https://api.deepseek.com',+ defaultModel: 'deepseek-flash',+ models: ['deepseek-flash', 'deepseek-v4-pro'],+ envKey: 'DEEPSEEK_API_KEY',+},+```++Then add a matching entry to `AI_PROVIDER_GUIDE` in `walkthrough.js` and a setup option in `utils/credential-manager.js`, add the provider to [`docs/providers.md`](docs/providers.md), and run `npm test`. The walkthrough test fails if any provider is missing a complete guide.++### Add a video provider++Video providers live in `utils/video-providers.js`. Each one extends `VideoProvider`, implements `isAvailable`, `createTask`, `getTask`, and `downloadResult`, and is registered in `VideoProviderRegistry`.++## README screenshots++The screenshots in the README are captured by `npm run docs:screenshots`, which starts the dashboard from your checkout and saves PNGs to `assets/screenshots/`. Re-run it after a visible dashboard change. Capture from a database with at least one real production: the project never presents mock or simulated output as real.+## Where help is most wantedCheck the [open issues](https://github.com/darkzOGx/youtube-automation-agent/issues) and the roadmap in the latest [release notes](https://github.com/darkzOGx/youtube-automation-agent/releases). Current priorities: Gemini image/TTS parity, slideshow rendering performance, and template-content quality.diff --git a/README.md b/README.mdindex 92f5d8b..06451bc 100644--- a/README.md+++ b/README.md@@ -7,10 +7,15 @@ It researches topics, writes scripts, generates narration and visuals, assembles[](https://github.com/darkzOGx/youtube-automation-agent/actions/workflows/ci.yml)[](LICENSE)[](package.json)+[](https://github.com/darkzOGx/youtube-automation-agent/releases)-**Latest release:** v2.11.0 (October 13, 2026). See the [changelog](CHANGELOG.md) for release notes and what has landed on `master` since.+-<!-- Launch gate: add only a real 30β45 second dashboard demo captured from a verified end-to-end run. -->+|  |  |+| :--: | :--: |+| Content review: quality checks and approval for one video | Autonomous operator: your mandate and the agent's plan |++*Screenshots use sample data so every panel is populated. Regenerate them with `npm run docs:screenshots`.*## Why it's different@@ -25,8 +30,8 @@ It researches topics, writes scripts, generates narration and visuals, assemblesYou need:- Node.js 18.17 or newer-- A Google account and YouTube Data API credentials ([setup steps](#youtube-required-free))-- An API key for at least one [text provider](#text). Gemini has free tiers for text and narration.+- A Google account and YouTube Data API credentials ([setup steps](#youtube-credentials))+- An API key for at least one [text provider](docs/providers.md#text). Gemini has free tiers for text and narration.```bashgit clone https://github.com/darkzOGx/youtube-automation-agent.git@@ -43,7 +48,14 @@ Then open `http://localhost:3456`.2. **Check readiness.** In the dashboard, open **Production readiness** and choose **Run verified check**. It makes small live text and narration requests, checks access to your channel, and builds and decodes a test MP4, without uploading anything.3. **Make videos.** Open **Autonomous operator**, describe the channel you want, and choose **Activate & run now**, or create a single video from the dashboard. Finished videos wait in **Pipeline** for your review and approval.-FFmpeg is installed with `npm install` through `ffmpeg-static`. Python is only needed to test an external DarkzSEO checkout.+FFmpeg is installed with `npm install` through `ffmpeg-static`.++### YouTube credentials++1. Create a project in [Google Cloud Console](https://console.cloud.google.com/).+2. Enable **YouTube Data API v3**, and **YouTube Analytics API** for retention and outcome data.+3. Create an OAuth 2.0 client of type **Desktop app** (not Web application) and save the JSON as `config/credentials.json`.+4. Under **Google Auth Platform β Audience**, add the Google account that owns your channel as a **test user**. Otherwise sign-in fails with `Error 403: access_denied`. While the app is in Testing mode, Google expires the sign-in after 7 days.## How it works@@ -56,22 +68,6 @@ FFmpeg is installed with `npm install` through `ffmpeg-static`. Python is only n| Publish | Schedules and uploads approved content | Privacy, timing, final decision || Learn | Captures 24-hour and 7-day evidence, measures your chosen outcome, then proposes the next move | Choose the KPI and approve or reject each lesson |-```mermaid-graph TD- O[Autonomous Channel Operator] --> A[Research and Editorial Plan]- A --> B[Content Strategy Agent]- B --> C[Script Writer Agent]- C --> D[Thumbnail Designer Agent]- C --> E[SEO Optimizer Agent]- D --> F[Production Management Agent]- E --> F- F --> Z[DarkzSEO Discoverability Preflight]- Z --> G[Review and Approval Gates]- G --> H[Publishing & Scheduling Agent]- H --> I[Analytics & Optimization Agent]- I -->|feedback loop| A-```-## FeaturesEach item links to its walkthrough in the [feature guide](docs/features.md).@@ -90,7 +86,7 @@ Each item links to its walkthrough in the [feature guide](docs/features.md).- **Content review:** quality checks, metadata editing, approval, and scheduling for each video.- [Scene Repair Studio](docs/features.md#scene-repair-studio-and-narration): edit, reorder, lock, replace, or regenerate a single scene, then rebuild the video.- [Evidence desk](docs/features.md#evidence-desk): link each factual claim in the script to a verified source before approval.-- [Discoverability preflight](docs/features.md#discoverability-preflight): advisory search and AI-answer checks from a bundled DarkzSEO audit. No Python needed.+- [Discoverability preflight](docs/features.md#discoverability-preflight): advisory search and AI-answer checks from a bundled DarkzSEO audit.**Learn**- [Learning loop](docs/features.md#learning-loop): compares each video's 24-hour and 7-day results with your channel's own history and proposes changes for you to approve.@@ -102,75 +98,13 @@ Each item links to its walkthrough in the [feature guide](docs/features.md).## AI providers-### Text--Pick one in the walkthrough, or set its key in `.env`. The SDK base URL is configured for you.--| Provider | Models | Key | Env var |-| --- | --- | --- | --- |-| **Google Gemini** | Gemini 3.8 Flash, Gemini 4 Argon (paid only), 3.5 Flash-Lite | [AI Studio](https://aistudio.google.com/apikey) | `GEMINI_API_KEY` |-| **OpenAI** | GPT-6.1 Sol, GPT-6 Astra, GPT-6 Luna | [platform.openai.com](https://platform.openai.com/api-keys) | `OPENAI_API_KEY` |-| **OpenRouter** | 400+ models through one key; curated defaults are checked against its live catalog | [openrouter.ai](https://openrouter.ai/keys) | `OPENROUTER_API_KEY` |-| **Kimi (Moonshot AI)** | Kimi K3, K2.7 Code, K2.6 | [platform.kimi.ai](https://platform.kimi.ai) | `MOONSHOT_API_KEY` |-| **MiMo (Xiaomi)** | MiMo V2.6 Pro, V2.6 Flash | [mimo.mi.com](https://mimo.mi.com) | `MIMO_API_KEY` |-| **GLM (Zhipu AI)** | GLM-5.3, 5.3 Flash, 5.2 | [z.ai](https://z.ai) | `GLM_API_KEY` |-| **DeepSeek** | DeepSeek V4.1 Flash, V4 Pro | [platform.deepseek.com](https://platform.deepseek.com/api_keys) | `DEEPSEEK_API_KEY` |-| **MiniMax** | MiniMax M3.1 Flash, M3 | [platform.minimax.io](https://platform.minimax.io/user-center/basic-information/interface-key) | `MINIMAX_TEXT_API_KEY` |--Anthropic Claude is available through OpenRouter (`anthropic/claude-fable-5.1`). OpenRouter, Kimi, MiMo, GLM, DeepSeek, and MiniMax cover scripts only. Add a Gemini or OpenAI key for images and narration, or ElevenLabs for narration.--### Narration and images--- **Narration** uses the first configured provider in this order: ElevenLabs (Eleven v3, needs `ELEVENLABS_API_KEY` and `ELEVENLABS_VOICE_ID`), OpenAI (`gpt-4o-mini-tts`), then Gemini (`gemini-3.8-flash-tts`). A video without working narration can't be approved.-- **Images** use OpenAI (GPT Image 2) and Gemini (`gemini-3.1-flash-image`, which needs billing enabled), each falling back to the other. With neither, slides use gradient backgrounds and thumbnails come from the built-in designer.--### Video--Local slideshow rendering is the default, so you never pay for video unless you choose a provider in **Channel setup** and set a paid-seconds cap. If a provider fails, the video falls back to the local slideshow.+One key gets you started. Pick a text provider in the walkthrough: Gemini, OpenAI, OpenRouter (400+ models, including Claude), Kimi, MiMo, GLM, DeepSeek, or MiniMax. Gemini has free tiers for text and narration.-| Provider | Default model | Best fit | Clip limits | Env var |-| --- | --- | --- | --- | --- |-| ByteDance | `bytedance/seedance-2.5` through Replicate | Cinematic long scenes and large reference sets | 4β30 seconds | `REPLICATE_API_TOKEN` |-| MiniMax | `MiniMax-H3` | Multimodal references, native stereo audio, optional 2K | 4β15 seconds | `MINIMAX_API_KEY` |-| Google | `gemini-omni-1.1-flash` | Fast generation and conversational editing | 3β10 seconds | `GEMINI_API_KEY` |-| Kuaishou | `kling-v3-omni` | Storyboards and character/voice consistency | 3β15 seconds | `KLING_ACCESS_KEY`, `KLING_SECRET_KEY` |-| Alibaba | Wan 2.7 task-specific models | Efficient generation, reference video, and continuation | 2β15 seconds | `DASHSCOPE_API_KEY` |+- **Narration** comes from ElevenLabs, OpenAI, or Gemini, in that order of preference. A video without working narration can't be approved.+- **Images** come from OpenAI or Gemini, each falling back to the other.+- **Video** is a free local slideshow by default. Choose Seedance, MiniMax H3, Gemini Omni, Kling, or Wan for generated clips and set a cap on paid seconds; if a provider fails, the video falls back to the slideshow.-Long videos use hybrid assembly: generated clips for the hook and key sections, with the rest of the timeline filled locally. See [AI video generation](docs/features.md#ai-video-generation).--## Configuration--### YouTube (required, free)--1. Create a project in [Google Cloud Console](https://console.cloud.google.com/).-2. Enable **YouTube Data API v3**, and **YouTube Analytics API** for retention and outcome data.-3. Create an OAuth 2.0 client of type **Desktop app** (not Web application) and save the JSON as `config/credentials.json`.-4. Under **Google Auth Platform β Audience**, add the Google account that owns your channel as a **test user**. Otherwise sign-in fails with `Error 403: access_denied`. While the app is in Testing mode, Google expires the sign-in after 7 days.--### Environment variables--`npm run walkthrough` writes your configuration for you. To edit it by hand, copy [`.env.example`](.env.example) to `.env`; it documents every setting. The essentials:--```env-# One text provider (see the table above)-GEMINI_API_KEY=...--# Optional: narration, images, and AI video-# ELEVENLABS_API_KEY=...-# ELEVENLABS_VOICE_ID=...-# OPENAI_API_KEY=sk-...-# VIDEO_PROVIDER=slideshow # auto, seedance, minimax_h3, google_omni, kling, wan-# VIDEO_MAX_GENERATED_SECONDS=60--# App-PORT=3456-# HOST=127.0.0.1 # default: this machine only-# API_KEY=some-long-random-string-CHANNEL_NAME=Your Channel Name-DEFAULT_PRIVACY_STATUS=private-```--The dashboard listens on `127.0.0.1` by default. If you set `HOST=0.0.0.0` to reach it from other devices, also set `API_KEY`, which every request that changes something must then send in the `x-api-key` header.+Models, keys, env vars, clip limits, and the `.env` essentials are in the [providers guide](docs/providers.md).## Automation@@ -187,83 +121,27 @@ The scheduler starts with `npm start` and uses the server's local time.Details are in the [feature guide](docs/features.md#automation-schedule).-## HTTP API+## Docs-The dashboard server also exposes an HTTP API:--```bash-curl http://localhost:3456/health+- [Feature guide](docs/features.md): a walkthrough of every studio and gate.+- [AI providers](docs/providers.md): text, narration, image, and video providers with keys and limits.+- [API reference](docs/api.md): every HTTP route the dashboard server exposes, for example `POST /generate` with `x-api-key`.+- [Troubleshooting](docs/troubleshooting.md): fixes for setup, sign-in, and generation problems.+- [Changelog](CHANGELOG.md) and [releases](https://github.com/darkzOGx/youtube-automation-agent/releases).-curl -X POST http://localhost:3456/generate \- -H "Content-Type: application/json" \- -H "x-api-key: $API_KEY" \- -d '{"topic": "Top 10 Life Hacks", "style": "list"}'--curl http://localhost:3456/api/jobs/:jobId-```--See the [API reference](docs/api.md) for every route.--## Troubleshooting+The three problems people hit most:| Problem | Fix || --- | --- |-| `Missing credentials for: an AI provider` | Configure any one text provider with `npm run walkthrough` or `npm run credentials:setup`. OpenAI isn't required. |+| `Missing credentials for: an AI provider` | Configure any one text provider with `npm run walkthrough`. OpenAI isn't required. || Google sign-in shows `Error 403: access_denied` | Add your Google account as a test user under **Google Auth Platform β Audience**. |-| No video is produced, or it's marked simulated | Read the β lines in the startup capability check. Make sure you ran `npx playwright install chromium` and that FFmpeg is available (`npm install` fetches it, or set `FFMPEG_PATH`). |-| Images or thumbnails are missing | Image generation needs OpenAI, or Gemini with billing enabled. The content review panel shows the provider's exact error. |-| Narration failed (for example, ElevenLabs HTTP 400) | Check the key, its credits, and that `ELEVENLABS_VOICE_ID` is a voice in your account, then use **Regenerate narration only**. |-| `Error loading sharp module` on Android/Termux | Update to the latest `master`, then run `rm -rf node_modules && npm install --cpu=wasm32`. |-| The publishing queue runs but nothing publishes | Approved videos publish at their scheduled time (default: the next day at 2 PM). |-| YouTube API quota exceeded | Check quotas in Google Cloud Console and reduce posting frequency. |-| Content generation failed | Check your keys and credits, the job's error in the dashboard, and `logs/`. |--For debug logging, run `LOG_LEVEL=debug NODE_ENV=development npm start`. Questions and setup help go in [Discussions](https://github.com/darkzOGx/youtube-automation-agent/discussions).--## Project structure--```-youtube-automation-agent/-βββ agents/ # one file per pipeline agent (strategy, script, thumbnail, SEO, production, publishing, analytics)-βββ dashboard/ # web dashboard served by index.js-βββ database/ # SQLite schema and access layer-βββ schedules/ # cron-based automation-βββ utils/ # AI text, media, and video providers; operator, readiness, engagement, and other services-βββ config/ # credential files (examples are committed)-βββ data/ # generated content and the local database-βββ docs/ # feature guide, API reference, design notes-βββ examples/ # verified real output from the community-βββ index.js # Express server and agent startup-βββ walkthrough.js # guided setup (npm run walkthrough)-βββ setup.js # classic setup (npm run setup)-βββ test.js # system test suite (npm test)-```--## Extending--### Add a text provider--Any provider with an OpenAI-compatible chat completions API can be added as a preset in `utils/ai-text-service.js`:--```javascript-deepseek: {- name: 'DeepSeek',- baseURL: 'https://api.deepseek.com',- defaultModel: 'deepseek-flash',- models: ['deepseek-flash', 'deepseek-v4-pro'],- envKey: 'DEEPSEEK_API_KEY',-},-```--Then add a matching entry to `AI_PROVIDER_GUIDE` in `walkthrough.js` and a setup option in `utils/credential-manager.js`, and run `npm test`. The walkthrough test fails if any provider is missing a complete guide.--### Add a video provider+| No video is produced, or it's marked simulated | Read the β lines in the startup capability check, and make sure you ran `npx playwright install chromium`. |-Video providers live in `utils/video-providers.js`. Each one extends `VideoProvider`, implements `isAvailable`, `createTask`, `getTask`, and `downloadResult`, and is registered in `VideoProviderRegistry`.+Questions and setup help go in [Discussions](https://github.com/darkzOGx/youtube-automation-agent/discussions).## Contributing-See [CONTRIBUTING.md](CONTRIBUTING.md) for ground rules (short version: one focused concern per PR, no lockfile churn, lint and tests must pass). For questions and setup help, use [Discussions](https://github.com/darkzOGx/youtube-automation-agent/discussions); Issues are for bugs.+See [CONTRIBUTING.md](CONTRIBUTING.md) for ground rules, project structure, and how to add a provider. Short version: one focused concern per PR, no lockfile churn, lint and tests must pass. Issues are for bugs.```bashgit clone <your-fork>@@ -277,9 +155,15 @@ Made something real with it? Share verified output in [examples](examples/README## Built by-[@darkzOGx](https://github.com/darkzOGx), a solo builder shipping AI automation and developer tools. Find me on [X](https://x.com/darkzOGx) and [laderalabs.io](https://laderalabs.io).+[@darkzOGx](https://github.com/darkzOGx), a solo builder shipping AI automation and developer tools. Find me on [X](https://x.com/darkzOGx) and [laderalabs.io](https://laderalabs.io). If YouTube Automation Agent saves you time, a star helps it reach more developers.-If YouTube Automation Agent saves you time, a star helps it reach more developers.+## License++MIT. See [LICENSE](LICENSE). Model and API acknowledgments are in the [providers guide](docs/providers.md#acknowledgments).++> This tool is for legitimate content creation. Comply with [YouTube's Terms of Service](https://www.youtube.com/t/terms) and Community Guidelines.++---More from darkzOGx:@@ -288,26 +172,3 @@ More from darkzOGx:- [open-sales-researcher](https://github.com/darkzOGx/open-sales-researcher): autonomous B2B company research. Works with Claude Code, Cursor, Copilot.- [darkzseo](https://github.com/darkzOGx/darkzseo): SEO tooling- [ConstructionBids.ai](https://constructionbids.ai): AI scans every federal, state & local public works bid and matches you to contracts you'll win.--## License--MIT. See [LICENSE](LICENSE).--## Acknowledgments--- [Google](https://ai.google.dev/): Gemini 3.8 Flash, Gemini 4 Argon, Gemini 3.1 Flash Image, Gemini 3.8 Flash TTS, Gemini Omni Flash, and the YouTube Data and Analytics APIs-- [OpenAI](https://openai.com/): GPT-6.1 Sol, GPT Image 2, gpt-4o-mini-tts-- [OpenRouter](https://openrouter.ai/): unified multi-model API-- [Moonshot AI](https://www.moonshot.ai/): Kimi K3-- [Xiaomi](https://mimo.mi.com/): MiMo V2.6 Pro-- [Zhipu AI](https://z.ai/): GLM-5.3-- [DeepSeek](https://www.deepseek.com/): DeepSeek V4.1 Flash-- [MiniMax](https://www.minimax.io/): MiniMax M3 text and H3 video-- [ElevenLabs](https://elevenlabs.io/): Eleven v3 TTS-- [Replicate](https://replicate.com/): Seedance 2.5 and Wan 2.7 hosting-- [Kuaishou Kling](https://kling.ai/): Kling 3.0 Omni-- [Alibaba Cloud Model Studio](https://modelstudio.console.alibabacloud.com/): Wan 2.7-------> This tool is for legitimate content creation. Comply with [YouTube's Terms of Service](https://www.youtube.com/t/terms) and Community Guidelines.diff --git a/assets/screenshots/operator.png b/assets/screenshots/operator.pngnew file mode 100644index 0000000..3ddb7b4Binary files /dev/null and b/assets/screenshots/operator.png differdiff --git a/assets/screenshots/overview.png b/assets/screenshots/overview.pngnew file mode 100644index 0000000..6d4783eBinary files /dev/null and b/assets/screenshots/overview.png differdiff --git a/assets/screenshots/review.png b/assets/screenshots/review.pngnew file mode 100644index 0000000..b97d804Binary files /dev/null and b/assets/screenshots/review.png differdiff --git a/assets/youtube-automation-agent.jpg b/assets/youtube-automation-agent.jpgdeleted file mode 100644index efb143d..0000000Binary files a/assets/youtube-automation-agent.jpg and /dev/null differdiff --git a/docs/features.md b/docs/features.mdindex 264e030..ee26d4b 100644--- a/docs/features.md+++ b/docs/features.md@@ -48,7 +48,7 @@ Autonomous Operator runs preserve their research and editorial plan, so **ResumeLocal slideshow rendering is the default, so upgrading does not start paid video requests. The slideshow is rendered in headless Chromium (install it once with `npx playwright install chromium`) and assembled with FFmpeg. Generated images fill each slide; slides without an image use a gradient background.-To generate real clips, choose a provider in **Channel setup**, set a paid-seconds cap, then run the separately opted-in paid video readiness probe. The supported providers and their clip limits are listed in the [README](../README.md#video).+To generate real clips, choose a provider in **Channel setup**, set a paid-seconds cap, then run the separately opted-in paid video readiness probe. The supported providers and their clip limits are listed in [AI providers](providers.md#video).Long-form productions use hybrid assembly: the agent generates bounded provider clips for the hook and important sections, fills the remaining timeline locally, mixes the existing narration, and keeps the generated caption file alongside the production. As soon as a provider returns its task ID, the agent persists it before polling, so interrupted jobs can resume that known task instead of submitting it again. If a provider fails, the production falls back to the local slideshow.@@ -84,7 +84,7 @@ Use the altered or synthetic media control only when the video contains realistiEvery saved production receives an optional **DarkzSEO Discoverability Preflight** in Review Studio after metadata and provenance are assembled. The bundled content auditor reviews a canonical content package (not the private dashboard) with versioned GEO, AIO, AEO, and web-search checks, and stores the engine version, schema version, severity summary, stable rule IDs, and individual findings in SQLite.-Findings are advisory. Keep a useful recommendation as actionable, or dismiss a false positive with a reviewer reason that carries forward to matching findings on later audits. The bundled audit requires no Python package and never silently changes scripts or metadata.+Findings are advisory. Keep a useful recommendation as actionable, or dismiss a false positive with a reviewer reason that carries forward to matching findings on later audits. The bundled audit requires no Python package and never silently changes scripts or metadata. Python is only needed to test an external DarkzSEO checkout, described next.To test a separate DarkzSEO 1.4+ checkout (requires Python 3.9+) instead of the bundled auditor:diff --git a/docs/providers.md b/docs/providers.mdnew file mode 100644index 0000000..ea264e5--- /dev/null+++ b/docs/providers.md@@ -0,0 +1,83 @@+# AI providers++YouTube Automation Agent runs on your own API keys. One text provider is enough to start. Narration, images, and AI video are optional layers on top. Pick providers in `npm run walkthrough`, or set their keys in `.env` ([`.env.example`](../.env.example) documents every setting).++## Text++Pick one in the walkthrough, or set its key in `.env`. The SDK base URL is configured for you.++| Provider | Models | Key | Env var |+| --- | --- | --- | --- |+| **Google Gemini** | Gemini 3.8 Flash, Gemini 4 Argon (paid only), 3.5 Flash-Lite | [AI Studio](https://aistudio.google.com/apikey) | `GEMINI_API_KEY` |+| **OpenAI** | GPT-6.1 Sol, GPT-6 Astra, GPT-6 Luna | [platform.openai.com](https://platform.openai.com/api-keys) | `OPENAI_API_KEY` |+| **OpenRouter** | 400+ models through one key; curated defaults are checked against its live catalog | [openrouter.ai](https://openrouter.ai/keys) | `OPENROUTER_API_KEY` |+| **Kimi (Moonshot AI)** | Kimi K3, K2.7 Code, K2.6 | [platform.kimi.ai](https://platform.kimi.ai) | `MOONSHOT_API_KEY` |+| **MiMo (Xiaomi)** | MiMo V2.6 Pro, V2.6 Flash | [mimo.mi.com](https://mimo.mi.com) | `MIMO_API_KEY` |+| **GLM (Zhipu AI)** | GLM-5.3, 5.3 Flash, 5.2 | [z.ai](https://z.ai) | `GLM_API_KEY` |+| **DeepSeek** | DeepSeek V4.1 Flash, V4 Pro | [platform.deepseek.com](https://platform.deepseek.com/api_keys) | `DEEPSEEK_API_KEY` |+| **MiniMax** | MiniMax M3.1 Flash, M3 | [platform.minimax.io](https://platform.minimax.io/user-center/basic-information/interface-key) | `MINIMAX_TEXT_API_KEY` |++Anthropic Claude is available through OpenRouter (`anthropic/claude-fable-5.1`). OpenRouter, Kimi, MiMo, GLM, DeepSeek, and MiniMax cover scripts only. Add a Gemini or OpenAI key for images and narration, or ElevenLabs for narration.++## Narration and images++- **Narration** uses the first configured provider in this order: ElevenLabs (Eleven v3, needs `ELEVENLABS_API_KEY` and `ELEVENLABS_VOICE_ID`), OpenAI (`gpt-4o-mini-tts`), then Gemini (`gemini-3.8-flash-tts`). A video without working narration can't be approved.+- **Images** use OpenAI (GPT Image 2) and Gemini (`gemini-3.1-flash-image`, which needs billing enabled), each falling back to the other. With neither, slides use gradient backgrounds and thumbnails come from the built-in designer.++## Video++Local slideshow rendering is the default, so you never pay for video unless you choose a provider in **Channel setup** and set a paid-seconds cap. If a provider fails, the video falls back to the local slideshow.++| Provider | Default model | Best fit | Clip limits | Env var |+| --- | --- | --- | --- | --- |+| ByteDance | `bytedance/seedance-2.5` through Replicate | Cinematic long scenes and large reference sets | 4β30 seconds | `REPLICATE_API_TOKEN` |+| MiniMax | `MiniMax-H3` | Multimodal references, native stereo audio, optional 2K | 4β15 seconds | `MINIMAX_API_KEY` |+| Google | `gemini-omni-1.1-flash` | Fast generation and conversational editing | 3β10 seconds | `GEMINI_API_KEY` |+| Kuaishou | `kling-v3-omni` | Storyboards and character/voice consistency | 3β15 seconds | `KLING_ACCESS_KEY`, `KLING_SECRET_KEY` |+| Alibaba | Wan 2.7 task-specific models | Efficient generation, reference video, and continuation | 2β15 seconds | `DASHSCOPE_API_KEY` |++Long videos use hybrid assembly: generated clips for the hook and key sections, with the rest of the timeline filled locally. See [AI video generation](features.md#ai-video-generation).++## Environment variables++`npm run walkthrough` writes your configuration for you. To edit it by hand, copy [`.env.example`](../.env.example) to `.env`. The essentials:++```env+# One text provider (see the table above)+GEMINI_API_KEY=...++# Optional: narration, images, and AI video+# ELEVENLABS_API_KEY=...+# ELEVENLABS_VOICE_ID=...+# OPENAI_API_KEY=sk-...+# VIDEO_PROVIDER=slideshow # auto, seedance, minimax_h3, google_omni, kling, wan+# VIDEO_MAX_GENERATED_SECONDS=60++# App+PORT=3456+# HOST=127.0.0.1 # default: this machine only+# API_KEY=some-long-random-string+CHANNEL_NAME=Your Channel Name+DEFAULT_PRIVACY_STATUS=private+```++The dashboard listens on `127.0.0.1` by default. If you set `HOST=0.0.0.0` to reach it from other devices, also set `API_KEY`, which every request that changes something must then send in the `x-api-key` header.++## Adding a provider++See [Extending](../CONTRIBUTING.md#extending) in the contributing guide for how to add a text or video provider.++## Acknowledgments++- [Google](https://ai.google.dev/): Gemini 3.8 Flash, Gemini 4 Argon, Gemini 3.1 Flash Image, Gemini 3.8 Flash TTS, Gemini Omni Flash, and the YouTube Data and Analytics APIs+- [OpenAI](https://openai.com/): GPT-6.1 Sol, GPT Image 2, gpt-4o-mini-tts+- [OpenRouter](https://openrouter.ai/): unified multi-model API+- [Moonshot AI](https://www.moonshot.ai/): Kimi K3+- [Xiaomi](https://mimo.mi.com/): MiMo V2.6 Pro+- [Zhipu AI](https://z.ai/): GLM-5.3+- [DeepSeek](https://www.deepseek.com/): DeepSeek V4.1 Flash+- [MiniMax](https://www.minimax.io/): MiniMax M3 text and H3 video+- [ElevenLabs](https://elevenlabs.io/): Eleven v3 TTS+- [Replicate](https://replicate.com/): Seedance 2.5 and Wan 2.7 hosting+- [Kuaishou Kling](https://kling.ai/): Kling 3.0 Omni+- [Alibaba Cloud Model Studio](https://modelstudio.console.alibabacloud.com/): Wan 2.7diff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdnew file mode 100644index 0000000..993671b--- /dev/null+++ b/docs/troubleshooting.md@@ -0,0 +1,28 @@+# Troubleshooting++Most problems show up in the startup capability check (the `π Capability check:` block when you run `npm start`) or in the job's error in the dashboard. Start there.++| Problem | Fix |+| --- | --- |+| `Missing credentials for: an AI provider` | Configure any one text provider with `npm run walkthrough` or `npm run credentials:setup`. OpenAI isn't required. |+| Google sign-in shows `Error 403: access_denied` | Add your Google account as a test user under **Google Auth Platform β Audience**. While the app is in Testing mode, Google expires the sign-in after 7 days. |+| No video is produced, or it's marked simulated | Read the β lines in the startup capability check. Make sure you ran `npx playwright install chromium` and that FFmpeg is available (`npm install` fetches it, or set `FFMPEG_PATH`). |+| Images or thumbnails are missing | Image generation needs OpenAI, or Gemini with billing enabled. The content review panel shows the provider's exact error. |+| Narration failed (for example, ElevenLabs HTTP 400) | Check the key, its credits, and that `ELEVENLABS_VOICE_ID` is a voice in your account, then use **Regenerate narration only**. |+| `Error loading sharp module` on Android/Termux | Update to the latest `master`, then run `rm -rf node_modules && npm install --cpu=wasm32`. |+| The publishing queue runs but nothing publishes | Approved videos publish at their scheduled time (default: the next day at 2 PM). |+| YouTube API quota exceeded | Check quotas in Google Cloud Console and reduce posting frequency. |+| Content generation failed | Check your keys and credits, the job's error in the dashboard, and `logs/`. |+| The dashboard is unreachable from another device | It listens on `127.0.0.1` by default. Set `HOST=0.0.0.0` and an `API_KEY` in `.env`. See [environment variables](providers.md#environment-variables). |++## Debug logging++```bash+LOG_LEVEL=debug NODE_ENV=development npm start+```++Logs are written to `logs/`.++## Getting help++Questions and setup help go in [Discussions](https://github.com/darkzOGx/youtube-automation-agent/discussions). Issues are for bugs; the bug report template asks for the capability check block, which diagnoses most problems instantly.diff --git a/package.json b/package.jsonindex 0ec52ee..8426f15 100644--- a/package.json+++ b/package.json@@ -8,6 +8,7 @@"setup": "node setup.js","walkthrough": "node walkthrough.js","growth:snapshot": "node scripts/growth/snapshot-github.js",+ "docs:screenshots": "node scripts/docs/capture-screenshots.js","scheduler": "node schedules/daily-automation.js","test": "node test.js","agent:strategy": "node agents/content-strategy-agent.js",diff --git a/scripts/docs/capture-screenshots.js b/scripts/docs/capture-screenshots.jsnew file mode 100644index 0000000..10bdedd--- /dev/null+++ b/scripts/docs/capture-screenshots.js@@ -0,0 +1,270 @@+#!/usr/bin/env node+/**+ * Capture the README dashboard screenshots.+ *+ * npm run docs:screenshots # sample data (what the README uses)+ * node scripts/docs/capture-screenshots.js --live+ *+ * Starts the dashboard server from this checkout on a free port, opens it in+ * Playwright Chromium at 1440x900 (dark color scheme), and writes PNGs to+ * assets/screenshots/:+ *+ * overview.png the Overview view+ * review.png the content review dialog for the first pipeline item+ * operator.png the Autonomous operator view+ *+ * No credentials are needed; the console runs in setup mode without them.+ *+ * Sample mode (the default) injects a small set of example productions, jobs,+ * schedule entries, and activity into the dashboard's in-browser state so the+ * screenshots show a working channel. Nothing is written to the database and+ * the README captions say the images use sample data. The project never+ * presents simulated output as real, so keep that label whenever these images+ * are reused.+ *+ * Live mode (--live) captures whatever your local database holds. Use it with+ * at least one real production, or review.png is skipped.+ */++'use strict';++const path = require('path');+const fs = require('fs');+const net = require('net');+const { spawn } = require('child_process');++const ROOT = path.resolve(__dirname, '..', '..');+const OUT_DIR = path.join(ROOT, 'assets', 'screenshots');+const VIEWPORT = { width: 1440, height: 900 };+const MAX_BYTES = 400 * 1024;+const LIVE = process.argv.includes('--live');++function freePort() {+ return new Promise((resolve, reject) => {+ const server = net.createServer();+ server.unref();+ server.on('error', reject);+ server.listen(0, '127.0.0.1', () => {+ const { port } = server.address();+ server.close(() => resolve(port));+ });+ });+}++async function waitForHealth(baseUrl, timeoutMs = 60000) {+ const started = Date.now();+ while (Date.now() - started < timeoutMs) {+ try {+ const response = await fetch(`${baseUrl}/health`);+ if (response.ok) return response.json();+ } catch {+ // not up yet+ }+ await new Promise(resolve => setTimeout(resolve, 500));+ }+ throw new Error(`Dashboard did not answer /health within ${timeoutMs / 1000}s`);+}++function startServer(port) {+ const child = spawn(process.execPath, [path.join(ROOT, 'index.js')], {+ cwd: ROOT,+ env: { ...process.env, PORT: String(port), HOST: '127.0.0.1', LOG_LEVEL: process.env.LOG_LEVEL || 'warn' },+ stdio: ['ignore', 'pipe', 'pipe']+ });+ let output = '';+ child.stdout.on('data', chunk => { output += chunk; });+ child.stderr.on('data', chunk => { output += chunk; });+ child.on('exit', code => {+ if (code && code !== 0 && !child.killed) {+ console.error(output);+ console.error(`Dashboard server exited with code ${code}`);+ }+ });+ return child;+}++/**+ * Runs inside the page. Replaces the dashboard's in-memory state with sample+ * records and re-renders. Polling is stopped so the next refresh does not+ * overwrite it. The database is not touched.+ */+function applySampleData() {+ /* global ui, renderDashboard, api */+ // `ui` is a top-level const in dashboard/app.js, visible to evaluated code+ // through the page's global lexical scope rather than on `window`.+ const state = ui.state;+ const now = Date.now();+ const hoursAgo = h => new Date(now - h * 3600e3).toISOString();+ const hoursAhead = h => new Date(now + h * 3600e3).toISOString();+ const checks = passed => Array.from({ length: 10 }, (_, i) => ({+ passed: i < passed,+ message: [+ 'Hook lands in the first 12 seconds', 'Script length matches the target', 'No blocked terms used',+ 'Every statistic has a source', 'Narration matches the script', 'Captions pass the timing check',+ 'Thumbnail text is legible at 320px', 'Title under 70 characters', 'Description includes the CTA',+ 'Media rights recorded for every scene'+ ][i] + (i < passed ? '' : ': 2 scenes still unconfirmed')+ }));++ ui.refreshing = true; // the 8-second poll and the enhance.js tickers skip renders while this is set++ state.system = {+ ...state.system,+ setupRequired: false,+ automationPaused: false,+ initialized: true,+ agents: ['strategy', 'scriptWriter', 'thumbnailDesigner', 'seoOptimizer', 'production', 'publishing', 'analytics']+ };+ state.profile = { ...state.profile, channel_name: state.profile?.channel_name || 'Futurecraft' };+ state.stats = { ...state.stats, published: 12 };+ state.analytics = { ...state.analytics, totalVideos: 9, averagePerformanceScore: 71 };++ state.pipeline = [+ { id: 'p1', title: 'Why most AI automations fail in week two', topic: 'AI workflows', created_at: hoursAgo(5), review_status: 'needs_review', qualityChecks: checks(9), hasThumbnail: false },+ { id: 'p2', title: 'The 3 tools that replaced my editor', topic: 'Tool reviews', created_at: hoursAgo(30), review_status: 'needs_attention', qualityChecks: checks(7) },+ { id: 'p3', title: 'A repeatable research system for creators', topic: 'Automation playbooks', created_at: hoursAgo(80), schedule_status: 'scheduled', qualityChecks: checks(10) },+ { id: 'p4', title: 'Stop scripting by hand: a 40-minute workflow', topic: 'AI workflows', created_at: hoursAgo(200), schedule_status: 'published', qualityChecks: checks(10) }+ ];+ state.jobs = [+ {+ id: 'j1', title: 'How small teams audit their AI stack', status: 'running', stage: 'production', updated_at: hoursAgo(0.2), progress: 62,+ checkpoints: ['strategy', 'script', 'thumbnail', 'seo'].map(stage => ({ stage, status: 'completed' })),+ mediaTasks: [{ status: 'succeeded', provider: 'seedance' }, { status: 'succeeded', provider: 'seedance' }, { status: 'running', provider: 'seedance' }]+ },+ { id: 'j2', title: 'Pricing AI tools honestly', status: 'failed', stage: 'script', updated_at: hoursAgo(3), progress: 20, checkpoints: [{ stage: 'strategy', status: 'completed' }] }+ ];+ state.schedule = [+ { title: 'A repeatable research system for creators', publish_time: hoursAhead(48), status: 'scheduled', production_id: 'p3' },+ { title: 'Stop scripting by hand: a 40-minute workflow', publish_time: hoursAgo(200), status: 'published', production_id: 'p4' }+ ];+ state.notifications = [+ { level: 'success', title: 'Video published', message: '"Stop scripting by hand" went live as scheduled.', created_at: hoursAgo(200) },+ { level: 'warning', title: 'Quality review flagged claims', message: '2 statistics in "The 3 tools" have no source.', created_at: hoursAgo(30) },+ { level: 'error', title: 'Generation failed', message: 'Script stage: provider timeout after 3 retries.', created_at: hoursAgo(3) },+ { level: 'info', title: 'Operator run started', message: 'Planning 1 video for next week.', created_at: hoursAgo(1) }+ ];+ state.ideas = [+ { id: 'i1', topic: 'What an AI agent actually costs per video', angle: 'Real invoices, not estimates', status: 'backlog' },+ { id: 'i2', topic: 'Narration voices compared', angle: 'Blind test with 50 viewers', status: 'backlog' }+ ];+ state.channelStrategy = {+ ...(state.channelStrategy || {}),+ status: 'active',+ objective: 'Become the clearest practical guide to AI-assisted creator operations.',+ audience: 'Independent creators and small media teams who value quality, speed, and control.',+ value_proposition: 'Every video turns a noisy AI trend into a dependable workflow viewers can use this week.',+ contentPillars: ['Creator operating systems', 'Evidence-first AI workflows', 'Packaging and retention', 'Responsible automation'],+ cadence_per_week: 2, videos_per_run: 1, default_format: 'tutorial', default_length: 'medium',+ primary_kpi: 'subscribers', target_value: 500, target_window_days: 90, outcome_currency: 'USD',+ success_metric: 'Grow returning subscribers who come back for practical automation tutorials',+ constraints: 'No hype, no unverified statistics, explain costs and tradeoffs.'+ };+ state.operatorRuns = [{+ id: 'r1', status: 'running', stage: 'producing', progress: 60,+ research: { sources: ['YouTube trends', '3 competitor channels', 'channel history'] },+ summary: { planned: 2, generated: 1, needsReview: 1 },+ plan: [+ { topic: 'How small teams audit their AI stack', format: 'tutorial', length: 'medium', rationale: 'Highest search demand this month in the "Creator operating systems" pillar; no competitor covers the audit step.' },+ { topic: 'Why most AI automations fail in week two', format: 'explainer', length: 'medium', rationale: 'Retention data from the last three videos shows the "failure modes" segment held 84% of viewers.' }+ ],+ generatedJobs: [+ { topic: 'How small teams audit their AI stack', status: 'running' },+ { topic: 'Why most AI automations fail in week two', status: 'completed', reviewStatus: 'needs_review' }+ ]+ }];++ const sampleContent = {+ id: 'p1', review_status: 'needs_review', qualityChecks: state.pipeline[0].qualityChecks, assetUrls: {},+ seo: {+ title: 'Why most AI automations fail in week two',+ description: 'Most creators automate the wrong step first. This video walks through the three failure patterns we saw across 40 channels and the one fix that stuck.\n\nChapters:\n00:00 The week-two cliff\n01:40 Pattern 1: automating the output, not the input\n05:10 Pattern 2: no review gate\n08:30 Pattern 3: measuring the wrong thing\n11:00 The fix',+ tags: ['ai automation', 'creator workflow', 'youtube automation', 'small business ai']+ },+ editorData: { privacyStatus: 'private', factChecked: false, rightsConfirmed: true },+ scenes: [], provenance: {}, shorts: {}+ };+ const originalApi = api;+ window.api = async (url, ...rest) => {+ if (typeof url === 'string' && url.startsWith('/api/content/')) return sampleContent;+ return originalApi(url, ...rest);+ };++ renderDashboard();+ window.scrollTo(0, 0);+ return state.pipeline.length;+}++async function settle(page) {+ await page.waitForFunction(() => !document.documentElement.classList.contains('preboot'));+ await page.waitForFunction(() => document.querySelector('#stat-review')?.textContent.trim() !== 'β', null, { timeout: 15000 }).catch(() => {});+ await page.waitForTimeout(700);+}++async function save(page, name) {+ const file = path.join(OUT_DIR, name);+ await page.screenshot({ path: file, type: 'png' });+ const sharp = require('sharp');+ const meta = await sharp(file).metadata();+ if (meta.width > VIEWPORT.width || fs.statSync(file).size > MAX_BYTES) {+ const buffer = await sharp(file)+ .resize({ width: Math.min(meta.width, VIEWPORT.width), withoutEnlargement: true })+ .png({ compressionLevel: 9, palette: true, quality: 90 })+ .toBuffer();+ fs.writeFileSync(file, buffer);+ }+ const size = fs.statSync(file).size;+ console.log(`${name}: ${(size / 1024).toFixed(0)} KB${size > MAX_BYTES ? ' (over the 400 KB target; consider cropping)' : ''}`);+}++async function main() {+ fs.mkdirSync(OUT_DIR, { recursive: true });+ const port = await freePort();+ const baseUrl = `http://127.0.0.1:${port}`;+ const server = startServer(port);+ const stop = () => { if (!server.killed) server.kill(); };+ process.on('exit', stop);+ process.on('SIGINT', () => { stop(); process.exit(130); });++ let browser;+ try {+ const health = await waitForHealth(baseUrl);+ console.log(`Dashboard v${health.version || '?'} up at ${baseUrl} (${health.status}, ${LIVE ? 'live data' : 'sample data'})`);++ const { chromium } = require('playwright');+ browser = await chromium.launch();+ const page = await browser.newPage({ viewport: VIEWPORT, colorScheme: 'dark', deviceScaleFactor: 1 });+ await page.goto(baseUrl, { waitUntil: 'networkidle' });+ await settle(page);++ let pipelineCount = await page.evaluate(() => (ui?.state?.pipeline || []).length);+ if (!LIVE) {+ pipelineCount = await page.evaluate(applySampleData);+ await page.waitForTimeout(900); // count-up animation+ }++ await save(page, 'overview.png');++ await page.evaluate(() => window.switchView('operator'));+ await page.waitForTimeout(500);+ await save(page, 'operator.png');++ if (pipelineCount > 0) {+ await page.evaluate(() => window.switchView('pipeline'));+ await page.waitForTimeout(400);+ await page.click('.pipeline-item');+ await page.waitForSelector('#content-dialog[open]');+ await page.waitForTimeout(600);+ await save(page, 'review.png');+ } else {+ console.warn('No productions in the database: review.png was not captured. Generate a real video first, then run this again.');+ }+ } finally {+ if (browser) await browser.close();+ stop();+ }+}++main().catch(error => {+ console.error(error.message);+ process.exit(1);+});