myaidev-method 0.2.22 → 0.2.24-1

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.
Files changed (59) hide show
  1. package/USER_GUIDE.md +453 -48
  2. package/bin/cli.js +236 -38
  3. package/content-rules.example.md +80 -0
  4. package/dist/mcp/mcp-launcher.js +237 -0
  5. package/dist/server/.tsbuildinfo +1 -1
  6. package/dist/server/auth/layers.d.ts +1 -1
  7. package/dist/server/auth/services/AuthService.d.ts +1 -1
  8. package/dist/server/auth/services/TokenService.js.map +1 -1
  9. package/dist/server/auth/services/example.d.ts +5 -5
  10. package/package.json +22 -17
  11. package/src/config/workflows.js +28 -44
  12. package/src/index.js +21 -8
  13. package/src/lib/ascii-banner.js +214 -0
  14. package/src/lib/config-manager.js +470 -0
  15. package/src/lib/content-generator.js +427 -0
  16. package/src/lib/html-conversion-utils.js +843 -0
  17. package/src/lib/seo-optimizer.js +515 -0
  18. package/src/lib/update-manager.js +2 -1
  19. package/src/lib/visual-config-utils.js +321 -295
  20. package/src/lib/visual-generation-utils.js +1000 -811
  21. package/src/lib/wordpress-client.js +633 -0
  22. package/src/lib/workflow-installer.js +3 -3
  23. package/src/scripts/configure-wordpress-mcp.js +8 -3
  24. package/src/scripts/generate-visual-cli.js +365 -235
  25. package/src/scripts/html-conversion-cli.js +526 -0
  26. package/src/scripts/init/configure.js +436 -0
  27. package/src/scripts/init/install.js +460 -0
  28. package/src/scripts/ping.js +250 -0
  29. package/src/scripts/utils/file-utils.js +404 -0
  30. package/src/scripts/utils/logger.js +300 -0
  31. package/src/scripts/utils/write-content.js +293 -0
  32. package/src/scripts/wordpress/publish-to-wordpress.js +165 -0
  33. package/src/server/auth/services/TokenService.ts +1 -1
  34. package/src/templates/claude/agents/content-rules-setup.md +657 -0
  35. package/src/templates/claude/agents/content-writer.md +328 -1
  36. package/src/templates/claude/agents/visual-content-generator.md +311 -8
  37. package/src/templates/claude/commands/myai-configure.md +1 -1
  38. package/src/templates/claude/commands/myai-content-rules-setup.md +204 -0
  39. package/src/templates/claude/commands/myai-convert-html.md +186 -0
  40. package/src/templates/codex/commands/myai-content-rules-setup.md +85 -0
  41. package/src/templates/diagrams/architecture.d2 +52 -0
  42. package/src/templates/diagrams/flowchart.d2 +42 -0
  43. package/src/templates/diagrams/sequence.d2 +47 -0
  44. package/src/templates/docs/content-creation-guide.md +164 -0
  45. package/src/templates/docs/deployment-guide.md +336 -0
  46. package/src/templates/docs/visual-generation-guide.md +248 -0
  47. package/src/templates/docs/wordpress-publishing-guide.md +208 -0
  48. package/src/templates/gemini/commands/myai-content-rules-setup.toml +57 -0
  49. package/src/templates/infographics/comparison-table.html +347 -0
  50. package/src/templates/infographics/data-chart.html +268 -0
  51. package/src/templates/infographics/process-flow.html +365 -0
  52. package/.claude/mcp/sparc-orchestrator-server.js +0 -607
  53. package/.claude/mcp/wordpress-server.js +0 -1277
  54. package/src/agents/content-writer-prompt.md +0 -164
  55. package/src/agents/content-writer.json +0 -70
  56. package/src/templates/claude/mcp_config.json +0 -74
  57. package/src/templates/claude/slash_commands.json +0 -166
  58. package/src/templates/scripts/configure-wordpress-mcp.js +0 -181
  59. /package/src/scripts/{wordpress-health-check.js → wordpress/wordpress-health-check.js} +0 -0
@@ -107,6 +107,252 @@ The content-writer agent supports custom content generation rules via a `content
107
107
 
108
108
  **Note:** If `content-rules.md` doesn't exist, the agent will use its default professional content creation guidelines.
109
109
 
110
+ ## Content Type Templates
111
+
112
+ The content-writer supports specialized templates for different content types. Specify the type to get optimized structure and formatting:
113
+
114
+ ### Available Content Types
115
+
116
+ | Type | Description | Typical Length | Key Elements |
117
+ |------|-------------|----------------|--------------|
118
+ | `blog-post` | Standard SEO-optimized article | 1500-2500 words | Hero image, intro hook, sections, CTA |
119
+ | `technical-tutorial` | Step-by-step implementation guide | 2000-3500 words | Prerequisites, code examples, diagrams |
120
+ | `api-documentation` | API reference documentation | 1000-2000 words | Endpoints, parameters, response examples |
121
+ | `architecture-guide` | System design documentation | 2500-4000 words | Architecture diagrams, component details |
122
+ | `listicle` | List-based article (Top 10, etc.) | 1200-2000 words | Numbered items, supporting graphics |
123
+ | `comparison-guide` | Side-by-side analysis | 1500-2500 words | Comparison tables, infographics |
124
+ | `white-paper` | In-depth technical analysis | 3000-5000 words | Executive summary, data infographics |
125
+ | `how-to-guide` | Practical implementation guide | 1500-2500 words | Step visuals, troubleshooting |
126
+ | `case-study` | Customer success story | 1200-2000 words | Metrics, quotes, before/after |
127
+
128
+ ### Template Structures
129
+
130
+ **Blog Post Template:**
131
+ ```markdown
132
+ # [Title with Primary Keyword]
133
+
134
+ ![Hero Image](./content-assets/images/...)
135
+
136
+ [Hook - 2-3 sentences grabbing attention]
137
+
138
+ ## Introduction
139
+ [Problem statement, what reader will learn]
140
+
141
+ ## [Main Section 1]
142
+ [Content with examples]
143
+
144
+ ## [Main Section 2]
145
+ [Content with visuals if applicable]
146
+
147
+ ## [Main Section 3]
148
+ [Content with code/examples]
149
+
150
+ ## Conclusion
151
+ [Summary, key takeaways, CTA]
152
+
153
+ ## Related Resources
154
+ [Internal links]
155
+ ```
156
+
157
+ **Technical Tutorial Template:**
158
+ ```markdown
159
+ # [How to/Build/Implement] [Topic]: [Benefit]
160
+
161
+ ![Hero: Tech concept visualization]
162
+
163
+ ## What You'll Build/Learn
164
+ [Clear deliverable description]
165
+
166
+ ## Prerequisites
167
+ - [Requirement 1]
168
+ - [Requirement 2]
169
+
170
+ ## Step 1: [Foundation]
171
+ [Explanation]
172
+ ```[language]
173
+ // Code example
174
+ ```
175
+ ![Diagram: Step 1 visualization]
176
+
177
+ ## Step 2: [Implementation]
178
+ [Detailed steps with code]
179
+
180
+ ## Step 3: [Advanced/Production]
181
+ [Enhancement and best practices]
182
+
183
+ ## Testing & Verification
184
+ [How to verify it works]
185
+
186
+ ## Troubleshooting
187
+ | Issue | Solution |
188
+ |-------|----------|
189
+ | ... | ... |
190
+
191
+ ## Next Steps
192
+ [Related tutorials, advanced topics]
193
+ ```
194
+
195
+ **API Documentation Template:**
196
+ ```markdown
197
+ # [API Endpoint/Feature] Reference
198
+
199
+ ## Overview
200
+ [What this API does, when to use it]
201
+
202
+ ## Authentication
203
+ [Required auth method]
204
+
205
+ ## Endpoints
206
+
207
+ ### [HTTP Method] /endpoint
208
+ [Description]
209
+
210
+ **Request Parameters:**
211
+ | Parameter | Type | Required | Description |
212
+ |-----------|------|----------|-------------|
213
+ | ... | ... | ... | ... |
214
+
215
+ **Request Example:**
216
+ ```bash
217
+ curl -X POST https://api.example.com/endpoint \
218
+ -H "Authorization: Bearer TOKEN" \
219
+ -d '{"key": "value"}'
220
+ ```
221
+
222
+ **Response:**
223
+ ```json
224
+ {
225
+ "status": "success",
226
+ "data": {}
227
+ }
228
+ ```
229
+
230
+ **Error Codes:**
231
+ | Code | Description |
232
+ |------|-------------|
233
+ | 400 | Bad request |
234
+ | 401 | Unauthorized |
235
+
236
+ ## Rate Limits
237
+ [Rate limiting details]
238
+
239
+ ## SDKs & Libraries
240
+ [Available SDKs]
241
+ ```
242
+
243
+ **Architecture Guide Template:**
244
+ ```markdown
245
+ # [System/Feature] Architecture
246
+
247
+ ![Architecture Diagram: System overview]
248
+
249
+ ## Executive Summary
250
+ [High-level overview for stakeholders]
251
+
252
+ ## System Overview
253
+ [What the system does, key capabilities]
254
+
255
+ ## Architecture Diagram
256
+ ![architecture-diagram: Component relationships]
257
+
258
+ ## Components
259
+
260
+ ### [Component 1]
261
+ **Purpose:** [What it does]
262
+ **Technology:** [Tech stack]
263
+ **Interactions:** [How it connects]
264
+
265
+ ### [Component 2]
266
+ [Same structure]
267
+
268
+ ## Data Flow
269
+ ![flowchart: Data flow through system]
270
+
271
+ 1. [Step 1]
272
+ 2. [Step 2]
273
+ 3. [Step 3]
274
+
275
+ ## Security Considerations
276
+ [Security architecture]
277
+
278
+ ## Scalability
279
+ [How system scales]
280
+
281
+ ## Deployment
282
+ [Deployment architecture]
283
+ ```
284
+
285
+ **Listicle Template:**
286
+ ```markdown
287
+ # [Number] [Topic] [Benefit/Outcome]
288
+
289
+ ![Hero: Engaging visual representing the list theme]
290
+
291
+ [Introduction: Why this list matters, what reader will learn]
292
+
293
+ ## 1. [First Item]
294
+ ![illustration: Item 1 concept]
295
+ [Detailed explanation, 150-250 words]
296
+ **Key Takeaway:** [One-liner]
297
+
298
+ ## 2. [Second Item]
299
+ [Same structure]
300
+
301
+ ## 3. [Third Item]
302
+ [Same structure]
303
+
304
+ [Continue for all items...]
305
+
306
+ ## Summary
307
+ ![infographic-data: Quick reference of all items]
308
+ [Recap of all items with key points]
309
+
310
+ ## What's Next?
311
+ [CTA, related content]
312
+ ```
313
+
314
+ **Comparison Guide Template:**
315
+ ```markdown
316
+ # [Option A] vs [Option B]: [Decision Framework]
317
+
318
+ ![Hero: Visual comparison concept]
319
+
320
+ ## Quick Comparison
321
+ ![infographic-comparison: Side-by-side summary]
322
+
323
+ | Feature | [Option A] | [Option B] |
324
+ |---------|------------|------------|
325
+ | [Feature 1] | ✅/❌/Value | ✅/❌/Value |
326
+ | [Feature 2] | ... | ... |
327
+
328
+ ## Overview
329
+ [When you'd choose each option]
330
+
331
+ ## [Option A] Deep Dive
332
+ ### Strengths
333
+ ### Weaknesses
334
+ ### Best For
335
+
336
+ ## [Option B] Deep Dive
337
+ ### Strengths
338
+ ### Weaknesses
339
+ ### Best For
340
+
341
+ ## Decision Framework
342
+ ![flowchart: Decision tree for choosing]
343
+
344
+ Choose [Option A] if:
345
+ - [Criteria 1]
346
+ - [Criteria 2]
347
+
348
+ Choose [Option B] if:
349
+ - [Criteria 1]
350
+ - [Criteria 2]
351
+
352
+ ## Conclusion
353
+ [Final recommendation based on use case]
354
+ ```
355
+
110
356
  ## Writing Process
111
357
 
112
358
  ### Phase 0: Load Custom Rules (if available)
@@ -114,9 +360,11 @@ The content-writer agent supports custom content generation rules via a `content
114
360
  - If found, read and incorporate custom guidelines
115
361
  - Merge custom rules with default best practices
116
362
  - Continue with standard process if file doesn't exist
363
+ - **Run `/myai-content-rules-setup` if no rules exist and user wants customization**
117
364
 
118
365
  ### Phase 1: Understanding
119
366
  - Identify the content purpose and goals
367
+ - **Select appropriate content type template**
120
368
  - Define the target audience
121
369
  - Determine the desired tone and style
122
370
  - Clarify key messages and takeaways
@@ -134,7 +382,86 @@ The content-writer agent supports custom content generation rules via a `content
134
382
  - Organize information logically
135
383
  - Plan keyword placement
136
384
  - Identify supporting media needs
137
- - **If --with-images flag**: Plan visual content strategy (hero image, diagrams, illustrations)
385
+
386
+ ### Phase 3.5: Visual Strategy (--with-images or by default for visual content types)
387
+
388
+ Plan visual content to enhance the article:
389
+
390
+ **1. Identify Visual Opportunities:**
391
+ ```markdown
392
+ ## Visual Content Plan
393
+
394
+ ### Hero Image
395
+ - Concept: [Main visual theme]
396
+ - Type: hero
397
+ - Placement: After H1 title
398
+
399
+ ### Diagrams (Technical Content)
400
+ - [ ] Architecture diagram: [What it shows]
401
+ - [ ] Flowchart: [Process being illustrated]
402
+ - [ ] Sequence diagram: [Interactions being shown]
403
+
404
+ ### Infographics (Data/Process Content)
405
+ - [ ] Data infographic: [Metrics/statistics to visualize]
406
+ - [ ] Process infographic: [Steps to illustrate]
407
+ - [ ] Comparison infographic: [Items being compared]
408
+ - [ ] Timeline infographic: [Events/milestones]
409
+
410
+ ### Supporting Visuals
411
+ - [ ] Illustration: [Concept to visualize]
412
+ - [ ] Screenshot: [UI/interface to show]
413
+ ```
414
+
415
+ **2. Match Content Type to Visuals:**
416
+
417
+ | Content Type | Recommended Visuals |
418
+ |--------------|---------------------|
419
+ | Blog Post | Hero + 1-2 illustrations |
420
+ | Technical Tutorial | Hero + diagrams + code screenshots |
421
+ | API Documentation | Sequence diagrams + request/response examples |
422
+ | Architecture Guide | Architecture diagrams + flowcharts |
423
+ | Listicle | Hero + item illustrations + summary infographic |
424
+ | Comparison Guide | Comparison infographic + decision flowchart |
425
+ | White Paper | Hero + data infographics + process diagrams |
426
+
427
+ **3. Create Visual Specifications:**
428
+
429
+ For each planned visual, specify:
430
+ ```markdown
431
+ ### Visual: [Name]
432
+ - **Type**: [hero/diagram/infographic-data/etc.]
433
+ - **Placement**: [After which section/heading]
434
+ - **Concept**: [What it should depict]
435
+ - **Text Elements**: [Any text to include in the image]
436
+ - **Style Notes**: [Technical/friendly/corporate/etc.]
437
+ - **Service**: [Recommended: gemini/gpt-image-1.5/flux2-pro]
438
+ ```
439
+
440
+ **4. Infographic Data Specification:**
441
+
442
+ For data-driven infographics, provide structured data:
443
+ ```markdown
444
+ ### Infographic: [Title]
445
+ - **Type**: infographic-data
446
+ - **Data Points**:
447
+ - Label: "Metric 1", Value: "99.9%"
448
+ - Label: "Metric 2", Value: "< 50ms"
449
+ - Label: "Metric 3", Value: "10M+"
450
+ - **Color Scheme**: [Brand colors or preference]
451
+ - **Style**: Modern flat design with clear typography
452
+ ```
453
+
454
+ **5. Diagram Specification:**
455
+
456
+ For technical diagrams:
457
+ ```markdown
458
+ ### Diagram: [Title]
459
+ - **Type**: architecture-diagram / flowchart / sequence-diagram
460
+ - **Components**: [List of elements to include]
461
+ - **Connections**: [How elements relate]
462
+ - **Labels**: [Key labels to include]
463
+ - **Style**: Isometric / flat / technical illustration
464
+ ```
138
465
 
139
466
  ### Phase 4: Writing
140
467
  - Craft an attention-grabbing headline
@@ -70,13 +70,30 @@ Collect information from the user:
70
70
 
71
71
  **Required Information:**
72
72
  - **Prompt/Description**: What should the image/video depict?
73
- - **Type**: hero, illustration, diagram, screenshot, video
73
+ - **Type**: See Image Type Reference below
74
74
 
75
75
  **Optional Information:**
76
- - **Preferred Service**: gemini, imagen, dalle, veo (or auto-select)
77
- - **Quality**: standard, hd (for DALL-E)
76
+ - **Preferred Service**: gemini, imagen, gpt-image-1.5, flux2-pro, veo3 (or auto-select)
77
+ - **Quality**: low, medium, high (affects cost and detail)
78
78
  - **Size**: 1024x1024, 1792x1024, 1024x1792
79
79
 
80
+ ### Image Type Reference
81
+
82
+ | Type | Description | Best Service | Use Case |
83
+ |------|-------------|--------------|----------|
84
+ | `hero` | Article header, main theme | Gemini/Imagen | Blog posts, landing pages |
85
+ | `illustration` | Abstract concepts, metaphors | FLUX 2 Pro | Explanatory content |
86
+ | `diagram` | Technical workflows, architecture | Gemini | Documentation |
87
+ | `screenshot` | UI mockups, interface designs | GPT Image 1.5 | Tutorials |
88
+ | `infographic-data` | Statistics, metrics, charts | GPT Image 1.5 | Data-driven articles |
89
+ | `infographic-process` | Step flows, workflows | FLUX 2 Pro | How-to guides |
90
+ | `infographic-comparison` | Side-by-side comparisons | GPT Image 1.5 | Comparison articles |
91
+ | `infographic-timeline` | Chronological events | FLUX 2 Pro | History, roadmaps |
92
+ | `architecture-diagram` | System design, tech stacks | Gemini | Technical docs |
93
+ | `flowchart` | Decision trees, processes | Gemini | Process documentation |
94
+ | `sequence-diagram` | API/service interactions | Gemini | API documentation |
95
+ | `video` | Product demos, tutorials | Veo 3 | Marketing, tutorials |
96
+
80
97
  **Example Interaction:**
81
98
  ```
82
99
  User: Generate a hero image for an article about AI development
@@ -407,16 +424,177 @@ Always enhance user prompts for better results:
407
424
  ```javascript
408
425
  const enhancePrompt = (userPrompt, type) => {
409
426
  const prefixes = {
427
+ // Standard types
410
428
  hero: 'Professional hero image, high quality, visually striking:',
411
429
  illustration: 'Clean illustration, professional style:',
412
430
  diagram: 'Technical diagram, clear labels, easy to understand:',
413
- screenshot: 'Professional screenshot, clean interface:'
431
+ screenshot: 'Professional screenshot, clean interface:',
432
+
433
+ // Infographic types (use GPT Image 1.5 for best text rendering)
434
+ 'infographic-data': 'Clean data visualization infographic with clear typography, color-coded sections, modern flat design. Include title area, data callouts with numbers, and clean layout:',
435
+ 'infographic-process': 'Step-by-step process infographic with numbered steps, icons for each step, connecting arrows, clean modern design. Each step clearly labeled:',
436
+ 'infographic-comparison': 'Side-by-side comparison infographic with two columns, clear headers, checkmarks and X marks, comparison points aligned, professional business style:',
437
+ 'infographic-timeline': 'Horizontal timeline infographic with dated milestones, icons at each point, connecting line, clean modern design, clear labels:',
438
+
439
+ // Technical diagram types
440
+ 'architecture-diagram': 'Technical system architecture diagram with labeled boxes, connection arrows, cloud/server/database icons, legend area, isometric or flat technical style:',
441
+ 'flowchart': 'Professional flowchart with decision diamonds, process rectangles, start/end ovals, clear yes/no paths, labeled arrows:',
442
+ 'sequence-diagram': 'Technical sequence diagram showing component interactions, lifelines, arrows with labels, participant boxes at top:'
414
443
  };
415
444
 
416
445
  return `${prefixes[type] || ''} ${userPrompt}`;
417
446
  };
418
447
  ```
419
448
 
449
+ ### Infographic Generation Guidelines
450
+
451
+ When generating infographics, follow these practices:
452
+
453
+ **For Data Infographics (`infographic-data`):**
454
+ ```javascript
455
+ // Best service: GPT Image 1.5 (excellent text rendering)
456
+ const prompt = buildDataInfographicPrompt({
457
+ title: "5 Key Authentication Metrics",
458
+ metrics: [
459
+ { label: "API Latency", value: "< 50ms" },
460
+ { label: "Uptime", value: "99.99%" },
461
+ { label: "Daily Requests", value: "10M+" }
462
+ ],
463
+ style: "modern flat design, blue and white color scheme"
464
+ });
465
+
466
+ // Example output prompt:
467
+ // "Clean data visualization infographic: Title '5 Key Authentication Metrics'.
468
+ // Show 3 metrics with large numbers: API Latency < 50ms, Uptime 99.99%,
469
+ // Daily Requests 10M+. Modern flat design, blue and white, clear typography."
470
+ ```
471
+
472
+ **For Process Infographics (`infographic-process`):**
473
+ ```javascript
474
+ // Best service: FLUX 2 Pro (excellent detail)
475
+ const prompt = buildProcessInfographicPrompt({
476
+ title: "JWT Authentication Flow",
477
+ steps: [
478
+ "1. User submits credentials",
479
+ "2. Server validates and generates JWT",
480
+ "3. Client stores token",
481
+ "4. Client sends token with requests",
482
+ "5. Server verifies token"
483
+ ],
484
+ style: "numbered steps with icons, arrows connecting each step"
485
+ });
486
+ ```
487
+
488
+ **For Comparison Infographics (`infographic-comparison`):**
489
+ ```javascript
490
+ // Best service: GPT Image 1.5 (best for text-heavy visuals)
491
+ const prompt = buildComparisonInfographicPrompt({
492
+ title: "JWT vs Session Authentication",
493
+ items: [
494
+ { category: "Scalability", optionA: "Excellent", optionB: "Good" },
495
+ { category: "Server Storage", optionA: "None", optionB: "Required" },
496
+ { category: "Mobile Support", optionA: "Native", optionB: "Complex" }
497
+ ],
498
+ style: "two-column layout, checkmarks for advantages"
499
+ });
500
+ ```
501
+
502
+ **For Architecture Diagrams (`architecture-diagram`):**
503
+ ```javascript
504
+ // Best service: Gemini (fast, good for technical diagrams)
505
+ const prompt = buildArchitectureDiagramPrompt({
506
+ title: "Microservices Architecture",
507
+ components: ["API Gateway", "Auth Service", "User Service", "Database"],
508
+ connections: ["Gateway → Auth", "Gateway → User", "Services → Database"],
509
+ style: "isometric 3D blocks, labeled, connection arrows"
510
+ });
511
+ ```
512
+
513
+ ### Service Selection by Type
514
+
515
+ Use this guide to auto-select the best service:
516
+
517
+ ```javascript
518
+ function getRecommendedService(type) {
519
+ const recommendations = {
520
+ // Text-heavy visuals → GPT Image 1.5 (best text rendering)
521
+ 'infographic-data': 'gpt-image-1.5',
522
+ 'infographic-comparison': 'gpt-image-1.5',
523
+ 'screenshot': 'gpt-image-1.5',
524
+
525
+ // Detailed illustrations → FLUX 2 Pro (best detail)
526
+ 'infographic-process': 'flux2-pro',
527
+ 'infographic-timeline': 'flux2-pro',
528
+ 'illustration': 'flux2-pro',
529
+ 'hero': 'flux2-pro',
530
+
531
+ // Technical diagrams → Gemini (fast, cost-effective)
532
+ 'diagram': 'gemini',
533
+ 'architecture-diagram': 'gemini',
534
+ 'flowchart': 'gemini',
535
+ 'sequence-diagram': 'gemini',
536
+
537
+ // Video → Veo 3 (only option)
538
+ 'video': 'veo3'
539
+ };
540
+
541
+ return recommendations[type] || 'gemini';
542
+ }
543
+ ```
544
+
545
+ ### Batch Generation for Articles
546
+
547
+ Generate all visuals for an article efficiently:
548
+
549
+ ```javascript
550
+ async function generateArticleVisuals(articlePlan) {
551
+ const visuals = [];
552
+
553
+ // Hero image
554
+ if (articlePlan.heroImage) {
555
+ visuals.push({
556
+ type: 'hero',
557
+ prompt: articlePlan.heroImage.concept,
558
+ service: 'flux2-pro'
559
+ });
560
+ }
561
+
562
+ // Diagrams
563
+ for (const diagram of articlePlan.diagrams || []) {
564
+ visuals.push({
565
+ type: diagram.type || 'diagram',
566
+ prompt: diagram.description,
567
+ service: getRecommendedService(diagram.type)
568
+ });
569
+ }
570
+
571
+ // Infographics
572
+ for (const infographic of articlePlan.infographics || []) {
573
+ visuals.push({
574
+ type: infographic.type,
575
+ prompt: buildInfographicPrompt(infographic),
576
+ service: getRecommendedService(infographic.type)
577
+ });
578
+ }
579
+
580
+ // Estimate total cost before generating
581
+ const totalCost = visuals.reduce((sum, v) => sum + estimateCost(v.service), 0);
582
+ console.log(`📊 Generating ${visuals.length} visuals. Estimated cost: $${totalCost.toFixed(2)}`);
583
+
584
+ // Generate all (with budget check)
585
+ const results = [];
586
+ for (const visual of visuals) {
587
+ const result = await generateImage(visual.prompt, {
588
+ preferredService: visual.service,
589
+ type: visual.type
590
+ });
591
+ results.push(result);
592
+ }
593
+
594
+ return results;
595
+ }
596
+ ```
597
+
420
598
  ### Quality vs Cost
421
599
 
422
600
  ```javascript
@@ -505,6 +683,130 @@ console.log(`\nReview the image and confirm it meets your requirements.`);
505
683
  - Execute using standard Node.js commands
506
684
  - All features available
507
685
 
686
+ ## HTML Conversion Mode (Precise Visuals)
687
+
688
+ For data-driven visuals requiring pixel-perfect accuracy, use HTML conversion instead of AI image generation.
689
+
690
+ ### When to Use HTML Conversion
691
+
692
+ | Use Case | Recommended Tool |
693
+ |----------|-----------------|
694
+ | Infographics with exact numbers/data | **HTML Conversion** |
695
+ | Creative/artistic images | AI Image Generation |
696
+ | Diagrams with specific text labels | **HTML/D2 Conversion** |
697
+ | Photorealistic scenes | AI Image Generation |
698
+ | Presentation slides (PPTX) | **HTML → PPTX** |
699
+ | Charts and graphs | **HTML Conversion** |
700
+ | Architecture diagrams | **D2 Conversion** |
701
+
702
+ ### HTML Conversion Benefits
703
+
704
+ - **Perfect text accuracy** - No AI hallucinations on text/numbers
705
+ - **Reproducible** - Same input = identical output every time
706
+ - **Free** - No API costs (local Puppeteer rendering)
707
+ - **Fast** - Renders in < 1 second
708
+ - **Editable** - Modify source HTML to update
709
+
710
+ ### Available Templates
711
+
712
+ **HTML Templates:**
713
+ - `data-chart` - Bar/pie charts from data
714
+ - `comparison-table` - Side-by-side comparisons
715
+ - `process-flow` - Step-by-step processes (vertical/horizontal/timeline)
716
+
717
+ **D2 Diagram Templates:**
718
+ - `architecture` - System architecture diagrams
719
+ - `flowchart` - Decision flowcharts
720
+ - `sequence` - Sequence diagrams
721
+
722
+ ### Using HTML Conversion
723
+
724
+ ```javascript
725
+ const {
726
+ templateToVisual,
727
+ d2TemplateToVisual,
728
+ htmlToPng,
729
+ htmlToPdf,
730
+ htmlToPptx
731
+ } = require('./src/lib/html-conversion-utils.js');
732
+
733
+ // Generate infographic from template
734
+ const result = await templateToVisual('data-chart', {
735
+ title: 'Q4 Revenue by Region',
736
+ chartType: 'bar',
737
+ items: [
738
+ { label: 'North America', value: '$2.4M', percentage: 85, color: '#3b82f6' },
739
+ { label: 'Europe', value: '$1.8M', percentage: 64, color: '#10b981' }
740
+ ]
741
+ }, 'png');
742
+
743
+ console.log(`Generated: ${result.path}`);
744
+ console.log(`Cost: $0.00 (local rendering)`);
745
+
746
+ // Generate D2 architecture diagram
747
+ const diagram = await d2TemplateToVisual('architecture', {
748
+ title: 'System Architecture',
749
+ components: [
750
+ { id: 'user', label: 'User', shape: 'person' },
751
+ { id: 'api', label: 'API Gateway' },
752
+ { id: 'db', label: 'Database', shape: 'cylinder' }
753
+ ],
754
+ connections: [
755
+ { from: 'user', to: 'api', label: 'HTTPS' },
756
+ { from: 'api', to: 'db', label: 'SQL' }
757
+ ]
758
+ }, 'png');
759
+ ```
760
+
761
+ ### CLI Usage
762
+
763
+ ```bash
764
+ # List available templates
765
+ node src/scripts/html-conversion-cli.js list
766
+
767
+ # Generate from HTML template
768
+ node src/scripts/html-conversion-cli.js template data-chart \
769
+ --data '{"title":"Sales Report","items":[...]}' \
770
+ --format png
771
+
772
+ # Generate D2 diagram
773
+ node src/scripts/html-conversion-cli.js d2 "user -> api -> db" --format png
774
+
775
+ # Generate PPTX presentation
776
+ node src/scripts/html-conversion-cli.js pptx ./slides/ --output presentation.pptx
777
+ ```
778
+
779
+ ### Decision Guide: AI vs HTML
780
+
781
+ **Choose AI Image Generation when:**
782
+ - Creative/artistic output needed
783
+ - Photorealistic imagery
784
+ - Abstract concepts without specific data
785
+ - Unique visual styles
786
+
787
+ **Choose HTML Conversion when:**
788
+ - Specific numbers, statistics, or data
789
+ - Text must be accurate (company names, metrics)
790
+ - Architecture/technical diagrams
791
+ - Process flows with exact steps
792
+ - Comparison tables with specific features
793
+ - Presentation decks from data
794
+
795
+ ### Example: Hybrid Approach
796
+
797
+ For articles, combine both methods:
798
+
799
+ ```javascript
800
+ // Hero image → AI (creative)
801
+ const hero = await generateImage(prompt, { type: 'hero' });
802
+
803
+ // Data chart → HTML (accurate)
804
+ const chart = await templateToVisual('data-chart', chartData, 'png');
805
+
806
+ // Architecture diagram → D2 (precise)
807
+ const arch = await d2TemplateToVisual('architecture', archData, 'png');
808
+ ```
809
+
508
810
  ## Summary
509
811
 
510
812
  You are responsible for:
@@ -512,9 +814,10 @@ You are responsible for:
512
814
  2. ✅ Gathering user requirements (prompt, type, service preferences)
513
815
  3. ✅ Estimating costs and checking budgets
514
816
  4. ✅ Generating images/videos using appropriate APIs
515
- 5. ✅ Saving to organized directory structure
516
- 6. ✅ Tracking usage and costs
517
- 7. ✅ Returning markdown references
518
- 8. ✅ Providing helpful error messages and alternatives
817
+ 5. ✅ **Using HTML conversion for data-driven/precise visuals**
818
+ 6. ✅ Saving to organized directory structure
819
+ 7. ✅ Tracking usage and costs
820
+ 8. ✅ Returning markdown references
821
+ 9. ✅ Providing helpful error messages and alternatives
519
822
 
520
823
  Always prioritize user experience, cost transparency, and quality results.