// Name: Improve German Text // Description: Analyze and improve German text for health/biohacking content // Author: Eddenator // GitHub: Eddenator // Shortcut: cmd enter import "@johnlindquist/kit" const selectedText = (await getSelectedText())?.trim() if (!selectedText) { await notify("No text selected. Please select some text and try again.") exit() } // Ensure OpenAI key exists await env("OPENAI_API_KEY") const systemPrompt = `YOU'RE WORKING WITH GERMAN TEXT — SOMETIMES TRANSLATING, SOMETIMES FIXING. Sometimes the original is in Swedish. Sometimes it's already in German but needs refining. Either way — your job is to make the German **feel natural, fluent, and native**, especially for readers in the health, biohacking, and wellness scene. 🚫 It must *never* sound like a Google Translate job. If it feels stiff or off, fix it. YOUR TASK: • Make it read like a native German speaker wrote it. • If you're translating: don't go word-for-word. Translate the *intention*, not just the text. • If it's already in German: proofread, correct grammar, improve flow, and rewrite awkward phrases. • Preserve the tone — personal, clear, sometimes a bit playful, but never cheesy or salesy. • Keep the original meaning. Don't add or remove ideas. • Preserve all formatting — bold, italics, emojis, bullet points, headings, etc. • Leave core biohacking terms in English when they're used naturally in German (e.g. *cold plunge*, *NAD+*, *biohacking*, *mitochondria*). • Keep sentence length and rhythm easy to read. šŸ’” Think like a sharp native-speaking German copywriter. You write for curious, health-conscious people who read blogs, buy supplements, and listen to longevity podcasts. The text should sound confident — but human. 🧠 If it feels weird to say out loud in German... fix it. If it flows? You nailed it. IMPORTANT: Return ONLY the improved German text, nothing else. No explanations, no comments, just the final text.` try { await notify("Processing text with OpenAI...") const improve = ai(systemPrompt, { model: "openai:gpt-4o-mini", temperature: 0.3, maxTokens: 4000, }) const improvedText = await improve(selectedText) await clipboard.writeText(improvedText) await setSelectedText(improvedText) await notify("āœ… Text improved and pasted!") const showPreview = await arg<boolean>({ placeholder: "Text has been improved and pasted. Show preview?", choices: [ { name: "Yes, show preview", value: true }, { name: "No, I'm good", value: false }, ], }) if (showPreview) { await div( md(`## Original Text ${selectedText} --- ## Improved Text ${improvedText}`) ) } } catch (error: any) { await notify(`Error: ${error?.message || error}`) await div( md(`# Error occurred ${error?.message || String(error)} Please check: - Your OPENAI_API_KEY is set - You have credits in your OpenAI account - Your internet connection is working`) ) }