fix(meme-maker): stop inviting sharp installs in PNG error (#109612)

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
wuqxuan
2026-07-16 21:42:12 -07:00
committed by GitHub
co-authored by Peter Steinberger
parent 7641aa80c2
commit 9638c3ae07
3 changed files with 24 additions and 3 deletions
+1
View File
@@ -40,3 +40,4 @@ Hygiene
- Do not ship template image files in the skill.
- Do not use shared or hardcoded Imgflip credentials.
- Keep Know Your Meme lookups out of the render hot path; use KYM links for explanation/provenance only.
- If PNG output fails because `sharp` is missing, use `--out meme.svg` (or another `.svg` path). Do not `npm install` packages into the skill directory or the OpenClaw tree to enable PNG.
+3 -3
View File
@@ -283,9 +283,9 @@ async function renderLocal(template, texts, flags) {
try {
sharp = (await import("sharp")).default;
} catch {
throw new Error(
"PNG output needs the optional sharp package. Use --out meme.svg or install sharp near the skill runner.",
);
// Keep this message free of package-install advice: agents follow it
// literally and can corrupt pnpm-managed OpenClaw installs (see #109405).
throw new Error("PNG output needs the optional sharp package. Use --out meme.svg instead.");
}
await sharp(Buffer.from(svg)).png().toFile(out);
} else {
+20
View File
@@ -0,0 +1,20 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
const memeScriptPath = path.resolve(process.cwd(), "skills/meme-maker/scripts/meme.mjs");
describe("meme-maker PNG missing-sharp error text", () => {
it("directs SVG output and never invites package installs near the skill runner", () => {
const source = fs.readFileSync(memeScriptPath, "utf8");
expect(source).toContain("PNG output needs the optional sharp package.");
expect(source).toContain("Use --out meme.svg instead.");
// Agents treat install hints literally and can corrupt pnpm workspaces.
expect(source).not.toMatch(/install\s+sharp/iu);
expect(source).not.toMatch(/npm\s+install/iu);
expect(source).not.toMatch(/near the skill runner/iu);
expect(source).not.toMatch(/install\s+.*\s+near/iu);
});
});