From 9638c3ae07a193c00cb3371f5d8dde9a5386da27 Mon Sep 17 00:00:00 2001 From: wuqxuan Date: Fri, 17 Jul 2026 12:42:12 +0800 Subject: [PATCH] fix(meme-maker): stop inviting sharp installs in PNG error (#109612) Co-authored-by: Peter Steinberger --- skills/meme-maker/SKILL.md | 1 + skills/meme-maker/scripts/meme.mjs | 6 +++--- test/scripts/meme-maker-png-error.test.ts | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test/scripts/meme-maker-png-error.test.ts diff --git a/skills/meme-maker/SKILL.md b/skills/meme-maker/SKILL.md index 1a02dd0f663..26bd5bf6a5b 100644 --- a/skills/meme-maker/SKILL.md +++ b/skills/meme-maker/SKILL.md @@ -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. diff --git a/skills/meme-maker/scripts/meme.mjs b/skills/meme-maker/scripts/meme.mjs index 14116b11a57..031016f59d0 100755 --- a/skills/meme-maker/scripts/meme.mjs +++ b/skills/meme-maker/scripts/meme.mjs @@ -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 { diff --git a/test/scripts/meme-maker-png-error.test.ts b/test/scripts/meme-maker-png-error.test.ts new file mode 100644 index 00000000000..6ea85f7fe14 --- /dev/null +++ b/test/scripts/meme-maker-png-error.test.ts @@ -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); + }); +});