Skip to content

gooseworks-ai/goose-skills / skills/video/render-hook-replacement

render-hook-replacement

Verified

Replace an existing video's opening with a supplied clip or free kinetic text hook while retaining and verifying every original body frame, audio, captions and ending. Use for surgical hook tests rather than regenerating the complete ad.

FileKindSize
SKILL.mdskill md8.7 KB
config.example.jsonconfig254 B
references/hook-replacement.mdmarkdown4.9 KB
scripts/make_demo.pyscript2.9 KB
scripts/replace_hook.pyscript28.4 KB
scripts/replace_pack.pyscript3.6 KB
skill.meta.jsonconfig274 B
tests/smoke-test.mdmarkdown571 B
tests/test_replace_hook.pyscript11.9 KB

scripts/replace_pack.py

View on GitHub
#!/usr/bin/env python3
"""Create complete labelled hook alternatives against one frozen source.

Successful siblings survive a failed alternative. This is local assembly only;
project/batch identity and approvals are owned by the caller.
"""
import argparse
import copy
import json
from pathlib import Path
import re
import sys
from replace_hook import file_hash, replace, resolve


def replace_pack(config, base):
    source = config.get("source")
    variants = config.get("variants")
    if not isinstance(source, dict) or not isinstance(variants, list) or not variants:
        raise ValueError("pack needs source and one or more labelled variants")
    frozen = copy.deepcopy(source)
    path = resolve(base, frozen.get("path"), "source.path")
    actual_hash = file_hash(path)
    if frozen.get("sha256") and frozen["sha256"] != actual_hash:
        raise ValueError("source SHA256 mismatch; selected original changed")
    frozen["sha256"] = actual_hash
    output_dir = resolve(base, config.get("output_dir"), "output_dir")
    manifest_path = output_dir / "pack-manifest.json"
    if manifest_path.exists():
        raise ValueError("pack manifest exists; resume individual targets or choose a new output directory")
    slugs = []
    for variant in variants:
        label = variant.get("label") if isinstance(variant, dict) else None
        if not isinstance(label, str) or not label.strip():
            raise ValueError("each variant needs a label")
        slug = re.sub(r"[^a-z0-9]+", "-", label.lower()).strip("-")
        if not slug or slug in slugs:
            raise ValueError("variant labels must have unique file-safe names")
        slugs.append(slug)
    output_dir.mkdir(parents=True, exist_ok=True)
    results = []
    for index, (variant, slug) in enumerate(zip(variants, slugs)):
        candidate = {key: copy.deepcopy(config[key]) for key in ["hook_end_sec", "words", "word_times", "captions"] if key in config}
        candidate.update(source=frozen, hook=variant.get("hook"), output={"path": str(output_dir / (slug + ".mp4"))})
        if candidate.get("captions"):
            suffix = Path(candidate["captions"]["path"]).suffix
            candidate["captions"]["output_path"] = str(output_dir / (slug + suffix))
        try:
            manifest = replace(candidate, base)
            results.append({"variant_index": index, "label": variant["label"], "status": "needs_review",
                            "output": manifest["output"], "manifest_path": str(output_dir / (slug + ".mp4.manifest.json"))})
        except (ValueError, OSError, KeyError, TypeError) as error:
            results.append({"variant_index": index, "label": variant["label"], "status": "failed", "error": str(error)})
    summary = {"version": 1, "source": frozen, "hook_end_sec": config.get("hook_end_sec"), "variants": results,
               "status": "partial_failure" if any(r["status"] == "failed" for r in results) else "needs_review",
               "media_generation_cost_usd": 0}
    manifest_path.write_text(json.dumps(summary, indent=2) + "\n")
    return summary


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--config", required=True, type=Path)
    args = parser.parse_args()
    try:
        path = args.config.resolve()
        summary = replace_pack(json.loads(path.read_text()), path.parent)
        print(json.dumps(summary, indent=2))
        sys.exit(2 if summary["status"] == "partial_failure" else 0)
    except (ValueError, OSError, KeyError, TypeError) as error:
        print(f"Hook pack blocked: {error}", file=sys.stderr)
        sys.exit(2)
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall