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

package.pyskills/reel-builder/scripts/

#!/usr/bin/env python3
"""One recording -> a content package: a longer video plus complementary
shorts, each with its own purpose and platform, all traceable to source moments.

The point is a coherent week of content, not the same edit exported five
times. This checks that the plan keeps those promises and reports where each
item stands in its own project's pipeline. What each piece is for is the
editor's call; the shapes and overlaps are checkable.

plan/package.json (schema_version 1), beside the source recording's shortlist:
  {"schema_version": 1, "source": "talk.mp4", "duration": 1840.0,
   "items": [
     {"id": "long", "kind": "long", "platform": "youtube", "structure": "demonstration",
      "purpose": "the full method, start to finish", "ranges": [[0, 1840]],
      "day": "Mon", "project": "../talk-long"},
     {"id": "s1", "kind": "short", "platform": "ig_reels", "structure": "opinion",
      "purpose": "the one mistake, as a hook into the long video",
      "ranges": [[312.4, 351.0]], "day": "Tue", "project": "../talk-s1"}]}

check:
  - every item has a purpose, platform, structure and ranges inside the source
  - no two items share a purpose on the same platform (repetition)
  - shorts overlapping each other by more than OVERLAP_SHARE of the shorter one
    are flagged: the same moment twice is a repeat, not a package
  - more than one long video, or none, is flagged
status: for each item with a project, that project's next pipeline step.

Exit codes: 0 valid; 1 invalid. JSON on stdout.

Usage:
  package.py check plan/package.json
  package.py status plan/package.json
"""

import argparse
import json
import subprocess
import sys
from pathlib import Path

SCHEMA_VERSION = 1
KINDS = ("long", "short")
OVERLAP_SHARE = 0.5


def overlap(a, b):
    return max(0.0, min(a[1], b[1]) - max(a[0], b[0]))


def analyse(doc):
    """(errors, warnings)."""
    errors, warnings = [], []
    if doc.get("schema_version") != SCHEMA_VERSION:
        return [f"schema_version must be {SCHEMA_VERSION}"], []
    dur = doc.get("duration")
    if not isinstance(dur, (int, float)) or dur <= 0:
        errors.append("duration of the source recording (seconds) is required")
        dur = float("inf")
    items = doc.get("items") or []
    if not items:
        return errors + ["the package has no items"], warnings
    seen_ids, seen_purpose = set(), {}
    for it in items:
        tag = f"item {it.get('id') or '?'}"
        if not it.get("id") or it["id"] in seen_ids:
            errors.append(f"{tag}: needs a unique id")
        seen_ids.add(it.get("id"))
        if it.get("kind") not in KINDS:
            errors.append(f"{tag}: kind must be long or short")
        for f in ("purpose", "platform", "structure"):
            if not (it.get(f) or "").strip():
                errors.append(f"{tag}: {f} is required")
        ranges = it.get("ranges") or []
        if not ranges:
            errors.append(f"{tag}: ranges tie it to the source — at least one [start, end]")
        for r in ranges:
            if not (isinstance(r, list) and len(r) == 2 and 0 <= r[0] < r[1] <= dur):
                errors.append(f"{tag}: range {r} is not inside the source")
        key = ((it.get("purpose") or "").strip().lower(), it.get("platform"))
        if key[0] and key in seen_purpose:
            warnings.append(
                f"{tag} repeats {seen_purpose[key]}'s purpose on {key[1]} — "
                "give each piece its own job"
            )
        seen_purpose.setdefault(key, it.get("id"))
    longs = [i for i in items if i.get("kind") == "long"]
    if len(longs) != 1:
        warnings.append(f"{len(longs)} long videos — a package usually anchors on one")
    shorts = [i for i in items if i.get("kind") == "short"]
    for i, a in enumerate(shorts):
        for b in shorts[i + 1 :]:
            ov = sum(
                overlap(ra, rb)
                for ra in a.get("ranges") or []
                for rb in b.get("ranges") or []
                if isinstance(ra, list) and isinstance(rb, list) and len(ra) == 2 and len(rb) == 2
            )
            la = sum(
                r[1] - r[0] for r in a.get("ranges") or [] if isinstance(r, list) and len(r) == 2
            )
            lb = sum(
                r[1] - r[0] for r in b.get("ranges") or [] if isinstance(r, list) and len(r) == 2
            )
            if la and lb and ov > OVERLAP_SHARE * min(la, lb):
                warnings.append(
                    f"shorts {a['id']} and {b['id']} share {ov:.0f}s of the same "
                    "source — the same moment twice"
                )
    return errors, warnings


def item_status(item):
    proj = item.get("project")
    if not proj:
        return "not started (no project yet — promote it from the shortlist)"
    pdir = Path(proj)
    if not (pdir / "state.json").exists():
        return f"project {proj} not initialised"
    script = Path(__file__).with_name("pipeline.py")
    r = subprocess.run(
        [sys.executable, str(script), "next"], cwd=pdir, capture_output=True, text=True
    )
    return (
        (r.stdout.strip().splitlines() or ["(no status)"])[0]
        if r.returncode == 0
        else f"pipeline error: {r.stderr.strip()[-200:]}"
    )


def main():
    ap = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    sub = ap.add_subparsers(dest="cmd", required=True)
    for name in ("check", "status"):
        sub.add_parser(name).add_argument("package")
    a = ap.parse_args()
    try:
        doc = json.loads(Path(a.package).read_text())
    except (OSError, json.JSONDecodeError) as e:
        print(json.dumps({"ok": False, "errors": [f"cannot read {a.package}: {e}"]}))
        sys.exit(1)
    errors, warnings = analyse(doc)
    if a.cmd == "check" or errors:
        print(json.dumps({"ok": not errors, "errors": errors, "warnings": warnings}))
        sys.exit(1 if errors else 0)
    print(
        json.dumps(
            {
                "ok": True,
                "warnings": warnings,
                "items": [
                    {
                        "id": i["id"],
                        "kind": i["kind"],
                        "platform": i["platform"],
                        "day": i.get("day"),
                        "purpose": i["purpose"],
                        "status": item_status(i),
                    }
                    for i in doc["items"]
                ],
            },
            indent=1,
        )
    )


if __name__ == "__main__":
    main()

skills

tile.json