diff --git a/.agents/hooks.json b/.agents/hooks.json new file mode 100644 index 0000000..27f6d93 --- /dev/null +++ b/.agents/hooks.json @@ -0,0 +1,39 @@ +{ + "eomd-stage-gate": { + "PreToolUse": [ + { + "matcher": "write_file|edit_file|run_command|invoke_subagent", + "hooks": [ + { + "type": "command", + "command": "sh -c 'f=.agents/hooks/stage_gate.py; [ -f \"$f\" ] || f=hooks/stage_gate.py; exec python3 \"$f\" --harness antigravity --event PreToolUse'", + "timeout": 10 + } + ] + } + ], + "PostToolUse": [ + { + "matcher": "invoke_subagent|read_file|write_file|edit_file|run_command", + "hooks": [ + { + "type": "command", + "command": "sh -c 'f=.agents/hooks/stage_gate.py; [ -f \"$f\" ] || f=hooks/stage_gate.py; exec python3 \"$f\" --harness antigravity --event PostToolUse'", + "timeout": 10 + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "sh -c 'f=.agents/hooks/stage_gate.py; [ -f \"$f\" ] || f=hooks/stage_gate.py; exec python3 \"$f\" --harness antigravity --event Stop'", + "timeout": 15 + } + ] + } + ] + } +} diff --git a/.agents/hooks/stage_gate.py b/.agents/hooks/stage_gate.py new file mode 100644 index 0000000..0734e27 --- /dev/null +++ b/.agents/hooks/stage_gate.py @@ -0,0 +1,527 @@ +#!/usr/bin/env python3 +"""Programmatic stage-gate & receipt hook for EOMD across Antigravity, Claude Code, and Codex CLI. + +Enforces EOMD's interview -> brief -> concepts -> storyboard/stills/sound -> build -> fresh-eyes QA pipeline: +- PostToolUse records inspected PNGs, ffmpeg/QA command runs, and isolated fresh-eyes reviewer subagents. +- PreToolUse blocks writing storyboard/stills before brief APPROVED, and blocks players/.html before + storyboard APPROVED + inspected stills + fresh-eyes review (in full creative mode), plus budget model caps. +- Stop blocks completing a locally edited players/.html until QA checks, >=2 inspected QA frame PNGs, + and an isolated fresh-eyes review (proj//qa/review.md) pass for the current HTML. +""" +from __future__ import annotations + +import argparse +import glob +import hashlib +import json +import os +import re +import subprocess +import sys +import time +from pathlib import Path + +TOOL_ROOT = Path(__file__).resolve().parents[2] +RECEIPT_NAMES = ( + ".qa_checked.json", + ".inspected_pngs.json", + ".subagent_receipts.jsonl", + ".review_receipts.jsonl", +) + + +def _read_text(path: Path, limit: int | None = None) -> str: + try: + with path.open("r", encoding="utf-8") as fh: + return fh.read(limit) if limit else fh.read() + except OSError: + return "" + + +def _load_json(path: Path, default): + txt = _read_text(path) + if not txt: + return default + try: + return json.loads(txt) + except ValueError: + return default + + +def _file_sha256(path: Path) -> str: + try: + return hashlib.sha256(path.read_bytes()).hexdigest() + except OSError: + return "" + + +def _parse_brief_meta(root: Path, piece: str) -> tuple[str, str, str, bool]: + """Return (stage, mode, budget, budget_override) from proj//brief.md.""" + brief = root / "proj" / piece / "brief.md" + head = _read_text(brief, 2500) + stage_m = re.search(r"Stage:\s*([a-zA-Z_-]+)", head) + stage = stage_m.group(1).lower() if stage_m else "" + mode_m = re.search(r"Mode:\s*([^\n·|]+)", head, re.I) + mode = mode_m.group(1).strip().lower() if mode_m else "" + budget_m = re.search(r"Budget:\s*([a-zA-Z_-]+)", head, re.I) + budget = budget_m.group(1).lower() if budget_m else "standard" + override = bool( + re.search(r"Budget-Override:\s*(approved|yes|true)", head, re.I) + or (root / "proj" / piece / ".budget_override").exists() + ) + return stage, mode, budget, override + + +def _newest_active_piece(root: Path) -> str | None: + best: tuple[float, str] | None = None + for brief in glob.glob(str(root / "proj" / "*" / "brief.md")): + p = Path(brief) + try: + mt = p.stat().st_mtime + except OSError: + continue + if best is None or mt > best[0]: + best = (mt, p.parent.name) + return best[1] if best else None + + +def _rel_path(root: Path, raw: str) -> str: + if not raw: + return "" + p = Path(raw) + p = (root / p).resolve() if not p.is_absolute() else p.resolve() + try: + return p.relative_to(root.resolve()).as_posix() + except ValueError: + return raw.replace("\\", "/") + + +def _extract_paths_from_shell(cmd: str) -> list[str]: + paths: list[str] = [] + for m in re.finditer(r"(?:^|[\s'\"(=])((?:\./)?(?:proj|players|dist)/[^\s'\"`;|>&)]+)", cmd): + paths.append(m.group(1)) + return paths + + +def _extract_target_paths(root: Path, tool_name: str, args: dict) -> list[str]: + low = tool_name.lower() + raw_paths: list[str] = [] + for key in ("Path", "file_path", "path", "target_file"): + val = args.get(key) + if isinstance(val, str) and val: + raw_paths.append(val) + if "patch" in low or "apply_patch" in low: + patch_text = str(args.get("patch") or args.get("input") or args.get("Patch") or "") + for m in re.finditer(r"^\*\*\*\s+(?:Add|Update|Delete)\s+File:\s*(.+)$", patch_text, re.M): + raw_paths.append(m.group(1).strip()) + if low in ("run_command", "bash", "shell", "command"): + cmd = str(args.get("CommandLine") or args.get("command") or "") + if re.search(r"(>|>>|\btee\b|\bmv\b|\bcp\b|write_text|open\s*\()", cmd): + raw_paths.extend(_extract_paths_from_shell(cmd)) + return [_rel_path(root, p) for p in raw_paths if p] + + +def _normalize_input(harness: str, event: str, payload: dict) -> dict: + cwd_raw = payload.get("cwd") or os.environ.get("CLAUDE_PROJECT_DIR") + if not cwd_raw and isinstance(payload.get("workspacePaths"), list) and payload["workspacePaths"]: + cwd_raw = payload["workspacePaths"][0] + root = Path(cwd_raw).resolve() if cwd_raw else TOOL_ROOT + + if harness == "antigravity": + tc = payload.get("toolCall") or {} + tool_name = str(tc.get("name") or "") + args = tc.get("args") if isinstance(tc.get("args"), dict) else {} + error = payload.get("error") + term = str(payload.get("terminationReason") or "") + active = bool(payload.get("continuationActive", False)) + return { + "root": root, + "tool": tool_name, + "args": args, + "error": error, + "stop_active": active or (event == "Stop" and term not in ("", "NO_TOOL_CALL")), + } + + tool_name = str(payload.get("tool_name") or (payload.get("toolCall") or {}).get("name") or "") + args = payload.get("tool_input") or (payload.get("toolCall") or {}).get("args") or {} + if not isinstance(args, dict): + args = {} + error = payload.get("error") + tr = payload.get("tool_response") + if not error and isinstance(tr, dict): + if tr.get("is_error") or tr.get("exit_code", 0) != 0 or tr.get("returncode", 0) != 0: + error = "tool_response error" + active = bool(payload.get("stop_hook_active", False)) + return { + "root": root, + "tool": tool_name, + "args": args, + "error": error, + "stop_active": active, + } + + +def _subagent_receipts_path(root: Path, piece: str) -> Path: + return root / "proj" / piece / ".subagent_receipts.jsonl" + + +def _review_receipts_path(root: Path, piece: str) -> Path: + return root / "proj" / piece / ".review_receipts.jsonl" + + +def _inspected_pngs_path(root: Path, piece: str) -> Path: + return root / "proj" / piece / ".inspected_pngs.json" + + +def _qa_checked_path(root: Path, piece: str) -> Path: + return root / "proj" / piece / ".qa_checked.json" + + +def _piece_has_local_changes(root: Path, piece: str) -> bool: + if not (root / ".git").exists(): + return True + try: + p = subprocess.run( + ["git", "status", "--porcelain", "--", f"proj/{piece}", f"players/{piece}.html"], + cwd=str(root), + capture_output=True, + text=True, + timeout=3, + ) + except OSError: + return True + if p.returncode != 0: + return True + for line in p.stdout.splitlines(): + path = line[3:].strip().strip('"') + if not path.endswith(RECEIPT_NAMES): + return True + return False + + +def _player_html_has_local_changes(root: Path, piece: str) -> bool: + if not (root / ".git").exists(): + return True + try: + p = subprocess.run( + ["git", "status", "--porcelain", "--", f"players/{piece}.html"], + cwd=str(root), + capture_output=True, + text=True, + timeout=3, + ) + except OSError: + return True + if p.returncode != 0: + return True + return bool(p.stdout.strip()) + + +def _is_fresh_eyes_subagent(args: dict) -> bool: + sub_type = str(args.get("subagent_type") or args.get("TypeName") or args.get("agent_type") or "").lower() + role = str(args.get("Role") or args.get("role") or args.get("name") or "").lower() + prompt = str(args.get("Prompt") or args.get("prompt") or "").lower() + if "fresh-eyes" in sub_type or "fresh_eyes" in sub_type or "reviewer" in sub_type: + return True + if "fresh" in role or "review" in role: + return True + return any(tok in prompt for tok in ("fresh-eyes", "fresh eyes", "stills/review.md", "qa/review.md", "craft.md")) + + +def _extract_piece_from_subagent(root: Path, args: dict) -> list[str]: + blob = " ".join( + str(args.get(k) or "") + for k in ("Prompt", "prompt", "Role", "role") + ) + found: list[str] = [] + for m in re.finditer(r"proj/([a-zA-Z0-9_-]+)/", blob): + name = m.group(1) + if (root / "proj" / name / "brief.md").exists() and name not in found: + found.append(name) + if found: + return found + newest = _newest_active_piece(root) + return [newest] if newest else [] + + +def _record_post_tool(root: Path, tool_name: str, args: dict, error) -> None: + if error: + return + low = tool_name.lower() + now = time.time() + + # 1. Subagent / fresh-eyes reviewer execution receipt + if low in ("invoke_subagent", "agent", "task", "spawn_agent"): + targets = _extract_piece_from_subagent(root, args) + is_review = _is_fresh_eyes_subagent(args) + for piece in targets: + stage, _, _, _ = _parse_brief_meta(root, piece) + rpath = _subagent_receipts_path(root, piece) + rpath.parent.mkdir(parents=True, exist_ok=True) + with rpath.open("a", encoding="utf-8") as fh: + fh.write(json.dumps({"ts": now, "tool": tool_name, "review": is_review}) + "\n") + if is_review: + html = root / "players" / f"{piece}.html" + rec = { + "ts": now, + "tool": tool_name, + "stage": stage, + "html_sha256": _file_sha256(html) if html.exists() else "", + } + rev_path = _review_receipts_path(root, piece) + with rev_path.open("a", encoding="utf-8") as fh: + fh.write(json.dumps(rec) + "\n") + return + + # 2. PNG inspection receipt + if low in ("read_file", "read", "view_file", "view_image"): + for raw_key in ("Path", "file_path", "path"): + val = args.get(raw_key) + if not isinstance(val, str) or not val.lower().endswith(".png"): + continue + rel = _rel_path(root, val) + m = re.match(r"proj/([^/]+)/(.+\.png)$", rel, re.I) + if not m: + continue + piece = m.group(1) + abs_png = root / rel + if not abs_png.exists(): + continue + ipath = _inspected_pngs_path(root, piece) + data = _load_json(ipath, {}) + data[rel] = max(now, abs_png.stat().st_mtime) + if not rel.startswith(f"proj/{piece}/stills/"): + html = root / "players" / f"{piece}.html" + sha = _file_sha256(html) + if sha: + by_sha = data.setdefault("_sha256_pngs", {}) + lst = by_sha.setdefault(sha, []) + if rel not in lst: + lst.append(rel) + ipath.parent.mkdir(parents=True, exist_ok=True) + ipath.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8") + return + + # 3. Audio / render / player QA command receipt + if low in ("run_command", "bash", "shell", "command"): + cmd = str(args.get("CommandLine") or args.get("command") or "") + if any(k in cmd for k in ("ebur128", "render_piece.py", "regress", "html_to_mp4.py", "gen_export.py", "playwright")): + for brief in glob.glob(str(root / "proj" / "*" / "brief.md")): + piece = Path(brief).parent.name + html = root / "players" / f"{piece}.html" + qpath = _qa_checked_path(root, piece) + if html.exists() and (not qpath.exists() or _piece_has_local_changes(root, piece)): + qpath.write_text( + json.dumps({"ts": now, "sha256": _file_sha256(html), "cmd": cmd[:200]}) + "\n", + encoding="utf-8", + ) + + +def _check_pre_subagent(root: Path, harness: str, tool_name: str, args: dict) -> str | None: + low = tool_name.lower() + if low not in ("agent", "task", "spawn_agent", "invoke_subagent"): + return None + + if harness in ("claude", "codex"): + model = str(args.get("model") or args.get("Model") or "").lower() + effort = str(args.get("reasoning_effort") or args.get("effort") or "").lower() + if "fable" in model or "turbo" in model: + return "Budget gate: 'fable' and 'turbo' models are prohibited for subagents at any budget tier." + if effort in ("max", "xhigh", "extra", "turbo"): + return "Budget gate: subagent reasoning effort above 'high' is prohibited." + + targets = _extract_piece_from_subagent(root, args) + piece = targets[0] if targets else _newest_active_piece(root) + if not piece: + return None + + _, _, budget, override = _parse_brief_meta(root, piece) + if budget != "light" or override: + return None + + rpath = _subagent_receipts_path(root, piece) + prior = len([ln for ln in _read_text(rpath).splitlines() if ln.strip()]) + if prior >= 3: + return ( + f"Light budget gate: {piece} already ran {prior} subagent(s). " + f"Ask the user before exceeding the 3-subagent light budget (Budget-Override: approved)." + ) + return None + + +def _has_review_receipt(root: Path, piece: str, html_sha: str = "", min_ts: float = 0.0) -> bool: + rpath = _review_receipts_path(root, piece) + for ln in _read_text(rpath).splitlines(): + ln = ln.strip() + if not ln: + continue + try: + rec = json.loads(ln) + except ValueError: + continue + if html_sha: + if rec.get("html_sha256") == html_sha or float(rec.get("ts", 0.0)) >= min_ts: + return True + else: + return True + return False + + +def _check_pre_write(root: Path, rel_path: str) -> str | None: + m_sb = re.match(r"^proj/([^/]+)/(storyboard\.md|stills/[^/]+\.(?:html|svg))$", rel_path) + if m_sb: + piece = m_sb.group(1) + stage, _, _, _ = _parse_brief_meta(root, piece) + brief_txt = _read_text(root / "proj" / piece / "brief.md") + if stage == "interview" or not re.search(r"\bAPPROVED\b", brief_txt): + return ( + f"Stage gate: proj/{piece}/brief.md must be marked APPROVED (and past Stage: interview) " + f"before creating {rel_path}." + ) + return None + + m_player = re.match(r"^(?:players|dist)/([^/]+)\.html$", rel_path) + if m_player: + piece = m_player.group(1) + brief = root / "proj" / piece / "brief.md" + if not brief.exists(): + return None + stage, mode, _, _ = _parse_brief_meta(root, piece) + brief_txt = _read_text(brief) + if stage == "interview" or not re.search(r"\bAPPROVED\b", brief_txt): + return f"Stage gate: proj/{piece}/brief.md must be marked APPROVED before building {rel_path}." + if "efficient" not in mode: + sb = root / "proj" / piece / "storyboard.md" + if not re.search(r"\bAPPROVED\b", _read_text(sb)): + return ( + f"Stage gate: proj/{piece}/storyboard.md must be marked APPROVED before building {rel_path} " + f"in full creative mode." + ) + stills_dir = root / "proj" / piece / "stills" + png_stills = list(stills_dir.glob("*.png")) if stills_dir.is_dir() else [] + inspected = _load_json(_inspected_pngs_path(root, piece), {}) + inspected_stills = [k for k in inspected if k.startswith(f"proj/{piece}/stills/") and (root / k).exists()] + if not png_stills or not inspected_stills: + return ( + f"Visual gate: render and inspect at least 1 still PNG in proj/{piece}/stills/ via " + f"read_file/Read/view_image before building {rel_path}." + ) + review_md = stills_dir / "review.md" + if not _has_review_receipt(root, piece) or len(_read_text(review_md).strip()) < 80: + return ( + f"Fresh-eyes gate: run an isolated fresh-eyes reviewer subagent on proj/{piece}/stills/ " + f"writing proj/{piece}/stills/review.md before building {rel_path}." + ) + return None + + return None + + +def _check_stop(root: Path, stop_active: bool) -> str | None: + if stop_active: + return None + for brief_str in glob.glob(str(root / "proj" / "*" / "brief.md")): + piece = Path(brief_str).parent.name + stage, _, _, _ = _parse_brief_meta(root, piece) + if stage in ("done", "published"): + continue + html = root / "players" / f"{piece}.html" + if not html.exists() or not _player_html_has_local_changes(root, piece): + continue + html_mtime = html.stat().st_mtime + html_sha = _file_sha256(html) + + qa_rec = _load_json(_qa_checked_path(root, piece), {}) + qa_ok = bool(qa_rec) and ( + (html_sha and qa_rec.get("sha256") == html_sha) or float(qa_rec.get("ts", 0.0)) >= html_mtime + ) + if not qa_ok: + return ( + f"Run audio/render QA (`ebur128`, `render_piece.py`, `regress.py`, or `html_to_mp4.py`) " + f"after the final edit to players/{piece}.html before finishing." + ) + + inspected = _load_json(_inspected_pngs_path(root, piece), {}) + mtime_pngs = [ + k for k, ts in inspected.items() + if not k.startswith("_") + and not k.startswith(f"proj/{piece}/stills/") + and isinstance(ts, (int, float)) + and (root / k).exists() + and float(ts) >= html_mtime + ] + sha_pngs = [ + k for k in (inspected.get("_sha256_pngs") or {}).get(html_sha, []) + if (root / k).exists() + ] if html_sha else [] + if len(set(mtime_pngs) | set(sha_pngs)) < 2: + return ( + f"Capture and inspect >=2 QA frame PNGs of players/{piece}.html " + f"(under proj/{piece}/qa/) via read_file/Read/view_image before finishing." + ) + + qa_review = root / "proj" / piece / "qa" / "review.md" + if not _has_review_receipt(root, piece, html_sha=html_sha, min_ts=html_mtime) or len(_read_text(qa_review).strip()) < 80: + return ( + f"Run an isolated fresh-eyes reviewer subagent on proj/{piece}/qa/ writing proj/{piece}/qa/review.md " + f"for the current players/{piece}.html before finishing." + ) + return None + + +def _emit(harness: str, event: str, reason: str | None) -> int: + if event == "PostToolUse": + print("{}") + return 0 + if not reason: + if harness == "antigravity": + print(json.dumps({"decision": "allow"} if event == "PreToolUse" else {})) + return 0 + if harness == "antigravity": + if event == "PreToolUse": + print(json.dumps({"decision": "deny", "reason": reason})) + else: + print(json.dumps({"decision": "continue", "reason": reason})) + return 0 + print(reason, file=sys.stderr) + return 2 + + +def main(argv: list[str] | None = None) -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--harness", choices=("antigravity", "claude", "codex"), required=True) + ap.add_argument("--event", choices=("PreToolUse", "PostToolUse", "Stop"), required=True) + opts = ap.parse_args(argv) + + try: + raw = sys.stdin.read() + payload = json.loads(raw) if raw.strip() else {} + except ValueError: + payload = {} + + info = _normalize_input(opts.harness, opts.event, payload) + root = info["root"] + + if opts.event == "PostToolUse": + _record_post_tool(root, info["tool"], info["args"], info["error"]) + return _emit(opts.harness, opts.event, None) + + if opts.event == "PreToolUse": + sub_reason = _check_pre_subagent(root, opts.harness, info["tool"], info["args"]) + if sub_reason: + return _emit(opts.harness, opts.event, sub_reason) + for rel in _extract_target_paths(root, info["tool"], info["args"]): + reason = _check_pre_write(root, rel) + if reason: + return _emit(opts.harness, opts.event, reason) + return _emit(opts.harness, opts.event, None) + + if opts.event == "Stop": + reason = _check_stop(root, info["stop_active"]) + return _emit(opts.harness, opts.event, reason) + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.agents/hooks/test_stage_gate.py b/.agents/hooks/test_stage_gate.py new file mode 100644 index 0000000..aa7d296 --- /dev/null +++ b/.agents/hooks/test_stage_gate.py @@ -0,0 +1,177 @@ +"""End-to-end unit tests for EOMD .agents/hooks/stage_gate.py across Antigravity, Claude Code, and Codex CLI.""" +import json +import os +import re +import subprocess +import sys +import tempfile +import time +import tomllib +import unittest +from pathlib import Path + +GATE = Path(__file__).resolve().parent / "stage_gate.py" +REPO_ROOT = Path(__file__).resolve().parents[2] + + +def _run_gate(harness: str, event: str, payload: dict) -> tuple[int, str, str]: + p = subprocess.run( + [sys.executable, str(GATE), "--harness", harness, "--event", event], + input=json.dumps(payload), + text=True, + capture_output=True, + ) + return p.returncode, p.stdout.strip(), p.stderr.strip() + + +class EomdStageGateTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "proj" / "demo" / "stills").mkdir(parents=True) + (self.root / "proj" / "demo" / "qa").mkdir(parents=True) + (self.root / "players").mkdir(parents=True) + (self.root / "proj" / "demo" / "brief.md").write_text( + "# Brief: Demo\n\nStatus: DRAFT · Stage: interview · Mode: full creative · Budget: standard\n", + encoding="utf-8", + ) + + def tearDown(self): + self.tmp.cleanup() + + def test_full_creative_and_fresh_eyes_pipeline(self): + # 1. Storyboard blocked during interview + rc, out, _ = _run_gate("antigravity", "PreToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "write_file", "args": {"Path": "proj/demo/storyboard.md"}}, + }) + self.assertEqual(json.loads(out)["decision"], "deny") + + # 2. Approve brief -> storyboard allowed; players/demo.html still blocked + (self.root / "proj" / "demo" / "brief.md").write_text( + "# Brief: Demo\n\nStatus: APPROVED today · Stage: storyboard · Mode: full creative · Budget: standard\n", + encoding="utf-8", + ) + rc, out, _ = _run_gate("antigravity", "PreToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "write_file", "args": {"Path": "proj/demo/storyboard.md"}}, + }) + self.assertEqual(json.loads(out)["decision"], "allow") + rc, out, _ = _run_gate("antigravity", "PreToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "write_file", "args": {"Path": "players/demo.html"}}, + }) + self.assertEqual(json.loads(out)["decision"], "deny") + + # 3. Approve storyboard + inspect still PNG + fresh-eyes reviewer receipt -> players/demo.html allowed + (self.root / "proj" / "demo" / "storyboard.md").write_text("Stage: storyboard · APPROVED\n", encoding="utf-8") + (self.root / "proj" / "demo" / "stills" / "s1.png").write_bytes(b"PNG") + _run_gate("antigravity", "PostToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "read_file", "args": {"Path": "proj/demo/stills/s1.png"}}, + }) + # Still blocked without fresh-eyes review receipt + stills/review.md + rc, out, _ = _run_gate("antigravity", "PreToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "write_file", "args": {"Path": "players/demo.html"}}, + }) + self.assertEqual(json.loads(out)["decision"], "deny") + self.assertIn("Fresh-eyes", json.loads(out)["reason"]) + + _run_gate("antigravity", "PostToolUse", { + "cwd": str(self.root), + "toolCall": { + "name": "invoke_subagent", + "args": {"Role": "Fresh-eyes Reviewer", "Prompt": "Review proj/demo/stills/ per CRAFT.md"}, + }, + }) + (self.root / "proj" / "demo" / "stills" / "review.md").write_text("Checked: " + "ok " * 35, encoding="utf-8") + rc, out, _ = _run_gate("antigravity", "PreToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "write_file", "args": {"Path": "players/demo.html"}}, + }) + self.assertEqual(json.loads(out)["decision"], "allow") + + # 4. Stop blocked once players/demo.html exists until QA command + >=2 QA PNGs + fresh-eyes qa/review.md + html = self.root / "players" / "demo.html" + html.write_text("player", encoding="utf-8") + rc, out, _ = _run_gate("antigravity", "Stop", { + "cwd": str(self.root), "terminationReason": "NO_TOOL_CALL", "continuationActive": False, + }) + self.assertEqual(json.loads(out)["decision"], "continue") + + time.sleep(0.01) + _run_gate("antigravity", "PostToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "run_command", "args": {"CommandLine": "ffmpeg -i out.wav -af ebur128=peak=true -f null -"}}, + }) + for shot in ("frame1.png", "frame2.png"): + (self.root / "proj" / "demo" / "qa" / shot).write_bytes(b"PNG") + _run_gate("antigravity", "PostToolUse", { + "cwd": str(self.root), + "toolCall": {"name": "read_file", "args": {"Path": f"proj/demo/qa/{shot}"}}, + }) + # Still blocked without fresh-eyes QA review for current HTML + rc, out, _ = _run_gate("antigravity", "Stop", { + "cwd": str(self.root), "terminationReason": "NO_TOOL_CALL", "continuationActive": False, + }) + self.assertEqual(json.loads(out)["decision"], "continue") + self.assertIn("qa/review.md", json.loads(out)["reason"]) + + _run_gate("antigravity", "PostToolUse", { + "cwd": str(self.root), + "toolCall": { + "name": "invoke_subagent", + "args": {"Role": "Fresh-eyes QA Reviewer", "Prompt": "Review proj/demo/qa/"}, + }, + }) + (self.root / "proj" / "demo" / "qa" / "review.md").write_text("QA verified: " + "ok " * 35, encoding="utf-8") + rc, out, _ = _run_gate("antigravity", "Stop", { + "cwd": str(self.root), "terminationReason": "NO_TOOL_CALL", "continuationActive": False, + }) + self.assertEqual(json.loads(out), {}) + + def test_claude_codex_budget_caps_and_manifests(self): + # 1. Prohibited model/effort blocked on Claude Code & Codex + rc, _, err = _run_gate("claude", "PreToolUse", { + "cwd": str(self.root), + "tool_name": "Agent", + "tool_input": {"model": "fable-1", "prompt": "Review"}, + }) + self.assertEqual(rc, 2) + self.assertIn("fable", err.lower()) + + rc, _, err = _run_gate("codex", "PreToolUse", { + "cwd": str(self.root), + "tool_name": "spawn_agent", + "tool_input": {"reasoning_effort": "xhigh", "prompt": "Review"}, + }) + self.assertEqual(rc, 2) + + # 2. Declared hook manifests execute cleanly + ag = json.loads((REPO_ROOT / ".agents" / "hooks.json").read_text(encoding="utf-8")) + cl = json.loads((REPO_ROOT / ".claude" / "settings.json").read_text(encoding="utf-8")) + cx = json.loads((REPO_ROOT / ".codex" / "hooks.json").read_text(encoding="utf-8")) + cx_cfg = tomllib.loads((REPO_ROOT / ".codex" / "config.toml").read_text(encoding="utf-8")) + self.assertTrue(cx_cfg.get("features", {}).get("hooks")) + self.assertIn("eomd-stage-gate", ag) + self.assertIn("hooks", cl) + self.assertIn("hooks", cx) + + # 3. Skills have valid YAML frontmatter and house.md preserves grammar + for sf in list((REPO_ROOT / ".agents" / "skills").glob("*/SKILL.md")) + list( + (REPO_ROOT / ".claude" / "skills").glob("*/SKILL.md") + ): + txt = sf.read_text(encoding="utf-8") + m = re.match(r"^---\s*\n(.*?)\n---\s*\n", txt, re.S) + self.assertIsNotNone(m, f"Missing YAML frontmatter in {sf}") + self.assertRegex(m.group(1), re.compile(r"^name:\s*\S+", re.M)) + self.assertRegex(m.group(1), re.compile(r"^description:\s*\S+", re.M)) + + house = (REPO_ROOT / "brief" / "taste" / "house.md").read_text(encoding="utf-8") + for ln in [ln for ln in house.splitlines() if re.match(r"^T\d+\b", ln)]: + self.assertRegex(ln, r"^T\d+ · (strong|soft) · ") + + +if __name__ == "__main__": + unittest.main() diff --git a/.agents/skills/auto-piece/SKILL.md b/.agents/skills/auto-piece/SKILL.md new file mode 100644 index 0000000..0c7ef83 --- /dev/null +++ b/.agents/skills/auto-piece/SKILL.md @@ -0,0 +1,25 @@ +--- +name: auto-piece +description: >- + Run EOMD's build, audio calibration, frame rendering, and isolated fresh-eyes visual/audio QA pipeline once + the brief (efficient mode) or storyboard, stills, and sound concept (full creative mode) are approved. +--- + +# Guided-Brief + Autonomous Build & Fresh-Eyes QA (`auto-piece`) + +## Stage 1 — Always Align With the User First (`Stage: interview -> brief / storyboard`) +1. Unless the user explicitly instructed otherwise, **always interview first** (`brief/INTERVIEW.md`, Round 1+): confirm viewing context, tone, voice, mode (`efficient` vs. `full creative`), and `Budget: light | standard | deep`. +2. In `full creative` mode, draft concepts and `proj//storyboard.md` + stills (`proj//stills/*.png`), run an **isolated fresh-eyes subagent review** (`brief/CRAFT.md` §11) writing `proj//stills/review.md`, fix clear mistakes, and present to the user until `APPROVED`. + +## Budget & model rules +- **Antigravity:** Run the coordinator on **Hydrogen High**; leave subagent model overrides unset unless requested. +- **Claude Code / Codex:** Never use `fable`, `turbo`, or effort above `high` (`max`, `xhigh`, `extra`). On `Budget: light`, route reviewer/helper subagents to `sonnet` (or `haiku` for narrow checks) and ask before spawning `>3` subagents (`Budget-Override: approved`). On `Budget: standard`, Opus (`medium` effort) is fine for coordination with `sonnet` workers. + +## Stage 2 — Build & Audio Verification (`Stage: build`) +1. Open `/toolbox` at the gate, write the **Build plan** in `proj//brief.md`, and share the plain-words plan before building if not yet confirmed. +2. Build the player (`players/.html`) and synthesized audio (48 kHz, true peak ≤ −1.5 dBTP). Verify audio via `ffmpeg` (`ebur128=peak=true:framelog=quiet`, `showspectrumpic`, `showwavespic`, `silencedetect`), `tools/render_piece.py`, or `tools/regress.py` (`python3 -c ...`). + +## Stage 3 — Isolated Fresh-Eyes QA (`proj//qa/`) +1. Capture ≥ 2 frame PNGs (`proj//qa/`, plus loop-seam / cut frames if applicable) and inspect them via `read_file`/`Read`/`view_image`. +2. Launch an **isolated fresh-eyes reviewer subagent** (`.claude/agents/fresh-eyes-reviewer.md` in Claude Code, `invoke_subagent` in Antigravity, `spawn_agent` in Codex) giving it ONLY `proj//brief.md`, `storyboard.md`, the `qa/*.png` frames, and the ffmpeg audio measurement sheet (no source code). Have it write `proj//qa/review.md`. +3. Fix any reported mistakes, re-capture & re-inspect affected frames/audio, update `index.html` and `STATUS.md` if publishing, and present the verified piece + review summary. diff --git a/.agents/skills/new-piece/SKILL.md b/.agents/skills/new-piece/SKILL.md new file mode 100644 index 0000000..b07ffa8 --- /dev/null +++ b/.agents/skills/new-piece/SKILL.md @@ -0,0 +1,10 @@ +--- +name: new-piece +description: Start any new EOMD piece (video, promo, poster, player, screensaver, or a screen loop made for an audience) by interviewing the client and getting a brief approved before any design or build. Use whenever someone asks for a new piece, however short the request. Not for changes to an existing piece. +--- +Follow `brief/INTERVIEW.md` from the top: ask round 1 first (open nothing else before it), then start `proj//brief.md` from `brief/TEMPLATE.md` with `Stage: interview` and `Budget: light | standard | deep` (looking at `proj//` and `brief/clients/` before asking the client to re-type); interview in rounds (the ★ questions every time, mode + budget in round 1), weigh asides before elevating them, get the brief approved, then concepts, then storyboard + stills + sound concept (`brief/CRAFT.md`, with isolated fresh-eyes subagent review before showing the client). `brief/example-academies.md` is the level of detail to aim for. + +Gates (update `Stage:` in the brief's status line at each one; enforced by `.agents/hooks/stage_gate.py`): +- interview → brief (APPROVED) → concepts → storyboard (table, stills, sound concept; fresh-eyes reviewed; APPROVED) → build & QA (`auto-piece`). +- **Efficient mode:** run `/toolbox` right after the brief is approved. +- **Full creative mode:** run `/toolbox` only after the storyboard, stills and sound concept are approved. Until then, read only `brief/`, this skill, the root `STATUS.md` index, the piece's own `proj//` and what the client supplied. diff --git a/.claude/agents/fresh-eyes-reviewer.md b/.claude/agents/fresh-eyes-reviewer.md new file mode 100644 index 0000000..30e51d3 --- /dev/null +++ b/.claude/agents/fresh-eyes-reviewer.md @@ -0,0 +1,15 @@ +--- +name: fresh-eyes-reviewer +description: Isolated EOMD reviewer agent for stills, choice panels, music sheets, and final players (CRAFT.md §11). Sees only the brief and rendered outputs, never source code or pitch text. +model: sonnet +tools: Read, Glob, Grep, Write +--- + +You are an isolated EOMD fresh-eyes reviewer (`brief/CRAFT.md` §11). Look at the work cold: read ONLY `proj//brief.md`, `proj//storyboard.md` (if present), and the rendered images / audio measurement sheets (`stills/*.png`, `qa/*.png`, spectrograms, waveforms, `ebur128` output). Do NOT read player/engine/gen JS source code or pitch prose. + +Check for **mistakes, not taste**: +- **Picture:** clipped/overlapping/off-edge text; copy not word-for-word from the brief or invented facts; type too small for viewing distance or illegible at 25% scale; contrast below WCAG AA; >3 flashes/s; loop seam on a cut. +- **Sound:** loudness or true peak off brief targets (≤ −1.5 dBTP); loop-point click/jump/gap; duration mismatch; key moves missing beats; harsh sustained high tones or big drops on repeating pieces; unintended silences. +- **Galleries:** options that are really the same idea in different colors or spectrograms. + +Never rank options, cut bold concepts, judge taste, or log verdicts. Write your factual findings to `proj//stills/review.md` (for pre-build stills/panels) or `proj//qa/review.md` (for final player QA). diff --git a/.claude/settings.json b/.claude/settings.json index 08c6d23..86c692d 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -1,5 +1,17 @@ { "hooks": { + "PreToolUse": [ + { + "matcher": "Write|Edit|MultiEdit|Bash|Agent|Task", + "hooks": [ + { + "type": "command", + "command": "python3 \"$CLAUDE_PROJECT_DIR/.agents/hooks/stage_gate.py\" --harness claude --event PreToolUse", + "timeout": 10 + } + ] + } + ], "PostToolUse": [ { "matcher": "Read|Grep|Glob|Bash", @@ -10,6 +22,27 @@ "timeout": 10 } ] + }, + { + "matcher": "Agent|Task|Read|Write|Edit|MultiEdit|Bash", + "hooks": [ + { + "type": "command", + "command": "python3 \"$CLAUDE_PROJECT_DIR/.agents/hooks/stage_gate.py\" --harness claude --event PostToolUse || true", + "timeout": 10 + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "python3 \"$CLAUDE_PROJECT_DIR/.agents/hooks/stage_gate.py\" --harness claude --event Stop", + "timeout": 15 + } + ] } ] } diff --git a/.claude/skills/auto-piece/SKILL.md b/.claude/skills/auto-piece/SKILL.md new file mode 100644 index 0000000..84989ac --- /dev/null +++ b/.claude/skills/auto-piece/SKILL.md @@ -0,0 +1,25 @@ +--- +name: auto-piece +description: >- + Run EOMD's build, audio calibration, frame rendering, and isolated fresh-eyes visual/audio QA pipeline once + the brief (efficient mode) or storyboard, stills, and sound concept (full creative mode) are approved. +--- + +# Guided-Brief + Autonomous Build & Fresh-Eyes QA (`auto-piece`) + +## Stage 1 — Always Align With the User First (`Stage: interview -> brief / storyboard`) +1. Unless the user explicitly instructed otherwise, **always interview first** (`brief/INTERVIEW.md`, Round 1+): confirm viewing context, tone, voice, mode (`efficient` vs. `full creative`), and `Budget: light | standard | deep`. +2. In `full creative` mode, draft concepts and `proj//storyboard.md` + stills (`proj//stills/*.png`), run an **isolated fresh-eyes subagent review** (`brief/CRAFT.md` §11) writing `proj//stills/review.md`, fix clear mistakes, and present to the user until `APPROVED`. + +## Budget & model rules +- **Antigravity:** Run the coordinator on **Hydrogen High**; leave subagent model overrides unset unless requested. +- **Claude Code / Codex:** Never use `fable`, `turbo`, or effort above `high` (`max`, `xhigh`, `extra`). On `Budget: light`, route reviewer/helper subagents to `sonnet` (or `haiku` for narrow checks) and ask before spawning `>3` subagents (`Budget-Override: approved`). On `Budget: standard`, Opus (`medium` effort) is fine for coordination with `sonnet` workers. + +## Stage 2 — Build & Audio Verification (`Stage: build`) +1. Open `/toolbox` at the gate, write the **Build plan** in `proj//brief.md`, and share the plain-words plan before building if not yet confirmed. +2. Build the player (`players/.html`) and synthesized audio (48 kHz, true peak ≤ −1.5 dBTP). Verify audio via `ffmpeg` (`ebur128=peak=true:framelog=quiet`, `showspectrumpic`, `showwavespic`, `silencedetect`), `tools/render_piece.py`, or `tools/regress.py`. + +## Stage 3 — Isolated Fresh-Eyes QA (`proj//qa/`) +1. Capture ≥ 2 frame PNGs (`proj//qa/`, plus loop-seam / cut frames if applicable) and inspect them via `Read`/`view_image`. +2. Launch an **isolated fresh-eyes reviewer subagent** (`subagent_type: "fresh-eyes-reviewer"`, `.claude/agents/fresh-eyes-reviewer.md`) giving it ONLY `proj//brief.md`, `storyboard.md`, the `qa/*.png` frames, and the ffmpeg audio measurement sheet (no source code). Have it write `proj//qa/review.md`. +3. Fix any reported mistakes, re-capture & re-inspect affected frames/audio, update `index.html` and `STATUS.md` if publishing, and present the verified piece + review summary. diff --git a/.claude/skills/new-piece/SKILL.md b/.claude/skills/new-piece/SKILL.md index d85001d..b07ffa8 100644 --- a/.claude/skills/new-piece/SKILL.md +++ b/.claude/skills/new-piece/SKILL.md @@ -2,9 +2,9 @@ name: new-piece description: Start any new EOMD piece (video, promo, poster, player, screensaver, or a screen loop made for an audience) by interviewing the client and getting a brief approved before any design or build. Use whenever someone asks for a new piece, however short the request. Not for changes to an existing piece. --- -Follow `brief/INTERVIEW.md` from the top: ask round 1 first (open nothing else before it), then start `proj//brief.md` from `brief/TEMPLATE.md` with `Stage: interview`; interview in rounds (the ★ questions every time, the mode question in round 1), get the brief approved, then concepts, then storyboard. `brief/example-academies.md` is the level of detail to aim for. +Follow `brief/INTERVIEW.md` from the top: ask round 1 first (open nothing else before it), then start `proj//brief.md` from `brief/TEMPLATE.md` with `Stage: interview` and `Budget: light | standard | deep` (looking at `proj//` and `brief/clients/` before asking the client to re-type); interview in rounds (the ★ questions every time, mode + budget in round 1), weigh asides before elevating them, get the brief approved, then concepts, then storyboard + stills + sound concept (`brief/CRAFT.md`, with isolated fresh-eyes subagent review before showing the client). `brief/example-academies.md` is the level of detail to aim for. -Gates (update `Stage:` in the brief's status line at each one): -- interview → brief (approved) → concepts → storyboard (table, stills, sound concept; approved) → build. +Gates (update `Stage:` in the brief's status line at each one; enforced by `.agents/hooks/stage_gate.py`): +- interview → brief (APPROVED) → concepts → storyboard (table, stills, sound concept; fresh-eyes reviewed; APPROVED) → build & QA (`auto-piece`). - **Efficient mode:** run `/toolbox` right after the brief is approved. - **Full creative mode:** run `/toolbox` only after the storyboard, stills and sound concept are approved. Until then, read only `brief/`, this skill, the root `STATUS.md` index, the piece's own `proj//` and what the client supplied. diff --git a/.codex/config.toml b/.codex/config.toml new file mode 100644 index 0000000..a78e878 --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1,7 @@ +[features] +hooks = true + +# EOMD subagent efficiency defaults (never use fable or reasoning above high) +[agents.fresh_eyes_reviewer] +description = "Isolated EOMD fresh-eyes reviewer for stills, galleries, audio sheets, and final players (CRAFT.md §11)" +model_reasoning_effort = "medium" diff --git a/.codex/hooks.json b/.codex/hooks.json new file mode 100644 index 0000000..db7a88e --- /dev/null +++ b/.codex/hooks.json @@ -0,0 +1,39 @@ +{ + "hooks": { + "PreToolUse": [ + { + "matcher": "Bash|apply_patch|write_file|edit_file|.*", + "hooks": [ + { + "type": "command", + "command": "python3 .agents/hooks/stage_gate.py --harness codex --event PreToolUse", + "timeout": 10 + } + ] + } + ], + "PostToolUse": [ + { + "matcher": "Bash|read_file|view_image|apply_patch|write_file|edit_file|spawn_agent|.*", + "hooks": [ + { + "type": "command", + "command": "python3 .agents/hooks/stage_gate.py --harness codex --event PostToolUse || true", + "timeout": 10 + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "python3 .agents/hooks/stage_gate.py --harness codex --event Stop", + "timeout": 15 + } + ] + } + ] + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3feacc7..648b32a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,3 +63,13 @@ jobs: python-version: '3.12' - name: tools/check_stage_reads.py (never fails; reports peeks as warnings) run: python tools/check_stage_reads.py || true + + hooks-and-skills: + name: hook gates, manifests, and skill checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: python3 .agents/hooks/test_stage_gate.py -v diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..d6812b9 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,21 @@ +# EOMD: notes for AI agents (Antigravity, Codex, and others) + +Read `CLAUDE.md` and `STATUS.md` first: all ground rules apply to every agent (`never invent facts`, +`copy is word for word`, single offline HTML player, time-based motion, synthesized 48 kHz audio ≤ −1.5 dBTP, +restricted-path stage order). + +- **Standard hybrid flow (`new-piece` + `auto-piece`):** + 1. **Interview first** (`brief/INTERVIEW.md`, looking at `proj//` and `brief/clients/` after Round 1): confirm + purpose, audience, viewing context ("How it's watched"), voice, mode (`efficient` vs. `full creative`), and + `Budget: light | standard | deep`. + 2. **Concepts, storyboard & stills** (`Stage: concepts -> storyboard`): `brief/CRAFT.md` + `brief/STORYBOARD.md`, + with isolated **fresh-eyes subagent review** (`brief/CRAFT.md` §11) before showing stills or choice panels to the + user. + 3. **Autonomous build & QA (`auto-piece`):** after brief (efficient) or storyboard/stills/sound concept (full + creative) is `APPROVED`, open `/toolbox`, build `players/.html`, run ffmpeg `ebur128` / spectrogram checks, + render QA frames into `proj//qa/`, pass isolated **fresh-eyes subagent review** (`proj//qa/review.md`), + and finish QA before presenting. +- **Programmatic gates:** `.agents/hooks/stage_gate.py` (wired in `.agents/hooks.json`, `.claude/settings.json`, and + `.codex/hooks.json`) enforces stage order, budget limits, inspected stills/QA PNGs, and fresh-eyes review receipts. +- **Fast ops & bookkeeping:** For file moves, non-visual tweaks, or pure Q&A (unless asked), skip `STATUS.md` updates + and Playwright/MP4 renders. diff --git a/CLAUDE.md b/CLAUDE.md index cd745cb..584ef36 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,8 @@ EOMD (Efficient Offline Motion Designer) makes motion-design pieces for clients: with synthesized music. The repo is maintained by Bryan Murphy; a client can be anyone, and is usually not technical. Read the root `STATUS.md` index at the start of every session; read a piece's own `STATUS.md` (in its folder) when -working on that piece. Update both at the end of a working session. +working on that piece. Update them after substantive design, copy, audio, or build changes; skip for file moves, +trivial fixes, or pure Q&A. ## Rules for every piece - **Never invent facts:** names, dates, programs, places, numbers. If it isn't in a brief, copy file or config, ask. @@ -26,10 +27,12 @@ working on that piece. Update both at the end of a working session. ## New pieces: interview first Before any NEW piece (a new video, poster or player; not a change to an existing one), run `/new-piece`: interview -the client, then write `proj//brief.md` and get it approved. A one-line request is the start of the interview, -not the brief. Details: `brief/INTERVIEW.md`. -- **Gates:** interview → brief approved → concepts → storyboard, stills and sound concept → build. The brief's status - line carries `Stage:`, so any session knows where it is. +the client, then write `proj//brief.md` (`Budget: light | standard | deep`) and get it approved. A one-line +request is the start of the interview, not the brief. Details: `brief/INTERVIEW.md`. +- **Gates:** interview → brief approved → concepts → storyboard, stills and sound concept (with isolated fresh-eyes + subagent review, `brief/CRAFT.md` §11) → build & QA. Once approved, `auto-piece` (`.claude/skills/auto-piece/SKILL.md`) + runs the autonomous build and fresh-eyes visual/audio QA; `.agents/hooks/stage_gate.py` enforces gates across + Antigravity, Claude Code, and Codex. The brief's status line carries `Stage:`. - **Design comes before tools.** During design, stay out of the picture, sound and tool folders (`gen/`, `living/`, `engine/`, `academies-film/`, `players/`, `dist/`, `media/`, `audio/`, `score/`, `jukebox/`, `tools/`), other pieces' `proj/` folders and their `STATUS.md` files (the full list: `notes/context-plan.md`, "The restricted diff --git a/README.md b/README.md index 3bff71b..7b2ebf6 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,25 @@ nothing here is classroom-only. Make whatever you want. Animate your tax returns ## How it's meant to be used -**Clone the whole repo to your drive and let your AI coding assistant go nuts.** Claude Code, Qwen via AnythingLLM, -Cursor, Aider, whatever you use: point it at this folder and describe what you want. +**Clone the whole repo to your drive and work with an AI coding assistant.** Antigravity, Claude Code, Codex, Cursor, +or any other assistant: point it at this folder and describe what you want. ```bash git clone https://github.com/BPMData/EOMD.git ``` -The repo is set up for that: -- **`CLAUDE.md`** is the map: the house rules and where to go; each folder has its own `CLAUDE.md` with its files and how to build. Claude Code reads them - automatically; with any other assistant, tell it "read CLAUDE.md and STATUS.md first" (STATUS.md is an index; each piece has its own STATUS.md in its folder). +The repo is set up for a staged design-first workflow: +- **`CLAUDE.md` and `AGENTS.md`** hold the house rules and routing; each folder has its own `CLAUDE.md` with its files + and how to build. Ask your assistant to "read `CLAUDE.md` and `STATUS.md` first" if it doesn't load them automatically. +- **New pieces start with `/new-piece` (`brief/INTERVIEW.md`):** short plain-English rounds that check existing + `proj//` and `brief/clients/` files first, ask for your writing voice early, keep jokes/asides as side notes + until you make them main, skip production deadlines, and set `Mode` (`efficient` vs. `full creative`) plus `Budget` + (`light | standard | deep`). +- **Fresh-eyes review & autonomous QA (`/auto-piece`):** in full creative mode, storyboard stills and choice panels go + through an **isolated fresh-eyes reviewer subagent** (`brief/CRAFT.md` §11) before you see them; once approved, + `/toolbox` opens and `/auto-piece` builds `players/.html`, checks 48 kHz audio (`ebur128` / spectrograms), and + runs a final fresh-eyes visual/audio review (`proj//qa/review.md`). Programmatic hooks + (`.agents/hooks/stage_gate.py`) enforce stage gates and receipts across Antigravity, Claude Code, and Codex. - **`STATUS.md`** is the working state: what's finished, what's untested, what's next. - **Pieces are small JSON "cartridges"** (see below), so asking an AI for a new piece costs a short JSON file instead of a new 600-line program, and the math (noise, 3D, physics, the music arranger) never has to be rewritten. @@ -151,7 +160,8 @@ the project: the reusable parts are already here, so a new piece is mostly a sho | `score/` | Music cartridges (`*.json`) and `FORMAT.md`, which explains every field | | `audio/` | The music engine: instruments, the arranger and one file per arranger style | | `tools/` | The Python scripts you run (builds, MP4 export, music tools) | -| `brief/` | How a new piece starts: the client interview, the brief template, and the brief behind the Academies film as the example | +| `brief/` | How a new piece starts: the client interview, brief and storyboard templates, craft guide, house taste, client profiles, and the Academies brief as the example | +| `.agents/`, `.claude/`, `.codex/` | Skills (`new-piece`, `auto-piece`, `toolbox`), `fresh-eyes-reviewer` subagent, and cross-harness stage-gate hooks | | `proj//` | One piece's brief, copy and sources (`cdrom`, `pltw`, `cs`, `ex`, `ssr`, `academies`) | | `living/`, `jukebox/` | The living-poster engine and the jukebox page | | `engine/` | The starter timeline engine the Academies film grew from; `engine/src/audio/dsp.js` is the DSP everything uses | diff --git a/brief/INTERVIEW.md b/brief/INTERVIEW.md index 509cab5..0a7de09 100644 --- a/brief/INTERVIEW.md +++ b/brief/INTERVIEW.md @@ -33,6 +33,12 @@ It works in any chat, not only in this repo: paste this file and `TEMPLATE.md` i - **Hunt the landmines:** words the piece must never say, promises it must never make, things it must never rank. (Academies: never "choose" or "pick" an academy, never promise placement, no academy above another.) - **Facts come from the client, with a source.** Never fill a gap yourself; keep a running list of what's missing. +- **Ask for the client's voice early.** One sentence they'd write about the subject, or a page of theirs they like, + is enough. Draft every line of copy in that voice, not in clipped "X. Y. Z." AI cadence (`taste/house.md` T35). +- **Weigh asides before you build on them.** Clients think out loud: jokes, "maybe we should mention X". An aside is + a **side note** until the client says otherwise. It never becomes a beat by itself or a main message; log it as + **side**, and in the next reflect-back ask what weight it gets: "You mentioned X. Main point, a quick side note, or + just a joke?" Only an answer of "main point" makes it a main point (`taste/house.md` T38). - **Reflect back** in one sentence per round ("So: a 30-s loop for the cafeteria TV, sound off, for 9th graders who've never heard of PLTW."). Misreadings surface while they're cheap. - **Delegation must be explicit.** "You decide" is a fine answer for concept, design and music ("Concept, script, @@ -48,19 +54,19 @@ It works in any chat, not only in this repo: paste this file and `TEMPLATE.md` i **1. The ask** - ★ First, check it belongs here: motion pieces, players, posters and screen loops do. An infographic (a page that explains something with numbers) belongs in ProofEr (`BPMData/ProofEr`); say so and stop. -- ★ What is it, where will it be seen, and by when? *"A 90-second video for the robotics club's open-house night, - shown once on a projector, by Nov 15."* -- ★ How to build it, in Claude-usage terms (numbers from "Usage estimates" below; say they are rough): - "There are two good ways to make your video: - 1. **Ready-made styles (quicker).** Built mostly from designs this kit already has. It uses a small part of your - Claude usage: roughly 5–20% of one 5-hour limit. - 2. **From scratch (most original).** Designed only for your video. It uses a lot: roughly half to all of one 5-hour - limit. It's best to start it just before your limit resets, or before you step away for a few hours (overnight, - or before work), and check back later. - Either way there's no surprise bill: if you hit your limit, Claude stops (unless you've switched on paid extra - usage), and you pick up where you left off after it resets. Which would you like?" - (Ready-made styles = efficient mode; from scratch = full creative mode. The numbers assume a Pro plan and the - recommended setting, Opus 5.5 at medium effort; a bigger plan uses a smaller share.) +- ★ What is it, who is it for, and where will it be seen? *"A 90-second video for the robotics club's open-house night, + shown once on a projector."* Don't ask for a production deadline or set one (`taste/house.md` T39; if an event date + belongs on screen, put it in §5 facts). +- ★ Usage budget (`Budget: light | standard | deep`): ask in everyday words how much session usage they want to spend: + *Light* (keep under ~25% of a 5-hour Pro limit—fewer workers/reviews), *Standard* (balanced—Opus medium / Hydrogen + High coordination, lighter helper workers), or *Deep* (go all-out on custom concepts, iterations, and QA). +- ★ How to build it, in plain words: + 1. **Ready-made styles (quicker / efficient mode).** Built mostly from designs this kit already has. Uses much less + of your session usage. + 2. **From scratch (most original / full creative mode).** Designed only for your piece. Uses more usage—best started + with headroom or when you can step away and check back. + Either way there's no surprise bill: if you hit your limit, the tool stops and you pick up where you left off. Which + would you like? **2. Purpose and tone** - ★ After watching, what should a viewer know, feel and do? One line each. @@ -77,8 +83,9 @@ It works in any chat, not only in this repo: paste this file and `TEMPLATE.md` i - What plays it (a laptop, a TV, a phone, a projector, a video upload), and who presses start? **4. How the subject works** -- What's the system or story behind it that the piece must get right? *(Academies: every 9th grader starts in - Exploration, ranks pathways, and placement is by lottery.)* +- What's the system or story behind it that the piece must get right? What do viewers usually get wrong, and does a + walk-up viewer need a 3-second primer before the payoff? *(Academies: every 9th grader starts in Exploration, ranks + pathways, and placement is by lottery.)* - ★ What must it never say or imply? **5. Content and facts** @@ -139,9 +146,10 @@ model knows where the piece is and what it may open. Update it at each gate and stage commit. 0. **Ask round 1 first;** open nothing else before it. Once round 1 is answered, copy `TEMPLATE.md` to - `proj//brief.md` with `Stage: interview` and the mode, and fill it in as answers come. Once you know who the - client is, read their file in `clients/` if there is one. -1. **Reflect back** the whole piece in one paragraph, plus the open questions. + `proj//brief.md` with `Stage: interview`, the mode, and the `Budget:` tier, and fill it in as answers come. + Once you know who the client is, read their file in `clients/` if there is one. +1. **Reflect back** the whole piece in one paragraph, plus the open questions. Name the side notes separately + ("Side notes, a line each unless you say otherwise: ..."), so the client sees how much room each one gets. 2. **Draft the brief** (`Stage: brief`), in the client's words where possible, with the reasons kept. Mark gaps **ASK** and Claude's drafts (translations, suggested copy) **DRAFT**. In §13 list the house taste items that apply (`taste/house.md`). Commit. diff --git a/brief/TEMPLATE.md b/brief/TEMPLATE.md index 995b7e5..2cd2e92 100644 --- a/brief/TEMPLATE.md +++ b/brief/TEMPLATE.md @@ -1,6 +1,6 @@ # Brief: -Status: DRAFT | APPROVED by · Stage: interview | brief | concepts | storyboard | build · Mode: efficient | full creative · Client: · Sign-off: +Status: DRAFT | APPROVED by · Stage: interview | brief | concepts | storyboard | build · Mode: efficient | full creative · Budget: light | standard | deep · Client: · Sign-off: Usage: · _Copy to `proj//brief.md` once round 1 of the interview is answered (`brief/INTERVIEW.md`) and update `Stage:` at each gate. Write it in the client's words where @@ -8,7 +8,8 @@ possible and keep the reasons. **ASK** = missing, **DRAFT** = Claude's draft (tr **Claude's call** = delegated by the client. `brief/example-academies.md` shows the level of detail to aim for._ ## 1. The ask -_What it is, where it plays, how long it runs, by when._ +_What it is, who it's for, where it plays, how long it runs. No production deadline (`taste/house.md` T39; real event +dates belong in §5)._ ## 2. Purpose and tone _What viewers should know, feel and do afterwards; what they believe now vs after; the tone in three words; what it @@ -23,11 +24,13 @@ it, what plays it._ _The system or story the piece must get right, and the words or promises to avoid._ ## 5. Content and facts -_Every fact that appears on screen, with its source. Fixed copy: the path of the copy file, used word for word._ +_Every fact that appears on screen, with its source. Fixed copy: the path of the copy file, used word for word. +Weight: **main** (the piece is built on it) or **side** (a cameo or passing line). Anything said in passing stays +**side** until the client calls it main (`taste/house.md` T38)._ -| Fact | Source | -|---|---| -| | | +| Fact | Weight | Source | +|---|---|---| +| | | | ## 6. Structure and hierarchy _Beats; hero vs supporting text in each; whether every beat must stand alone; how often the name or message must be diff --git a/brief/clients/bryan.md b/brief/clients/bryan.md index 9240d7f..0facc73 100644 --- a/brief/clients/bryan.md +++ b/brief/clients/bryan.md @@ -21,6 +21,11 @@ Use these as the starting answer for "How it's watched"; confirm them per piece. - Classroom loops: the same students hear them every day, so nothing harsh on repeat. -## His taste -The house taste profile (`brief/taste/house.md`) is distilled from his verdicts; it is the default for everyone, so -there is no separate Bryan profile. His own words for each verdict stay in that piece's brief or `STATUS.md`. +## His voice and taste +- **His voice:** long, clause-heavy sentences, colons and semicolons, dry jokes; he rewrites clipped AI cadence on + sight (`T35`). +- **Taste he's named:** loves illustrated reference books (DK-style) and period-true pixel/arcade craft; hates generic + default AI web gloss, rounded cards everywhere, and anything that reads like homework. +- **Testing:** Chromium on Mac (no iPhone), and doesn't use reduced motion; test in Chromium and say so. +- The house taste profile (`brief/taste/house.md`) is distilled from his verdicts and is the default for everyone. His + own words for each verdict stay in that piece's brief or `STATUS.md`. diff --git a/brief/taste/house.md b/brief/taste/house.md index 4ef7be7..2392421 100644 --- a/brief/taste/house.md +++ b/brief/taste/house.md @@ -54,3 +54,5 @@ T34 · soft · color · Punchy, saturated fields (primary and secondary colors) T35 · strong · copy · Write copy in the client's voice, not the AI's: no stacked clipped sentences ("Thinner cuts easier. Thinner breaks easier."), no rule-of-three punchlines; for Bryan, long clause-heavy sentences with colons and semicolons. — Knife Country storyboard (Nov 2; the piece now lives in ProofEr): clipped lines "read claude-coded as fuck"; "I'm a wordy pretentious fuck who loves colons and semi-colons and run-on sentences" T36 · strong · structure · when scrolling · Explain every name-drop (a law, an event, an institution): long reads have no word penalty, so put the detail behind a drill-down rather than leave it out. — Knife Country round 2 (Nov 3; now in ProofEr): "There's no 'penalty' for more words in an infographic, especially if they're held behind drill-down menus" T37 · strong · type · A section's title (the question) must be as noticeable as its answer; a small kicker over a giant headline reads as an answer to nothing. — Knife Country round 2 (Nov 3; now in ProofEr): "the titles of the 'slides' should be a lot more noticeable" +T38 · strong · process · An offhand remark gets an offhand place: asides stay side notes (a line or a cameo) until the client calls them main. — ProofEr, Pomewawa (Oct 26, T13): "the thing was just like a joke by me" +T39 · strong · process · No production deadlines: don't ask for one, set one or plan around one; real event dates belong in §5 facts, not as build deadlines. — ProofEr, Sicilian folk magic (Nov 22, T22): deadlines only invite putting the work off