From ec6781a231deb5928474df80ea0c22181d8eed4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Liu=20=E5=AE=9D=E7=8E=89?= Date: Sun, 1 Feb 2026 19:48:46 -0600 Subject: [PATCH] feat(baoyu-article-illustrator): add reference image support - Add reference image handling with direct/style/palette usage types - Enhance first-time setup as blocking operation - Update prompt construction with reference frontmatter format --- skills/baoyu-article-illustrator/SKILL.md | 213 ++++++++++++++---- .../references/config/first-time-setup.md | 8 + .../references/prompt-construction.md | 49 ++++ 3 files changed, 231 insertions(+), 39 deletions(-) diff --git a/skills/baoyu-article-illustrator/SKILL.md b/skills/baoyu-article-illustrator/SKILL.md index 47fa9ad..0449402 100644 --- a/skills/baoyu-article-illustrator/SKILL.md +++ b/skills/baoyu-article-illustrator/SKILL.md @@ -60,10 +60,22 @@ Copy this checklist and track progress: ``` Progress: - [ ] Step 1: Pre-check + - [ ] 1.5 Check preferences (EXTEND.md) ⛔ BLOCKING + - [ ] Found → load preferences → continue + - [ ] Not found → run first-time setup → MUST complete before other steps + - [ ] 1.0 Reference images ⚠️ (if provided) + - [ ] File path given → saved to references/ ✓ + - [ ] No path → asked user OR extracted verbally + - [ ] 1.2-1.4 Config questions (1 AskUserQuestion, max 4 Qs) - [ ] Step 2: Setup & Analyze -- [ ] Step 3: Confirm Settings ⚠️ REQUIRED +- [ ] Step 3: Confirm Settings (1 AskUserQuestion, max 4 Qs) + - [ ] Q1: Type ⚠️ + - [ ] Q2: Density ⚠️ MUST ASK + - [ ] Q3: Style ⚠️ - [ ] Step 4: Generate Outline - [ ] Step 5: Generate Images + - [ ] 5.1 Prompts created (references in frontmatter ONLY if files exist) + - [ ] 5.3 References verified before generation - [ ] Step 6: Finalize ``` @@ -71,6 +83,55 @@ Progress: ### Step 1: Pre-check +**1.0 Detect & Save Reference Images** ⚠️ REQUIRED if images provided + +Check if user provided reference images. Handle based on input type: + +| Input Type | Action | +|------------|--------| +| Image file path provided | Copy to `references/` subdirectory → can use `--ref` | +| Image in conversation (no path) | **ASK user for file path** with AskUserQuestion | +| User can't provide path | Extract style/palette verbally → append to prompts (NO frontmatter references) | + +**CRITICAL**: Only add `references` to prompt frontmatter if files are ACTUALLY SAVED to `references/` directory. + +**If user provides file path**: +1. Copy to `references/NN-ref-{slug}.png` +2. Create description: `references/NN-ref-{slug}.md` +3. Verify files exist before proceeding + +**If user can't provide path** (extracted verbally): +1. Analyze image visually, extract: colors, style, composition +2. Create `references/extracted-style.md` with extracted info +3. DO NOT add `references` to prompt frontmatter +4. Instead, append extracted style/colors directly to prompt text + +**Description File Format** (only when file saved): +```yaml +--- +ref_id: NN +filename: NN-ref-{slug}.png +--- +[User's description or auto-generated description] +``` + +**Verification** (only for saved files): +``` +Reference Images Saved: +- 01-ref-{slug}.png ✓ (can use --ref) +- 02-ref-{slug}.png ✓ (can use --ref) +``` + +**Or for extracted style**: +``` +Reference Style Extracted (no file): +- Colors: #E8756D coral, #7ECFC0 mint... +- Style: minimal flat vector, clean lines... +→ Will append to prompt text (not --ref) +``` + +--- + **1.1 Determine Input Type** | Input | Output Directory | Next | @@ -80,41 +141,30 @@ Progress: **Backup rule for pasted content**: If `source.md` exists in target directory, rename to `source-backup-YYYYMMDD-HHMMSS.md` before saving. -**1.2 Determine Output Directory** (file path input only) +**1.2-1.4 Configuration** (file path input only) -Check `default_output_dir` in preferences: +Check preferences and existing state, then ask ALL needed questions in ONE AskUserQuestion call (max 4 questions). -| Preference Value | Action | -|------------------|--------| -| `same-dir` | Use `{article-dir}/`, display "Output: {path}" | -| `imgs-subdir` | Use `{article-dir}/imgs/`, display "Output: {path}" | -| `illustrations-subdir` | Use `{article-dir}/illustrations/`, display "Output: {path}" | -| `independent` | Use `illustrations/{topic-slug}/`, display "Output: {path}" | -| Not configured | **MUST** ask with AskUserQuestion ↓ | +**Questions to include** (skip if preference exists or not applicable): -**AskUserQuestion** (when no preference): -- `{article-dir}/` - Same directory as article -- `{article-dir}/imgs/` - Images subdirectory -- `{article-dir}/illustrations/` - Illustrations subdirectory (Recommended) -- `illustrations/{topic-slug}/` - Independent directory -- Save as default - Remember this choice for future runs +| Question | When to Ask | Options | +|----------|-------------|---------| +| Output directory | No `default_output_dir` in EXTEND.md | `{article-dir}/`, `{article-dir}/imgs/` (Recommended), `{article-dir}/illustrations/`, `illustrations/{topic-slug}/` | +| Existing images | Target dir has `.png/.jpg/.webp` files | `supplement`, `overwrite`, `regenerate` | +| Article update | Always (file path input) | `update`, `copy` | -**1.3 Check Existing Images** +**Preference Values** (if configured, skip asking): -Scan target directory for `.png/.jpg/.webp` files. +| `default_output_dir` | Path | +|----------------------|------| +| `same-dir` | `{article-dir}/` | +| `imgs-subdir` | `{article-dir}/imgs/` | +| `illustrations-subdir` | `{article-dir}/illustrations/` | +| `independent` | `illustrations/{topic-slug}/` | -If images exist → AskUserQuestion: How to handle? -- `supplement` - Keep existing, generate only new positions -- `overwrite` - Overwrite same-name files -- `regenerate` - Clear all and regenerate +**1.5 Load Preferences (EXTEND.md) ⛔ BLOCKING** -**1.4 Confirm Article Update Method** (file path input only) - -AskUserQuestion: How to update article? -- `update` - Modify original file directly -- `copy` - Create `{name}-illustrated.md` copy - -**1.5 Load Preferences (EXTEND.md)** +**CRITICAL**: If EXTEND.md not found, MUST complete first-time setup before ANY other questions or steps. Do NOT proceed to reference images, do NOT ask about content, do NOT ask about type/style — ONLY complete the preferences setup first. ```bash test -f .baoyu-skills/baoyu-article-illustrator/EXTEND.md && echo "project" @@ -123,8 +173,8 @@ test -f "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "user" | Result | Action | |--------|--------| -| Found | Read, parse, display summary | -| Not found | Ask with AskUserQuestion (see references/config/first-time-setup.md) | +| Found | Read, parse, display summary → Continue | +| Not found | ⛔ **BLOCKING**: Run first-time setup ONLY ([references/config/first-time-setup.md](references/config/first-time-setup.md)) → Complete and save EXTEND.md → Then continue | **Supports**: Watermark | Preferred type/style | Custom styles | Language | Output directory @@ -164,22 +214,41 @@ test -f "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "user" - Decorative scenes - Generic illustrations +**2.4 Analyze Reference Images** (if provided in Step 1.0) + +For each reference image: + +| Analysis | Description | +|----------|-------------| +| Visual characteristics | Style, colors, composition | +| Content/subject | What the reference depicts | +| Suitable positions | Which sections match this reference | +| Style match | Which illustration types/styles align | +| Usage recommendation | `direct` / `style` / `palette` | + +| Usage | When to Use | +|-------|-------------| +| `direct` | Reference matches desired output closely | +| `style` | Extract visual style characteristics only | +| `palette` | Extract color scheme only | + --- ### Step 3: Confirm Settings ⚠️ -**Do NOT skip.** Use AskUserQuestion with 3-4 questions in ONE call. +**Do NOT skip.** Use ONE AskUserQuestion call with max 4 questions. **Q1, Q2, Q3 are ALL REQUIRED.** -**Q1: Illustration Type** +**Q1: Illustration Type** ⚠️ REQUIRED - [Recommended based on analysis] (Recommended) - infographic / scene / flowchart / comparison / framework / timeline / mixed -**Q2: Density** +**Q2: Density** ⚠️ REQUIRED - DO NOT SKIP - minimal (1-2) - Core concepts only -- balanced (3-5) (Recommended) - Major sections -- rich (6+) - Comprehensive support +- balanced (3-5) - Major sections +- per-section - At least 1 per section/chapter (Recommended) +- rich (6+) - Comprehensive coverage -**Q3: Style** (ALWAYS ask, even with preferred_style in EXTEND.md) +**Q3: Style** ⚠️ REQUIRED (ALWAYS ask, even with preferred_style in EXTEND.md) If EXTEND.md has `preferred_style`: - [Custom style name + brief description] (Recommended) @@ -199,6 +268,18 @@ Full specs: `references/styles/