Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.
Python ai-toolsauto-captionscaptionscliffmpegmcpmcp-serveropusclip-alternativepodcast-clipspodcastsshortform-videovertical-videowhisper
feat: add fast draft rendering mode
Nika Siradzea9c736a70250
diff --git a/backend/cli.py b/backend/cli.pyindex d676eb0..a08cd1a 100644--- a/backend/cli.py+++ b/backend/cli.py@@ -49,6 +49,34 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))from presets import MIN_CLIP_DURATION, MAX_CLIP_DURATION, TARGET_CLIP_DURATION_MIN, TARGET_CLIP_DURATION_MAX+def _thumbnail_lead_timestamp(start_second: float, frame_offset: float = 1 / 30) -> float:+ """Timestamp for the still frame that leads into a rendered clip."""+ try:+ start = float(start_second)+ except (TypeError, ValueError):+ start = 0.0+ return max(0.0, start - max(0.0, frame_offset))+++def _extract_thumbnail_lead_frame(video_path: str, output_path: str, start_second: float) -> str | None:+ """Extract the frame just before a clip start for thumbnail generation."""+ from utils.proc import run as proc_run++ timestamp = _thumbnail_lead_timestamp(start_second)+ cmd = [+ "ffmpeg", "-y",+ "-ss", f"{timestamp:.3f}",+ "-i", video_path,+ "-frames:v", "1",+ "-q:v", "2",+ output_path,+ ]+ result = proc_run(cmd, timeout=60, check=False)+ if result.returncode == 0 and os.path.exists(output_path):+ return output_path+ return None++def _ensure_ssl_certs():"""Fix SSL certificate issues automatically (macOS + corporate proxies)."""import ssl@@ -252,6 +280,27 @@ def cmd_process(args):config["no_cache"] = Trueif args.quality:config["quality"] = args.quality+ if getattr(args, "allow_ass_fallback", False):+ config["allow_ass_fallback"] = True++ if getattr(args, "fast", False):+ # Fast mode is a draft-render path inspired by Clipify: skip the+ # slowest analysis and polish passes while preserving explicit flags.+ config["fast_mode"] = True+ config["whisper_model"] = "tiny.en"+ config["top_clips"] = args.top or min(config.get("top_clips", 5), 3)+ config["energy_boost"] = False+ config["no_speakers"] = True+ config["quality"] = args.quality or "low"+ config["crop_strategy"] = args.crop or "center"+ config["allow_ass_fallback"] = True+ config["use_ass_captions"] = True+ config["generate_thumbnails"] = False+ config["generate_content"] = False+ config["ai_select"] = False+ if not args.outro:+ config["outro_path"] = ""+ os.environ["PODCLI_TRANSITION_AUTOFIX_PASSES"] = "0"# Set quality env var before importing video_processorquality = config.get("quality", os.environ.get("PODCLI_QUALITY", "max"))@@ -271,6 +320,8 @@ def cmd_process(args):print(f"\n podcli — processing")print(f" Encoder: {enc_info['best']} ({enc_info['system']})")print(f" Quality: {quality}")+ if config.get("fast_mode"):+ print(" Mode: fast draft")print(f" Video: {os.path.basename(video_path)}")print()@@ -431,7 +482,7 @@ def cmd_process(args):from services.claude_suggest import suggest_initial_with_claude, _engine_label, _find_ai_cliai_path, ai_engine = _find_ai_cli()- if ai_path:+ if ai_path and config.get("ai_select", True):ai_label = _engine_label(ai_engine)print(f" [3/4] Selecting moments with {ai_label} (PodStack)...")clips = suggest_initial_with_claude(@@ -444,6 +495,8 @@ def cmd_process(args):print(f" ✓ {_engine_label(actual_engine)} selected {len(clips)} clips")else:print(" ⚠ AI CLI unavailable, falling back to heuristics")+ elif not config.get("ai_select", True):+ print(f" [3/4] Scoring clips (fast heuristic mode)...")else:print(f" [3/4] Scoring clips (heuristic mode)...")print(f" ℹ Install Claude Code or Codex for smarter selection")@@ -472,14 +525,20 @@ def cmd_process(args):# ── Step 4: Export ──# Check if thumbnail generation is enabledthumb_dir = os.path.join(output_dir, "thumbnails")- _thumb_enabled = True+ _thumb_enabled = bool(config.get("generate_thumbnails", True))+ _thumb_intro_duration = 0.8_tc_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".podcli", "thumbnail-config.json")- if os.path.exists(_tc_path):+ if _thumb_enabled and os.path.exists(_tc_path):try:with open(_tc_path) as _tcf:- _thumb_enabled = json.load(_tcf).get("enabled", True)+ _thumb_cfg = json.load(_tcf)+ _thumb_enabled = _thumb_cfg.get("enabled", True)+ _thumb_intro_duration = float(+ _thumb_cfg.get("intro_duration", _thumb_cfg.get("clip_start_duration", _thumb_intro_duration))+ )except Exception:pass+ _thumb_intro_duration = max(0.5, min(_thumb_intro_duration, 1.0))# Check if AI CLI is available for per-clip content generationfrom services.claude_suggest import _find_ai_cli@@ -503,7 +562,7 @@ def cmd_process(args):except Exception:_thumb_enabled = False- _ai_label = " (+ AI titles)" if _ai_cli_path else ""+ _ai_label = " (+ AI titles)" if (_ai_cli_path and config.get("generate_content", True)) else ""print(f"\n [4/4] Exporting {len(clips)} clips{_ai_label} to {output_dir}/")results = []t0 = time.time()@@ -529,6 +588,8 @@ def cmd_process(args):outro_path=config.get("outro_path") or None,keep_segments=clip.get("segments"),face_map=face_map,+ allow_ass_fallback=config.get("allow_ass_fallback", False),+ use_ass_captions=config.get("use_ass_captions", False),)results.append(result)ok = True@@ -539,34 +600,40 @@ def cmd_process(args):if ok:print(f" ✓ Clip {i+1}/{len(clips)}: {result['file_size_mb']}MB")- # Generate thumbnail and hard-cut append to clip end+ # Generate thumbnail from the lead-in frame and hard-cut prepend it.if _thumb_enabled and _thumb_gen and result.get("output_path"):try:clip_thumb_dir = os.path.join(thumb_dir, f"clip_{i+1}")+ os.makedirs(clip_thumb_dir, exist_ok=True)+ lead_frame = _extract_thumbnail_lead_frame(+ video_path=video_path,+ output_path=os.path.join(clip_thumb_dir, "_lead_frame.jpg"),+ start_second=result.get("start_second", clip.get("start_second", 0)),+ )paths = _thumb_gen(title=clip.get("title", f"Clip {i+1}"),output_dir=clip_thumb_dir,- photo_path=_thumb_photo,+ photo_path=lead_frame or _thumb_photo,video_path=video_path,- start_second=clip.get("start_second"),- end_second=clip.get("end_second"),+ start_second=result.get("start_second", clip.get("start_second")),+ end_second=result.get("end_second", clip.get("end_second")),logo_path=_thumb_logo,)if paths:thumb_video = os.path.join(clip_thumb_dir, "thumb_frame.mp4")- _thumb_to_video(paths[0], thumb_video, duration=1.5)+ _thumb_to_video(paths[0], thumb_video, duration=_thumb_intro_duration)from services.video_processor import concat_outrofinal_with_thumb = result["output_path"].replace(".mp4", "_with_thumb.mp4")- # Hard cut — no crossfade, so thumbnail appears cleanly- # after outro ends, no overlap with captions- concat_outro(result["output_path"], thumb_video, final_with_thumb, crossfade_duration=0.0)+ # Hard cut — thumbnail uses the frame just before content,+ # so playback feels like the clip has started.+ concat_outro(thumb_video, result["output_path"], final_with_thumb, crossfade_duration=0.0)os.replace(final_with_thumb, result["output_path"])- print(f" + thumbnail appended ({len(paths)} variations in {os.path.basename(clip_thumb_dir)}/)")+ print(f" + thumbnail prepended ({_thumb_intro_duration:.2f}s, {len(paths)} variations in {os.path.basename(clip_thumb_dir)}/)")except Exception as e:print(f" ⚠ thumbnail: {e}")# Generate titles, descriptions, tags for this clip immediately- if _ai_cli_path and result.get("output_path"):+ if _ai_cli_path and config.get("generate_content", True) and result.get("output_path"):try:from services.content_generator import generate_clip_contentcontent_result = generate_clip_content(@@ -734,6 +801,8 @@ def cmd_process(args):outro_path=config.get("outro_path") or None,keep_segments=clip.get("segments"),face_map=face_map,+ allow_ass_fallback=config.get("allow_ass_fallback", False),+ use_ass_captions=config.get("use_ass_captions", False),)results[-1] = resultprint(f" ✓ Re-rendered: {result['file_size_mb']}MB")@@ -1190,6 +1259,8 @@ def _post_render_loop(outro_path=config.get("outro_path") or None,keep_segments=clip.get("segments"),face_map=face_map,+ allow_ass_fallback=config.get("allow_ass_fallback", False),+ use_ass_captions=config.get("use_ass_captions", False),)r["result"] = new_resultok = True@@ -1373,6 +1444,8 @@ def _post_render_loop(outro_path=config.get("outro_path") or None,keep_segments=f_clip.get("segments"),face_map=face_map,+ allow_ass_fallback=config.get("allow_ass_fallback", False),+ use_ass_captions=config.get("use_ass_captions", False),)rendered.append({"clip": f_clip, "result": new_result, "index": len(clips)})clips.append(f_clip)@@ -1425,6 +1498,8 @@ def _post_render_loop(outro_path=config.get("outro_path") or None,keep_segments=nc.get("segments"),face_map=face_map,+ allow_ass_fallback=config.get("allow_ass_fallback", False),+ use_ass_captions=config.get("use_ass_captions", False),)rendered.append({"clip": nc, "result": new_result, "index": len(clips)})clips.append(nc)@@ -2458,13 +2533,15 @@ def print_help():print(f" {green}-o{reset}, {green}--output{reset} {gray}<dir>{reset} Output directory {dim}(default: ./clips){reset}")print(f" {green}-p{reset}, {green}--preset{reset} {gray}<name>{reset} Load a saved preset")print(f" {green}--caption-style{reset} {gray}<style>{reset} branded | hormozi | karaoke | subtle")- print(f" {green}--crop{reset} {gray}<strategy>{reset} speaker | face | center")+ print(f" {green}--crop{reset} {gray}<strategy>{reset} speaker | speaker-hardcut | face | center")+ print(f" {green}--fast{reset} Draft mode: tiny Whisper, heuristic clips, low quality")print(f" {green}--logo{reset} {gray}<asset|path>{reset} Overlay logo image")print(f" {green}--outro{reset} {gray}<asset|path>{reset} Append outro video")print(f" {green}--quality{reset} {gray}<level>{reset} low | medium | high | max")print(f" {green}--no-energy{reset} Skip audio energy analysis")print(f" {green}--no-speakers{reset} Skip speaker detection (faster)")print(f" {green}--no-cache{reset} Force re-transcription")+ print(f" {green}--allow-ass-fallback{reset} Use ASS captions if Remotion fails")print()print(f" {bold}Examples:{reset}")print(f" {dim}${reset} podcli process episode.mp4")@@ -2506,8 +2583,9 @@ def main():proc.add_argument("-n", "--top", type=int, help="Number of top clips to export (default: 5)")proc.add_argument("-o", "--output", help="Output directory (default: ./clips)")proc.add_argument("-p", "--preset", help="Load a saved preset")+ proc.add_argument("--fast", action="store_true", help="Draft mode: tiny Whisper, heuristic selection, center crop, low quality")proc.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle"])- proc.add_argument("--crop", choices=["center", "face", "speaker"])+ proc.add_argument("--crop", choices=["center", "face", "speaker", "speaker-hardcut"])proc.add_argument("--logo", help="Logo image (asset name or path)")proc.add_argument("--outro", help="Outro video (asset name or path)")proc.add_argument("--time-adjust", type=float, help="Timestamp offset in seconds")@@ -2515,6 +2593,7 @@ def main():proc.add_argument("--no-speakers", action="store_true", help="Skip speaker detection (faster, uses face detection only)")proc.add_argument("--no-cache", action="store_true", help="Force re-transcription (ignore cached transcript)")proc.add_argument("--quality", choices=["low", "medium", "high", "max"], help="Output quality (default: high)")+ proc.add_argument("--allow-ass-fallback", action="store_true", help="Use ASS captions if Remotion rendering fails")proc.add_argument("--review-each", action="store_true", help="Review each rendered clip interactively")proc.add_argument("--post-review", action="store_true", help="Open the post-render review loop after export")@@ -2530,7 +2609,7 @@ def main():pre_save.add_argument("--transcript", help="Default transcript path")pre_save.add_argument("--output", help="Default output directory")pre_save.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle"])- pre_save.add_argument("--crop", choices=["center", "face", "speaker"])+ pre_save.add_argument("--crop", choices=["center", "face", "speaker", "speaker-hardcut"])pre_save.add_argument("--logo", help="Logo (asset name or path)")pre_save.add_argument("--outro", help="Outro (asset name or path)")pre_save.add_argument("--top", type=int, help="Default top clips count")@@ -2779,8 +2858,94 @@ def _ask(prompt, default=None, validate=None, required=False, is_path=False):return val+def _codex_podstack_prompt(prompt: str) -> str:+ """Wrap a PodStack slash prompt so Codex can run the same command file."""+ return (+ "Run the PodStack workflow from .claude/commands/auto.md with these "+ f"arguments, then follow that workflow exactly: {prompt}"+ )+++def _launch_podstack_auto(prompt: str, ai_engine: str = "auto") -> int | None:+ """Launch /auto in Claude, Codex, or auto fallback order."""+ import shutil+ import subprocess as _sp++ accent = "\033[38;2;212;135;74m"+ green = "\033[38;2;74;222;128m"+ yellow = "\033[38;2;250;204;21m"+ gray = "\033[38;5;245m"+ dim = "\033[2m"+ bold = "\033[1m"+ reset = "\033[0m"++ project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))+ if ai_engine not in {"auto", "claude", "codex"}:+ print()+ print(f" {bold}Invalid AI engine:{reset} {ai_engine}")+ print(f" {dim}Use PODCLI_AI=codex, PODCLI_AI=claude, or PODCLI_AI=auto.{reset}")+ print()+ return None++ claude_bin = shutil.which("claude")+ codex_bin = shutil.which("codex")++ if ai_engine == "codex" and not codex_bin:+ print()+ print(f" {bold}Codex not found in PATH.{reset}")+ print(f" {dim}Install Codex, then run:{reset}")+ print(f" {accent}codex --cd \"{project_root}\" \"{_codex_podstack_prompt(prompt)}\"{reset}")+ print()+ return 1+ if ai_engine == "claude" and not claude_bin:+ print()+ print(f" {bold}Claude Code not found in PATH.{reset}")+ print(f" {dim}Install it, then run:{reset}")+ print(f" {accent}claude \"{prompt}\"{reset}")+ print()+ return 1++ if ai_engine != "codex" and claude_bin:+ print()+ print(f" {green}▶{reset} Launching Claude Code with: {accent}{prompt}{reset}")+ print(f" {dim}cwd: {project_root}{reset}")+ print()+ sys.stdout.flush()+ code = _sp.call([claude_bin, prompt], cwd=project_root)+ if code == 0:+ return code+ if ai_engine == "claude":+ return code+ if not codex_bin:+ return code+ print()+ print(f" {yellow}⚠{reset} Claude exited with code {code}; trying Codex...")+ elif ai_engine != "claude" and not codex_bin:+ print()+ print(f" {bold}No AI agent CLI found in PATH.{reset}")+ print(f" {dim}Install Claude Code or Codex, then run one of:{reset}")+ print(f" {accent}claude \"{prompt}\"{reset}")+ print(f" {accent}codex --cd \"{project_root}\" \"{_codex_podstack_prompt(prompt)}\"{reset}")+ print()+ return None+ else:+ print()+ if ai_engine == "codex":+ print(f" {gray}Using Codex because it was requested.{reset}")+ else:+ print(f" {gray}Claude Code not found; using Codex.{reset}")++ codex_prompt = _codex_podstack_prompt(prompt)+ print()+ print(f" {green}▶{reset} Launching Codex with: {accent}{prompt}{reset}")+ print(f" {dim}cwd: {project_root}{reset}")+ print()+ sys.stdout.flush()+ return _sp.call([codex_bin, "--cd", project_root, codex_prompt], cwd=project_root)++def _interactive_auto():- """Pick a video (preset or new), then launch Claude Code with /auto <path>."""+ """Pick a video (preset or new), then launch /auto in Claude or Codex."""import questionaryfrom questionary import Style@@ -2876,24 +3041,9 @@ def _interactive_auto():prompt_parts.append(f"— {brief.strip()}")prompt = " ".join(prompt_parts)- import shutil- claude_bin = shutil.which("claude")- if not claude_bin:- print()- print(f" {bold}Claude Code not found in PATH.{reset}")- print(f" {dim}Install it, then run:{reset}")- print(f" {accent}claude \"{prompt}\"{reset}")- print()- return-- project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))- print()- print(f" {green}▶{reset} Launching Claude Code with: {accent}{prompt}{reset}")- print(f" {dim}cwd: {project_root}{reset}")- print()- sys.stdout.flush()- import subprocess as _sp- sys.exit(_sp.call([claude_bin, prompt], cwd=project_root))+ code = _launch_podstack_auto(prompt, os.environ.get("PODCLI_AI", "auto"))+ if code is not None:+ sys.exit(code)def _interactive_process():diff --git a/backend/main.py b/backend/main.pyindex ef54ae1..5399601 100644--- a/backend/main.py+++ b/backend/main.py@@ -113,6 +113,7 @@ def handle_create_clip(task_id: str, params: dict):face_map=params.get("face_map"),keep_segments=params.get("keep_segments"),allow_ass_fallback=params.get("allow_ass_fallback", False),+ use_ass_captions=params.get("use_ass_captions", False),progress_callback=lambda pct, msg: emit_progress(task_id, "processing", pct, msg),)emit_result(task_id, "success", data=result)@@ -149,6 +150,7 @@ def handle_batch_clips(task_id: str, params: dict):face_map=params.get("face_map"),keep_segments=clip.get("keep_segments"),allow_ass_fallback=clip.get("allow_ass_fallback", params.get("allow_ass_fallback", False)),+ use_ass_captions=clip.get("use_ass_captions", params.get("use_ass_captions", False)),progress_callback=lambda pct, msg, _i=i: emit_progress(task_id, "batch", int((_i / total) * 100 + pct / total), msg),diff --git a/backend/presets.py b/backend/presets.pyindex 3d15514..efd6d75 100644--- a/backend/presets.py+++ b/backend/presets.py@@ -43,6 +43,11 @@ DEFAULT_PRESET = {"energy_boost": True,"quality": "max","no_speakers": False,+ "allow_ass_fallback": False,+ "use_ass_captions": False,+ "generate_thumbnails": True,+ "generate_content": True,+ "ai_select": True,"review_each_clip": False,"post_render_review": False,"more_suggestions_multiplier": 3,diff --git a/backend/services/clip_generator.py b/backend/services/clip_generator.pyindex dbab0bb..d752da8 100644--- a/backend/services/clip_generator.py+++ b/backend/services/clip_generator.py@@ -564,6 +564,7 @@ def generate_clip(clean_fillers: bool = True,keep_segments: list[dict] = None,allow_ass_fallback: bool = False,+ use_ass_captions: bool = False,progress_callback: Optional[Callable[[int, str], None]] = None,) -> dict:"""@@ -574,7 +575,7 @@ def generate_clip(start_second: Clip start timeend_second: Clip end timecaption_style: "hormozi", "karaoke", "subtle", or "branded"- crop_strategy: "center", "face", or "speaker"+ crop_strategy: "center", "face", "speaker", or "speaker-hardcut"transcript_words: Word-level timestamps from transcriptiontitle: Clip title (used in filename)output_dir: Where to save the final clip (defaults to temp)@@ -744,14 +745,16 @@ def generate_clip(captioned_path = os.path.join(work_dir, "captioned.mp4")- remotion_ok = _render_with_remotion(- video_path=cropped_path,- words=clip_words,- caption_style=caption_style,- output_path=captioned_path,- time_offset=caption_time_offset,- logo_path=logo_path if (style_config.get("logo_support", False) and logo_path) else None,- )+ remotion_ok = False+ if not use_ass_captions:+ remotion_ok = _render_with_remotion(+ video_path=cropped_path,+ words=clip_words,+ caption_style=caption_style,+ output_path=captioned_path,+ time_offset=caption_time_offset,+ logo_path=logo_path if (style_config.get("logo_support", False) and logo_path) else None,+ )if not remotion_ok and not allow_ass_fallback:raise RuntimeError(diff --git a/backend/services/video_processor.py b/backend/services/video_processor.pyindex 8dfc28a..db14cbd 100644--- a/backend/services/video_processor.py+++ b/backend/services/video_processor.py@@ -65,6 +65,8 @@ def crop_to_vertical(- face: Detect face position, center crop on face (falls back to center)- speaker: Like face, but switches to the active speaker using transcriptword-level speaker labels. Falls back to face then center.+ - speaker-hardcut: Prefer precomputed face_map positions and snap between+ speakers without pan animation. Falls back to speaker.transcript_words: Word dicts with 'speaker', 'start', 'end' keys (from Whisper+pyannote).Used by 'face' strategy when speaker data is available.@@ -76,7 +78,41 @@ def crop_to_vertical(source_ratio = width / height- if strategy in ("face", "speaker"):+ if strategy == "speaker-hardcut" and face_map:+ crop_h = height+ crop_y = max(0, (height - crop_h) // 2)+ x_expr = _use_face_map(+ face_map=face_map,+ transcript_words=transcript_words,+ clip_start=clip_start,+ width=width,+ height=height,+ target_ratio=target_ratio,+ crop_h=crop_h,+ hard_cut=True,+ )+ if x_expr:+ crop_w = int(crop_h * target_ratio)+ crop_w = min(crop_w, width)+ vf = f"crop={crop_w}:{crop_h}:{x_expr}:{crop_y},scale={target_w}:{target_h}"+ return _run_ffmpeg_with_fallback(+ cmd_parts_before_enc=[+ "ffmpeg", "-y",+ "-i", input_path,+ "-vf", vf,+ ],+ cmd_parts_after_enc=[+ "-c:a", "aac",+ "-b:a", "192k",+ "-ar", "44100",+ "-movflags", "+faststart",+ ],+ output_path=output_path,+ label="crop_speaker_hardcut",+ )+ strategy = "speaker"++ if strategy in ("face", "speaker", "speaker-hardcut"):speakers_in_clip = {w.get("speaker") for w in (transcript_words or []) if w.get("speaker")}@@ -1703,6 +1739,7 @@ def _use_face_map(height: int,target_ratio: float,crop_h: int = None,+ hard_cut: bool = False,) -> Optional[str]:"""Use pre-computed face_map from transcription to determine crop position.@@ -1795,8 +1832,8 @@ def _use_face_map(default_ci = speaker_mappings.get(dominant, 0)default_x = clusters[min(default_ci, len(clusters) - 1)]["crop_x"]- # Build keyframes — instant cut for split-screen, smooth pan otherwise- pan_duration = 0.0 if is_split_screen else 0.4+ # Build keyframes — instant cut for split-screen/hard-cut, smooth pan otherwise+ pan_duration = 0.0 if hard_cut or is_split_screen else 0.4duration = segments[-1][1] if segments else 1.0keyframes = []prev_x = default_x@@ -1817,6 +1854,13 @@ def _use_face_map(if not keyframes:return str(default_x)+ if pan_duration == 0.0:+ expr = str(default_x)+ for i in range(len(keyframes) - 1, -1, -1):+ start_t, x = keyframes[i]+ expr = f"if(gte(t\\,{start_t:.2f})\\,{x}\\,{expr})"+ return expr+# Build FFmpeg expressionexpr_parts = []for i in range(0, len(keyframes) - 1, 2):diff --git a/podcli b/podcliindex c45a41c..7eb8b18 100755--- a/podcli+++ b/podcli@@ -17,7 +17,7 @@ elsePYTHON="python3"fi-# ── PodStack slash commands → redirect to Claude Code ──+# ── PodStack slash commands → launch an AI agent ──CMD="$1"# Strip leading / or -- prefix (user might try /prep-episode, --prep-episode, or prep-episode)CMD_CLEAN="${CMD#/}"@@ -25,18 +25,144 @@ CMD_CLEAN="${CMD_CLEAN#--}"PODSTACK_COMMANDS="auto prep-episode process-transcript generate-titles generate-descriptions plan-thumbnails review-content publish-checklist retro-episode plan-episode produce-shorts"+launch_auto() {+ ACCENT="\033[38;2;212;135;74m"+ GREEN="\033[38;2;74;222;128m"+ YELLOW="\033[38;2;250;204;21m"+ BOLD="\033[1m"+ DIM="\033[2m"+ RESET="\033[0m"++ shift+ AI_ENGINE="${PODCLI_AI:-auto}"+ PROMPT_ARGS=()+ while [ "$#" -gt 0 ]; do+ case "$1" in+ --codex)+ AI_ENGINE="codex"+ shift+ ;;+ --claude)+ AI_ENGINE="claude"+ shift+ ;;+ --ai)+ shift+ if [ -z "${1:-}" ]; then+ echo -e " ${BOLD}Missing value for --ai.${RESET} Use: --ai codex|claude|auto"+ exit 1+ fi+ AI_ENGINE="$1"+ shift+ ;;+ --ai=*)+ AI_ENGINE="${1#--ai=}"+ shift+ ;;+ *)+ PROMPT_ARGS+=("$1")+ shift+ ;;+ esac+ done++ case "$AI_ENGINE" in+ auto|claude|codex) ;;+ *)+ echo -e " ${BOLD}Invalid AI engine:${RESET} $AI_ENGINE"+ echo -e " ${DIM}Use: --codex, --claude, or --ai codex|claude|auto${RESET}"+ exit 1+ ;;+ esac++ PROMPT="/auto"+ if [ "${#PROMPT_ARGS[@]}" -gt 0 ]; then+ PROMPT="$PROMPT ${PROMPT_ARGS[*]}"+ fi+ CODEX_PROMPT="Run the PodStack workflow from .claude/commands/auto.md with these arguments, then follow that workflow exactly: $PROMPT"++ CLAUDE_BIN="$(command -v claude 2>/dev/null || true)"+ CODEX_BIN="$(command -v codex 2>/dev/null || true)"++ if [ "$AI_ENGINE" = "codex" ]; then+ if [ -z "$CODEX_BIN" ]; then+ echo ""+ echo -e " ${BOLD}Codex not found in PATH.${RESET}"+ echo -e " ${DIM}Install Codex, then run:${RESET}"+ echo -e " ${ACCENT}codex --cd \"$SCRIPT_DIR\" \"$CODEX_PROMPT\"${RESET}"+ echo ""+ exit 1+ fi+ elif [ "$AI_ENGINE" = "claude" ]; then+ if [ -z "$CLAUDE_BIN" ]; then+ echo ""+ echo -e " ${BOLD}Claude Code not found in PATH.${RESET}"+ echo -e " ${DIM}Install it, then run:${RESET}"+ echo -e " ${ACCENT}claude \"$PROMPT\"${RESET}"+ echo ""+ exit 1+ fi+ fi++ if [ "$AI_ENGINE" != "codex" ] && [ -n "$CLAUDE_BIN" ]; then+ echo ""+ echo -e " ${GREEN}▶${RESET} Launching Claude Code with: ${ACCENT}$PROMPT${RESET}"+ echo -e " ${DIM}cwd: $SCRIPT_DIR${RESET}"+ echo ""+ (cd "$SCRIPT_DIR" && "$CLAUDE_BIN" "$PROMPT")+ STATUS=$?+ if [ "$STATUS" -eq 0 ]; then+ exit 0+ fi+ if [ "$AI_ENGINE" = "claude" ]; then+ exit "$STATUS"+ fi+ if [ -z "$CODEX_BIN" ]; then+ exit "$STATUS"+ fi+ echo ""+ echo -e " ${YELLOW}⚠${RESET} Claude exited with code $STATUS; trying Codex..."+ elif [ "$AI_ENGINE" != "claude" ] && [ -z "$CODEX_BIN" ]; then+ echo ""+ echo -e " ${BOLD}No AI agent CLI found in PATH.${RESET}"+ echo -e " ${DIM}Install Claude Code or Codex, then run one of:${RESET}"+ echo -e " ${ACCENT}claude \"$PROMPT\"${RESET}"+ echo -e " ${ACCENT}codex --cd \"$SCRIPT_DIR\" \"$CODEX_PROMPT\"${RESET}"+ echo ""+ exit 0+ else+ echo ""+ if [ "$AI_ENGINE" = "codex" ]; then+ echo -e " ${DIM}Using Codex because it was requested.${RESET}"+ else+ echo -e " ${DIM}Claude Code not found; using Codex.${RESET}"+ fi+ fi++ echo ""+ echo -e " ${GREEN}▶${RESET} Launching Codex with: ${ACCENT}$PROMPT${RESET}"+ echo -e " ${DIM}cwd: $SCRIPT_DIR${RESET}"+ echo ""+ exec "$CODEX_BIN" --cd "$SCRIPT_DIR" "$CODEX_PROMPT"+}+for pc in $PODSTACK_COMMANDS; doif [ "$CMD_CLEAN" = "$pc" ]; then+ if [ "$pc" = "auto" ]; then+ launch_auto "$@"+ fiACCENT="\033[38;2;212;135;74m"BOLD="\033[1m"DIM="\033[2m"RESET="\033[0m"echo ""- echo -e " ${BOLD}/$pc${RESET} is a PodStack command — it runs inside ${ACCENT}Claude Code${RESET}, not the terminal."+ echo -e " ${BOLD}/$pc${RESET} is a PodStack command — it runs inside ${ACCENT}Claude Code or Codex${RESET}, not the terminal."echo ""echo -e " ${BOLD}How to use:${RESET}"echo -e " 1. Open Claude Code: ${DIM}claude${RESET}"+ echo -e " Or open Codex: ${DIM}codex --cd \"$SCRIPT_DIR\"${RESET}"echo -e " 2. Type: ${ACCENT}/$pc${RESET}"+ echo -e " Force /auto Codex: ${ACCENT}./podcli /auto --codex <video>${RESET}"echo ""echo -e " ${DIM}PodStack commands use AI to generate titles, descriptions, thumbnails, etc.${RESET}"echo -e " ${DIM}They need Claude Code's LLM context to work.${RESET}"diff --git a/tests/test_cli_output_dir.py b/tests/test_cli_output_dir.pyindex ad2845f..e6300bc 100644--- a/tests/test_cli_output_dir.py+++ b/tests/test_cli_output_dir.py@@ -1,6 +1,8 @@import osimport sys+import tempfileimport unittest+from unittest import mockROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))@@ -99,6 +101,35 @@ class CliOutputDirTests(unittest.TestCase):self.assertTrue(should_enter)+ def test_thumbnail_lead_timestamp_uses_frame_before_clip(self):+ self.assertAlmostEqual(+ cli_mod._thumbnail_lead_timestamp(10.0, frame_offset=0.04),+ 9.96,+ )++ def test_thumbnail_lead_timestamp_clamps_at_zero(self):+ self.assertEqual(cli_mod._thumbnail_lead_timestamp(0.01, frame_offset=0.04), 0.0)++ def test_extract_thumbnail_lead_frame_returns_path_on_success(self):+ with tempfile.TemporaryDirectory() as td:+ output_path = os.path.join(td, "lead.jpg")++ def fake_run(cmd, timeout, check):+ with open(output_path, "wb") as f:+ f.write(b"jpg")+ return mock.Mock(returncode=0)++ with mock.patch("utils.proc.run", side_effect=fake_run) as run_mock:+ result = cli_mod._extract_thumbnail_lead_frame(+ "/tmp/source.mp4",+ output_path,+ start_second=12.0,+ )++ self.assertEqual(result, output_path)+ cmd = run_mock.call_args.args[0]+ self.assertIn("11.967", cmd)+if __name__ == "__main__":unittest.main()