--- name: youtube-knowledge-ingestion description: "AUTO-TRIGGER: If the operator's message consists solely of a YouTube URL (youtube.com/watch, youtu.be, youtube.com/shorts — no other words), ALWAYS run the full ingestion flow immediately, without asking any clarifying questions: 1. Verbatim transcript → ai_vault_kb (the vault) per the \"Transcript Ingestion (verbatim)\" section (dedup-first, separate doc if a recipe/summary doc for the video already exists). 2. Distilled summary → Cognee brain (the brain) per the \"Brain Injection (Cognee)\" section. 3. If the video's description or pinned comment links a workflow or downloadable assets, download them to the NAS stock library per the existing procedure. 4. Reply with a minimal 4-line completion status (Brain ingest / Vault ingest / Workflow dl / Workflow(s)); write the full proof report (doc_id, chunk count, excerpt, BM25 outputs, file paths + sizes) to ~/workspace/general/logs/yt_ingestion_proofs.log instead of sending it to the operator. Use when user drops a YouTube link. Transcript→vault+brain→NAS." version: 1.1.0 platforms: [linux] --- # YouTube Knowledge Ingestion Pipeline ## AUTO-TRIGGER (read first — highest priority) AUTO-TRIGGER: If the operator's message consists solely of a YouTube URL (youtube.com/watch, youtu.be, youtube.com/shorts — no other words), ALWAYS run the full ingestion flow immediately, without asking any clarifying questions: 1. Verbatim transcript → ai_vault_kb (the vault) per the "Transcript Ingestion (verbatim)" section (dedup-first, separate doc if a recipe/summary doc for the video already exists). 2. Distilled summary → Cognee brain (the brain) per the "Brain Injection (Cognee)" section. 3. If the video's description or pinned comment links a workflow or downloadable assets, download them to the NAS stock library per the existing procedure. 4. Reply with a minimal 4-line completion status (see "Completion output" below); write the full proof report to ~/workspace/general/logs/yt_ingestion_proofs.log instead of sending it to the operator. **The failure mode this trigger exists to prevent (recurring user correction):** loading the `youtube-content` skill and producing a chat summary. A bare URL is NOT a request for a summary — it is a request to run THIS pipeline. Do NOT load `youtube-content` for a bare URL; load THIS skill (`youtube-knowledge-ingestion`). Do NOT summarize the video in chat under any circumstances. The user has corrected this multiple times ("WHY DO YOU KEEP DOING THIS — YOU HAVE A YT INGEST SKILL"). The two skills are easy to confuse: `youtube-content` = fetch transcript + format (summary/thread/blog); `youtube-knowledge-ingestion` = the full transcript→vault + summary→brain + workflow→NAS pipeline. A bare URL always means the latter. ## When to use User drops a YouTube link for AI/ML video content (ComfyUI workflows, LTX, MiniMax, Krea, model tutorials, prompting guides). Run the full four-step pipeline — never skip any step. ## Pipeline (always all four steps) ### 1. Transcript Load the `youtube-content` skill and fetch: ```bash uv run python3 /scripts/fetch_transcript.py "URL" --text-only --timestamps ``` If `youtube-transcript-api` is missing, install with `pip3 install --user youtube-transcript-api`. ### 2. Vault Injection (ai_vault_kb) (MANDATORY) Load the `ai-vault-kb` skill. Always dedup-first, then ingest: ```bash # Dedup check python3 /home/n8n/bin/ai_vault_kb.py search --query "" --limit 5 # Ingest — use --type workflow for tutorials python3 /home/n8n/bin/ai_vault_kb.py add \ --type workflow \ --title "Descriptive Title — Key Topics" \ --stage \ --tool \ --host 10.0.0.202 \ --trust community \ --importance 0.7-0.85 \ --tags "comma,separated,keywords,creator-name" \ --url "https://www.youtube.com/watch?v=VIDEO_ID" \ --content "..." \ --json # Verify BM25 leg python3 /home/n8n/bin/ai_vault_kb.py search --query "" \ --mode bm25 --doc-id ``` **Content format**: Dense, factual technical summary. Use CAPITALIZED section headers. Include specific settings, model names, thresholds, commands, and failure modes. This is a technical reference, not a blog post. **MANDATORY: workflow links in the vault content.** Every vault entry must include a `## WORKFLOW LINKS` section listing the DOWNLOADED workflow files on NAS (TrueNAS 10.0.0.117, proxmoxBackup/ai_vid_stock_material/workflows/, exact filenames + the smbclient get command), the source repo URL, and the video URL. The NAS copies are the primary links — the user wants links to the downloaded workflows, not upstream URLs. If the description links elsewhere (Patreon etc.) and is unreachable, say so in the content. Append as a separate chunk via `--doc-id` if the main content was already ingested. **Tag strategy**: model name, tool name, creator name, key techniques. Tags are exact-match keyword indexes. ### 3. Brain Injection (Cognee) (MANDATORY) Load the `cognee-brain` skill. Write the distilled summary to the shared Cognee brain (10.0.0.23) as a narrative finding — LLM extraction pulls out the entities (models, tools, creators) and facts (claims, settings, comparisons) automatically: Call the Cognee MCP tool `mcp__cognee__remember` with: - `data` = the distilled summary (2-4 sentences) - `dataset_name` = `homelab-stack` - omit `session_id` (permanent memory — runs add + cognify, builds the graph) - `remember` is synchronous (`status: completed` means the graph is built). No polling needed; verify later with `recall` if needed. - Always use dataset `homelab-stack` (the single shared brain dataset). Never create a second dataset. - The brain holds the distilled facts; the vault (ai_vault_kb) holds the verbatim transcript. Both are written for every video — never skip either. **MCP timeout + REST fallback (learned 2026-08-29).** The MCP `remember` call can fail with `TimeoutError: MCP call timed out after 120.0s` because cognify is variable — the REST path took 77s for a 6-item ingest, while MCP full-size payloads ran 9.8–12.2s. The MCP server itself is healthy; it is the client-side 120s per-tool-call timeout that aborts slow cognify runs. Two-part fix: 1. **Raise the timeout** in `~/.hermes/profiles/general/config.yaml` (cognee MCP block): `timeout: 120` → `timeout: 300`. Takes effect on next Hermes restart (MCP connections are read once at startup). Note: the `patch` tool refuses to edit Hermes config files — use terminal Python for an exact string replace, then `python3 -c "import yaml; yaml.safe_load(open('config.yaml'))"` to validate. 2. **REST fallback** when MCP times out (documented in the `cognee-brain` skill): ```bash # Write (synchronous; returns status:completed + items_processed) curl -s -m 300 -X POST "http://10.0.0.23:8080/api/v1/remember" \ -F "data=@/tmp/brain_summary.txt" \ -F "datasetName=homelab-stack" # Verify (field names are query + searchType, NOT query_text/query_type) curl -s -m 60 -X POST "http://10.0.0.23:8080/api/v1/search" \ -H "Content-Type: application/json" \ -d '{"query":"","datasets":["homelab-stack"],"searchType":"HYBRID_COMPLETION"}' ``` A `status: completed` from the REST write is proof the graph is built — no separate cognify step. If the MCP call times out, do NOT retry it blindly; use the REST path and verify with the search call above. ### 4. NAS Workflow Download If the video description contains workflow links (GitHub repos, direct JSON files), extract the description with `yt-dlp --print description "URL"`, clone the repos, and copy workflow JSONs to the NAS: ```bash # Clone cd /tmp && rm -rf 2>/dev/null git clone --depth 1 # Find workflows find /tmp/ -name "*.json" # Copy to NAS with creator prefix for disambiguation smbclient -N //10.0.0.117/proxmoxBackup \ -c 'cd ai_vid_stock_material/workflows; put "" "-.json"' ``` **Naming convention**: `--.json` Examples: `amao2001-ltx2.5-video_ltx2_5_t2v1.json`, `vionex-krea2-film-studio-v01.json` **Target**: `proxmoxBackup/ai_vid_stock_material/workflows/` on TrueNAS (10.0.0.117). **ComfyUI custom-node repos (no workflow JSONs) → `scripts/`, not `workflows/`.** When the description links a ComfyUI custom-node pack (e.g. PlagueKind's `ComfyUI-PlagueKind-Nodes` — the SLA attention node), the repo is Python source with no `example_workflows/*.json` to copy. Archive it as a tarball under `ai_vid_stock_material/scripts/` (same pattern as full apps — see `references/fetch-path-and-walled-links.md`): ```bash cd /tmp && rm -rf && git clone --depth 1 COMMIT=$(cd && git log -1 --format=%h) tar czf --.tar.gz smbclient -N //10.0.0.117/proxmoxBackup \ -c 'cd ai_vid_stock_material/scripts; put /tmp/ ' ``` `workflows/` stays reserved for ComfyUI JSONs; `scripts/` is the home for node packs and tools. Record the commit hash in the WORKFLOW LINKS section. ## Transcript Ingestion (verbatim) — when the task says "transcript" When the task asks for the TRANSCRIPT (not a summary/recipe), the vault doc must contain the verbatim spoken text. A distilled recipe summary is NOT a transcript. **Omit useless segments.** "Verbatim" means the informative spoken content word-for-word — not the filler around it. Cut entirely: sponsor reads / ad segments, song lyrics and music-only passages, giveaway/merch/Patreon plugs, like-and-subscribe boilerplate, and unrelated channel promo. Replace each cut with a one-line marker at that spot — [sponsor segment omitted], [music omitted], [channel promo omitted] — so the cut is visible and auditable. When in doubt, keep it: anything touching the technical content (settings, models, node names, reasoning, results) is never filler, even if it sounds chatty. The word count in the summary header notes omissions, e.g. "2,140 words (3 segments omitted: 2 sponsor, 1 music)." 1. **Fetch the caption track**: `yt-dlp --skip-download --write-auto-subs --write-subs --sub-langs "en.*" ` (fall back to `--sub-langs en` if needed). Clean the VTT/SRT to plain text: strip WEBVTT headers, cue timestamps, and inline ``/timestamp tags; dedupe rolling-caption repeated lines. Result must read as continuous spoken sentences. 2. **Body layout**: short distilled summary header (10–15 lines max) at top, then the FULL verbatim transcript. Title pattern: `YT: