add xhs-images prompt
This commit is contained in:
parent
1ff435812c
commit
6eaa822542
|
|
@ -11,6 +11,7 @@ description: Interacts with Gemini Web to generate text and images. Use when the
|
|||
npx -y bun scripts/main.ts "Hello, Gemini"
|
||||
npx -y bun scripts/main.ts --prompt "Explain quantum computing"
|
||||
npx -y bun scripts/main.ts --prompt "A cute cat" --image cat.png
|
||||
npx -y bun scripts/main.ts --promptfiles system.md content.md --image out.png
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
|
@ -60,6 +61,7 @@ npx -y bun scripts/main.ts "Hello" --json
|
|||
| Option | Short | Description |
|
||||
|--------|-------|-------------|
|
||||
| `--prompt <text>` | `-p` | Prompt text |
|
||||
| `--promptfiles <files...>` | | Read prompt from files (concatenated in order) |
|
||||
| `--model <id>` | `-m` | Model: gemini-3-pro (default), gemini-2.5-pro, gemini-2.5-flash |
|
||||
| `--image [path]` | | Generate image, save to path (default: generated.png) |
|
||||
| `--json` | | Output as JSON |
|
||||
|
|
@ -108,3 +110,9 @@ npx -y bun scripts/main.ts "A photorealistic image of a golden retriever puppy"
|
|||
```bash
|
||||
npx -y bun scripts/main.ts "Hello" --json | jq '.text'
|
||||
```
|
||||
|
||||
### Generate image from prompt files
|
||||
```bash
|
||||
# Concatenate system.md + content.md as prompt
|
||||
npx -y bun scripts/main.ts --promptfiles system.md content.md --image output.png
|
||||
```
|
||||
|
|
|
|||
|
|
@ -19,9 +19,11 @@ function printUsage(exitCode = 0): never {
|
|||
npx -y bun skills/gemini-web/scripts/main.ts --prompt "Hello"
|
||||
npx -y bun skills/gemini-web/scripts/main.ts "Hello"
|
||||
npx -y bun skills/gemini-web/scripts/main.ts --prompt "A cute cat" --image generated.png
|
||||
npx -y bun skills/gemini-web/scripts/main.ts --promptfiles system.md content.md --image out.png
|
||||
|
||||
Options:
|
||||
-p, --prompt <text> Prompt text
|
||||
--promptfiles <files...> Read prompt from one or more files (concatenated in order)
|
||||
-m, --model <id> gemini-3-pro | gemini-2.5-pro | gemini-2.5-flash (default: gemini-3-pro)
|
||||
--json Output JSON
|
||||
--image [path] Generate an image and save it (default: ./generated.png)
|
||||
|
|
@ -51,8 +53,22 @@ async function readPromptFromStdin(): Promise<string | null> {
|
|||
return text ? text : null;
|
||||
}
|
||||
|
||||
function readPromptFiles(filePaths: string[]): string {
|
||||
const contents: string[] = [];
|
||||
for (const filePath of filePaths) {
|
||||
const resolved = path.isAbsolute(filePath) ? filePath : path.resolve(process.cwd(), filePath);
|
||||
if (!fs.existsSync(resolved)) {
|
||||
throw new Error(`Prompt file not found: ${resolved}`);
|
||||
}
|
||||
const content = fs.readFileSync(resolved, 'utf8').trim();
|
||||
contents.push(content);
|
||||
}
|
||||
return contents.join('\n\n');
|
||||
}
|
||||
|
||||
function parseArgs(argv: string[]): {
|
||||
prompt?: string;
|
||||
promptFiles?: string[];
|
||||
model?: string;
|
||||
json?: boolean;
|
||||
imagePath?: string;
|
||||
|
|
@ -101,6 +117,19 @@ function parseArgs(argv: string[]): {
|
|||
out.prompt = arg.slice('--prompt='.length);
|
||||
continue;
|
||||
}
|
||||
if (arg === '--promptfiles') {
|
||||
out.promptFiles = [];
|
||||
while (i + 1 < argv.length) {
|
||||
const next = argv[i + 1];
|
||||
if (next && !next.startsWith('-')) {
|
||||
out.promptFiles.push(next);
|
||||
i += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (arg === '--model' || arg === '-m') {
|
||||
out.model = argv[i + 1] ?? '';
|
||||
i += 1;
|
||||
|
|
@ -148,6 +177,7 @@ function parseArgs(argv: string[]): {
|
|||
if (out.imagePath === '') delete out.imagePath;
|
||||
if (out.cookiePath === '') delete out.cookiePath;
|
||||
if (out.profileDir === '') delete out.profileDir;
|
||||
if (out.promptFiles?.length === 0) delete out.promptFiles;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
@ -227,7 +257,8 @@ async function main(): Promise<void> {
|
|||
}
|
||||
|
||||
const promptFromStdin = await readPromptFromStdin();
|
||||
const prompt = args.prompt || promptFromStdin;
|
||||
const promptFromFiles = args.promptFiles ? readPromptFiles(args.promptFiles) : null;
|
||||
const prompt = promptFromFiles || args.prompt || promptFromStdin;
|
||||
if (!prompt) printUsage(1);
|
||||
|
||||
let cookieMap = await ensureGeminiCookieMap({ cookiePath, profileDir });
|
||||
|
|
|
|||
|
|
@ -0,0 +1,203 @@
|
|||
---
|
||||
name: xhs-images
|
||||
description: 小红书 (Xiaohongshu/RedNote) infographic series generator. Breaks down content into 1-10 cartoon-style infographics, generates outline and creates images using gemini-web skill.
|
||||
---
|
||||
|
||||
# 小红书 Infographic Series Generator
|
||||
|
||||
Break down complex content into eye-catching cartoon-style infographic series for Xiaohongshu (Little Red Book).
|
||||
|
||||
## Role
|
||||
|
||||
Visual content strategist specializing in breaking down complex content into engaging cartoon-style infographic series.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Option 1: Specify article path
|
||||
/xhs-images posts/ai-future/article.md
|
||||
|
||||
# Option 2: Direct content input
|
||||
/xhs-images
|
||||
[paste content]
|
||||
```
|
||||
|
||||
## File Management
|
||||
|
||||
### With Article Path
|
||||
|
||||
Save to `xhs-images/` subdirectory in the same folder as the article:
|
||||
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
### Without Article Path
|
||||
|
||||
Save to `xhs-outputs/YYYY-MM-DD/[topic-slug]/`:
|
||||
|
||||
```
|
||||
xhs-outputs/
|
||||
└── 2026-01-08/
|
||||
└── ai-agent-guide/
|
||||
├── outline.md
|
||||
├── prompts/
|
||||
│ ├── 01-cover.md
|
||||
│ └── ...
|
||||
├── 01-cover.png
|
||||
└── 02-ending.png
|
||||
```
|
||||
|
||||
- `[topic-slug]`: lowercase English with hyphens based on topic
|
||||
- **Conflict handling**: If slug directory exists, generate a different slug; never overwrite
|
||||
- Same day + same topic → same directory
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Analyze Content & Determine Image Count
|
||||
|
||||
| Content Type | Image Count |
|
||||
|-------------|-------------|
|
||||
| Simple opinion / single topic | 2-3 |
|
||||
| Medium complexity / tutorial | 4-6 |
|
||||
| Deep dive / multi-dimensional | 7-10 |
|
||||
|
||||
### Step 2: Generate Outline
|
||||
|
||||
Plan for each image:
|
||||
- Position (cover / content / ending)
|
||||
- Core message (one sentence)
|
||||
- Text content (title, subtitle, key points)
|
||||
- Visual prompt
|
||||
|
||||
**Outline Format:**
|
||||
|
||||
```markdown
|
||||
# 小红书 Infographic Series Outline
|
||||
|
||||
**Topic**: [topic description]
|
||||
**Image Count**: N
|
||||
**Generated**: YYYY-MM-DD HH:mm
|
||||
|
||||
---
|
||||
|
||||
## Image 1 of N
|
||||
|
||||
**Position**: Cover
|
||||
**Core Message**: [one-liner]
|
||||
**Filename**: 01-cover.png
|
||||
|
||||
**Text Content**:
|
||||
- Title: xxx
|
||||
- Subtitle: xxx
|
||||
|
||||
**Visual Prompt** (image-specific only, system.md provides base style):
|
||||
```
|
||||
小红书风格信息图,竖版(3:4),卡通风格,手绘风格文字,[具体背景色]背景。
|
||||
[具体内容布局描述]
|
||||
文字内容:...
|
||||
卡通元素:...
|
||||
整体风格:手绘、可爱、清新,信息精简,多留白,重点突出。
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Image 2 of N
|
||||
...
|
||||
```
|
||||
|
||||
### Step 3: Save Outline
|
||||
|
||||
Save outline as `outline.md`.
|
||||
|
||||
### Step 4: Generate Images One by One
|
||||
|
||||
For each image in the outline:
|
||||
|
||||
1. **Save prompt file** to `prompts/` subdirectory (filename matches image, .md extension):
|
||||
|
||||
```markdown
|
||||
小红书风格信息图,竖版(3:4),卡通风格,手绘风格文字,[background color]背景。
|
||||
|
||||
[Layout description: title position, text arrangement, visual hierarchy]
|
||||
|
||||
文字内容:
|
||||
- 主标题:「xxx」(大号手绘字体,居中/顶部)
|
||||
- 副标题/要点:「xxx」「xxx」
|
||||
|
||||
卡通元素:[specific elements: lightbulb icons, speech bubbles, arrows, emoji-style expressions]
|
||||
|
||||
整体风格:手绘、可爱、清新,信息精简,多留白,重点突出。
|
||||
```
|
||||
|
||||
2. **Generate image using `/gemini-web` skill**:
|
||||
|
||||
```
|
||||
/gemini-web --promptfiles [SKILL_ROOT]/skills/xhs-images/prompts/system.md [TARGET_DIR]/prompts/01-cover.md --image [TARGET_DIR]/01-cover.png
|
||||
```
|
||||
|
||||
- `[SKILL_ROOT]`: The baoyu-skills root directory
|
||||
- `--promptfiles`: Concatenates system.md (style guidelines) + image-specific prompt
|
||||
- `--image`: Output path for generated image
|
||||
|
||||
After each image:
|
||||
1. Confirm generation success
|
||||
2. Report progress: "Generated X/N"
|
||||
3. Continue to next
|
||||
|
||||
### Step 5: Completion Report
|
||||
|
||||
```
|
||||
小红书 Infographic Series Complete!
|
||||
|
||||
Topic: [topic]
|
||||
Location: [directory path]
|
||||
Images: N total
|
||||
|
||||
- 01-cover.png ✓ Cover
|
||||
- 02-content-1.png ✓ Content
|
||||
- 03-content-2.png ✓ Content
|
||||
- 04-ending.png ✓ Ending
|
||||
|
||||
Outline: outline.md
|
||||
```
|
||||
|
||||
## Content Breakdown Principles
|
||||
|
||||
1. **Cover (Image 1)**: Strong visual impact, core title, attention hook
|
||||
2. **Content (Middle)**: One core point per image, moderate information density
|
||||
3. **Ending (Last)**: Summary / call-to-action / memorable quote
|
||||
|
||||
## Visual Style Guidelines
|
||||
|
||||
- **Type**: Infographic
|
||||
- **Orientation**: Portrait, 3:4
|
||||
- **Style**: Cartoon, hand-drawn
|
||||
- **Background**: Morandi colors / cream / off-white / soft tones
|
||||
- **Text**: Must be hand-drawn style, no realistic fonts
|
||||
- **Decoration**: Simple cartoon elements, icons for visual interest
|
||||
- **Layout**: Concise info, ample whitespace, clear hierarchy
|
||||
|
||||
## Terminology
|
||||
|
||||
- Token → Token
|
||||
- AI Agent → AI 智能体
|
||||
- Vibe Coding → 凭感觉编程
|
||||
- AI Wrapper → AI 套壳
|
||||
|
||||
## Notes
|
||||
|
||||
- Image generation typically takes 10-30 seconds per image
|
||||
- Auto-retry once on generation failure
|
||||
- Use cartoon alternatives for sensitive public figures
|
||||
- Output language matches input content language
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
Create a 小红书 (Little Red Book) style infographic following these guidelines:
|
||||
|
||||
## Image Specifications
|
||||
|
||||
- **Type**: Infographic
|
||||
- **Orientation**: Portrait (vertical)
|
||||
- **Aspect Ratio**: 3:4
|
||||
- **Style**: Cartoon / Hand-drawn illustration
|
||||
|
||||
## Background & Colors
|
||||
|
||||
- Use soft, gentle color palettes: Morandi colors, cream, off-white, light pink, mint green
|
||||
- Colors should be cohesive and harmonious
|
||||
- Match 小红书's aesthetic preferences
|
||||
|
||||
## Text Style (CRITICAL)
|
||||
|
||||
- **ALL text MUST be hand-drawn style**
|
||||
- Main titles should be prominent and eye-catching
|
||||
- Key text should be bold and enlarged
|
||||
- Use highlighter effects to emphasize keywords
|
||||
- **DO NOT use realistic or computer-generated fonts**
|
||||
|
||||
## Decorative Elements
|
||||
|
||||
- Include simple cartoon elements, icons to enhance visual interest and memorability
|
||||
- Acceptable: emoji-style icons, hand-drawn stickers, sticky note textures, speech bubbles
|
||||
- If content involves sensitive or copyrighted figures, create stylistically similar cartoon alternatives - DO NOT refuse to generate
|
||||
- **ALL visual elements MUST be hand-drawn/cartoon style - NO realistic imagery**
|
||||
|
||||
## Layout Principles
|
||||
|
||||
- Keep information concise, highlight keywords and core concepts
|
||||
- Use ample whitespace for easy visual scanning
|
||||
- Present points in clearly separated sections
|
||||
- Maintain clear visual hierarchy
|
||||
|
||||
## Language
|
||||
|
||||
- Unless otherwise specified, use Chinese (中文)
|
||||
- Use Chinese full-width punctuation: "",。!
|
||||
|
||||
---
|
||||
|
||||
Please generate the infographic based on the content provided below:
|
||||
Loading…
Reference in New Issue