Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8725 feat(tooling): upload PR evidence as native GitHub attachments (#10156)

Multica Eve2dd88c2ace02
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 03be57a87c..79c1c8eff1 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -16,7 +16,7 @@
## Screenshots
-<!-- Required for UI or interaction changes: attach screenshots or a screen recording from the running app showing the affected screens and states. Without either, these PRs are rejected by default. Before/after comparisons are strongly preferred; for a new screen, include the after screenshot. If there is no UI or interaction impact, write "N/A" and explain why. -->
+<!-- Required for UI or interaction changes: attach screenshots or a screen recording from the running app showing the affected screens and states. Without either, these PRs are rejected by default. Before/after comparisons are strongly preferred; for a new screen, include the after screenshot. Upload with scripts/pr-shots (see CONTRIBUTING.md#screenshots-and-recordings) or GitHub's web editor. If there is no UI or interaction impact, write "N/A" and explain why. -->
<!-- Link the issue this PR resolves so it closes on merge. -->
Closes #
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4682b67119..ff23f9c1f5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -40,8 +40,8 @@ jobs:
with:
node-version: 22
- - name: Test CI selection and gates
- run: node --test scripts/ci-scope.test.mjs scripts/check-image-budget.test.mjs
+ - name: Test CI selection and repository tooling
+ run: node --test scripts/ci-scope.test.mjs scripts/check-image-budget.test.mjs scripts/pr-shots.test.mjs
- name: Filter paths
id: filter
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6a2f05aa60..1b347b1ee8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -70,6 +70,97 @@ default.** Reviewers should request changes or close the PR until one is
provided. PRs
missing the problem, goal, or high-level proposal are also not ready for review.
+### Screenshots and Recordings
+
+Store PR evidence as [GitHub attachments](https://docs.github.com/en/github-cli/github-cli/attaching-files-with-github-cli).
+Their URLs do not depend on a temporary Git branch and have no preset expiry;
+GitHub does not promise permanent archival. Keep visual-test reference images
+with their tests, and use CI artifacts for temporary debugging reports. Actions
+artifacts expire, so they are unsuitable as the only copy of PR evidence.
+
+From the repository root, upload files to an existing PR with Node.js 22+ and
+[GitHub CLI 2.103.2+](https://github.com/cli/cli/releases/tag/v2.103.2):
+
+```bash
+scripts/pr-shots --repo multica-ai/multica 123 ./before.png ./after.png ./demo.mp4
+```
+
+By default, the script appends attachments at the end of the PR description
+(after any closing issue reference), preserves its existing content, and prints
+the resulting attachment Markdown to stdout. A PR URL can replace the number;
+`--repo` is optional when `gh` can identify the repository. Diagnostics
+go to stderr. Files are identified by SHA-256 in hidden comments next to the
+attachments in the PR body, so retries and renamed files reuse uploaded content
+across checkouts. Keep those comments if you want that retry behavior. Changed
+file content produces a new attachment.
+
+The attachments are already in the PR description; do not paste another copy
+of the stdout Markdown into it. To place an attachment under Screenshots, move
+its entire block from the end of the description: the hidden hash comment,
+blank lines, and image Markdown or video URL together.
+
+Uploads run one file at a time and stop at the first failure. Already confirmed
+files remain saved; stderr identifies the failed and unattempted files. The
+script reads back the PR even when `gh` exits nonzero, because a write may have
+succeeded. Re-run the same command to reuse confirmed attachments and upload
+the missing ones. Run one uploader per PR at a time and avoid editing the
+description during an upload; GitHub body edits are not conditional writes.
+
+To migrate an existing screenshot while keeping its caption and position, use
+`--replace` with exactly one image file. The old URL must occur in a standalone
+Markdown image, such as `![Original caption](https://example.com/old.png)`:
+
+```bash
+scripts/pr-shots --repo multica-ai/multica \
+ --replace https://example.com/old.png 123 ./after.png
+```
+
+Verify the new attachments render and remain accessible to the PR's reviewers
+before deleting old storage. Check other PRs and repository references before
+removing a shared evidence branch. Preserve old links for any failed migration.
+
+You can also use the native CLI directly, including during PR creation:
+
+```bash
+gh pr create --body-file ./pr.md --attach ./before.png --attach ./after.png
+gh pr edit 123 --attach ./demo.mp4
+```
+
+In `pr.md`, write `![Before](./before.png)` and `![After](./after.png)` where
+the images should appear. For video, put `![](./demo.mp4)` in its own paragraph.
+The CLI replaces these local references with uploaded URLs; unreferenced
+attachments are appended. Native `gh --attach` does not deduplicate retries.
+
+CLI uploads require **push access to the target repository** and a credential
+accepted by GitHub's upload endpoint. Version 2.103.2 lets that endpoint decide
+which GitHub App tokens can upload; it does not guarantee support for every App
+or an Actions `GITHUB_TOKEN`. Verify the actual agent/CI credential. Without
+push access, upload through the PR editor in GitHub's web interface. Contributors
+who must stay in the CLI should ask a maintainer in the PR to upload their files;
+opening a fork PR alone does not grant upload permission on the upstream repo.
+This helper targets GitHub.com, not GitHub Enterprise Server.
+
+Supported files are PNG, JPEG, GIF, WebP, SVG, MP4, MOV, and WebM. Images are
+limited to 10 MB; video limits are 10 MB on Free plans and 100 MB on paid plans.
+Use H.264 MP4 for broad playback support. Public-repository attachments are
+publicly accessible: use test data and inspect captures before uploading.
+
+Capture the affected screens from the running application and record the
+commit, viewport, theme, and reproduction steps with the evidence. Use the
+local environment workflow below; for Desktop recording, see
+[Scripting Desktop over CDP](#scripting-desktop-over-cdp). For stable screenshots:
+
+```js
+await page.screenshot({ path: "after.png", animations: "disabled" });
+```
+
+This completes finite CSS/Web Animations and resets infinite ones to their
+initial frame during capture. To compare a particular animation frame, pause
+`document.getAnimations()` and set each animation's `currentTime` to the same
+timestamp on both versions instead. Hold a loading state with a controlled
+local API response, rather than relying on a fixed sleep. Include a short
+recording when the motion or sequence itself is the change under review.
+
## Development Model
Local development uses one shared PostgreSQL container and one database per checkout.
diff --git a/scripts/pr-shots b/scripts/pr-shots
new file mode 100755
index 0000000000..352c63a7fd
--- /dev/null
+++ b/scripts/pr-shots
@@ -0,0 +1,184 @@
+#!/usr/bin/env node
+import { spawnSync } from "node:child_process";
+import { createHash } from "node:crypto";
+import { mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { basename, extname, join, resolve } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const usage = `Usage: scripts/pr-shots [--repo OWNER/REPO] [--replace OLD_URL] PR FILE...
+
+Upload screenshots or recordings to an existing GitHub PR and print attachment
+Markdown to stdout. Diagnostics go to stderr. PR may be a number or GitHub URL.
+Requires Node.js 22+ and gh 2.103.2+ with repository write access.
+
+ scripts/pr-shots --repo multica-ai/multica 123 ./before.png ./after.png ./demo.mp4
+ scripts/pr-shots --repo multica-ai/multica --replace https://example.com/old.png 123 ./after.png
+
+--replace replaces existing standalone inline image references, keeping their
+alt text and surrounding prose; it accepts exactly one file. Without it, new
+attachments are appended. Identical content already marked in this PR is reused.
+Run only one uploader per PR at a time; avoid editing its body during upload.
+`;
+
+function parseArgs(args) {
+ const options = { files: [], repo: "", replace: "", pr: "" };
+ let positional = false;
+ for (let i = 0; i < args.length; i++) {
+ const arg = args[i];
+ if (!positional && (arg === "--help" || arg === "-h")) return { help: true };
+ if (!positional && arg === "--") { positional = true; continue; }
+ if (!positional && (arg === "--repo" || arg === "-R" || arg === "--replace")) {
+ const value = args[++i];
+ if (!value || value.startsWith("-")) throw new Error(`Missing value for ${arg}`);
+ options[arg === "--replace" ? "replace" : "repo"] = value;
+ } else if (!positional && arg.startsWith("-")) {
+ throw new Error(`Unknown option: ${arg}`);
+ } else if (!options.pr) options.pr = arg;
+ else options.files.push(arg);
+ }
+ if (!options.pr || !options.files.length) throw new Error(usage);
+ if (!/^[1-9]\d*$/.test(options.pr) && !/^https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/[1-9]\d*$/.test(options.pr)) {
+ throw new Error("PR must be a positive number or a github.com pull request URL");
+ }
+ if (options.repo && !/^[\w.-]+\/[\w.-]+$/.test(options.repo)) throw new Error("--repo must be OWNER/REPO");
+ if (options.replace && (options.files.length !== 1 || !/^https:\/\/[^\s<>]+$/.test(options.replace))) {
+ throw new Error("--replace requires an HTTPS URL and exactly one file");
+ }
+ return options;
+}
+
+function runGh(args) {
+ const result = spawnSync("gh", args, { encoding: "utf8", timeout: 120_000, maxBuffer: 4 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
+ return { status: result.status ?? 1, stdout: result.stdout ?? "", stderr: result.error?.message ?? result.stderr ?? "" };
+}
+
+function checkedGh(gh, args) {
+ const result = gh(args);
+ if (result.status !== 0) throw new Error(result.stderr.trim() || `gh ${args.slice(0, 2).join(" ")} failed`);
+ return result.stdout;
+}
+
+function checkVersion(gh) {
+ const match = checkedGh(gh, ["--version"]).match(/^gh version (\d+)\.(\d+)\.(\d+)/);
+ const [major, minor, patch] = match ? match.slice(1).map(Number) : [];
+ if (!(major > 2 || (major === 2 && (minor > 103 || (minor === 103 && patch >= 2))))) {
+ throw new Error("Upgrade GitHub CLI to gh 2.103.2 or newer");
+ }
+}
+
+function snapshot(file) {
+ const path = resolve(file);
+ const extension = extname(path).slice(1).toLowerCase();
+ const video = ["mp4", "mov", "webm"].includes(extension);
+ if (!video && !["png", "jpg", "jpeg", "gif", "webp", "svg"].includes(extension)) {
+ throw new Error(`${file}: unsupported image/video extension`);
+ }
+ const info = statSync(path);
+ const limit = (video ? 100 : 10) * 1024 * 1024;
+ if (!info.isFile() || info.size === 0 || info.size > limit) throw new Error(`${file}: expected a nonempty file up to ${video ? 100 : 10} MB`);
+ const bytes = readFileSync(path);
+ return { path, extension, video, bytes, hash: createHash("sha256").update(bytes).digest("hex") };
+}
+
+function marker(hash) { return `<!-- pr-shots:sha256=${hash} -->`; }
+function escapeRegex(value) { return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); }
+function escapeAlt(value) { return value.replace(/\\/g, "\\\\").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/[\r\n]/g, " "); }
+
+function nativeUrl(value) {
+ try {
+ const url = new URL(value);
+ return url.protocol === "https:" && url.hostname === "github.com" && /^\/user-attachments\/assets\/[\w-]+$/.test(url.pathname);
+ } catch { return false; }
+}
+
+function savedAttachment(body, hash) {
+ const pattern = new RegExp(`${escapeRegex(marker(hash))}[ \\t]*\\r?\\n(?:[ \\t]*\\r?\\n)*([^\\r\\n]+)`, "g");
+ for (const match of body.matchAll(pattern)) {
+ const markdown = match[1].trim();
+ const image = markdown.match(/^!\[(?:\\.|[^\]\\])*\]\((https:\/\/[^\s)]+)\)$/);
+ const url = image ? image[1] : markdown;
+ if (nativeUrl(url)) return { markdown, url };
+ }
+ return null;
+}
+
+function replaceImage(body, oldUrl, newUrl, hash) {
+ const pattern = new RegExp(`^(!\\[(?:\\\\.|[^\\]\\\\])*\\]\\()${escapeRegex(oldUrl)}(\\))[ \\t]*$`, "gm");
+ let count = 0;
+ const next = body.replace(pattern, (_match, before, after) => {
+ count++;
+ return `${marker(hash)}\n\n${before}${newUrl}${after}`;
+ });
+ if (!count) throw new Error("--replace URL must match an existing image on its own line; the PR was not changed");
+ return next;
+}
+
+export function runPrShots(args, { gh = runGh, out = (text) => process.stdout.write(text), log = (text) => process.stderr.write(`${text}\n`) } = {}) {
+ let directory;
+ try {
+ const options = parseArgs(args);
+ if (options.help) { out(usage); return 0; }
+ // Snapshot every input before the first remote mutation, including paths with #.
+ const files = [...new Map(options.files.map((file) => {
+ const asset = snapshot(file);
+ return [asset.hash, asset];
+ })).values()];
+ if (options.replace && files[0].video) throw new Error("--replace supports images; append recordings instead");
+ checkVersion(gh);
+ const readPr = (target, repo = "") => {
+ const flags = repo ? ["--repo", repo] : [];
+ const pr = JSON.parse(checkedGh(gh, ["pr", "view", target, ...flags, "--json", "body,url"]));
+ if (typeof pr.body !== "string" || !/^https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/[1-9]\d*$/.test(pr.url)) {
+ throw new Error("Expected a GitHub.com PR body and canonical URL");
+ }
+ return pr;
+ };
+ const target = readPr(options.pr, options.repo).url;
+ directory = mkdtempSync(join(tmpdir(), "pr-shots-"));
+ for (let i = 0; i < files.length; i++) {
+ const file = files[i];
+ try {
+ const pr = readPr(target);
+ const existing = savedAttachment(pr.body, file.hash);
+ if (existing && (!options.replace || !pr.body.includes(options.replace))) {
+ log(`Reused ${basename(file.path)}`);
+ out(`${existing.markdown}\n\n`);
+ continue;
+ }
+ const staged = join(directory, `${file.hash}.${file.extension}`);
+ writeFileSync(staged, file.bytes, { mode: 0o600 });
+ const destination = existing?.url ?? staged;
+ const markdown = file.video ? `![](${destination})` : `![${escapeAlt(basename(file.path))}](${destination})`;
+ const body = options.replace
+ ? replaceImage(pr.body, options.replace, destination, file.hash)
+ : `${pr.body}${pr.body ? "\n\n" : ""}${marker(file.hash)}\n\n${markdown}\n`;
+ const bodyFile = join(directory, "body.md");
+ writeFileSync(bodyFile, body, { mode: 0o600 });
+ const attach = existing ? [] : ["--attach", staged];
+ const result = gh(["pr", "edit", target, "--body-file", bodyFile, ...attach]);
+ // A nonzero exit can follow a successful write: read back before retrying.
+ const saved = savedAttachment(readPr(target).body, file.hash);
+ if (!saved) throw new Error(result.stderr.trim() || "Upload was not confirmed in the PR body; inspect the PR before retrying");
+ out(`${saved.markdown}\n\n`);
+ log(`Saved ${basename(file.path)}`);
+ if (result.status !== 0) throw new Error(`Attachment saved, but gh exited ${result.status}: ${result.stderr.trim()}`);
+ } catch (error) {
+ log(`Failed ${basename(file.path)}: ${error.message}`);
+ if (i + 1 < files.length) log(`Not attempted: ${files.slice(i + 1).map((file) => basename(file.path)).join(", ")}`);
+ log("Earlier confirmed attachments remain saved. Re-run the same command to reuse them.");
+ return 1;
+ }
+ }
+ return 0;
+ } catch (error) {
+ log(error.message);
+ return 1;
+ } finally {
+ if (directory) rmSync(directory, { recursive: true, force: true });
+ }
+}
+
+if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
+ process.exitCode = runPrShots(process.argv.slice(2));
+}
diff --git a/scripts/pr-shots.test.mjs b/scripts/pr-shots.test.mjs
new file mode 100644
index 0000000000..aa1ba2d4d7
--- /dev/null
+++ b/scripts/pr-shots.test.mjs
@@ -0,0 +1,165 @@
+import assert from "node:assert/strict";
+import { mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+import { runPrShots } from "./pr-shots";
+
+const prUrl = "https://github.com/multica-ai/multica/pull/123";
+
+function setup(t, body = "## Problem\n\nExisting prose and formatting.\n") {
+ const directory = mkdtempSync(join(tmpdir(), "pr-shots-test-"));
+ t.after(() => rmSync(directory, { recursive: true, force: true }));
+ const state = { body, edits: 0, uploads: 0, version: "2.103.2", failAt: 0, failAfterSave: false, beforeRead: null };
+ const file = (name, content = name) => {
+ const path = join(directory, name);
+ writeFileSync(path, content);
+ return path;
+ };
+ const gh = (args) => {
+ const ok = (stdout = "") => ({ status: 0, stdout, stderr: "" });
+ if (args[0] === "--version") return ok(`gh version ${state.version} (test)`);
+ if (args[1] === "view") {
+ state.beforeRead?.();
+ return ok(JSON.stringify({ body: state.body, url: prUrl }));
+ }
+ assert.equal(args[1], "edit");
+ assert.equal(args[2], prUrl, "writes must use the resolved repository/PR");
+ state.edits++;
+ if (state.failAt === state.edits) return { status: 1, stdout: "", stderr: "upload denied" };
+ let body = readFileSync(args[args.indexOf("--body-file") + 1], "utf8");
+ if (args.includes("--attach")) {
+ const staged = args[args.indexOf("--attach") + 1];
+ assert.doesNotMatch(staged, /[#\[\]]/, "upload paths must not become gh alt text or Markdown syntax");
+ assert.ok(readFileSync(staged).length);
+ const url = `https://github.com/user-attachments/assets/attachment-${++state.uploads}`;
+ body = body.replace(`![](${staged})`, url).split(staged).join(url);
+ }
+ state.body = body;
+ return state.failAfterSave ? { status: 1, stdout: prUrl, stderr: "connection lost after write" } : ok(prUrl);
+ };
+ const run = (...args) => {
+ let stdout = "", stderr = "";
+ const status = runPrShots(args, { gh, out: (s) => { stdout += s; }, log: (s) => { stderr += `${s}\n`; } });
+ return { status, stdout, stderr };
+ };
+ return { state, file, run, directory };
+}
+
+test("preserves prose, emits attachment Markdown, and reuses content after a rename", (t) => {
+ const { state, file, run, directory } = setup(t);
+ const original = state.body;
+ const image = file("before [login] #1.png");
+ const first = run("--repo", "multica-ai/multica", "123", image);
+ assert.equal(first.status, 0, first.stderr);
+ assert.ok(state.body.startsWith(original));
+ assert.match(first.stdout, /^!\[before \\\[login\\\] #1\.png\]\(https:\/\/github\.com\/user-attachments\/assets\//);
+ assert.doesNotMatch(first.stdout, /pr-shots:|pr-shots-test-/);
+ const renamed = join(directory, "renamed.png");
+ renameSync(image, renamed);
+ const second = run("123", renamed, renamed);
+ assert.equal(second.status, 0, second.stderr);
+ assert.equal(second.stdout, first.stdout);
+ assert.equal(state.uploads, 1);
+ assert.equal(state.edits, 1);
+});
+
+test("changed content at the same path is uploaded again", (t) => {
+ const { state, file, run } = setup(t);
+ const image = file("screen.png", "before");
+ assert.equal(run("123", image).status, 0);
+ writeFileSync(image, "after");
+ assert.equal(run("123", image).status, 0);
+ assert.equal(state.uploads, 2);
+});
+
+test("failed batch retains successes and retry uploads only missing files", (t) => {
+ const { state, file, run } = setup(t);
+ const files = [file("one.png"), file("two.png"), file("three.png")];
+ state.failAt = 2;
+ const failed = run("123", ...files);
+ assert.equal(failed.status, 1);
+ assert.match(failed.stdout, /attachment-1/);
+ assert.match(failed.stderr, /Failed two.png: upload denied/);
+ assert.match(failed.stderr, /Not attempted: three.png/);
+ assert.equal(state.uploads, 1);
+ state.failAt = 0;
+ const retried = run("123", ...files);
+ assert.equal(retried.status, 0, retried.stderr);
+ assert.equal(state.uploads, 3);
+ assert.equal((state.body.match(/pr-shots:sha256=/g) ?? []).length, 3);
+});
+
+test("nonzero gh exit after a successful write is read back and not reuploaded", (t) => {
+ const { state, file, run } = setup(t);
+ const image = file("screen.png");
+ state.failAfterSave = true;
+ const first = run("123", image);
+ assert.equal(first.status, 1);
+ assert.match(first.stdout, /attachment-1/);
+ assert.match(first.stderr, /Attachment saved, but gh exited 1/);
+ state.failAfterSave = false;
+ assert.equal(run("123", image).status, 0);
+ assert.equal(state.uploads, 1);
+});
+
+test("migration replaces the image in place, preserving captions and alt text", (t) => {
+ const old = "https://github.com/multica-ai/multica/raw/2492562/pr-10077/loader-frames.png";
+ const before = `Before caption.\n\n![Original alt](${old})\n\nAfter caption.\n`;
+ const { state, file, run } = setup(t, before);
+ const image = file("screen.png");
+ const args = ["--replace", old, "123", image];
+ state.failAt = 1;
+ assert.equal(run(...args).status, 1);
+ assert.equal(state.body, before, "failed migration must retain the old working link");
+ state.failAt = 0;
+ const migrated = run(...args);
+ assert.equal(migrated.status, 0, migrated.stderr);
+ assert.match(migrated.stdout, /^!\[Original alt\]/);
+ assert.ok(state.body.startsWith("Before caption.\n\n"));
+ assert.ok(state.body.endsWith("\n\nAfter caption.\n"));
+ assert.ok(!state.body.includes(old));
+ assert.equal(run(...args).status, 0);
+ assert.equal(state.uploads, 1);
+});
+
+test("reads the latest body between uploads", (t) => {
+ const { state, file, run } = setup(t);
+ const one = file("one.png"), two = file("two.png");
+ state.beforeRead = () => {
+ if (state.uploads === 1 && !state.body.includes("New author note.")) state.body += "\nNew author note.\n";
+ };
+ assert.equal(run("123", one, two).status, 0);
+ assert.match(state.body, /New author note\./);
+});
+
+test("videos emit a player URL on its own line and are deduplicated", (t) => {
+ const { state, file, run } = setup(t);
+ const video = file("interaction.webm");
+ const first = run("123", video);
+ assert.equal(first.status, 0, first.stderr);
+ assert.match(first.stdout, /^https:\/\/github\.com\/user-attachments\/assets\/attachment-1\n\n$/);
+ assert.equal(run("123", video).stdout, first.stdout);
+ assert.equal(state.uploads, 1);
+});
+
+test("preflights all files and gh version before any writes", (t) => {
+ const { state, file, run, directory } = setup(t);
+ const image = file("screen.png");
+ assert.equal(run("123", image, join(directory, "missing.png")).status, 1);
+ assert.equal(run("123", image, file("secret.txt")).status, 1);
+ assert.equal(run("123", file("empty.png", "")).status, 1);
+ state.version = "2.99.0";
+ assert.match(run("123", image).stderr, /Upgrade GitHub CLI/);
+ assert.equal(state.edits, 0);
+});
+
+test("bad migration targets and unsupported arguments do not change the PR", (t) => {
+ const { state, file, run } = setup(t);
+ const image = file("screen.png");
+ assert.equal(run("--replace", "https://example.com/missing.png", "123", image).status, 1);
+ assert.equal(run("--replace", "https://example.com/video.mp4", "123", file("video.mp4")).status, 1);
+ assert.equal(run("--replace", "https://example.com/old.png", "123", image, image).status, 1);
+ assert.equal(run("--unexpected", "123", image).status, 1);
+ assert.equal(state.edits, 0);
+});