π₯ Make videos programmatically with React
Skills: Redesign Vercel deployment monitor (#10253)
Jonny Burger248ec2380b03
diff --git a/.agents/skills/vercel/SKILL.md b/.agents/skills/vercel/SKILL.mdindex 4210c4f5a9..b89f85750d 100644--- a/.agents/skills/vercel/SKILL.md+++ b/.agents/skills/vercel/SKILL.md@@ -5,100 +5,115 @@ description: Set up a Codex monitor for Vercel deployments and preview URLs. Use# Vercel Monitor-## Overview+Monitor one immutable Vercel deployment for the `remotion` project and notify the+current task when that exact deployment becomes ready or fails.-Set up a short-lived Codex heartbeat that watches the `remotion` Vercel deployment and reports back in the current thread when it is ready or failed. Always include both the Vercel deployment/dashboard URL and the public preview URL in the final notification.+## Non-negotiable rules-## Project Selection+- Never infer deployment state from an HTTP response. A branch preview alias can+ return 200 from the previous deployment while the new deployment is building.+- Never monitor a branch preview alias. It is movable and can resolve to an older+ or newer deployment.+- Pin the monitor to a Vercel deployment ID (`dpl_...`) or the immutable automatic+ deployment hostname (`<project>-<random>-<scope>.vercel.app`).+- Read the machine-readable Vercel deployment state. Do not parse human CLI output.+- Default to the `remotion` project and the `remotion` Vercel scope. Ignore the+ `bugs` project unless the user explicitly asks for it.-This repository has two Vercel deployments: `bugs` and `remotion`. The Vercel monitor skill always means the `remotion` deployment unless the user explicitly asks for another project.+## Resolve the exact deployment-- Select checks, deployment URLs, preview URLs, and CLI results for the `remotion` project.-- Ignore the `bugs` deployment, even if it appears first or is newer.-- When output contains links for both projects, use surrounding check names, project names, or deployment metadata to associate the links with `remotion`. If necessary, inspect the candidates before creating a monitor.-- Do not ask the user which project they mean merely because both deployments exist; default to `remotion`.+Prefer these sources, in order:-## Workflow+1. A Vercel deployment/dashboard URL supplied by the user.+2. The `Vercel β remotion` check on the active GitHub PR. Its dashboard URL has+ the form `https://vercel.com/remotion/remotion/<deployment-id-suffix>`.+3. The `remotion` row in the Vercel bot's PR comment.+4. `vercel list remotion --scope remotion --format=json`, matched to the exact PR,+ commit SHA, or branch in `.deployments[].meta`.-1. Resolve the deployment to monitor.-2. Check whether it is already ready.-3. Create a heartbeat monitor if it is still building or queued.-4. Tell the user what is being monitored and which links will be reported.+The final path segment of a dashboard URL becomes the deployment ID by prefixing+it with `dpl_`. For example:-## Resolve Links--Prefer sources in this order:+```text+https://vercel.com/remotion/remotion/AbCd1234 -> dpl_AbCd1234+```-1. A Vercel deployment URL or preview URL explicitly provided by the user.-2. URLs in the current terminal output or pasted logs.-3. Vercel URLs from the active GitHub PR's `remotion` check or deployment status. Ignore the `bugs` check.-4. Vercel CLI output for the `remotion` project, if the repository is linked and the user asked for the latest deployment.+The `Preview` link in a Vercel PR comment is normally a branch alias. Preserve it+for the final notification, but do not use it for state checks.-Use `scripts/extract-vercel-links.py` to normalize raw terminal, Vercel CLI, or GitHub output:+When using `vercel list`, select the newest deployment that matches all available+identity fields:-```bash-python3 .agents/skills/vercel/scripts/extract-vercel-links.py < deployment-output.txt-```+- `.name == "remotion"`+- `.meta.githubPrId == <PR number>`, when a PR is known+- `.meta.githubCommitSha == <full commit SHA>`, when a commit is known-If only one link is available, use `vercel inspect <url>` when authenticated to confirm that it belongs to the `remotion` project and discover the missing deployment or preview URL. If neither a deployment URL nor a preview URL can be found, ask the user for one concise piece of context: the Vercel URL, PR URL/number, or branch name.+Do not silently fall back to a different commit. If no exact deployment can be+identified, ask for the Vercel dashboard URL, PR number, or commit SHA.-## Check Status+## Read state-Prefer Vercel's deployment status over HTTP probing:+Run the bundled checker from the repository root:```bash-vercel inspect <deployment-or-preview-url>+python3 .agents/skills/vercel/scripts/check-deployment.py <deployment-id-or-url>```-Treat these as terminal states:--- `READY`: report success immediately; do not create a monitor.-- `ERROR`, `FAILED`, `CANCELED`, or `CANCELLED`: report failure immediately; do not create a monitor.+The checker calls:-Treat these as monitorable states:--- `BUILDING`, `QUEUED`, `INITIALIZING`, or unknown but plausibly in progress.+```bash+vercel inspect <deployment-id-or-immutable-url> \+ --scope remotion \+ --format=json+```-If Vercel CLI is unavailable or unauthenticated, probe the preview URL with `curl -I -L --max-time 20 <preview-url>`. HTTP 2xx or 3xx means the preview is ready. HTTP 401 or 403 can also mean the deployment is ready but protected; report it as ready/protected if the response is clearly from Vercel deployment protection. A Vercel `DEPLOYMENT_NOT_FOUND`, 404, timeout, or DNS failure means keep monitoring unless a terminal Vercel status says otherwise.+It validates the project, rejects moving aliases, and emits normalized JSON.+Use its `state` field:-## Create The Monitor+- `READY`: success.+- `ERROR`, `CANCELED`, or `CANCELLED`: failure.+- `BUILDING`, `QUEUED`, or `INITIALIZING`: still in progress.+- `UNKNOWN`: not terminal. Report the diagnostic only if it persists or prevents+ creation of a trustworthy monitor.-Use the Codex app automation tool. If `automation_update` is not already in the tool list, search for it with `tool_search` before creating the monitor.+HTTP probing may be used after `READY` as an optional reachability check. It must+never promote a non-ready or unknown deployment to `READY`.-Create a `heartbeat`, not a cron, because the user wants this thread to be notified later. Use a one-minute cadence with a bounded count, usually 30 attempts unless the user asked for a different window. Do not show the raw RRULE string to the user.+## Create the monitor-The heartbeat prompt must be self-contained. Include:+Use the Codex automation tool to create a one-minute heartbeat with a bounded+count, normally 30 attempts. The heartbeat prompt must be self-contained and+include:-- Deployment/dashboard URL, if known.-- Preview URL, if known.-- Branch, PR, project, or commit context, if known.-- Status command to prefer, normally `vercel inspect <url>`.-- HTTP fallback command for the preview URL.-- Ready criteria and failure criteria.-- Instruction to reply in the current thread only when ready or failed.-- Instruction to include both links in the notification.-- Instruction to delete or pause this heartbeat after reporting a terminal state, if the automation id is available.+- The pinned deployment ID or immutable deployment hostname.+- The dashboard URL.+- The branch preview alias, if known, for the final notification only.+- The project, PR, branch, and commit context, if known.+- The exact checker command.+- The terminal-state rules above.-Example heartbeat prompt:+Use this prompt shape:```text-Check this Vercel deployment until it reaches a terminal state.--Deployment URL: <deployment-url-or-unknown>-Preview URL: <preview-url-or-unknown>-Context: <branch/pr/project/commit-or-unknown>--Prefer `vercel inspect <deployment-or-preview-url>` if available and authenticated. If that is unavailable, use `curl -I -L --max-time 20 <preview-url>` and, if needed, fetch the response body to distinguish Vercel deployment protection from DEPLOYMENT_NOT_FOUND.+Monitor this exact Vercel deployment until it reaches a terminal state.-Ready means Vercel status READY, or the preview URL returns HTTP 2xx/3xx, or it returns Vercel deployment-protection HTTP 401/403. Failure means Vercel status ERROR, FAILED, CANCELED, or CANCELLED.+Pinned deployment: <dpl_id_or_immutable_hostname>+Dashboard: <dashboard_url>+Preview alias (reporting only; never use for state): <preview_url_or_unknown>+Context: <project/pr/branch/commit>-If ready, reply in the thread: "Vercel deployment is ready" and include:-- Deployment: <deployment-url>-- Preview: <preview-url>+From the repository root, run:+python3 .agents/skills/vercel/scripts/check-deployment.py <pinned_deployment>-If failed, reply in the thread with the failure status and include the same two links.+Only the JSON `state` is authoritative.+- READY: reply "Vercel deployment is ready" and include Dashboard and Preview.+- ERROR, CANCELED, or CANCELLED: reply with the failure state and include both links.+- BUILDING, QUEUED, INITIALIZING, or UNKNOWN: stay quiet and check again next time.-If still building, queued, initializing, not found, or unknown, stay quiet and let the next heartbeat check again. After reporting ready or failed, delete or pause this heartbeat if the automation id is available.+Never curl the preview URL to determine readiness. After reporting a terminal+state, delete or pause this heartbeat if its automation ID is available.```-After creating the heartbeat, tell the user briefly which deployment/preview is being watched and the check cadence. If the deployment is already ready or failed, do not create a monitor; report the terminal status and links immediately.+Before creating a heartbeat, run the checker once. If the deployment is already+terminal, report immediately instead. Otherwise, tell the user which exact+deployment is being watched and the cadence.diff --git a/.agents/skills/vercel/scripts/check-deployment.py b/.agents/skills/vercel/scripts/check-deployment.pynew file mode 100755index 0000000000..1990810d0d--- /dev/null+++ b/.agents/skills/vercel/scripts/check-deployment.py@@ -0,0 +1,173 @@+#!/usr/bin/env python3+"""Return the authoritative state of one immutable Vercel deployment."""++from __future__ import annotations++import argparse+import json+import subprocess+import sys+from urllib.parse import urlparse+++IN_PROGRESS_STATES = {"BUILDING", "QUEUED", "INITIALIZING"}+FAILURE_STATES = {"ERROR", "CANCELED", "CANCELLED"}+++def emit(payload: dict[str, object], exit_code: int = 0) -> int:+ print(json.dumps(payload, indent=2, sort_keys=True))+ return exit_code+++def normalize_reference(reference: str, scope: str, project: str) -> tuple[str, str | None]:+ parsed = urlparse(reference if "://" in reference else f"https://{reference}")+ if parsed.hostname == "vercel.com" or parsed.hostname == "www.vercel.com":+ parts = [part for part in parsed.path.split("/") if part]+ if len(parts) != 3:+ raise ValueError(+ "Expected a Vercel deployment dashboard URL with /<scope>/<project>/<deployment>."+ )+ url_scope, url_project, suffix = parts+ if url_scope != scope or url_project != project:+ raise ValueError(+ f"Dashboard URL is for {url_scope}/{url_project}, expected {scope}/{project}."+ )+ deployment_id = suffix if suffix.startswith("dpl_") else f"dpl_{suffix}"+ return deployment_id, reference++ if reference.startswith("dpl_"):+ return reference, None++ if parsed.hostname and parsed.hostname.endswith(".vercel.app"):+ return parsed.hostname, None++ raise ValueError("Expected a dpl_ deployment ID, dashboard URL, or vercel.app URL.")+++def main() -> int:+ parser = argparse.ArgumentParser(+ description="Read Vercel readyState for one pinned deployment.",+ )+ parser.add_argument("deployment", help="Deployment ID, dashboard URL, or immutable URL")+ parser.add_argument("--scope", default="remotion", help="Vercel team scope")+ parser.add_argument("--project", default="remotion", help="Expected Vercel project")+ args = parser.parse_args()++ try:+ reference, supplied_dashboard_url = normalize_reference(+ args.deployment,+ args.scope,+ args.project,+ )+ except ValueError as error:+ return emit({"state": "UNKNOWN", "error": str(error)}, 2)++ result = subprocess.run(+ [+ "vercel",+ "inspect",+ reference,+ "--scope",+ args.scope,+ "--format=json",+ ],+ capture_output=True,+ text=True,+ check=False,+ )+ if result.returncode != 0:+ return emit(+ {+ "state": "UNKNOWN",+ "error": "vercel inspect failed",+ "diagnostic": result.stderr.strip() or result.stdout.strip(),+ },+ 2,+ )++ try:+ deployment = json.loads(result.stdout)+ except json.JSONDecodeError as error:+ return emit(+ {+ "state": "UNKNOWN",+ "error": f"vercel inspect returned invalid JSON: {error}",+ },+ 2,+ )++ name = deployment.get("name")+ context_name = deployment.get("contextName")+ if name != args.project or (context_name is not None and context_name != args.scope):+ return emit(+ {+ "state": "UNKNOWN",+ "error": "Deployment belongs to a different Vercel project or scope.",+ "actual_project": name,+ "actual_scope": context_name,+ },+ 2,+ )++ canonical_hostname = deployment.get("url")+ parsed_input = urlparse(+ args.deployment if "://" in args.deployment else f"https://{args.deployment}"+ )+ if (+ parsed_input.hostname+ and parsed_input.hostname.endswith(".vercel.app")+ and parsed_input.hostname != canonical_hostname+ ):+ return emit(+ {+ "state": "UNKNOWN",+ "error": "Refusing to monitor a moving Vercel alias.",+ "alias": parsed_input.hostname,+ "currently_resolves_to": canonical_hostname,+ "deployment_id": deployment.get("id"),+ },+ 2,+ )++ state = str(deployment.get("readyState") or "UNKNOWN").upper()+ if state == "READY":+ terminal = True+ outcome = "success"+ elif state in FAILURE_STATES:+ terminal = True+ outcome = "failure"+ elif state in IN_PROGRESS_STATES:+ terminal = False+ outcome = "in_progress"+ else:+ terminal = False+ outcome = "unknown"++ deployment_id = deployment.get("id")+ dashboard_url = supplied_dashboard_url+ if dashboard_url is None and isinstance(deployment_id, str):+ dashboard_url = (+ f"https://vercel.com/{args.scope}/{args.project}/"+ f"{deployment_id.removeprefix('dpl_')}"+ )++ return emit(+ {+ "state": state,+ "terminal": terminal,+ "outcome": outcome,+ "deployment_id": deployment_id,+ "deployment_url": (+ f"https://{canonical_hostname}" if canonical_hostname else None+ ),+ "dashboard_url": dashboard_url,+ "preview_aliases": [f"https://{alias}" for alias in deployment.get("aliases", [])],+ "project": name,+ "scope": context_name,+ "created_at": deployment.get("createdAt"),+ }+ )+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/.agents/skills/vercel/scripts/extract-vercel-links.py b/.agents/skills/vercel/scripts/extract-vercel-links.pydeleted file mode 100755index 01471a1745..0000000000--- a/.agents/skills/vercel/scripts/extract-vercel-links.py+++ /dev/null@@ -1,86 +0,0 @@-#!/usr/bin/env python3-"""Extract Vercel-related URLs and statuses from command output."""--from __future__ import annotations--import argparse-import json-import re-import sys-from pathlib import Path-from urllib.parse import urlparse---URL_RE = re.compile(r"https?://[^\s<>'\")\]}]+")-STATUS_RE = re.compile(- r"\b(READY|BUILDING|QUEUED|INITIALIZING|ERROR|FAILED|CANCELED|CANCELLED)\b",- re.IGNORECASE,-)-TRAILING_PUNCTUATION = ".,;:"---def unique(values: list[str]) -> list[str]:- seen: set[str] = set()- result: list[str] = []- for value in values:- if value not in seen:- seen.add(value)- result.append(value)- return result---def clean_url(url: str) -> str:- return url.rstrip(TRAILING_PUNCTUATION)---def host_for(url: str) -> str:- return urlparse(url).hostname or ""---def is_preview_url(url: str) -> bool:- host = host_for(url)- return host == "vercel.app" or host.endswith(".vercel.app")---def is_dashboard_url(url: str) -> bool:- host = host_for(url)- return host == "vercel.com" or host.endswith(".vercel.com")---def read_text(paths: list[str]) -> str:- if not paths:- return sys.stdin.read()-- chunks: list[str] = []- for path in paths:- chunks.append(Path(path).read_text())- return "\n".join(chunks)---def main() -> int:- parser = argparse.ArgumentParser(- description="Extract Vercel dashboard links, preview links, and statuses.",- )- parser.add_argument("paths", nargs="*", help="Files to parse. Reads stdin if omitted.")- args = parser.parse_args()-- text = read_text(args.paths)- urls = unique([clean_url(match.group(0)) for match in URL_RE.finditer(text)])- statuses = [match.group(1).upper() for match in STATUS_RE.finditer(text)]-- payload = {- "status": statuses[-1] if statuses else None,- "statuses": unique(statuses),- "deployment_urls": [url for url in urls if is_dashboard_url(url)],- "preview_urls": [url for url in urls if is_preview_url(url)],- "other_urls": [- url for url in urls if not is_dashboard_url(url) and not is_preview_url(url)- ],- "urls": urls,- }- print(json.dumps(payload, indent=2, sort_keys=True))- return 0---if __name__ == "__main__":- raise SystemExit(main())