From db07f7453070bf67b21dc895630f4b7d1a3793a4 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Tue, 2 Jun 2026 15:59:31 +0800 Subject: [PATCH] Tighten illustrated PDF workflow acceptance --- .../content-pdf-with-images/SKILL.md | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/skills/workflows/content-pdf-with-images/SKILL.md b/skills/workflows/content-pdf-with-images/SKILL.md index f707005..1034906 100644 --- a/skills/workflows/content-pdf-with-images/SKILL.md +++ b/skills/workflows/content-pdf-with-images/SKILL.md @@ -7,6 +7,9 @@ description: "图文 PDF 工作流:将主题或文章拆成章节,为每章 This is an orchestration skill. It does not replace planning, image, or PDF skills. It forces a staged handoff so the final artifact is a real PDF with real image inputs, not a placeholder file. +Hard rule: image prompts are not images. A PDF that contains only chapter text +and image prompts is incomplete and must not be reported as delivered. + ## Output Contract Final deliverables must stay inside the current XWorkmate/OpenClaw task artifact scope: @@ -48,10 +51,17 @@ Do not claim completion after this phase. Use the image-series skill path for one standalone PNG per chapter. +If an image-generation tool is available, call it for each chapter before PDF +assembly. If no image-generation tool is available, stop after `article.md` and +`prompts/image-prompts.md`, then report that the PDF cannot be completed because +the required image artifacts are missing. + Required checks before continuing: - PNG count equals chapter count. - Every `assets/images/*.png` is a real non-empty PNG. +- Every chapter image is a generated or user-provided bitmap image, not a text + placeholder, blank rectangle, SVG prompt card, or decorative filler. - `assets/images/manifest.md` exists and references only relative paths inside the artifact scope. - `prompts/image-prompts.md` and `series.config.json` exist. @@ -70,6 +80,29 @@ The PDF must contain: Use a PDF library such as reportlab when available. The file must be large enough to plausibly contain text and images; a tiny one-page placeholder PDF is a failure. +Do not use a Markdown-to-PDF command by itself unless the Markdown contains real +image links and the generated PDF is verified to contain embedded image objects. + +After creating the PDF, verify at least one embedded image object exists and the +image count is at least the chapter count. With `pypdf`, use an equivalent check: + +```python +from pypdf import PdfReader + +reader = PdfReader("exports/final.pdf") +image_count = 0 +for page in reader.pages: + resources = page.get("/Resources", {}) + xobjects = resources.get("/XObject", {}) + if hasattr(xobjects, "get_object"): + xobjects = xobjects.get_object() + for obj in xobjects.values(): + target = obj.get_object() + if target.get("/Subtype") == "/Image": + image_count += 1 +assert image_count >= EXPECTED_CHAPTER_COUNT, image_count +``` + ## Phase 5: Delivery Check Before final response, run equivalent checks: @@ -81,4 +114,8 @@ pdfinfo exports/final.pdf pdftotext exports/final.pdf - | head -40 ``` -Only report success if `exports/final.pdf` exists and the expected source files are present. +Also run an embedded-image check equivalent to the `pypdf` snippet in Phase 4. + +Only report success if `exports/final.pdf` exists, the expected source files are +present, and the PDF contains embedded images. If the PDF has no embedded image +objects, report it as incomplete and keep the missing-image issue visible.