Skip to content

dse120071750/m8m-harness-builder / skills/m8m/m8m-task-builder

m8m-task-builder

Verified

Author reusable M8M Task packages for server installation, or persist and manage the current live M8M Task's instructions, progress, waits and final JSON.

scripts/m8m_local_bundle.py

View on GitHub
"""Export reusable builder definitions or collect semantic installation context."""
import argparse
from io import BytesIO
import json
from pathlib import Path
import sys
import zipfile

sys.path.insert(0, str(Path(__file__).resolve().parent))
from m8m_delivery_common import collect, encoded, immutable, relative, sha256

FORBIDDEN = {"room_id", "thread_id", "wait_id", "task_state", "task_output", "ledger", "progress", "source_message_id"}

def reusable(value):
    if isinstance(value, dict):
        if FORBIDDEN & set(value):
            raise ValueError("Reusable definitions must not contain live Task/session state.")
        for child in value.values():
            reusable(child)
    elif isinstance(value, list):
        for child in value:
            reusable(child)

def main(argv=None):
    if hasattr(sys.stdout, "reconfigure"):
        sys.stdout.reconfigure(encoding="utf-8")
    parser = argparse.ArgumentParser(description=__doc__)
    commands = parser.add_subparsers(dest="command", required=True)
    task = commands.add_parser("task")
    for key in ("key", "title"):
        task.add_argument("--" + key, required=True)
    for key in ("goal", "master-prompt", "output-schema", "output"):
        task.add_argument("--" + key, type=Path, required=True)
    for key in ("workflow-references", "resource-requirements", "runtime-configuration"):
        task.add_argument("--" + key, type=Path)
    schedule = commands.add_parser("schedule")
    schedule.add_argument("--key", required=True)
    schedule.add_argument("--definition", type=Path, required=True)
    schedule.add_argument("--output", type=Path, required=True)
    bundle = commands.add_parser("bundle")
    bundle.add_argument("--source", type=Path, action="append", required=True)
    bundle.add_argument("--output", type=Path, required=True)
    args = parser.parse_args(argv)
    if args.command == "task":
        schema = json.loads(args.output_schema.read_bytes())
        if not isinstance(schema, (dict, bool)):
            raise ValueError("The output schema must be a JSON Schema object or boolean.")
        # The server validates the complete schema during semantic preparation;
        # exporting context requires only the standard Python library.
        value = {"schema": "m8m.task_template.v1", "template_key": args.key, "title": args.title,
            "definition": {"goal": args.goal.read_bytes().decode("utf-8"),
                "master_prompt": args.master_prompt.read_bytes().decode("utf-8"), "output_schema": schema,
                "workflows": json.loads(args.workflow_references.read_bytes()) if args.workflow_references else {}},
            "resource_requirements": json.loads(args.resource_requirements.read_bytes()) if args.resource_requirements else []}
        if args.runtime_configuration:
            value["runtime_configuration"]=json.loads(args.runtime_configuration.read_bytes())
        reusable(value)
        payload = encoded(value)
    elif args.command == "schedule":
        value = {"schema": "m8m.schedule_template.v1", "template_key": args.key, "definition": json.loads(args.definition.read_bytes())}
        reusable(value)
        if value["definition"].get("target", {}).get("kind") == "resume_session":
            raise ValueError("Create a reminder from its real server Task wait; export only reusable follow-up policy.")
        payload = encoded(value)
    else:
        members = {}
        for root in args.source:
            for path, data in collect(root).items():
                name = relative(root.name + "/" + path if root.is_dir() else path)
                if name in members:
                    raise ValueError("Bundle sources have conflicting relative names.")
                members[name] = data
        from m8m_delivery_common import MAX_BYTES, MAX_FILES
        if len(members) > MAX_FILES or sum(map(len, members.values())) > MAX_BYTES:
            raise ValueError("Combined bundle exceeds the server transport bound.")
        memory = BytesIO()
        with zipfile.ZipFile(memory, "w", compression=zipfile.ZIP_DEFLATED) as archive:
            for name, data in sorted(members.items()):
                info = zipfile.ZipInfo(name, date_time=(1980, 1, 1, 0, 0, 0))
                info.compress_type = zipfile.ZIP_DEFLATED
                archive.writestr(info, data)
        payload = memory.getvalue()
    immutable(args.output.absolute(), payload)
    print(encoded({"path": str(args.output.absolute()), "digest": sha256(payload), "bytes": len(payload)}).decode())
    return 0

if __name__ == "__main__":
    raise SystemExit(main())
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall