From 83da59fa78c3eee9e20f515fe75c438bb5166efd Mon Sep 17 00:00:00 2001 From: bradautomates Date: Tue, 30 Jun 2026 17:20:07 +1000 Subject: [PATCH] Fix WATCH_DETAIL silently falling back to default An inline comment on the WATCH_DETAIL value line (e.g. `WATCH_DETAIL=balanced # ...`) parsed as the literal "balanced # ..." value, failed validation, and silently reverted to the default mode. - setup.py: move the allowed-values list off the value line in the env template so the wizard no longer models a trailing inline comment. - config.py: strip a whitespace-preceded inline comment from unquoted values so a stray comment can't silently break selection again (preserves '#' inside quotes / API keys). - SKILL.md: note to write the bare key with no trailing comment. Co-Authored-By: Claude Opus 4.8 (1M context) --- skills/watch/SKILL.md | 2 +- skills/watch/scripts/config.py | 9 +++++++++ skills/watch/scripts/setup.py | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/skills/watch/SKILL.md b/skills/watch/SKILL.md index cb8b072..7cd78b6 100644 --- a/skills/watch/SKILL.md +++ b/skills/watch/SKILL.md @@ -93,7 +93,7 @@ On macOS with Homebrew, it auto-installs `ffmpeg` and `yt-dlp`. On Linux/Windows - `balanced` (recommended) — scene-aware frames (cap 100, default). - `token-burner` — scene-aware, uncapped (maximum fidelity; high token cost). -Write the answer directly into `~/.config/watch/.env` by setting: +Write the answer directly into `~/.config/watch/.env` by setting the bare key on its own line — **no trailing inline comment** (a `# note` after the value can break parsing): ```bash WATCH_DETAIL=balanced diff --git a/skills/watch/scripts/config.py b/skills/watch/scripts/config.py index 93f70d1..3a97bad 100644 --- a/skills/watch/scripts/config.py +++ b/skills/watch/scripts/config.py @@ -32,6 +32,15 @@ def read_env_file(path: Path | None = None) -> dict[str, str]: value = value.strip() if len(value) >= 2 and value[0] in ('"', "'") and value[-1] == value[0]: value = value[1:-1] + else: + # Strip an inline comment (a '#' preceded by whitespace) from an + # unquoted value. Without this, `WATCH_DETAIL=balanced # note` + # parses as "balanced # note", fails validation, and silently + # falls back to the default. Keeps '#' inside quotes / API keys. + for i, ch in enumerate(value): + if ch == "#" and i > 0 and value[i - 1] in " \t": + value = value[:i].rstrip() + break values[key.strip()] = value return values diff --git a/skills/watch/scripts/setup.py b/skills/watch/scripts/setup.py index 5582eb4..9bc2190 100755 --- a/skills/watch/scripts/setup.py +++ b/skills/watch/scripts/setup.py @@ -52,8 +52,10 @@ ENV_TEMPLATE = """# /watch API configuration GROQ_API_KEY= OPENAI_API_KEY= -# Default watch behavior (the /watch first-run wizard sets this for you): -# WATCH_DETAIL=balanced # transcript | efficient | balanced | token-burner +# Default watch behavior (the /watch first-run wizard sets this for you). +# Allowed values: transcript | efficient | balanced | token-burner +# Keep the value on its own line with no trailing comment. +# WATCH_DETAIL=balanced """