@justin_666/square-couplets-master-skills 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -1
- package/bin/doufang-image.js +34 -0
- package/bin/doufang-init.js +81 -2
- package/bin/doufang-optimize.js +34 -0
- package/bin/doufang-prompt.js +34 -0
- package/constants.ts +240 -0
- package/package.json +10 -3
- package/services/geminiService.ts +236 -0
- package/skills/README.md +40 -1
- package/skills/generate-doufang-image/index.js +202 -0
- package/skills/generate-doufang-prompt/index.js +141 -0
- package/skills/optimize-doufang-prompt/index.js +103 -0
- package/types.ts +70 -0
- package/utils/errorHandler.ts +123 -0
- package/utils/imageUtils.ts +135 -0
- package/utils/retry.ts +41 -0
package/README.md
CHANGED
|
@@ -167,6 +167,13 @@ doufang init --ai claude
|
|
|
167
167
|
|
|
168
168
|
初始化後,在 Cursor / Windsurf / Antigravity 中使用 slash command:
|
|
169
169
|
|
|
170
|
+
**在 Cursor 中(自動註冊):**
|
|
171
|
+
- 執行 `doufang init --ai cursor` 後,`/doufang` 命令會自動註冊
|
|
172
|
+
- 輸入 `/` 會看到 `/doufang` 選項
|
|
173
|
+
- 選擇後輸入請求,例如:"Generate a prompt for wealth theme"
|
|
174
|
+
- Cursor 會自動使用 CLI 工具執行,無需手動編寫代碼
|
|
175
|
+
|
|
176
|
+
**在 Windsurf / Antigravity 中:**
|
|
170
177
|
```
|
|
171
178
|
/doufang Generate a prompt for wealth theme
|
|
172
179
|
/doufang Create a 2K image using Gemini 3 Pro
|
|
@@ -175,8 +182,9 @@ doufang init --ai claude
|
|
|
175
182
|
|
|
176
183
|
### CLI 工具命令
|
|
177
184
|
|
|
178
|
-
|
|
185
|
+
安裝後,您可以使用多個 CLI 命令:
|
|
179
186
|
|
|
187
|
+
**管理 Skills:**
|
|
180
188
|
```bash
|
|
181
189
|
# 列出所有可用的 skills
|
|
182
190
|
doufang-skills list
|
|
@@ -191,6 +199,25 @@ doufang-skills path generate-doufang-image
|
|
|
191
199
|
doufang-skills help
|
|
192
200
|
```
|
|
193
201
|
|
|
202
|
+
**執行 Skills(Agent 可直接調用):**
|
|
203
|
+
```bash
|
|
204
|
+
# 生成 prompt
|
|
205
|
+
doufang-prompt "財富"
|
|
206
|
+
doufang-prompt "健康" images/reference.png
|
|
207
|
+
|
|
208
|
+
# 生成圖片
|
|
209
|
+
doufang-image "A diamond-shaped Doufang..." gemini-3-pro-image-preview 2K
|
|
210
|
+
doufang-image "..." gemini-2.5-flash-image 1K images/ref.png output/my-doufang.png
|
|
211
|
+
|
|
212
|
+
# 優化 prompt
|
|
213
|
+
doufang-optimize "A diamond-shaped Doufang with wide white margins..."
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Agent 使用方式:**
|
|
217
|
+
Agent 可以直接執行這些 CLI 命令來生成圖片,無需手動編寫代碼。例如:
|
|
218
|
+
- Agent 執行:`doufang-prompt "財富"` → 獲得 prompt
|
|
219
|
+
- Agent 執行:`doufang-image "<prompt>" gemini-3-pro-image-preview 2K` → 生成圖片
|
|
220
|
+
|
|
194
221
|
### 本地安裝
|
|
195
222
|
|
|
196
223
|
```bash
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI command for generate-doufang-image skill
|
|
5
|
+
* Usage: doufang-image <prompt> [model] [size] [reference-image] [output-path]
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, join, resolve } from 'path';
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
const packageRoot = resolve(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// Path to the skill script
|
|
17
|
+
const skillScript = join(packageRoot, 'skills', 'generate-doufang-image', 'index.js');
|
|
18
|
+
|
|
19
|
+
// Forward all arguments to the skill script
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
const child = spawn('node', [skillScript, ...args], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
cwd: process.cwd()
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.on('error', (error) => {
|
|
28
|
+
console.error('Error:', error.message);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on('exit', (code) => {
|
|
33
|
+
process.exit(code || 0);
|
|
34
|
+
});
|
package/bin/doufang-init.js
CHANGED
|
@@ -106,10 +106,89 @@ Skills are located in the \`skills/\` directory.
|
|
|
106
106
|
writeFileSync(cursorRulesPath, cursorRules);
|
|
107
107
|
console.log(` ✅ Created ${cursorRulesPath}`);
|
|
108
108
|
|
|
109
|
+
// Create .cursor/rules directory for slash command
|
|
110
|
+
const cursorRulesDir = join(projectPath, '.cursor', 'rules');
|
|
111
|
+
if (!existsSync(cursorRulesDir)) {
|
|
112
|
+
mkdirSync(cursorRulesDir, { recursive: true });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Create doufang.mdc rule file for slash command
|
|
116
|
+
const doufangRulePath = join(cursorRulesDir, 'doufang.mdc');
|
|
117
|
+
const doufangRule = `---
|
|
118
|
+
description: Generate Chinese New Year Doufang artwork using Doufang Skills. Use /doufang command to generate prompts, images, or optimize prompts.
|
|
119
|
+
globs:
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
# Doufang Skills - Slash Command Handler
|
|
123
|
+
|
|
124
|
+
You are a Doufang assistant. When the user uses the \`/doufang\` command or asks about Doufang functionality, follow these guidelines:
|
|
125
|
+
|
|
126
|
+
## Available CLI Commands
|
|
127
|
+
|
|
128
|
+
1. **Generate Prompt**: \`doufang-prompt <keyword> [reference-image]\`
|
|
129
|
+
- Generates a professional Doufang artwork prompt based on a keyword
|
|
130
|
+
- Example: \`doufang-prompt "財富"\`
|
|
131
|
+
- Example with reference: \`doufang-prompt "健康" images/reference.png\`
|
|
132
|
+
|
|
133
|
+
2. **Generate Image**: \`doufang-image <prompt> [model] [size] [reference-image] [output-path]\`
|
|
134
|
+
- Generates actual Doufang artwork images using Gemini API
|
|
135
|
+
- Models: \`gemini-2.5-flash-image\` (fast, 1K only) or \`gemini-3-pro-image-preview\` (high quality, 1K/2K/4K)
|
|
136
|
+
- Sizes: \`1K\` (default), \`2K\`, \`4K\` (Pro model only)
|
|
137
|
+
- Example: \`doufang-image "A diamond-shaped Doufang..." gemini-3-pro-image-preview 2K\`
|
|
138
|
+
|
|
139
|
+
3. **Optimize Prompt**: \`doufang-optimize <prompt>\`
|
|
140
|
+
- Optimizes prompts to reduce white margins and improve composition
|
|
141
|
+
- Example: \`doufang-optimize "A prompt with wide margins..."\`
|
|
142
|
+
|
|
143
|
+
## Execution Guidelines
|
|
144
|
+
|
|
145
|
+
- **Direct CLI Execution**: When user requests Doufang functionality, directly execute the appropriate CLI command using terminal, do NOT create .js files
|
|
146
|
+
- **Read API Key**: Automatically read GEMINI_API_KEY from .env or .env.local file
|
|
147
|
+
- **Ask for Details**: If user doesn't provide required parameters (like keyword or prompt), ask for clarification
|
|
148
|
+
- **Error Handling**: If API key is missing, guide user to set GEMINI_API_KEY in .env file
|
|
149
|
+
- **Output Format**: For prompt generation, output JSON format. For image generation, save to output/ directory and provide file path
|
|
150
|
+
|
|
151
|
+
## Common Workflows
|
|
152
|
+
|
|
153
|
+
### Generate Image from Keyword
|
|
154
|
+
1. Generate prompt: \`doufang-prompt "財富"\`
|
|
155
|
+
2. Extract imagePrompt from JSON output
|
|
156
|
+
3. Generate image: \`doufang-image "<imagePrompt>" gemini-3-pro-image-preview 2K\`
|
|
157
|
+
|
|
158
|
+
### Generate Image with Reference
|
|
159
|
+
1. Generate prompt with reference: \`doufang-prompt "健康" images/reference.png\`
|
|
160
|
+
2. Extract imagePrompt from JSON output
|
|
161
|
+
3. Generate image: \`doufang-image "<imagePrompt>" gemini-3-pro-image-preview 2K images/reference.png\`
|
|
162
|
+
|
|
163
|
+
### Optimize and Generate
|
|
164
|
+
1. Generate prompt: \`doufang-prompt "財富"\`
|
|
165
|
+
2. Optimize prompt: \`doufang-optimize "<imagePrompt>"\`
|
|
166
|
+
3. Generate image with optimized prompt: \`doufang-image "<optimizedPrompt>" gemini-3-pro-image-preview 2K\`
|
|
167
|
+
|
|
168
|
+
## Skills Location
|
|
169
|
+
|
|
170
|
+
Skills are located in the \`skills/\` directory. Each skill has a \`SKILL.md\` file with detailed instructions.
|
|
171
|
+
|
|
172
|
+
## API Key Setup
|
|
173
|
+
|
|
174
|
+
The \`generate-doufang-image\` command requires GEMINI_API_KEY. Check for it in:
|
|
175
|
+
- .env.local (priority)
|
|
176
|
+
- .env
|
|
177
|
+
- Environment variable GEMINI_API_KEY
|
|
178
|
+
|
|
179
|
+
Get API key from: https://aistudio.google.com/
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
writeFileSync(doufangRulePath, doufangRule);
|
|
183
|
+
console.log(` ✅ Created ${doufangRulePath}`);
|
|
184
|
+
console.log(` ✅ Slash command /doufang registered in Cursor`);
|
|
185
|
+
|
|
109
186
|
console.log('\n✨ Cursor setup complete!');
|
|
110
187
|
console.log('\n📝 Usage:');
|
|
111
|
-
console.log(' Type "/
|
|
112
|
-
console.log('
|
|
188
|
+
console.log(' 1. Type "/" in Cursor chat to see available commands');
|
|
189
|
+
console.log(' 2. Select "/doufang" from the dropdown');
|
|
190
|
+
console.log(' 3. Enter your request, e.g.: "Generate a prompt for wealth theme"');
|
|
191
|
+
console.log(' 4. Or directly type: /doufang Generate a prompt for wealth theme');
|
|
113
192
|
|
|
114
193
|
return true;
|
|
115
194
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI command for optimize-doufang-prompt skill
|
|
5
|
+
* Usage: doufang-optimize <prompt>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, join, resolve } from 'path';
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
const packageRoot = resolve(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// Path to the skill script
|
|
17
|
+
const skillScript = join(packageRoot, 'skills', 'optimize-doufang-prompt', 'index.js');
|
|
18
|
+
|
|
19
|
+
// Forward all arguments to the skill script
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
const child = spawn('node', [skillScript, ...args], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
cwd: process.cwd()
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.on('error', (error) => {
|
|
28
|
+
console.error('Error:', error.message);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on('exit', (code) => {
|
|
33
|
+
process.exit(code || 0);
|
|
34
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI command for generate-doufang-prompt skill
|
|
5
|
+
* Usage: doufang-prompt <keyword> [reference-image]
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, join, resolve } from 'path';
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
const packageRoot = resolve(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// Path to the skill script
|
|
17
|
+
const skillScript = join(packageRoot, 'skills', 'generate-doufang-prompt', 'index.js');
|
|
18
|
+
|
|
19
|
+
// Forward all arguments to the skill script
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
const child = spawn('node', [skillScript, ...args], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
cwd: process.cwd()
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.on('error', (error) => {
|
|
28
|
+
console.error('Error:', error.message);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on('exit', (code) => {
|
|
33
|
+
process.exit(code || 0);
|
|
34
|
+
});
|
package/constants.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Image Processing Constants
|
|
2
|
+
export const IMAGE_CONSTANTS = {
|
|
3
|
+
MAX_SIZE_KB: 500,
|
|
4
|
+
MAX_DIMENSION: 1920,
|
|
5
|
+
MAX_FILE_SIZE_MB: 10,
|
|
6
|
+
COMPRESSION_QUALITY: 0.85,
|
|
7
|
+
MIN_COMPRESSION_QUALITY: 0.1
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
// Base system prompt for generating Doufang prompts
|
|
11
|
+
export const DOUFANG_SYSTEM_PROMPT = `
|
|
12
|
+
You are a professional Chinese New Year couplet and calligraphy art designer.
|
|
13
|
+
|
|
14
|
+
Your task is to generate a high-end, printable Chinese New Year "Doufang" (diamond-shaped) couplet artwork prompt based on ONE keyword provided by the user.
|
|
15
|
+
|
|
16
|
+
Step 1: Understand the meaning and blessing intention of the keyword.
|
|
17
|
+
- If the keyword is about wealth -> design a wealth-themed couplet.
|
|
18
|
+
- If about health -> design a health & longevity themed couplet.
|
|
19
|
+
- If about career -> design a success & promotion themed couplet.
|
|
20
|
+
- If about peace -> design a safety & harmony themed couplet.
|
|
21
|
+
- If about love -> design a relationship & harmony themed couplet.
|
|
22
|
+
- If about study -> design wisdom & academic success themed couplet.
|
|
23
|
+
- If about general luck -> design auspicious & good fortune themed couplet.
|
|
24
|
+
|
|
25
|
+
Step 2: Decide the final 4-character Chinese blessing phrase automatically.
|
|
26
|
+
- The phrase must be elegant, common in Chinese New Year usage, and culturally appropriate.
|
|
27
|
+
- If the user input itself is suitable (e.g. "馬上發財", "平安喜樂"), you may use it directly.
|
|
28
|
+
- Otherwise, transform or upgrade it into a proper 4-character blessing phrase.
|
|
29
|
+
|
|
30
|
+
Step 3: Generate the artwork prompt with the following visual style:
|
|
31
|
+
|
|
32
|
+
Artwork description:
|
|
33
|
+
A diamond-shaped Chinese New Year "Doufang" couplet on antique gold-flecked red Xuan paper.
|
|
34
|
+
|
|
35
|
+
Central theme: bold, powerful, energetic traditional Chinese ink wash calligraphy of the final 4-character blessing phrase: [INSERT PHRASE HERE].
|
|
36
|
+
|
|
37
|
+
Around the calligraphy: symbolic elements that visually represent the user's keyword, painted in traditional Chinese ink painting style (for example: horse, dragon, pine tree, crane, gold ingots, clouds, mountains, sun, plum blossoms, etc).
|
|
38
|
+
|
|
39
|
+
Style: traditional Chinese ink painting mixed with realistic illustration, elegant, prestigious, festive but high-class, not cartoon.
|
|
40
|
+
|
|
41
|
+
Material & texture: real Xuan paper texture, gold flecks, red rice paper, visible paper fibers, natural ink diffusion, subtle embossed gold foil details.
|
|
42
|
+
|
|
43
|
+
Color theme: deep Chinese red, gold, black ink, warm highlights.
|
|
44
|
+
|
|
45
|
+
Lighting: soft studio lighting, gentle glow on gold details, museum-quality artwork.
|
|
46
|
+
|
|
47
|
+
Composition:
|
|
48
|
+
The diamond-shaped Doufang fills the majority of the 1:1 frame, centered with minimal elegant margins (approximately 2-5% of frame width, just enough to prevent edge cropping).
|
|
49
|
+
The entire artwork is fully visible inside the frame, not touching any edge, not cropped, not cut off.
|
|
50
|
+
The Doufang should occupy 85-95% of the image area, maximizing visual impact.
|
|
51
|
+
Clean background, symmetrical, perfectly framed, suitable for printing and hanging on wall.
|
|
52
|
+
|
|
53
|
+
Quality: ultra high detail, 8k, masterpiece, professional artwork, 1:1 aspect ratio.
|
|
54
|
+
|
|
55
|
+
Framing requirements:
|
|
56
|
+
- The entire diamond-shaped Doufang must be fully visible inside the image.
|
|
57
|
+
- No part of the artwork is cut off, cropped, out of frame, or touching the image borders.
|
|
58
|
+
- Minimal margins - the Doufang should fill most of the frame (85-95% of image area).
|
|
59
|
+
|
|
60
|
+
Text requirements:
|
|
61
|
+
- The Chinese characters must be clear, correct, readable.
|
|
62
|
+
- No typo, no deformed text.
|
|
63
|
+
- No modern elements, no western style, no watermark.
|
|
64
|
+
|
|
65
|
+
OUTPUT FORMAT:
|
|
66
|
+
Return a JSON object with the following structure:
|
|
67
|
+
{
|
|
68
|
+
"blessingPhrase": "The 4 character phrase you chose",
|
|
69
|
+
"imagePrompt": "The full detailed English image generation prompt based on the instructions above."
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
export const getDoufangSystemPromptWithReference = (): string => {
|
|
74
|
+
return `You are a professional Chinese New Year Doufang (diamond-shaped couplet) designer and calligrapher.
|
|
75
|
+
|
|
76
|
+
### CORE MISSION:
|
|
77
|
+
Your task is to analyze a REFERENCE IMAGE and a KEYWORD to create a unique, high-end Chinese New Year Doufang. The reference image is your PRIMARY visual guide for style, subject category, and material language — but it must NEVER be copied.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### STEP 1: KEYWORD & BLESSING LOGIC
|
|
82
|
+
Transform the user's keyword into a 4-character Chinese blessing phrase:
|
|
83
|
+
- Wealth -> e.g., 招財進寶, 富貴吉祥
|
|
84
|
+
- Health -> e.g., 龍馬精神, 延年益壽
|
|
85
|
+
- Career/Success -> e.g., 大展宏圖, 步步高升
|
|
86
|
+
- Peace/Harmony -> e.g., 平安喜樂, 歲歲平安
|
|
87
|
+
- Love -> e.g., 永結同心, 花好月圓
|
|
88
|
+
- Custom -> If the user provides a 4-character phrase, use it directly.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### STEP 2: REFERENCE IMAGE DNA EXTRACTION (CRITICAL)
|
|
93
|
+
Analyze the reference image and extract the following "Visual DNA":
|
|
94
|
+
1. **Primary Subject Category**: Identify the type of subject (e.g., cat, dragon, robot, girl), not the exact instance.
|
|
95
|
+
2. **Artistic Style**: Is it 3D render, minimalist, oil painting, ink painting, cyberpunk, paper-cut, etc.
|
|
96
|
+
3. **Material & Texture Language**: e.g., glossy plastic, brushed metal, rough impasto, rice paper fibers, silk, ceramic.
|
|
97
|
+
4. **Color Language**: Identify the dominant colors beyond standard red/gold.
|
|
98
|
+
5. **Shape Language & Design Grammar**: e.g., rounded cute proportions, sharp mechanical shapes, flowing ink strokes, geometric blocks.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### STEP 2.5: REFERENCE TRANSFORMATION RULE (EXTREMELY IMPORTANT)
|
|
103
|
+
The reference image is **NOT** to be copied, replicated, traced, or minimally modified.
|
|
104
|
+
|
|
105
|
+
- You MUST:
|
|
106
|
+
- Keep the same **artistic style, subject category, and material feeling**
|
|
107
|
+
- But **redesign the pose, composition, structure, and details**
|
|
108
|
+
- You MUST:
|
|
109
|
+
- Change at least **3 major visual aspects** (for example: pose, camera angle, composition, costume/ornamentation, structure, surface details, silhouette, or proportion)
|
|
110
|
+
- The final artwork must:
|
|
111
|
+
- Be **clearly inspired by** the reference image
|
|
112
|
+
- But **obviously a new original creation**, not a variant, not a replica
|
|
113
|
+
- Think of it as:
|
|
114
|
+
> "Same species, same art director, but a completely new photoshoot."
|
|
115
|
+
|
|
116
|
+
- You MUST absolutely avoid:
|
|
117
|
+
- Same pose
|
|
118
|
+
- Same composition
|
|
119
|
+
- Same framing
|
|
120
|
+
- Same silhouette
|
|
121
|
+
- Any form of visual overlay similarity
|
|
122
|
+
|
|
123
|
+
- The generated image must not be visually alignable or overlayable with the reference image.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### STEP 3: ARTWORK SPECIFICATIONS (DOUFANG FORMAT)
|
|
128
|
+
- **Shape**: A perfect diamond-shaped (rotated square) "Doufang".
|
|
129
|
+
- **Background**: Traditional deep vermilion or "Wanshou" red Xuan paper, but infused with textures or visual language from the reference image.
|
|
130
|
+
- **Calligraphy Layout**: The 4-character blessing MUST be arranged in a **balanced 2x2 square grid** at the center.
|
|
131
|
+
- **Integration**: The subject inspired by the reference image should interact with the calligraphy (e.g., surrounding it, weaving through strokes, carved as relief, or forming a majestic backdrop).
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### STEP 4: PROMPT CONSTRUCTION GUIDELINES
|
|
136
|
+
Your generated "imagePrompt" must follow this logic:
|
|
137
|
+
- **Style Fusion**: Do NOT just say "ink painting." Instead, say "Traditional Doufang reimagined in [Style from Reference Image]."
|
|
138
|
+
- **Subject Redesign**: Describe the subject as "a reimagined, redesigned, and re-composed version inspired by the reference, not a copy".
|
|
139
|
+
- **Subject Adaptation**: Always adapt the subject into an auspicious Chinese New Year version.
|
|
140
|
+
- **Materiality**: Combine "red gold-flecked Xuan paper" with the material language from the reference (e.g., ceramic, metal, plastic, silk, oil paint).
|
|
141
|
+
- **Lighting**: Use high-end studio lighting or museum-grade lighting to emphasize the diamond shape, material depth, and calligraphy relief.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
### FINAL OUTPUT CONSTRAINTS:
|
|
146
|
+
1. **Framing**:
|
|
147
|
+
- The entire diamond Doufang must be fully contained within the 1:1 frame.
|
|
148
|
+
- Minimal, elegant margins - just enough to prevent edge cropping (approximately 2-5% of frame width).
|
|
149
|
+
- The Doufang should fill most of the frame (85-95% of the image area).
|
|
150
|
+
- No cropping, no touching edges, no cut-off.
|
|
151
|
+
2. **Text Quality**:
|
|
152
|
+
- Calligraphy must be clear, professional, and correctly written.
|
|
153
|
+
- No distorted strokes, no typos.
|
|
154
|
+
3. **No Modern Junk**:
|
|
155
|
+
- No UI elements, no watermarks, no photography credits, no signatures.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
Composition:
|
|
160
|
+
The diamond-shaped Doufang fills the majority of the 1:1 frame, centered with minimal elegant margins (just enough to prevent edge cropping, approximately 2-5% of frame width).
|
|
161
|
+
The entire artwork is fully visible inside the frame, not touching any edge, not cropped, not cut off.
|
|
162
|
+
The Doufang should occupy 85-95% of the image area, maximizing visual impact.
|
|
163
|
+
Clean background, symmetrical, perfectly framed, suitable for printing and hanging on wall.
|
|
164
|
+
|
|
165
|
+
Quality: ultra high detail, 8k, masterpiece, professional artwork, 1:1 aspect ratio.
|
|
166
|
+
|
|
167
|
+
Framing requirements:
|
|
168
|
+
- The entire diamond-shaped Doufang must be fully visible inside the image.
|
|
169
|
+
- No part of the artwork is cut off, cropped, out of frame, or touching the image borders.
|
|
170
|
+
- Minimal margins - the Doufang should fill most of the frame (85-95% of image area).
|
|
171
|
+
|
|
172
|
+
Text requirements:
|
|
173
|
+
- The Chinese characters must be clear, correct, readable.
|
|
174
|
+
- No typo, no deformed text.
|
|
175
|
+
- No modern elements, no western style, no watermark.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### OUTPUT FORMAT (JSON ONLY):
|
|
180
|
+
Return only a JSON object:
|
|
181
|
+
{
|
|
182
|
+
"blessingPhrase": "The chosen 4-character phrase",
|
|
183
|
+
"analysis": "Briefly describe what you extracted from the reference image and how you transformed it",
|
|
184
|
+
"imagePrompt": "A highly detailed, around 200-word English prompt that blends the reference image DNA with the Doufang requirements. Focus on textures, lighting, redesigned subject, 2x2 text layout, and centering."
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
// User input prompt template for reference image analysis
|
|
191
|
+
export const getReferenceImageAnalysisPrompt = (userKeyword: string): string => {
|
|
192
|
+
return `User input keyword: 「${userKeyword}」
|
|
193
|
+
|
|
194
|
+
CRITICAL INSTRUCTION: A reference image has been provided above. You MUST analyze this reference image in detail and generate a prompt that DIRECTLY USES the reference image's visual content, patterns, and style.
|
|
195
|
+
|
|
196
|
+
STEP-BY-STEP ANALYSIS REQUIRED:
|
|
197
|
+
1. FIRST, describe what you see in the reference image:
|
|
198
|
+
- What is the main subject or central figure? (e.g., samurai, warrior, character, object, etc.)
|
|
199
|
+
- What specific visual patterns, motifs, or decorative elements are present?
|
|
200
|
+
- What is the composition structure? How are elements arranged?
|
|
201
|
+
- What are the distinctive visual characteristics? (shapes, forms, graphic elements)
|
|
202
|
+
- What background elements or environmental details are visible?
|
|
203
|
+
|
|
204
|
+
2. THEN, identify the artistic style:
|
|
205
|
+
- What is the artistic technique? (ink wash, brush painting, illustration style, etc.)
|
|
206
|
+
- What is the color palette? (specific colors, tones, contrast levels)
|
|
207
|
+
- What is the brushwork quality? (bold strokes, fine lines, texture, etc.)
|
|
208
|
+
- What is the visual mood? (dramatic, serene, energetic, etc.)
|
|
209
|
+
- What material/texture characteristics are visible?
|
|
210
|
+
|
|
211
|
+
3. FINALLY, generate a prompt that:
|
|
212
|
+
- DIRECTLY incorporates the main subject or key visual elements from the reference image
|
|
213
|
+
- PRESERVES the exact visual patterns, motifs, and decorative elements visible in the reference
|
|
214
|
+
- MAINTAINS the same artistic style, brushwork, and technique
|
|
215
|
+
- USES the same color palette and visual mood
|
|
216
|
+
- ADAPTS these elements to the diamond-shaped Doufang format while keeping the reference image's visual identity
|
|
217
|
+
- BLENDS the user's keyword (${userKeyword}) with the reference image's visual content
|
|
218
|
+
|
|
219
|
+
The generated prompt MUST explicitly describe:
|
|
220
|
+
- The specific visual elements from the reference image to be included
|
|
221
|
+
- How to recreate the reference image's patterns and motifs in the Doufang
|
|
222
|
+
- The exact artistic style and technique to match the reference
|
|
223
|
+
- The color palette and visual characteristics to preserve
|
|
224
|
+
|
|
225
|
+
DO NOT create generic descriptions. Be SPECIFIC about what you see in the reference image and how to recreate it.`;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// Simple user input prompt without reference image
|
|
229
|
+
export const getSimpleUserInputPrompt = (userKeyword: string): string => {
|
|
230
|
+
return `User input keyword: 「${userKeyword}」`;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// Image generation prompt enhancement when reference image is provided
|
|
234
|
+
export const getImageGenerationPromptWithReference = (basePrompt: string): string => {
|
|
235
|
+
return `${basePrompt}
|
|
236
|
+
|
|
237
|
+
IMPORTANT COMPOSITION NOTE: The diamond-shaped Doufang should fill 85-95% of the frame with minimal margins (2-5% of frame width). Avoid excessive white space or wide margins. Maximize the visual impact by making the Doufang artwork occupy most of the image area.
|
|
238
|
+
|
|
239
|
+
Note: The reference image provided above should be used as a visual style guide. Follow the style, color palette, and artistic approach described in the prompt, which was generated based on analysis of this reference image.`;
|
|
240
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justin_666/square-couplets-master-skills",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Claude Agent Skills for generating Chinese New Year Doufang (diamond-shaped couplet) artwork using Google Gemini AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/doufang-skills.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"doufang-skills": "bin/doufang-skills.js",
|
|
9
|
-
"doufang": "bin/doufang-init.js"
|
|
9
|
+
"doufang": "bin/doufang-init.js",
|
|
10
|
+
"doufang-prompt": "bin/doufang-prompt.js",
|
|
11
|
+
"doufang-image": "bin/doufang-image.js",
|
|
12
|
+
"doufang-optimize": "bin/doufang-optimize.js"
|
|
10
13
|
},
|
|
11
14
|
"scripts": {
|
|
12
15
|
"dev": "vite",
|
|
13
16
|
"build": "vite build",
|
|
14
17
|
"preview": "vite preview",
|
|
15
|
-
"prepublishOnly": "node -e \"const fs = require('fs');
|
|
18
|
+
"prepublishOnly": "node -e \"const fs = require('fs'); ['doufang-skills.js', 'doufang-init.js', 'doufang-prompt.js', 'doufang-image.js', 'doufang-optimize.js'].forEach(f => fs.chmodSync('bin/' + f, 0o755));\""
|
|
16
19
|
},
|
|
17
20
|
"keywords": [
|
|
18
21
|
"claude",
|
|
@@ -42,6 +45,10 @@
|
|
|
42
45
|
"files": [
|
|
43
46
|
"bin/",
|
|
44
47
|
"skills/",
|
|
48
|
+
"services/",
|
|
49
|
+
"utils/",
|
|
50
|
+
"constants.ts",
|
|
51
|
+
"types.ts",
|
|
45
52
|
"README.md",
|
|
46
53
|
"LICENSE",
|
|
47
54
|
"package.json"
|