Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/scripts/build-plugin-mirror.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env node
// Builds the tree that plugin-mirror.yml pushes to getopenscreen/openscreen-plugin,
// the repository Claude's plugin directory reads.
//
// node .github/scripts/build-plugin-mirror.mjs <plugin dir> <out dir> [--edition full|directory]
//
// The directory accepts a local MCP server and any file that is not text, JSON, YAML
// or an image only from Verified organizations. Until getopenscreen is one, the
// mirror carries the "directory" edition: the skills alone, without the server's
// launcher (.mcp.json, scripts/) or the headless capture script. The "full" edition
// is plugin/ as it is, less evals/.
//
// Text that differs between the two editions is marked in the Markdown files:
//
// <!-- full-plugin -->text of the full plugin only<!-- /full-plugin -->
// <!-- directory-plugin
// text of the directory edition only
// -->
// <!-- directory-plugin inline text, for a table cell -->
//
// The full plugin is installed straight from plugin/, where the directory text stays
// an HTML comment. The directory edition drops the full-only text and unwraps the
// directory text. Markers stay out of the full edition's way: it is copied as it is.

import {
cpSync,
existsSync,
mkdirSync,
readdirSync,
readFileSync,
rmSync,
statSync,
writeFileSync,
} from "node:fs";
import { join, relative } from "node:path";
import { argv } from "node:process";

const FULL = /<!-- full-plugin -->([\s\S]*?)<!-- \/full-plugin -->\n?/g;
// A block on its own lines, or inline on one line: <!-- directory-plugin text -->.
const DIRECTORY = /<!-- directory-plugin(?:\n([\s\S]*?)-->\n?| (.*?) -->)/g;
const MARKER = /<!-- \/?(full-plugin|directory-plugin)\b/;

// What the directory accepts from an organization that is not Verified.
const ALLOWED = /\.(md|txt|json|ya?ml|png|jpe?g|gif|webp|ico)$/i;
const ALLOWED_NAMES = new Set(["LICENSE", ".gitignore"]);
// Paths the directory edition leaves out: the server's launcher and every script.
const DIRECTORY_DROPS = [".mcp.json", "scripts"];
// Words that would point Claude at something the directory edition does not ship.
const DANGLING = [/\.mjs\b/, /openscreenSetup/, /\/reload-plugins/, /\b(the|plugin.s) launcher\b/];

function walk(dir, root = dir) {
return readdirSync(dir).flatMap((name) => {
const path = join(dir, name);
return statSync(path).isDirectory() ? walk(path, root) : [relative(root, path)];
});
}

function checkMarkers(file, text) {
const unmatched = text.replace(FULL, "").replace(DIRECTORY, "");
if (MARKER.test(unmatched)) throw new Error(`${file}: an edition marker is not closed`);
}

export function applyDirectoryEdition(text) {
return text.replace(FULL, "").replace(DIRECTORY, (_, block, inline) => block ?? inline);
}

/**
* @param {string} pluginDir plugin/ in the main repository.
* @param {string} outDir An empty or missing folder to build into.
* @param {{ edition?: "full" | "directory", license?: string }} options
* @returns {string[]} The files of the built tree, relative to outDir.
*/
export function buildPluginMirror(pluginDir, outDir, { edition = "directory", license } = {}) {
if (edition !== "full" && edition !== "directory") throw new Error(`Unknown edition: ${edition}`);
mkdirSync(outDir, { recursive: true });
cpSync(pluginDir, outDir, { recursive: true });
// evals/ is development tooling (prompts, graders, mocks) and does not ship.
rmSync(join(outDir, "evals"), { recursive: true, force: true });
if (license) cpSync(license, join(outDir, "LICENSE"));

for (const file of walk(outDir).filter((f) => f.endsWith(".md"))) {
checkMarkers(file, readFileSync(join(outDir, file), "utf8"));
}
if (edition === "full") return walk(outDir).sort();

for (const drop of DIRECTORY_DROPS) rmSync(join(outDir, drop), { recursive: true, force: true });
const skills = join(outDir, "skills");
if (existsSync(skills)) {
for (const skill of readdirSync(skills)) {
rmSync(join(skills, skill, "scripts"), { recursive: true, force: true });
}
}

const problems = [];
for (const file of walk(outDir)) {
const path = join(outDir, file);
const name = file.split(/[\\/]/).pop();
if (!ALLOWED.test(name) && !ALLOWED_NAMES.has(name)) {
problems.push(`${file}: not a file the directory accepts from an unverified organization`);
continue;
}
if (!/\.(md|txt|json|ya?ml)$/i.test(name) && !ALLOWED_NAMES.has(name)) continue;
let text = readFileSync(path, "utf8");
if (text.startsWith("#!")) problems.push(`${file}: starts with #!`);
if (name.endsWith(".md")) {
text = applyDirectoryEdition(text);
writeFileSync(path, text);
for (const word of DANGLING) {
if (word.test(text))
problems.push(`${file}: still mentions ${word.source}, which this edition does not ship`);
}
}
}
if (problems.length)
throw new Error(`The directory edition is not clean:\n${problems.join("\n")}`);
return walk(outDir).sort();
}

if (import.meta.url === `file://${argv[1]}`) {
const [, , pluginDir, outDir, ...rest] = argv;
const at = rest.indexOf("--edition");
const edition = at >= 0 ? rest[at + 1] : "directory";
const li = rest.indexOf("--license");
const license = li >= 0 ? rest[li + 1] : undefined;
if (!pluginDir || !outDir) {
console.error(
"Usage: build-plugin-mirror.mjs <plugin dir> <out dir> [--edition full|directory] [--license <file>]",
);
process.exit(2);
}
const files = buildPluginMirror(pluginDir, outDir, { edition, license });
console.log(`Built the ${edition} edition: ${files.length} files`);
for (const f of files) console.log(` ${f}`);
}
95 changes: 95 additions & 0 deletions .github/scripts/build-plugin-mirror.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { applyDirectoryEdition, buildPluginMirror } from "./build-plugin-mirror.mjs";

let dir;

function write(rel, text) {
const path = join(dir, "plugin", rel);
mkdirSync(dirname(path), { recursive: true });
writeFileSync(path, text);
}

beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), "plugin-mirror-"));
write(".claude-plugin/plugin.json", '{ "name": "openscreen", "version": "2.4.0" }\n');
write(".mcp.json", '{ "mcpServers": {} }\n');
write("scripts/server.mjs", "#!/usr/bin/env node\n");
write("evals/README.md", "graders\n");
write("skills/demo/scripts/capture.mjs", "export {};\n");
write(
"skills/demo/SKILL.md",
[
"Setup. <!-- full-plugin -->The plugin's launcher starts it.<!-- /full-plugin -->",
"<!-- directory-plugin",
"Register it by hand.",
"-->",
"End.",
"",
].join("\n"),
);
writeFileSync(join(dir, "LICENSE"), "MIT\n");
});

afterEach(() => rmSync(dir, { recursive: true, force: true }));

describe("buildPluginMirror", () => {
it("ships the skills alone in the directory edition", () => {
const out = join(dir, "out");
const files = buildPluginMirror(join(dir, "plugin"), out, { license: join(dir, "LICENSE") });
expect(files).toEqual([".claude-plugin/plugin.json", "LICENSE", "skills/demo/SKILL.md"]);
expect(readFileSync(join(out, "skills/demo/SKILL.md"), "utf8")).toBe(
"Setup. Register it by hand.\nEnd.\n",
);
});

it("keeps plugin/ as it is, less evals/, in the full edition", () => {
const out = join(dir, "out");
const files = buildPluginMirror(join(dir, "plugin"), out, { edition: "full" });
expect(files).toContain(".mcp.json");
expect(files).toContain("skills/demo/scripts/capture.mjs");
expect(existsSync(join(out, "evals"))).toBe(false);
expect(readFileSync(join(out, "skills/demo/SKILL.md"), "utf8")).toContain(
"<!-- directory-plugin",
);
});

it("refuses directory text that still points at what the edition drops", () => {
write("skills/demo/SKILL.md", "Run capture.mjs.\n");
expect(() => buildPluginMirror(join(dir, "plugin"), join(dir, "out"))).toThrow(
/still mentions/,
);
});

it("refuses a file the directory does not accept", () => {
write("skills/demo/tool.py", "print(1)\n");
expect(() => buildPluginMirror(join(dir, "plugin"), join(dir, "out"))).toThrow(/tool\.py/);
});

it("refuses an edition marker left open", () => {
write("skills/demo/SKILL.md", "<!-- full-plugin -->never closed\n");
expect(() =>
buildPluginMirror(join(dir, "plugin"), join(dir, "out"), { edition: "full" }),
).toThrow(/not closed/);
});
});

describe("applyDirectoryEdition", () => {
it("drops full-only text and unwraps the directory text", () => {
expect(
applyDirectoryEdition(
"a<!-- full-plugin -->b<!-- /full-plugin -->c\n<!-- directory-plugin\nd\n-->\ne",
),
).toBe("ac\nd\ne");
});

it("unwraps inline directory text, as in a table cell", () => {
expect(
applyDirectoryEdition(
"| <!-- full-plugin -->x<!-- /full-plugin --><!-- directory-plugin y --> |\n",
),
).toBe("| y |\n");
});
});
16 changes: 10 additions & 6 deletions .github/workflows/plugin-mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ on:
- "plugin/**"
- "LICENSE"
- "package.json"
- ".github/scripts/build-plugin-mirror.mjs"
- ".github/workflows/plugin-mirror.yml"
pull_request:
branches: [main]
paths:
- "plugin/**"
- "package.json"
- ".github/scripts/build-plugin-mirror.mjs"
- ".github/workflows/plugin-mirror.yml"
workflow_dispatch:

Expand Down Expand Up @@ -65,14 +67,16 @@ jobs:
process.exit(bad.length ? 1 : 0);
'

# The directory edition carries the skills alone: the directory accepts a
# local MCP server and script files only from Verified organizations, which
# getopenscreen is not yet. Set PLUGIN_MIRROR_EDITION to "full" (a repository
# variable) once it is. The script says what it drops and why.
- name: Build the mirror's tree
env:
EDITION: ${{ vars.PLUGIN_MIRROR_EDITION || 'directory' }}
run: |
mkdir -p "$RUNNER_TEMP/mirror" "$RUNNER_TEMP/tree"
# evals/ is development tooling (prompts, graders, mocks) and does not
# ship to users.
cp -a plugin/. "$RUNNER_TEMP/tree/"
rm -rf "$RUNNER_TEMP/tree/evals"
cp LICENSE "$RUNNER_TEMP/tree/LICENSE"
mkdir -p "$RUNNER_TEMP/mirror"
node .github/scripts/build-plugin-mirror.mjs plugin "$RUNNER_TEMP/tree" --edition "$EDITION" --license LICENSE

- name: Push to getopenscreen/openscreen-plugin
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'getopenscreen/openscreen'
Expand Down
20 changes: 18 additions & 2 deletions plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

This plugin turns one sentence into a finished demo video of an app or a feature. Its skills have Claude plan a short storyboard, record the screen with [OpenScreen](https://getopenscreen.com), add zooms, captions and on-screen callouts, export an MP4, check the frames, and then either attach the video to a pull request or draft a post on X.

OpenScreen is a free, open-source (MIT) screen recorder and video editor for Windows, macOS and Linux. The plugin carries several skills and OpenScreen's MCP server, so the recording and editing tools are there as soon as the plugin is enabled. The tools themselves come from the desktop app's own executable, started with `mcp`.
OpenScreen is a free, open-source (MIT) screen recorder and video editor for Windows, macOS and Linux. <!-- full-plugin -->The plugin carries several skills and OpenScreen's MCP server, so the recording and editing tools are there as soon as the plugin is enabled. The tools themselves come from the desktop app's own executable, started with `mcp`.<!-- /full-plugin -->
<!-- directory-plugin
This edition of the plugin carries the skills. The recording and editing tools come from OpenScreen's MCP server, which is the desktop app's own executable started with `mcp`: the `openscreen-demo` skill registers it once, with your agreement.
-->

## The skills

- **`openscreen-demo`**: makes the whole video, from the storyboard to the export, then attaches it to a pull request or drafts a post on X.
- **`openscreen-capture`**: gets a clean, repeatable take, scripted or recorded, including a web page captured with no window on your desktop.
- **`openscreen-capture`**: gets a clean, repeatable take, scripted or recorded<!-- full-plugin -->, including a web page captured with no window on your desktop<!-- /full-plugin -->.
- **`openscreen-motion`**: places zooms, callouts, speed changes and the 3D camera with motion-design rules.
- **`openscreen-effects`**: writes custom shader effects, with a cookbook of worked examples.
- **`openscreen-sound`**: adds narration and music, and checks loudness, true peak and silences by measurement.
Expand All @@ -16,15 +19,21 @@ OpenScreen is a free, open-source (MIT) screen recorder and video editor for Win

## What the plugin runs, sends and fetches

<!-- full-plugin -->
- **Starts OpenScreen's MCP server at session start.** `scripts/openscreen-mcp.mjs`, a short Node script with no dependency, looks for the installed app in its usual locations (or the path in `OPENSCREEN_EXE`) and runs `<app> mcp` over stdio. The server runs locally and needs no account. The script downloads nothing and sends nothing.
- **Explains instead of failing when the app is missing.** If OpenScreen is not installed, is older than 2.1.0 or cannot start, the script serves one tool, `openscreenSetup`, that tells Claude what it checked and how to set OpenScreen up.
<!-- /full-plugin -->
<!-- directory-plugin
- **Registers OpenScreen's MCP server, only after you agree.** The `openscreen-demo` skill finds the installed app and registers it with `claude mcp add openscreen -- "<app>" mcp`. The server runs locally over stdio and needs no account.
-->
- **Installs OpenScreen, only after you agree.** If the app is missing, a skill offers to download the latest installer from [the project's GitHub releases](https://github.com/getopenscreen/openscreen/releases/latest), or the Microsoft Store on Windows, and install it.
- **Records the window you choose.** The recording and the project stay on your machine. The exported video leaves it only when you share it, as below.
- **Attaches the video to a pull request** with `gh`, on the repository you work in, when you ask for a pull request video.
- **Drafts a post on X** for a launch demo, and posts it only after your explicit yes.

## Use it

<!-- full-plugin -->
Install it in Claude Code:

```
Expand All @@ -36,4 +45,11 @@ Then ask Claude for a demo, for example: *make a 30-second demo of the new expor

The server needs Node.js on the PATH. Without it, or in an agent without plugin support, register the server by hand: `claude mcp add openscreen -- "<path to the OpenScreen executable>" mcp`, or the same command and `mcp` argument in your agent's MCP settings.

<!-- /full-plugin -->
<!-- directory-plugin
Install it from Claude's plugin directory, then ask Claude for a demo, for example: *make a 30-second demo of the new export dialog and add it to my PR*. The first time, Claude sets up OpenScreen's MCP server; its tools load in the next session.

The full plugin, which also starts the server by itself and records web pages headless, installs from the project's repository: `/plugin marketplace add getopenscreen/openscreen`, then `/plugin install openscreen@openscreen`.

-->
Documentation: [Letting an agent make the whole video](https://getopenscreen.com/docs/ai-editing/#letting-an-agent-make-the-whole-video).
12 changes: 10 additions & 2 deletions plugin/skills/openscreen-capture/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ A take is cheaper to redo than to repair. Aim for one that needs no cut: the fir
|---|---|---|
| A desktop app, a native window, anything a browser cannot show | `startRecording`, real mouse | Recorded with the take |
| A web app the user wants filmed as they use it | `startRecording`, real mouse | Recorded with the take |
| A web app, a repeatable take, nothing on the user's screen | Headless script (below) | `setPointerTrack` from the script's log |
| A web app, a repeatable take, nothing on the user's screen | <!-- full-plugin -->Headless script (below)<!-- /full-plugin --><!-- directory-plugin A headless script, with the full plugin (below) --> | `setPointerTrack` from the script's log |
| A web app shown in a real window, driven by Playwright or CDP | `startRecording`, script drives the page | `setPointerTrack` from the script's log |
| A video file that already exists | `createProject` with its `videoPath` | `setPointerTrack` if you know the clicks |

**Prefer a real recording** when the thing to show is not a web page, needs the user's real data or session, involves sound from the app (`startRecording` with `systemAudio: true`), needs the webcam (`camera`) or a narration (`microphone: true`), or when the user wants to drive it themselves. Everything else in a browser is cleaner headless: same timing on every run, no hesitation, the user's screen untouched.
**Prefer a real recording** when the thing to show is not a web page, needs the user's real data or session, involves sound from the app (`startRecording` with `systemAudio: true`), needs the webcam (`camera`) or a narration (`microphone: true`), or when the user wants to drive it themselves. <!-- full-plugin -->Everything else in a browser is cleaner headless: same timing on every run, no hesitation, the user's screen untouched.<!-- /full-plugin -->

## Stage the app

Expand Down Expand Up @@ -61,6 +61,7 @@ Log where each move starts and ends, and each click; OpenScreen glides between t

For a page shown in a real window, the tool's description gives the formula from a page point (`clientX`, `clientY`) to window fractions. `setPointerTrack` replaces the pointer the take had, then plans zooms on the new clicks (`autoZoomsAdded`). On a project not open in the editor it needs a checkpoint, which `stopRecording` and `createProject` make; `restoreCheckpoint` undoes it.

<!-- full-plugin -->
## The headless recipe

`scripts/capture.mjs` captures a web page in a browser with no window: a screenshot loop at twice the display scale (2560×1440 from a 1280×720 viewport, about 20 frames a second, enough for an interface), encoded to an H.264 MP4 at 30 fps, plus the pointer log in video time. Twice the scale is what keeps text sharp under a 1.5× to 2.2× zoom.
Expand All @@ -82,6 +83,13 @@ Never write a `.cursor.json` file yourself: `setPointerTrack` writes it, and a c
- Timers inside the page run on the real clock while frames arrive at their own pace: an on-screen clock or counter can look faster or slower than real time. Keep them out of the shot.
- A 3× scale (3840×2160) is worth it only for an effect that magnifies a detail, and costs frame rate.

<!-- /full-plugin -->
<!-- directory-plugin
## The headless recipe

Capturing a web page in a browser with no window needs a capture script that comes with the full OpenScreen plugin, from https://github.com/getopenscreen/openscreen (see its `plugin/` folder). Without it, record the page in a real window with `startRecording` as above.

-->
## Check the take before editing

Look at the whole take in one image: `getContactSheet` with the `videoPath` as `path` and `count: 12`. If that tool is not listed, use `getFrames` with `path` and `count: 6`. Then:
Expand Down
Loading
Loading