feat: add analysis framework for Xiaohongshu content

This commit is contained in:
Jim Liu 宝玉
2026-01-17 15:52:00 -06:00
parent 2677e730b9
commit 1df5e4974d
3 changed files with 576 additions and 235 deletions
+150 -235
View File
@@ -76,264 +76,146 @@ Detailed style definitions: `references/styles/<style>.md`
Detailed layout definitions: `references/layouts/<layout>.md`
## Auto Style Selection
## Auto Selection
When no `--style` is specified, analyze content to select:
| Content Signals | Style | Layout |
|-----------------|-------|--------|
| Beauty, fashion, cute, girl, pink | `cute` | sparse/balanced |
| Health, nature, clean, fresh, organic | `fresh` | balanced/flow |
| Tech, AI, code, digital, app, tool | `tech` | dense/list |
| Life, story, emotion, feeling, warm | `warm` | balanced |
| Warning, important, must, critical | `bold` | list/comparison |
| Professional, business, elegant, simple | `minimal` | sparse/balanced |
| Classic, vintage, old, traditional | `retro` | balanced |
| Fun, exciting, wow, amazing | `pop` | sparse/list |
| Knowledge, concept, productivity, SaaS | `notion` | dense/list |
| Content Signals | Selected Style |
|----------------|----------------|
| Beauty, fashion, cute, girl, pink | `cute` |
| Health, nature, clean, fresh, organic | `fresh` |
| Tech, AI, code, digital, app, tool | `tech` |
| Life, story, emotion, feeling, warm | `warm` |
| Warning, important, must, critical | `bold` |
| Professional, business, elegant, simple | `minimal` |
| Classic, vintage, old, traditional | `retro` |
| Fun, exciting, wow, amazing | `pop` |
| Knowledge, concept, productivity, SaaS, notion | `notion` |
## Auto Layout Selection
When no `--layout` is specified, analyze content structure to select:
| Content Signals | Selected Layout |
|----------------|-----------------|
| Single quote, one key point, cover | `sparse` |
| 3-4 points, explanation, tutorial | `balanced` |
| 5+ points, summary, cheat sheet, 干货 | `dense` |
| Numbered items, top N, checklist, steps | `list` |
| vs, compare, before/after, pros/cons | `comparison` |
| Process, flow, timeline, steps with order | `flow` |
**Layout by Position**:
| Position | Recommended Layout |
|----------|-------------------|
| Cover | `sparse` |
| Content | `balanced` or content-appropriate |
| Ending | `sparse` or `balanced` |
## File Management
### With Article Path
Save to `xhs-images/` subdirectory in the same folder as the article:
## File Structure
```
posts/ai-future/
├── article.md
── xhs-images/
├── outline.md
├── prompts/
├── 01-cover.md
├── 02-content-1.md
│ └── ...
├── 01-cover.png
├── 02-content-1.png
└── 03-ending.png
[target]/
├── source.md # Source content (if pasted)
── analysis.md # Deep analysis results
├── outline-style-[slug].md # Variant A (e.g., outline-style-tech.md)
├── outline-style-[slug].md # Variant B (e.g., outline-style-notion.md)
├── outline-style-[slug].md # Variant C (e.g., outline-style-minimal.md)
├── outline.md # Final selected
├── prompts/
├── 01-cover-[slug].md
├── 02-content-[slug].md
└── ...
├── 01-cover-[slug].png
├── 02-content-[slug].png
└── NN-ending-[slug].png
```
### Without Article Path (Pasted Content)
Save to `xhs-outputs/YYYY-MM-DD/[topic-slug]/`:
```
xhs-outputs/
└── 2026-01-13/
└── ai-agent-guide/
├── source.md # Saved pasted content
├── outline.md
├── prompts/
│ ├── 01-cover.md
│ └── ...
├── 01-cover.png
└── 02-ending.png
```
**Target directory**:
- With source path: `[source-dir]/xhs-images/`
- Without source: `xhs-outputs/YYYY-MM-DD/[topic-slug]/`
## Workflow
### Step 1: Analyze Content & Select Style/Layout
### Step 1: Analyze Content → `analysis.md`
Read source content, save it if needed, and perform deep analysis.
**Actions**:
1. **Save source content** (if not already a file):
- If user provides a file path: use as-is
- If user pastes content: save to `source.md` in target directory
2. Read content
3. If `--style` specified, use that style; otherwise auto-select 3 candidates
4. If `--layout` specified, use that layout; otherwise auto-select per image
5. **Language detection**:
- Detect **source language** from content
- Detect **user language** from conversation context
- Note if source_language ≠ user_language (will ask in Step 4)
6. Determine image count based on content complexity:
2. Read source content
3. **Deep analysis** following `references/analysis-framework.md`:
- Content type classification (种草/干货/测评/教程/避坑...)
- Hook analysis (爆款标题潜力)
- Target audience identification
- Engagement potential (收藏/分享/评论)
- Visual opportunity mapping
- Swipe flow design
4. Detect source language
5. Determine recommended image count (2-10)
6. Select 3 style+layout combinations
7. **Save to `analysis.md`**
| Content Type | Image Count |
|-------------|-------------|
| Simple opinion / single topic | 2-3 |
| Medium complexity / tutorial | 4-6 |
| Deep dive / multi-dimensional | 7-10 |
### Step 2: Generate 3 Outline Variants
**Note**: Layout can vary per image in a series. Cover typically uses `sparse`, content pages use `balanced`/`dense`/`list` as appropriate.
Based on analysis, create three distinct style variants.
### Step 2: Generate Outline
**For each variant**:
1. **Generate outline** (`outline-style-[slug].md`):
- YAML front matter with style, layout, image_count
- Cover design with hook
- Each image: layout, core message, text content, visual concept
- **Written in user's preferred language**
- Reference: `references/outline-template.md`
Plan for each image with style and layout specifications:
| Variant | Selection Logic | Example Filename |
|---------|-----------------|------------------|
| A | Primary recommendation | `outline-style-tech.md` |
| B | Alternative style | `outline-style-notion.md` |
| C | Different audience/mood | `outline-style-minimal.md` |
```markdown
# Xiaohongshu Infographic Series Outline
**All variants are preserved after selection for reference.**
**Topic**: [topic description]
**Style**: [selected style]
**Default Layout**: [selected layout or "varies"]
**Image Count**: N
**Generated**: YYYY-MM-DD HH:mm
---
## Image 1 of N
**Position**: Cover
**Layout**: sparse
**Core Message**: [one-liner]
**Filename**: 01-cover.png
**Text Content**:
- Title: xxx
- Subtitle: xxx
**Visual Concept**: [style + layout appropriate description]
---
## Image 2 of N
**Position**: Content
**Layout**: [balanced/dense/list/comparison/flow]
**Core Message**: [one-liner]
**Filename**: 02-xxx.png
**Text Content**:
- Title: xxx
- Points: [list based on layout density]
**Visual Concept**: [description matching style + layout]
---
...
```
### Step 3: Save Outline
Save outline as `outline.md`.
### Step 4: Review & Confirm
**Purpose**: Let user confirm all options in a single step before image generation.
### Step 3: User Confirms All Options
**IMPORTANT**: Present ALL options in a single confirmation step using AskUserQuestion. Do NOT interrupt workflow with multiple separate confirmations.
1. **Generate 3 style variants** (if style not specified):
- Analyze content to select 3 most suitable styles
- Generate complete outline for each style variant
- Save as `outline-{style}.md` (e.g., `outline-cute.md`, `outline-notion.md`, `outline-tech.md`)
**Determine which questions to ask**:
2. **Determine which questions to ask**:
| Question | When to Ask |
|----------|-------------|
| Style variant | Always (required) |
| Default layout | Only if user might want to override |
| Language | Only if `source_language ≠ user_language` |
| Question | When to Ask |
|----------|-------------|
| Style variant | Always (required) |
| Default layout | Always (offer common options) |
| Language | Only if `source_language ≠ user_language` |
**Language handling**:
- If source language = user language: Just inform user (e.g., "Images will be in Chinese")
- If different: Ask which language to use
3. **Present options** (use AskUserQuestion with all applicable questions):
**AskUserQuestion format**:
**Question 1 (Style)** - always:
- Style A (recommended): [style name] - [brief description]
- Style B: [style name] - [brief description]
- Style C: [style name] - [brief description]
- Custom: Provide custom style reference
```
Question 1 (Style): Which style variant?
- A: tech + dense (Recommended) - 专业科技感,适合干货
- B: notion + list - 清爽知识卡片
- C: minimal + balanced - 简约高端风格
- Custom: 自定义风格描述
**Question 2 (Layout)** - always:
- sparse (Recommended for cover) - minimal info, maximum impact
- balanced - standard 3-4 points
- dense - high info density, knowledge cards
- list / comparison / flow - special formats
Question 2 (Layout) - only if relevant:
- Keep variant default (Recommended)
- sparse / balanced / dense / list / comparison / flow
**Question 3 (Language)** - only if source ≠ user language:
- [Source language] (matches content)
- [User language] (your preference)
**Language handling**:
- If source language = user language: Just inform user (e.g., "Images will be in Chinese")
- If different: Ask which language to use
4. **Apply selection**:
- Copy selected `outline-{style}.md` to `outline.md`
- If custom style provided, generate new outline with that style
- If different language selected, regenerate outline in that language
- User may edit `outline.md` directly for fine-tuning
- If modified, reload outline before proceeding
5. **Proceed only after explicit user confirmation**
### Step 5: Generate Images One by One
For each image, create a prompt file with style and layout specifications.
**Prompt Format**:
```markdown
Infographic theme: [topic]
Style: [style name]
Layout: [layout name]
Position: [cover/content/ending]
Visual composition:
- Main visual: [style-appropriate description]
- Arrangement: [layout-specific structure]
- Decorative elements: [style-specific decorations]
Color scheme:
- Primary: [style primary color]
- Background: [style background color]
- Accent: [style accent color]
Text content:
- Title: 「xxx」(large, prominent)
- Key points: [based on layout density]
Layout instructions: [layout-specific guidance]
Style notes: [style-specific characteristics]
Question 3 (Language) - only if mismatch:
- 中文 (匹配原文)
- English (your preference)
```
**Layout-Specific Instructions**:
**After confirmation**:
1. Copy selected `outline-style-[slug].md``outline.md`
2. Update YAML front matter with confirmed options
3. If custom style: regenerate outline with that style
4. User may edit `outline.md` directly for fine-tuning
| Layout | Arrangement Instructions |
|--------|-------------------------|
| `sparse` | Single focal point centered, 1-2 text elements, maximum breathing room |
| `balanced` | Title at top, 3-4 points in clear sections, moderate spacing |
| `dense` | Grid or multi-section layout, 5-8 points, compact but organized |
| `list` | Vertical numbered/bulleted list, consistent item spacing, clear hierarchy |
| `comparison` | Two-column split, clear divider, mirrored structure left/right |
| `flow` | Horizontal or vertical flow with arrows, connected nodes/steps |
### Step 4: Generate Images
With confirmed outline + style + layout:
**For each image (cover + content + ending)**:
1. Save prompt to `prompts/NN-{type}-[slug].md` (in user's preferred language)
2. Generate image using confirmed style and layout
3. Report progress after each generation
**Image Generation Skill Selection**:
1. Check available image generation skills
2. If multiple skills available, ask user to choose
- Check available image generation skills
- If multiple skills available, ask user preference
**Session Management**:
If the image generation skill supports `--sessionId`:
1. Generate a unique session ID at the start (e.g., `xhs-{topic-slug}-{timestamp}`)
2. Use the same session ID for all images in the series
3. This ensures style consistency across all generated images
If image generation skill supports `--sessionId`:
1. Generate unique session ID: `xhs-{topic-slug}-{timestamp}`
2. Use same session ID for all images
3. Ensures visual consistency across generated images
**Generation Flow**:
1. Call selected image generation skill with prompt file, output path, and session ID
2. Confirm generation success
3. Report progress: "Generated X/N"
4. Continue to next
**All prompts are written in the user's confirmed language preference.**
### Step 6: Completion Report
### Step 5: Completion Report
```
Xiaohongshu Infographic Series Complete!
@@ -344,21 +226,48 @@ Layout: [layout name or "varies"]
Location: [directory path]
Images: N total
- 01-cover.png ✓ Cover (sparse)
- 02-content-1.png ✓ Content (balanced)
- 03-content-2.png ✓ Content (dense)
- 04-ending.png ✓ Ending (sparse)
✓ analysis.md
✓ outline-style-tech.md
✓ outline-style-notion.md
✓ outline-style-minimal.md
✓ outline.md (selected: tech + dense)
Outline: outline.md
Files:
- 01-cover-[slug].png ✓ Cover (sparse)
- 02-content-[slug].png ✓ Content (balanced)
- 03-content-[slug].png ✓ Content (dense)
- 04-ending-[slug].png ✓ Ending (sparse)
```
## Image Modification
### Edit Single Image
1. Identify image to edit (e.g., `03-content-chatgpt.png`)
2. Update prompt in `prompts/03-content-chatgpt.md` if needed
3. Regenerate image using same session ID
### Add New Image
1. Specify insertion position (e.g., after image 3)
2. Create new prompt with appropriate slug
3. Generate new image
4. **Renumber files**: All subsequent images increment NN by 1
5. Update `outline.md` with new image entry
### Delete Image
1. Remove image file and prompt file
2. **Renumber files**: All subsequent images decrement NN by 1
3. Update `outline.md` to remove image entry
## Content Breakdown Principles
1. **Cover (Image 1)**: Strong visual impact, core title, attention hook`sparse` layout
2. **Content (Middle)**: Core points per image, density varies by content`balanced`/`dense`/`list`/`comparison`/`flow`
3. **Ending (Last)**: Summary / call-to-action / memorable quote`sparse` or `balanced`
1. **Cover (Image 1)**: Hook + visual impact → `sparse` layout
2. **Content (Middle)**: Core value per image → `balanced`/`dense`/`list`/`comparison`/`flow`
3. **Ending (Last)**: CTA / summary`sparse` or `balanced`
**Style × Layout Matrix** (recommended combinations):
**Style × Layout Matrix** (✓✓ = highly recommended, ✓ = works well):
| | sparse | balanced | dense | list | comparison | flow |
|---|:---:|:---:|:---:|:---:|:---:|:---:|
@@ -372,13 +281,19 @@ Outline: outline.md
| pop | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✓ |
| notion | ✓✓ | ✓✓ | ✓✓ | ✓✓ | ✓✓ | ✓✓ |
✓✓ = highly recommended, ✓ = works well
## References
Detailed templates and guidelines in `references/` directory:
- `analysis-framework.md` - XHS-specific content analysis
- `outline-template.md` - Outline format and examples
- `styles/<style>.md` - Detailed style definitions
- `layouts/<layout>.md` - Detailed layout definitions
- `base-prompt.md` - Base prompt template
## Notes
- Image generation typically takes 10-30 seconds per image
- Auto-retry once on generation failure
- Use cartoon alternatives for sensitive public figures
- Prompts written in user's confirmed language preference
- Text on images uses confirmed language
- Maintain selected style consistency across all images in series
- All prompts and text use confirmed language preference
- Maintain style consistency across all images in series