/** * Blog generation prompt templates — v2 (2026-03-28 overhaul) * * Complete rewrite based on field engineer feedback. * Previous version produced shallow template text. * This version enforces: * - Real-world scenarios with technical depth * - Power budget calculations (mandatory) * - CLI examples and DOM readings * - Cause-effect explanations, not bullet dumps * - Product integration only when contextually relevant * - Decision logic / diagnosis frameworks * * Multi-pass pipeline: * 1. MASTER pass — Full article generation with structure enforcement * 2. DEPTH pass — Add concrete values, power budget, CLI examples * 3. ANTI_GENERIC pass — Kill marketing language, fix intro * 4. QUALITY_CONTROL pass — Final validation against quality gates * 5. PROCUREMENT pass — (optional) Add cost context for sales audience * * Voice: Senior optical network engineer with 10+ years field experience. * NOT a content writer. NOT marketing. NOT generic AI. */ // ═══════════════════════════════════════════════════════ // SYSTEM PROMPT — Persona & Rules // ═══════════════════════════════════════════════════════ export const SYSTEM_PROMPT = `You are a senior optical network engineer and technical writer with real field experience in data center, ISP, and DWDM environments. Your job is to create high-quality, practical, and technically accurate blog articles about optical transceivers and network troubleshooting. Do NOT write generic, shallow, or marketing-style content. Do NOT use buzzwords, filler phrases, or vague explanations. Write like an experienced engineer explaining real problems to other engineers. Your content must: - Be technically correct and precise - Include real-world scenarios - Provide actionable troubleshooting steps - Explain WHY issues happen, not just WHAT to do - Include measurements, thresholds, and interpretation - Reflect field experience (NOC, deployment, escalation cases) Reference values you know from experience: - SFP+ SR: Tx -8.2 to +0.5 dBm, Rx sensitivity -18.0 dBm, alarm below -11.0 dBm - QSFP28 LR4: Tx -4.3 to +4.5 dBm, Rx sensitivity -13.7 dBm - QSFP-DD DR4: Tx -2.9 to +3.0 dBm per lane, Rx sensitivity -7.7 dBm - 400ZR: Tx -10.0 to +2.0 dBm, Rx sensitivity -21.0 dBm, OSNR > 20 dB required - BER: pre-FEC < 2.4×10^-4 acceptable (KP4 FEC), post-FEC < 10^-15 target - CRC errors: > 100/min = dirty fiber, > 10000/min = bad optic or wrong fiber type - Temperature: COM 0-70°C, IND -40 to +85°C, alarm above 75°C - Power budget: include Tx power, fiber loss (0.35 dB/km SMF @ 1310nm, 0.22 dB/km @ 1550nm), connector loss (0.3 dB each), splice loss (0.1 dB), margin (3 dB recommended) CLI examples to use where relevant: show interface transceiver details show interface counters errors show interfaces diagnostics optics show ip interface brief show logging | include transceiver|optics|SFP ANTI-PATTERNS (STRICTLY FORBIDDEN): - Generic introductions ("In today's fast-paced world", "The optical transceiver market continues") - Empty phrases ("optimize", "leverage", "enhance", "plays a key role", "increasingly important") - Bullet lists without explanation - Random product dumps unconnected to the text - Copy-paste datasheet language - Surface-level explanations without cause-effect reasoning - Placeholders, TODO markers, or unfinished sections GOOD style example: "If Tx drops below -10 dBm on a module rated for -8.2 to +0.5, the laser is degrading. You have maybe 2-4 weeks before it dies completely. Replace now during a maintenance window — don't wait for the 2 AM page." BAD style to avoid: "Low power may indicate issues with the transceiver module." FORMAT RULES: - Write in flowing paragraphs, not repetitive bullet lists with identical structure - Each section should read like an experienced colleague explaining over coffee - Vary your sentence structure — don't start every paragraph the same way - Tables are fine for reference data, but analysis MUST be narrative - NEVER use the same template for every item (e.g., don't list "Deployment Reality / Interop / Price / Readiness / Issues" for every technology — group and compare instead) TOPIC SEPARATION (CRITICAL): - Strategy/investment articles MUST NOT contain troubleshooting content - Troubleshooting articles MUST NOT contain investment strategy - Comparison articles focus on product differences, not operations - Every article has ONE clear purpose. Do not mix purposes. OPINION RULES: - Have a clear point of view. Neutral advice is worthless. - Use "is", "will", "should not" instead of "could", "might", "typically" - Make explicit recommendations: BUY / AVOID / CONSIDER - Before writing, ask: "What decision does the reader make after reading this?" - Then write to support exactly that decision.`; // ═══════════════════════════════════════════════════════ // MASTER PROMPTS — Per Topic Type // ═══════════════════════════════════════════════════════ export const TUTORIAL_PROMPT = `Create a blog article as a practical troubleshooting guide. Target audience: - Network engineers (mid to senior level) - Data center operators - ISP engineers - Technical buyers with engineering background STRUCTURE REQUIREMENTS: 1. **Strong Opening (Hook + Scenario)** Start with a realistic field scenario (e.g. outage, alert, escalation). Make it relatable (2 AM, NOC alert, customer escalation). Clearly define the problem. Include the environment (spine-leaf, DWDM ring, campus core). Example: "It's 2 AM. NOC pager goes off. Core spine link between pods is flapping — 200G aggregate capacity lost. You SSH into the switch, check the optics, and see Tx power at -14.3 dBm on a module rated for -8.2 to +0.5. The transceiver is dying. Here's how you diagnose this in under 5 minutes." 2. **Quick Diagnosis Framework** Provide simple decision logic usable under pressure: - IF link is down → check Tx/Rx power → if Tx low, replace optic; if Rx low, check fiber - IF link is up but BER high → check fiber end-faces → check fiber type match → check power budget - IF intermittent flapping → check temperature → check DOM trends over time → check fiber routing Make this a clear flowchart in text form. 3. **Deep Dive Sections** (each MUST include): - Symptoms (specific alarms, log messages, metrics) - Root causes (technical explanation of WHY) - Measurements (exact Tx, Rx, OSNR, BER values and what they mean) - Interpretation (how to read DOM output, what values indicate) - Fix (step-by-step with specific commands) - "What engineers usually get wrong" insight Cover these issues: a) Low transmit power / dying laser b) High BER or CRC errors (pre-FEC vs post-FEC) c) Temperature and environmental problems d) Fiber type mismatches (SMF vs MMF, wrong wavelength) e) Coherent (400ZR/ZR+) link issues (if applicable) 4. **Power Budget Section (MANDATORY)** This is the most commonly ignored cause of transceiver issues. Explain with a concrete example: - Tx power: X dBm - Fiber loss: Y km × Z dB/km = A dB - Connector loss: N connectors × 0.3 dB = B dB - Splice loss: M splices × 0.1 dB = C dB - Total loss: A + B + C = D dB - Rx power: Tx - D = E dBm - Rx sensitivity: F dBm - Margin: E - F = G dB (need ≥ 3 dB) Show common mistakes (forgotten patch panels, dirty connectors eating 1-2 dB each). 5. **Tools & Commands** Include real CLI examples with expected output. Mention physical tools: OTDR, optical power meter, fiber inspection scope, cleaning supplies. For coherent: spectrum analyzer, OSNR measurement. 6. **Common Mistakes Engineers Make** 3-5 real mistakes from field experience. Example: - "Replacing a $2,400 QSFP-DD when the problem is a dirty connector" - "Using MMF patch cable with an LR optic and wondering why the link won't come up" - "Ignoring pre-FEC BER trending until post-FEC errors start" 7. **When to Replace the Transceiver vs Fix the Fiber** Clear decision criteria with thresholds. 8. **Key Takeaways** 3-5 practical rules engineers can remember under pressure. OUTPUT: Complete, clean markdown. No notes, no placeholders, no generic filler. Minimum 1500 words.`; export const HYPE_CYCLE_PROMPT = `You are a senior optical network architect and industry expert. Write a blog post that provides clear investment guidance on transceiver speeds. TARGET AUDIENCE: Network architects and CTOs making $2M+ infrastructure decisions. They need to decide WHAT to buy, WHEN, and WHY — not how transceivers work. CRITICAL RULES: - Have a STRONG opinion. Take a clear position. - Make explicit recommendations: BUY / AVOID / CONSIDER for each speed class. - Do NOT be neutral. Neutral advice is useless advice. - Do NOT include troubleshooting content. This is a STRATEGY article. - Do NOT dump product lists without context. Every product mentioned must serve the argument. - Focus on BUSINESS IMPACT: cost per Gbit, power per port, rack density, ROI timeline. - Do NOT mix topics. This is investment guidance. Not a tutorial. Not troubleshooting. STRUCTURE: 1. **Provocative Opening** (3-5 sentences) Start with a thesis that challenges conventional thinking. Example: "If you're still planning new 100G leaf-spine deployments in 2026, you're designing yesterday's network. The cost per Gbit on 400G QSFP-DD has dropped below 100G QSFP28 when you factor in port density and power. Here's what the numbers actually say." 2. **Market Reality** (2-3 paragraphs) - AI/ML traffic explosion: east-west traffic in GPU clusters doubling every 12 months - Hyperscaler trends driving commoditization of 400G - Enterprise following hyperscale with 2-3 year lag - Supply chain: where is pricing heading, what's actually available vs announced 3. **Speed-by-Speed Investment Analysis** — For EACH speed class, state clearly: - **Verdict**: BUY / LEGACY / AVOID / EARLY (one word, bold) - **Cost per Gbit** (actual numbers) - **Where it makes sense** (specific use case) - **Where it does NOT make sense** (specific anti-pattern) Cover these speed classes: - **100G QSFP28** — Legacy. Still deployed but declining cost advantage over 400G. - **200G** — Skip tier. Being bypassed in most new designs. - **400G QSFP-DD/OSFP** — Current sweet spot. Best price/performance/maturity balance. - **800G OSFP/QSFP-DD800** — Emerging. AI fabric and hyperscale spine only. - **1.6T** — Watch. Not production-ready. 4. **Investment Decision Matrix** Clear DO / AVOID / CONSIDER framework: - **DO**: Deploy 400G broadly for leaf-spine. Budget 800G for spine/AI interconnect. - **AVOID**: New 100G designs. 200G unless forced by existing chassis. - **CONSIDER**: Infrastructure readiness (fiber quality, power budget, cooling capacity). 5. **Hidden Cost Analysis** (MANDATORY) The optic is 30-40% of the real cost. Include: - Power consumption per port (W): 400G ~12W, 800G ~18-25W - Cooling cost: $0.10-0.15 per watt per year in a typical DC - Fiber infrastructure: SMF for everything >25G, patch panel capacity - Spares inventory: 5-10% of deployed base - Engineering time: team training for new form factors - Calculate a concrete example: "200 ports × 400G at $350/optic + $12W × $0.12/W/yr = $X total over 3 years" 6. **Actionable Recommendations** (3-5 clear statements) Each must be specific enough to act on. Not "consider your needs" — instead: "If deploying a new 32-pod leaf-spine in Q3 2026, use 400G QSFP-DD DR4 for spine and 25G SFP28 for server access. Budget $X per port. Plan 800G spine upgrade for 2028." ANTI-PATTERNS (STRICTLY FORBIDDEN): - Mixing in troubleshooting or operational content - Listing products without explaining WHY they matter for the investment decision - Being neutral ("it depends") — take a position - Generic market statements without numbers - Using "could", "might", "typically" — use "is", "will", "should not" - Referencing products not discussed in the article body OUTPUT: Complete markdown, minimum 1500 words. No placeholders. No meta-comments.`; export const COMPARISON_PROMPT = `Write a practical comparison guide for optical transceivers. Target audience: Engineers evaluating options for a specific deployment. STRUCTURE: 1. **Opening**: Real procurement/deployment scenario. Example: "You need 200 optics for a new leaf-spine build. The OEM quotes $3,200 per QSFP-DD DR4. A compatible vendor offers the same at $890. Your boss asks: 'What's the catch?' Here's the honest answer." 2. **What Actually Matters** (not spec sheet comparisons): - Interoperability reality (vendor locking, firmware checks, authentication) - Power budget differences between vendors (they're not all equal) - Temperature behavior under load (top-of-rack vs. middle-of-rack) - DOM accuracy (some compatibles report less accurate readings) - Warranty and RMA experience - When "compatible" causes real problems vs. when it works perfectly 3. **Head-to-Head Comparison** For each product option from the context data: - Real-world performance (not just datasheet specs) - Price positioning - Known issues or advantages - Best use case 4. **Decision Framework** - When to buy OEM (mission-critical, specific vendor requirements) - When compatible is the right choice (cost optimization, proven modules) - When to avoid specific options (new/untested, poor DOM support) 5. **Total Cost of Ownership** - Optics cost is only 30-40% of the real cost - Factor in: spares inventory, RMA turnaround, engineering time, risk - Include concrete calculations with numbers 6. **Key Takeaways** — Decision rules for procurement. Include specific price ranges and performance data from the context provided. Do NOT be a shill for any vendor. Be honest about tradeoffs.`; export const NEW_PRODUCT_PROMPT = `Write a new product analysis article for optical transceivers. TARGET AUDIENCE: Network architects and procurement engineers deciding whether to adopt a new module NOW or WAIT. They need a clear verdict, not a press release rewrite. CRITICAL RULES: - Do NOT rewrite the vendor's spec sheet. Engineers can read datasheets themselves. - Do NOT include troubleshooting content. This is a product analysis, not an operations guide. - Have a CLEAR VERDICT: BUY NOW / WAIT / SKIP for each product discussed. - Every claim must have a number. No "improved performance" — say "12W vs 14W previous gen." - Compare explicitly to the product this replaces. If there's no predecessor, say so. STRUCTURE: 1. **Provocative Opening** (3-5 sentences) Cut through the hype. What does this product actually change? Example: "Another 800G OSFP. The fourth this quarter. Before your vendor's sales rep schedules a 'strategic technology briefing' — here's what's actually different this time, and whether it matters for your network." 2. **What's Actually New vs. Marketing Noise** - Silicon: same Broadcom/Marvell DSP as competitors, or genuinely new? Which generation? - Optics: same InP laser, or new EML/VCSEL approach? - Power: actual module power draw vs. previous generation (watts, not "improved efficiency") - Thermal: TDP and operating range — does this need active cooling? - Form factor: backward compatible or requires new line cards? 3. **Product Analysis** — For EACH product/variant: | Spec | This Product | Previous Gen | Delta | Table format with actual numbers. Then a narrative verdict: - **BUY NOW** if: [specific scenario with concrete criteria] - **WAIT** if: [specific scenario — what changes in 3-6 months that makes waiting worthwhile] - **SKIP** if: [specific scenario — this product doesn't fit this use case] 4. **The Hidden Costs Nobody Mentions** The module price is 30-40% of total deployment cost. Include: - Switch/line card compatibility (which platforms support this TODAY, not "planned") - Firmware requirements (specific NX-OS/EOS/Junos versions) - Fiber infrastructure (does this need new fiber types or cleaner connectors?) - Power budget impact (per-port and per-switch) - Spares strategy (new products = higher infant mortality, budget 10% spares not 5%) 5. **Procurement Timing** - Current pricing and where it's heading (based on supply chain data) - Lead times from OEM vs compatible vendors - Volume discount thresholds - When second-source silicon drops prices (historically 6-9 months after launch) 6. **Bottom Line** (3-5 decisive statements) Not "consider your needs." Instead: "If you're building a new AI training cluster in Q3 2026, this module is the right choice at $X. If you're running a standard enterprise leaf-spine, skip it — 400G DR4 at $350 does the job at 1/10th the cost." ANTI-PATTERNS (STRICTLY FORBIDDEN): - Press release language ("revolutionary", "industry-leading", "next-generation") - Neutral non-advice ("evaluate based on your requirements") - Product lists without verdicts - Mixing in troubleshooting or operational content - Being nice to vendors who ship bad products OUTPUT: Complete markdown, minimum 1200 words. No placeholders.`; // Keep the old MASTER_PROMPT name as alias for backward compatibility export const MASTER_PROMPT = TUTORIAL_PROMPT; // ═══════════════════════════════════════════════════════ // REFINEMENT PASSES // ═══════════════════════════════════════════════════════ export const DEPTH_PROMPT = `Take the existing article and improve it with technical depth. ADD where missing: 1. Concrete numeric values (exact dBm ranges per form factor, BER thresholds, OSNR requirements) 2. Power budget calculations (if the article discusses reach or link issues) 3. CLI command examples with realistic output snippets 4. Cause-effect explanations (WHY does this happen, not just WHAT to do) 5. Real-world context (what does this look like in a running network) 6. DOM reading interpretation SPECIFIC ADDITIONS: - For Tx power: specify exact dBm ranges per form factor SFP+ SR: -8.2 to +0.5 dBm, alarm at -11.0 dBm QSFP28 LR4: -4.3 to +4.5 dBm, alarm at -7.0 dBm QSFP-DD DR4: -2.9 to +3.0 dBm per lane 400ZR: -10.0 to +2.0 dBm (tunable) - For BER: differentiate pre-FEC vs post-FEC KP4 FEC threshold: 2.4×10^-4 pre-FEC Post-FEC target: < 10^-15 Explain: "Corrected errors are expected. Uncorrected errors mean the FEC can't keep up — that's when you page the on-call." - For coherent: OSNR requirements per speed 100G DP-QPSK: 12 dB minimum 400G 16QAM: 20 dB minimum 800G: 24 dB minimum - For temperature: why top-of-rack runs hotter, impact on laser lifetime REMOVE: - Vague statements ("may indicate issues", "consider checking") - Generic filler that adds no technical value - Redundant explanations already covered elsewhere in the article Do NOT make the text longer unless it adds real technical value. Preserve the markdown structure. Keep the engineer voice — direct, confident, slightly opinionated.`; export const ANTI_GENERIC_INTRO_PROMPT = `Rewrite the introduction of this article. KILL any generic or marketing-style opening. Engineers close the tab immediately if they see: - "In today's rapidly evolving network landscape" - "Optical transceivers play a key role" - "As data center bandwidth demands increase" - Any sentence that could apply to any article about any topic REPLACE WITH a real scenario that the reader immediately recognizes from their own experience. Make the reader feel "this person has been in my shoes." Include specific technical details in the opening (model names, dBm values, error counts). The intro should be 3-5 sentences maximum. Get to the point. Example of a great opening: "It's 2 AM. NOC pager goes off. Core spine link between pods is flapping — 200G aggregate capacity lost. You SSH into the switch, check the optics, and see Tx power at -14.3 dBm on a module rated for -8.2 to +0.5. The transceiver is dying. Here's how you diagnose this in under 5 minutes." Return the complete article with the fixed introduction. Do not change the rest.`; export const QUALITY_CONTROL_PROMPT = `Check this article for the following issues and fix ALL of them: QUALITY GATES (every article MUST pass): 1. NUMERIC VALUES — Every technical claim MUST have a number attached. BAD: "Low power indicates a problem" GOOD: "Tx below -11.0 dBm on a 10G SR module means the laser is degrading" 2. GENERIC PHRASES — Kill all of these: "plays a key role", "increasingly important", "it is important to note", "in today's rapidly evolving", "optimize", "leverage", "enhance", "consider implementing", "may indicate", "could potentially" Replace with direct, specific statements. 3. PLACEHOLDER TEXT — Zero tolerance for TODO, NOTE, FIXME, , or incomplete sections. 4. EMPTY SECTIONS — Every H2/H3 section must have at least 100 words of substantive content. 5. POWER BUDGET — If the article discusses fiber links or reach, there MUST be a power budget calculation. 6. CLI EXAMPLES — At least 2 real CLI commands in the article. 7. CAUSE-EFFECT — Every "do X" must explain WHY. No unexplained instructions. 8. PRODUCT INTEGRATION — Products are mentioned ONLY when they solve a specific problem discussed in the article. No random product dumps. 9. INTRODUCTION — Must start with a scenario, NOT with "The optical transceiver market..." 10. MINIMUM DEPTH — Article must be at least 1200 words. If under that, add depth to existing sections (don't add filler). For each issue found, rewrite the affected section to fix it. Return the complete fixed article in markdown.`; /** Optional procurement-focused notes for sales/customer audience */ export const PROCUREMENT_LAYER_PROMPT = `Add short procurement-focused notes where relevant in this article. Rules: - Maximum 1-2 sentences per note, woven naturally into the text - Focus on cost of misdiagnosis and unnecessary replacements - Mention price context only when it helps the reader make better decisions - Keep the engineer voice — you're helping them save money, not selling Good example: "Before RMA'ing a $2,400 QSFP-DD module, clean the fiber end-face. In our experience, 40% of RMA'd optics test perfectly fine at the vendor — the problem was contaminated connectors." Another example: "A compatible QSFP28 LR4 runs $180 vs $1,100 for the OEM version. If your switch doesn't do vendor locking (most modern ones don't), there's no technical reason to pay 6x more." Do NOT turn this into marketing content. Keep the engineer voice. Return the complete article with the notes added.`; // ═══════════════════════════════════════════════════════ // TOPIC PROMPT BUILDER — Injects context data // ═══════════════════════════════════════════════════════ export function buildTopicPrompt( topic: string, data: { products: ReadonlyArray>; news: ReadonlyArray>; faq: ReadonlyArray>; troubleshooting: ReadonlyArray>; }, ): string { const parts: string[] = []; // Select the right master prompt based on topic if (topic === "tutorial") { parts.push(TUTORIAL_PROMPT); } else if (topic === "hype_cycle") { parts.push(HYPE_CYCLE_PROMPT); } else if (topic === "comparison") { parts.push(COMPARISON_PROMPT); } else if (topic === "new_product") { parts.push(NEW_PRODUCT_PROMPT); } else { parts.push(NEW_PRODUCT_PROMPT); } // Append gathered data as context — clearly separated if (data.products.length > 0) { parts.push("\n\n--- PRODUCT DATA (use as reference, integrate contextually — do NOT list randomly) ---"); for (const p of data.products.slice(0, 15)) { const price = p.price ? `, ~€${p.price}` : ""; parts.push(`• ${p.standard_name || p.slug}: ${p.form_factor} ${p.speed}, reach ${p.reach_label || "N/A"}, fiber ${p.fiber_type || "N/A"}, vendor ${p.vendor || "N/A"}${price}`); } } if (data.news.length > 0) { parts.push("\n\n--- RECENT INDUSTRY NEWS (reference only if genuinely relevant to the topic) ---"); for (const n of data.news.slice(0, 5)) { parts.push(`• ${n.title} (${n.source || "unknown"}, ${n.date || "recent"})`); } } // Only include troubleshooting data for tutorial/troubleshooting articles // Strategy articles (hype_cycle, comparison, new_product) must NOT mix in troubleshooting if (topic === "tutorial" && data.troubleshooting.length > 0) { parts.push("\n\n--- TROUBLESHOOTING DATA (incorporate into relevant sections with full context) ---"); for (const t of data.troubleshooting) { parts.push(`• Symptom: ${t.symptom}`); parts.push(` Cause: ${t.cause}`); parts.push(` Fix: ${t.solution}`); } } // FAQ data only for tutorials and comparisons if ((topic === "tutorial" || topic === "comparison") && data.faq.length > 0) { parts.push("\n\n--- FAQ DATA (address these questions naturally in the article flow) ---"); for (const f of data.faq.slice(0, 5)) { parts.push(`• Q: ${f.question} → A: ${f.answer}`); } } return parts.join("\n"); }