A local-first multi-agent app development platform, built on PenguinHarness
/**
* Capture the README screenshots — the committed `assets/readme/*.webp` are generated by this
* script, so they can be refreshed when the interface changes.
*
* It talks to a running Adelie server with a real Web build (the dev shadow instance is enough:
* `pnpm dev:server`, or any instance whose `packages/web/dist` is current) and shoots two pages
* per UI language per theme:
*
* assets/readme/evaluation-center-<lang>-<theme>.webp the Evaluation Center (reason 3)
* assets/readme/plugin-market-<lang>-<theme>.webp the plugin market (plugin library)
*
* Usage:
*
* node scripts/capture-readme-shots.mjs <base-url> <session-cookie> [out-dir]
*
* `<session-cookie>` is a signed-in `penguin_session` value. Getting one on a fresh data root:
* the server prints a first-login link on start; POST its token to `/api/auth/claim` and the
* cookie you need is the one that comes back (curl -c jar), or log in with
* `POST /api/auth/login` if the account already has a password.
*
* The UI language is a localStorage preference (`packages/web/src/state/locale.tsx`), not the
* browser's, so the script writes it before the app boots; the theme comes from the page's own
* `prefers-color-scheme`. Playwright is borrowed from the Web package's test dependency — this
* script adds no dependency of its own — and ffmpeg turns each PNG into the committed webp.
*/
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";
import { fileURLToPath } from "node:url";
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const requireHost = createRequire(path.join(REPO, "packages", "web", "package.json"));
const { chromium } = requireHost("@playwright/test");
const [baseUrl, token, outArg] = process.argv.slice(2);
if (baseUrl === undefined || token === undefined) {
console.error(
"usage: node scripts/capture-readme-shots.mjs <base-url> <session-cookie> [out-dir]",
);
process.exit(2);
}
const outDir = path.resolve(outArg ?? path.join(REPO, "assets", "readme"));
fs.mkdirSync(outDir, { recursive: true });
/** Pages shot for the README, and the file name stem each one lands under. */
const PAGES = [
{ route: "/benchmark", name: "evaluation-center" },
{ route: "/plugins", name: "plugin-market" },
];
const browser = await chromium.launch();
try {
for (const lang of ["zh", "en"]) {
for (const theme of ["light", "dark"]) {
const context = await browser.newContext({
viewport: { width: 1440, height: 900 },
deviceScaleFactor: 2,
colorScheme: theme,
});
await context.addCookies([
{ name: "penguin_session", value: token, domain: new URL(baseUrl).hostname, path: "/" },
]);
await context.addInitScript(`localStorage.setItem("penguin.lang", ${JSON.stringify(lang)});`);
const page = await context.newPage();
for (const { route, name } of PAGES) {
await page.goto(`${baseUrl}${route}`, { waitUntil: "domcontentloaded" });
// The page is client-rendered over SSE; give its first paint of data time to land.
await page.waitForTimeout(3000);
const png = path.join(outDir, `${name}-${lang}-${theme}.png`);
const webp = path.join(outDir, `${name}-${lang}-${theme}.webp`);
await page.screenshot({ path: png });
execFileSync("ffmpeg", ["-y", "-loglevel", "error", "-i", png, "-quality", "82", webp]);
fs.unlinkSync(png);
console.log(
`${name}-${lang}-${theme}.webp`,
`${Math.round(fs.statSync(webp).size / 1024)} KB`,
);
}
await context.close();
}
}
} finally {
await browser.close();
}