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
Surface the real AI CLI failure instead of a generic login hint
Nika Siradze43795b44f2d5
diff --git a/backend/main.py b/backend/main.pyindex 96dd9e2..0e78ec7 100644--- a/backend/main.py+++ b/backend/main.py@@ -520,19 +520,18 @@ def handle_suggest_clips(task_id: str, params: dict):)return+ errors: list[str] = []clips = suggest_with_claude(segments=segments,top_n=top_n,exclude_clips=existing_clips,progress_callback=lambda pct, msg: emit_progress(task_id, "suggesting", pct, msg),+ error_sink=errors,)if clips is None:- emit_result(- task_id,- "error",- error="AI CLI found but suggestion failed — check claude/codex login and try again",- )+ detail = errors[0] if errors else "check claude/codex login and try again"+ emit_result(task_id, "error", error=detail)returnemit_result(task_id, "success", data={"clips": clips})diff --git a/backend/services/claude_suggest.py b/backend/services/claude_suggest.pyindex 3bfcd6f..96d8840 100644--- a/backend/services/claude_suggest.py+++ b/backend/services/claude_suggest.py@@ -875,12 +875,28 @@ Transcript:pass+def classify_cli_error(detail: str) -> str:+ """Turn a raw AI CLI failure into an actionable hint. The generic+ 'check login' message hides whether it's auth, a plan limit, or a crash."""+ low = (detail or "").lower()+ if any(s in low for s in ("not logged in", "please run", "/login", "authenticate", "unauthorized", "invalid api key", "no credentials")):+ return "not logged in. Run `claude` (or `codex`) once in a terminal to authenticate, then retry."+ if any(s in low for s in ("usage limit", "rate limit", "quota", "too many requests", "429")):+ return "usage or rate limit reached on your plan. Wait for the limit to reset, then retry."+ if "timed out" in low or "timeout" in low:+ return detail+ if not detail:+ return "the AI CLI returned no output. Run `claude` once in a terminal to confirm it responds."+ return detail++def suggest_with_claude(segments: list[dict],top_n: int = 5,exclude_clips: list[dict] | None = None,progress_callback: Optional[Callable[[int, str], None]] = None,timeout: int = 300,+ error_sink: Optional[list[str]] = None,) -> Optional[list[dict]]:"""Use an AI CLI (Claude Code or Codex) to extract the best clip moments.@@ -939,6 +955,7 @@ def suggest_with_claude(except ValueError:return 0.0+ last_detail: Optional[str] = Nonefor idx, (cli_path, engine) in enumerate(candidates):label = _engine_label(engine)if idx > 0 and progress_callback:@@ -955,17 +972,20 @@ def suggest_with_claude(timeout=timeout,)except subprocess.TimeoutExpired:+ last_detail = f"{label} timed out ({_format_timeout_label(timeout)} limit)"if progress_callback:- progress_callback(0, f"{label} timed out ({_format_timeout_label(timeout)} limit)")+ progress_callback(0, last_detail)continueexcept Exception as e:+ last_detail = f"{label} error: {e}"if progress_callback:- progress_callback(0, f"{label} error: {e}")+ progress_callback(0, last_detail)continueif result.returncode != 0 or not result.stdout.strip():+ detail = (result.stderr or "no response").strip()[:200]+ last_detail = f"{label}: {detail}"if progress_callback:- detail = (result.stderr or "no response").strip()[:200]progress_callback(0, f"{label} returned error: {detail}")continue@@ -987,12 +1007,14 @@ def suggest_with_claude(else:data = json.loads(response)except json.JSONDecodeError as e:+ last_detail = f"{label} returned output that wasn't valid JSON ({e})"if progress_callback:progress_callback(0, f"Could not parse {label}'s response as JSON: {e}")continueclips = data.get("clips", [])if not clips:+ last_detail = f"{label} ran but found no clips in the transcript"if progress_callback:progress_callback(0, f"{label} returned no clips")continue@@ -1047,9 +1069,12 @@ def suggest_with_claude(progress_callback(100, f"{label} suggested {len(selected)} clips")return selected+ last_detail = f"{label} returned clips but none were usable (wrong length or format)"if progress_callback:progress_callback(0, f"{label} returned no usable clips")+ if error_sink is not None:+ error_sink.append(classify_cli_error(last_detail or ""))return Nonefinally:# Clean up temp file