Xiaohongshu Reference Image Remake (xhs-image-remake)
Automatically decompose, determine mode, route per-element "generate image vs. local draw", orchestrate image series, composite and render, review and archive based on reference images (single or a set) and user's actual product assets.
This Skill runs completely self-contained, without relying on external closed-source workflows or backend services; the image generation model can be freely swapped via a lightweight adapter layer.
Reference Documents on Demand
- Mode A/B Determination and Image Series Orchestration:
references/modes-and-series.md - Per-Element Routing Matrix and Core Techniques for Five Image Types:
references/element-routing.md - Image Generation Adapter Layer Protocol and Model Addition Guide:
references/adapter-contract.md - Lightweight Self-Improvement Lessons Library:
references/lessons.md(before each planning session, only scan the relevant 1-2 sections)
End-to-End Flow (Fully Automated + Single Quotation Checkpoint)
- Receive Input: Reference images (single/multiple) + user's actual product assets + copy or modification intent + target number of images (if any). When product facts are missing, clearly mark them as gaps or pending verification; never fabricate.
- Full Auto-Planning (Zero Cost):
- First, scan 1-2 sections of
references/lessons.mdrelevant to the current task and convert matched rules into constraints for this execution. - Actual Image Decomposition: Identify scene, composition, camera position, action, lighting, product relationships, stickers/text, and icons/cards for each image.
- Mode Determination: If the user does not specify, automatically determine Mode A (Same-Style Remake) or Mode B (Element Replacement) (rules in
modes-and-series.md). - Per-Element Routing: Decompose to the element level and decide "local drawing (HTML/CSS/SVG)" or "image generation model", determining whether the entire image is pure local / hybrid / pure generation (rules in
element-routing.md). - Image Series Orchestration: For multi-image references, set a series-level bible (Series Bible) + generate each image individually (Mode B can use
style_anchorfor the first shot); for single-image expansion to multiple angles, prefer nativesequential, and fall back to per-image generation when not supported. - Plan Persistence: Call
scripts/run_store.py initto initialize the run directory, writing decomposition highlights, keep/replace lists, per-element routing, and pending shots intorun.json.
- First, scan 1-2 sections of
- Single Checkpoint: Batch Quotation (Triggered only when paid generation is involved):
- If all elements are local draws (zero cost), skip this step and go directly to Step 4.
- If generation is needed, first call
scripts/gen_image.py quote --adapter <name> --request <req.json>to verify credential readiness at zero cost, plan batching, and estimate unit price (unconfigured credentials or single-shot limits will block the request directly). - Report to the user in one go: total number of images, model/adapter used, unit price and estimated total price (or risk warning if unit price is unknown), whether to batch or fall back to per-image generation.
- Hard rule: Never submit any paid request without the user's explicit confirmation; after confirmation, execute all images within the authorized scope in one batch.
- Auto Execution:
- Generation Layer: Call
scripts/gen_image.py run --adapter <name> --request <req.json>(--dry-runisolates and stores sandbox results indry_run/<call_id>/, without overwriting official evidence). Prompts must require clean base images without text (except for packaging-inherent text). The same output directory uses a shared submission lock for single and batch runs; on timeout or insufficient returned images (incomplete_delivery), markok=false, retain the lock and successful evidence to prevent re-entry into the same directory. Must first checkraw/andadapter_result.json, and never automatically resend paid requests. - Local Layer: First view the generated base image to confirm subject and prop safety zones, then write editable HTML/CSS/SVG source code into
local/, callscripts/render_local.py <html_path> <out_png> --base-image <base_png>to render and composite intooutputs/. - Write actual prompts, artifact paths, and cost details back to
run.json.
- Generation Layer: Call
- Visual Self-Check and Delivery:
- Must actually view each final image (never rely on exit codes or file sizes instead of visual review; if viewing is impossible, honestly state that visual check is incomplete).
- Verify: Mode consistency, product identity (brand/bottle shape/color/specifications), lighting and gesture linkage, base images free of garbled text and watermark residue, local text accurate and readable on mobile devices.
- Layered Fixes: Fix issues at the layer they occur (fix text/annotations only in the local layer, without touching the base image); if additional paid redraws exceed the authorized budget, re-quote.
- Deliver final images + a brief description (mode used, which were generated/which were locally drawn, whether fallback to per-image generation was needed), and call
scripts/run_store.py write-summaryto write intosummary.md. Do not produce side-by-side comparison images or lengthy reports.
- Lightweight Experience Capture (Low-intrusion, On-demand Trigger):
- Triggered only when any of the following conditions are met: 1) Substantial revisions ≥ 2 rounds after the first draft; 2) Troubleshooting and solving a new tool/model pitfall; 3) User explicitly requests a record.
- Not triggered for standard one-pass completions. When auto-trigger conditions are met, append a brief confirmation at the end of the delivery note (e.g., "There is 1 reusable experience from this run, write to
lessons.md?"), then deduplicate and persist according tolessons.mdrules after confirmation.
Archiving Directory and Script Quick Reference
Default archive root: ./runs/<task>/run-YYYYMMDD-HHmmss/ (can be overridden via environment variable XHS_IMAGE_REMAKE_OUT_ROOT or --out-root), containing run.json, summary.md, gen/, local/, outputs/.
python scripts/run_store.py init --task <task_name> [--out-root <directory>] [--mode A|B]
python scripts/gen_image.py capabilities --adapter <mock|ark_seedream>
python scripts/gen_image.py quote --adapter <mock|ark_seedream> --request <req.json>
python scripts/gen_image.py run --adapter <mock|ark_seedream> --request <req.json> [--dry-run]
python scripts/render_local.py <local/page.html> <outputs/final.png> [--base-image <base.png>]
Boundaries and Red Lines
- This iteration does not include: Pure style reconstruction (redesigning composition and camera position together), side-by-side comparison images, visual decomposition reports, videos, or per-image coordinate/font size parameter tables.
- Do not hardcode any API keys, Endpoint IDs, or unit prices; all image generation calls must go through
scripts/gen_image.pyand the adapter layer.