Skip to content

nexu-io/openmotion / library/design/skills/chat-motion-overlay

chat-motion-overlay

Verified

Generate configurable chat motion overlays from a transcript or screenshot, including plain bubble scenes, app-style chat containers, optional device frames, preset or uploaded avatars, nickname display rules, and transparent-video-ready Remotion bundles. Use when Codex needs to create reusable short-form chat clips for Douyin, demo videos, story reenactments, social-message proof scenes, or embeddable alpha overlays for Hyperframe and Remotion workflows.

scripts/prepare_chat_overlay_bundle.py

View on GitHub
#!/usr/bin/env python3
from __future__ import annotations

import argparse
import json
import shutil
from pathlib import Path

from build_chat_overlay_spec import build_spec, load_config, parse_transcript


BUNDLE_MARKER = ".chat-motion-overlay-bundle"


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description="Prepare a renderable Remotion chat overlay bundle.")
    parser.add_argument("--transcript", required=True, help="Path to transcript text file")
    parser.add_argument("--config", help="Path to scene config JSON")
    parser.add_argument("--output-dir", required=True, help="Directory to create the Remotion bundle in")
    parser.add_argument("--force", action="store_true", help="Overwrite the output directory if it exists")
    return parser.parse_args()


def script_dir() -> Path:
    return Path(__file__).resolve().parent


def skill_root() -> Path:
    return script_dir().parent


def template_dir() -> Path:
    return skill_root() / "assets" / "remotion-template"


def avatar_library_dir() -> Path:
    return skill_root() / "assets" / "avatar-library"


def repo_root() -> Path:
    return skill_root().parent.parent


def bundle_marker_path(output_dir: Path) -> Path:
    return output_dir / BUNDLE_MARKER


def validate_output_dir(output_dir: Path, force: bool) -> None:
    dangerous_targets = {
        Path.cwd().resolve(),
        Path.home().resolve(),
        repo_root(),
        skill_root(),
        template_dir(),
    }
    if output_dir in dangerous_targets:
        raise SystemExit(
            f"Refusing to use dangerous output directory: {output_dir}. "
            "Choose a dedicated generated-bundle directory instead."
        )
    if output_dir.exists() and force and not bundle_marker_path(output_dir).exists():
        raise SystemExit(
            f"Refusing to overwrite unmanaged output directory: {output_dir}. "
            f"Only directories containing {BUNDLE_MARKER} can be replaced with --force."
        )


def copy_template(output_dir: Path, force: bool) -> None:
    validate_output_dir(output_dir, force)
    if output_dir.exists():
        if not force:
            raise SystemExit(f"Output directory already exists: {output_dir}. Use --force to overwrite.")
        shutil.rmtree(output_dir)
    shutil.copytree(template_dir(), output_dir)
    bundle_marker_path(output_dir).write_text("generated by chat-motion-overlay\n", encoding="utf-8")


def write_chat_spec_ts(spec: dict, output_dir: Path) -> None:
    target = output_dir / "src" / "chatSpec.ts"
    content = "export const chatSpec = " + json.dumps(spec, ensure_ascii=False, indent=2) + " as const;\n"
    target.write_text(content, encoding="utf-8")


def remove_local_upload_paths(spec: dict) -> None:
    for participant in spec["participants"]:
        participant.pop("uploadPath", None)


def copy_avatar_assets(spec: dict, output_dir: Path) -> dict:
    upload_sources: list[tuple[dict, Path]] = []
    for participant in spec["participants"]:
        upload_path = participant.get("uploadPath")
        if upload_path:
            source = Path(upload_path).expanduser().resolve()
            if not source.exists():
                raise SystemExit(
                    f"Configured uploadPath for participant {participant['name']} does not exist: {source}. "
                    "Fix the upload avatar path before preparing the bundle."
                )
            upload_sources.append((participant, source))
    public_dir = output_dir / "public"
    public_dir.mkdir(parents=True, exist_ok=True)
    for preset_file in avatar_library_dir().glob("*.png"):
        shutil.copy2(preset_file, public_dir / preset_file.name)
    for participant, source in upload_sources:
        target_name = f"{participant['id']}-upload{source.suffix.lower()}"
        shutil.copy2(source, public_dir / target_name)
        participant["uploadAsset"] = target_name
    remove_local_upload_paths(spec)
    return spec


def main() -> None:
    args = parse_args()
    parsed = parse_transcript(Path(args.transcript))
    config = load_config(args.config)
    spec = build_spec(parsed, config)
    out_dir = Path(args.output_dir).resolve()
    copy_template(out_dir, args.force)
    try:
        sanitized_spec = copy_avatar_assets(spec, out_dir)
        write_chat_spec_ts(sanitized_spec, out_dir)
    except BaseException:
        if out_dir.exists():
            shutil.rmtree(out_dir)
        raise
    print(f"Prepared Remotion bundle at {out_dir}")


if __name__ == "__main__":
    main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall