// Name: AI Image Prompt Generator // Description: Generate customized AI image prompts with style options // Author: canvural import "@johnlindquist/kit" interface PromptStyle { name: string prefix: string suffix: string description: string } interface GeneratedPrompt { prompt: string style: string subject: string } const promptStyles: PromptStyle[] = [ { name: "Photorealistic", prefix: "ultra realistic, high resolution, detailed photography of", suffix: "professional lighting, sharp focus, 8k quality, DSLR camera", description: "Creates realistic, photo-like images" }, { name: "Digital Art", prefix: "digital art, concept art, highly detailed illustration of", suffix: "trending on artstation, digital painting, vibrant colors", description: "Modern digital artwork style" }, { name: "Oil Painting", prefix: "oil painting, classical art style, masterpiece painting of", suffix: "rich textures, painterly brushstrokes, museum quality", description: "Traditional oil painting aesthetic" }, { name: "Anime/Manga", prefix: "anime style, manga art, detailed anime illustration of", suffix: "cel shading, vibrant colors, studio quality animation", description: "Japanese anime and manga style" }, { name: "Cyberpunk", prefix: "cyberpunk style, futuristic neon aesthetic,", suffix: "neon lights, dark atmosphere, high tech low life, blade runner style", description: "Futuristic cyberpunk aesthetic" }, { name: "Watercolor", prefix: "watercolor painting, soft watercolor art of", suffix: "flowing colors, artistic brushwork, paper texture", description: "Soft watercolor painting style" }, { name: "Minimalist", prefix: "minimalist design, clean simple illustration of", suffix: "white background, geometric shapes, modern design", description: "Clean, simple minimalist style" }, { name: "Fantasy Art", prefix: "fantasy art, magical illustration, epic fantasy painting of", suffix: "mystical atmosphere, dramatic lighting, fantasy world", description: "Magical fantasy artwork" } ] const aspectRatios = [ { name: "Square (1:1)", value: "1:1" }, { name: "Portrait (3:4)", value: "3:4" }, { name: "Landscape (4:3)", value: "4:3" }, { name: "Widescreen (16:9)", value: "16:9" }, { name: "Ultra Wide (21:9)", value: "21:9" }, { name: "Vertical (9:16)", value: "9:16" } ] const qualityModifiers = [ "highly detailed", "masterpiece", "best quality", "ultra high resolution", "professional", "award winning", "stunning", "breathtaking" ] const lightingOptions = [ "golden hour lighting", "dramatic lighting", "soft natural lighting", "studio lighting", "cinematic lighting", "volumetric lighting", "rim lighting", "ambient lighting" ] let generatedPrompts: GeneratedPrompt[] = [] const generatePrompt = async () => { const subject = await arg({ placeholder: "What do you want to create? (e.g., 'a majestic dragon', 'portrait of a woman')", hint: "Describe the main subject of your image" }) if (!subject) return const selectedStyle = await arg("Choose a style:", promptStyles.map(style => ({ name: style.name, description: style.description, value: style }))) const aspectRatio = await arg("Select aspect ratio:", aspectRatios) const includeQuality = await arg("Include quality modifiers?", [ { name: "Yes - Add quality enhancers", value: true }, { name: "No - Keep it simple", value: false } ]) const includeLighting = await arg("Add lighting effects?", [ { name: "Yes - Add lighting", value: true }, { name: "No - Skip lighting", value: false } ]) // Build the prompt let finalPrompt = `${selectedStyle.prefix} ${subject}` if (includeQuality) { const randomQuality = qualityModifiers[Math.floor(Math.random() * qualityModifiers.length)] finalPrompt += `, ${randomQuality}` } if (includeLighting) { const randomLighting = lightingOptions[Math.floor(Math.random() * lightingOptions.length)] finalPrompt += `, ${randomLighting}` } finalPrompt += `, ${selectedStyle.suffix}` finalPrompt += `, aspect ratio ${aspectRatio.value}` const generatedPrompt: GeneratedPrompt = { prompt: finalPrompt, style: selectedStyle.name, subject: subject } generatedPrompts.unshift(generatedPrompt) if (generatedPrompts.length > 10) { generatedPrompts = generatedPrompts.slice(0, 10) } return generatedPrompt } const showPromptHistory = async () => { if (generatedPrompts.length === 0) { await div(md("# No prompts generated yet\n\nGenerate some prompts first!")) return } const selectedPrompt = await arg("Select a prompt to copy:", generatedPrompts.map((p, index) => ({ name: `${p.style}: ${p.subject.substring(0, 50)}...`, description: p.prompt.substring(0, 100) + "...", value: p, preview: () => md(`## ${p.style}\n\n**Subject:** ${p.subject}\n\n**Full Prompt:**\n\n${p.prompt}`) }))) await copy(selectedPrompt.prompt) await toast("Prompt copied to clipboard!") } const customPromptBuilder = async () => { const fields = await fields([ { label: "Subject", placeholder: "Main subject of the image" }, { label: "Style Prefix", placeholder: "Style description (optional)" }, { label: "Additional Details", placeholder: "Extra details (optional)" }, { label: "Quality Terms", placeholder: "Quality modifiers (optional)" }, { label: "Aspect Ratio", placeholder: "e.g., 16:9, 1:1 (optional)" } ]) const [subject, stylePrefix, details, quality, aspectRatio] = fields let customPrompt = subject if (stylePrefix) customPrompt = `${stylePrefix}, ${customPrompt}` if (details) customPrompt += `, ${details}` if (quality) customPrompt += `, ${quality}` if (aspectRatio) customPrompt += `, aspect ratio ${aspectRatio}` const generatedPrompt: GeneratedPrompt = { prompt: customPrompt, style: "Custom", subject: subject } generatedPrompts.unshift(generatedPrompt) await copy(customPrompt) await toast("Custom prompt copied to clipboard!") return generatedPrompt } // Main menu while (true) { const action = await arg({ placeholder: "AI Image Prompt Generator", hint: "Choose an action to get started" }, [ { name: "🎨 Generate New Prompt", description: "Create a new AI image prompt with style options", value: "generate" }, { name: "🛠️ Custom Prompt Builder", description: "Build a prompt from scratch with custom fields", value: "custom" }, { name: "📋 View Prompt History", description: "See and copy previously generated prompts", value: "history" }, { name: "📖 Style Guide", description: "Learn about different prompt styles", value: "guide" }, { name: "❌ Exit", description: "Close the prompt generator", value: "exit" } ]) if (action === "generate") { const result = await generatePrompt() if (result) { await copy(result.prompt) await div({ html: md(`# ✅ Prompt Generated!\n\n**Style:** ${result.style}\n\n**Subject:** ${result.subject}\n\n**Full Prompt:**\n\n\`\`\`\n${result.prompt}\n\`\`\`\n\n*Prompt has been copied to your clipboard!*`), shortcuts: [ { name: "Generate Another", key: "enter", onPress: () => submit("continue"), bar: "right" } ] }) } } else if (action === "custom") { await customPromptBuilder() } else if (action === "history") { await showPromptHistory() } else if (action === "guide") { const styleGuide = promptStyles.map(style => `## ${style.name}\n${style.description}\n\n**Example prefix:** ${style.prefix}\n**Example suffix:** ${style.suffix}\n` ).join("\n") await div(md(`# 🎨 Style Guide\n\n${styleGuide}`)) } else if (action === "exit") { break } }