CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

gamussa/reels-producer-skill

Write talking-head scripts and produce Instagram reels and YouTube shorts

1.07x
Quality

96%

Does it follow best practices?

Impact

98%

1.07x

Average score across 8 eval scenarios

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

brief.pyskills/reel-builder/scripts/

#!/usr/bin/env python3
"""The creative brief: who the reel is for and what it must do, before any
technical choice.

The brief is plan/brief.json. This script checks its SHAPE — every field the
rest of the pipeline relies on is present and well-formed — and carries the
answers that stay true across a series (viewer, platform, structure) from an
earlier project so they are never asked twice. Whether the promise is any good
is not something a script can judge; references/creative-brief.md covers that.

Fields (schema_version 1):
  viewer     who this is for, specifically ("busy beginner runners")
  need       the problem they have or the thing they want
  promise    the one thing the reel delivers, one sentence
  evidence   list — what in the footage/take proves or shows it (may be empty
             for a montage, never for an opinion or demonstration)
  response   what the viewer should do, try, or feel afterwards
  platform   primary platform (tiktok, ig_reels, yt_shorts, youtube, ...)
  structure  opinion | demonstration | story | comparison | montage
  duration   {"target": seconds, "basis": why that length}

Exit codes: 0 = valid (check) / written (init); 1 = invalid or refused;
JSON on stdout.

Usage:
  brief.py init --out plan/brief.json [--from ../last-reel/plan/brief.json]
  brief.py check plan/brief.json
"""

import argparse
import json
import sys
from pathlib import Path

SCHEMA_VERSION = 1
STRUCTURES = ("opinion", "demonstration", "story", "comparison", "montage")
TEXT_FIELDS = ("viewer", "need", "promise", "response", "platform")
CARRY = ("viewer", "platform", "structure")  # true for a whole series


def blank():
    return {
        "schema_version": SCHEMA_VERSION,
        "viewer": "",
        "need": "",
        "promise": "",
        "evidence": [],
        "response": "",
        "platform": "",
        "structure": "",
        "duration": {"target": None, "basis": ""},
    }


def validate(brief):
    """(missing, errors) — missing fields are the questions still to ask."""
    if not isinstance(brief, dict):
        return [], ["brief must be a JSON object"]
    missing, errors = [], []
    if brief.get("schema_version") != SCHEMA_VERSION:
        errors.append(f"schema_version must be {SCHEMA_VERSION}")
    for f in TEXT_FIELDS:
        v = brief.get(f)
        if not isinstance(v, str) or not v.strip():
            missing.append(f)
    structure = brief.get("structure")
    if not structure:
        missing.append("structure")
    elif structure not in STRUCTURES:
        errors.append(f"structure {structure!r} is not one of {', '.join(STRUCTURES)}")
    ev = brief.get("evidence")
    if not isinstance(ev, list) or not all(isinstance(x, str) and x.strip() for x in ev):
        errors.append("evidence must be a list of non-empty strings")
    elif not ev and structure in ("opinion", "demonstration", "comparison"):
        missing.append("evidence")
    dur = brief.get("duration")
    if not isinstance(dur, dict):
        missing.append("duration")
    else:
        t = dur.get("target")
        if t is None:
            missing.append("duration.target")
        elif not isinstance(t, (int, float)) or isinstance(t, bool) or t <= 0:
            errors.append("duration.target must be a positive number of seconds")
        if not (isinstance(dur.get("basis"), str) and dur["basis"].strip()):
            missing.append("duration.basis")
    return missing, errors


def carry_from(prev):
    out = blank()
    for f in CARRY:
        if isinstance(prev, dict) and prev.get(f):
            out[f] = prev[f]
    return out


def main():
    ap = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    sub = ap.add_subparsers(dest="cmd", required=True)
    i = sub.add_parser("init", help="write a brief to fill in")
    i.add_argument("--out", default="plan/brief.json")
    i.add_argument(
        "--from", dest="prev", help="earlier brief to carry viewer/platform/structure from"
    )
    c = sub.add_parser("check", help="validate a brief")
    c.add_argument("brief")
    a = ap.parse_args()

    if a.cmd == "init":
        out = Path(a.out)
        if out.exists():
            print(json.dumps({"ok": False, "error": f"{out} exists — edit it, or check it"}))
            sys.exit(1)
        prev = None
        if a.prev:
            try:
                prev = json.loads(Path(a.prev).read_text())
            except (OSError, json.JSONDecodeError) as e:
                print(json.dumps({"ok": False, "error": f"cannot read {a.prev}: {e}"}))
                sys.exit(1)
        brief = carry_from(prev) if prev else blank()
        out.parent.mkdir(parents=True, exist_ok=True)
        out.write_text(json.dumps(brief, indent=2) + "\n")
        missing, _ = validate(brief)
        print(
            json.dumps(
                {
                    "ok": True,
                    "out": str(out),
                    "carried": [f for f in CARRY if brief.get(f)],
                    "ask": missing,
                }
            )
        )
        return

    try:
        brief = json.loads(Path(a.brief).read_text())
    except (OSError, json.JSONDecodeError) as e:
        print(json.dumps({"ok": False, "missing": [], "errors": [f"cannot read {a.brief}: {e}"]}))
        sys.exit(1)
    missing, errors = validate(brief)
    ok = not missing and not errors
    print(
        json.dumps(
            {
                "ok": ok,
                "missing": missing,
                "errors": errors,
                "promise": brief.get("promise") if isinstance(brief, dict) else None,
            }
        )
    )
    sys.exit(0 if ok else 1)


if __name__ == "__main__":
    main()

skills

tile.json