myaidev-method 0.2.23 → 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.
- package/bin/cli.js +218 -38
- package/dist/server/.tsbuildinfo +1 -1
- package/package.json +10 -5
- package/src/config/workflows.js +28 -44
- package/src/lib/ascii-banner.js +214 -0
- package/src/lib/config-manager.js +470 -0
- package/src/lib/content-generator.js +427 -0
- package/src/lib/html-conversion-utils.js +843 -0
- package/src/lib/seo-optimizer.js +515 -0
- package/src/lib/wordpress-client.js +633 -0
- package/src/lib/workflow-installer.js +3 -3
- package/src/scripts/html-conversion-cli.js +526 -0
- package/src/scripts/init/configure.js +436 -0
- package/src/scripts/init/install.js +460 -0
- package/src/scripts/utils/file-utils.js +404 -0
- package/src/scripts/utils/logger.js +300 -0
- package/src/scripts/utils/write-content.js +293 -0
- package/src/templates/claude/agents/visual-content-generator.md +129 -4
- package/src/templates/claude/commands/myai-convert-html.md +186 -0
- package/src/templates/diagrams/architecture.d2 +52 -0
- package/src/templates/diagrams/flowchart.d2 +42 -0
- package/src/templates/diagrams/sequence.d2 +47 -0
- package/src/templates/docs/content-creation-guide.md +164 -0
- package/src/templates/docs/deployment-guide.md +336 -0
- package/src/templates/docs/visual-generation-guide.md +248 -0
- package/src/templates/docs/wordpress-publishing-guide.md +208 -0
- package/src/templates/infographics/comparison-table.html +347 -0
- package/src/templates/infographics/data-chart.html +268 -0
- package/src/templates/infographics/process-flow.html +365 -0
- /package/src/scripts/{wordpress-health-check.js → wordpress/wordpress-health-check.js} +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Write Content CLI
|
|
5
|
+
* Command-line wrapper for content generation
|
|
6
|
+
* Usage: node write-content.js "Topic" [options]
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ContentGenerator } from '../../lib/content-generator.js';
|
|
10
|
+
import { SEOOptimizer } from '../../lib/seo-optimizer.js';
|
|
11
|
+
import { logger, formatTable } from './logger.js';
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parse command line arguments
|
|
17
|
+
* @param {string[]} args - Command line arguments
|
|
18
|
+
* @returns {Object} Parsed options
|
|
19
|
+
*/
|
|
20
|
+
function parseArgs(args) {
|
|
21
|
+
const options = {
|
|
22
|
+
topic: '',
|
|
23
|
+
contentType: 'blog-post',
|
|
24
|
+
wordCount: 1500,
|
|
25
|
+
tone: 'professional',
|
|
26
|
+
keywords: [],
|
|
27
|
+
outputDir: './content',
|
|
28
|
+
outputFile: '',
|
|
29
|
+
analyze: false,
|
|
30
|
+
help: false
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
while (i < args.length) {
|
|
35
|
+
const arg = args[i];
|
|
36
|
+
|
|
37
|
+
if (arg === '--help' || arg === '-h') {
|
|
38
|
+
options.help = true;
|
|
39
|
+
} else if (arg === '--type' || arg === '-t') {
|
|
40
|
+
options.contentType = args[++i];
|
|
41
|
+
} else if (arg === '--word-count' || arg === '-w') {
|
|
42
|
+
options.wordCount = parseInt(args[++i], 10);
|
|
43
|
+
} else if (arg === '--tone') {
|
|
44
|
+
options.tone = args[++i];
|
|
45
|
+
} else if (arg === '--keywords' || arg === '-k') {
|
|
46
|
+
options.keywords = args[++i].split(',').map(k => k.trim());
|
|
47
|
+
} else if (arg === '--output' || arg === '-o') {
|
|
48
|
+
options.outputFile = args[++i];
|
|
49
|
+
} else if (arg === '--output-dir') {
|
|
50
|
+
options.outputDir = args[++i];
|
|
51
|
+
} else if (arg === '--analyze' || arg === '-a') {
|
|
52
|
+
options.analyze = true;
|
|
53
|
+
} else if (!arg.startsWith('-')) {
|
|
54
|
+
options.topic = arg;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
i++;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return options;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Show help message
|
|
65
|
+
*/
|
|
66
|
+
function showHelp() {
|
|
67
|
+
console.log(`
|
|
68
|
+
Write Content - Content Generation CLI
|
|
69
|
+
|
|
70
|
+
Usage: node write-content.js "Topic" [options]
|
|
71
|
+
|
|
72
|
+
Options:
|
|
73
|
+
-h, --help Show this help message
|
|
74
|
+
-t, --type <type> Content type (blog-post, tutorial, how-to, listicle, product-review, comparison)
|
|
75
|
+
-w, --word-count <num> Target word count (default: 1500)
|
|
76
|
+
--tone <tone> Writing tone (professional, conversational, technical, casual, authoritative)
|
|
77
|
+
-k, --keywords <list> Comma-separated keywords for SEO
|
|
78
|
+
-o, --output <file> Output filename (auto-generated if not specified)
|
|
79
|
+
--output-dir <dir> Output directory (default: ./content)
|
|
80
|
+
-a, --analyze Analyze content for SEO after generation
|
|
81
|
+
|
|
82
|
+
Examples:
|
|
83
|
+
node write-content.js "How to Train a Puppy" --type tutorial --tone conversational
|
|
84
|
+
node write-content.js "Best Laptops 2024" --type listicle --keywords "laptops,tech,reviews"
|
|
85
|
+
node write-content.js "React vs Vue" --type comparison --word-count 2500 --analyze
|
|
86
|
+
`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Generate content specification for the content-writer agent
|
|
91
|
+
* @param {Object} options - Generation options
|
|
92
|
+
*/
|
|
93
|
+
async function generateContentSpec(options) {
|
|
94
|
+
const generator = new ContentGenerator({
|
|
95
|
+
outputDir: options.outputDir,
|
|
96
|
+
tone: options.tone,
|
|
97
|
+
wordCount: options.wordCount
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
await generator.initialize();
|
|
101
|
+
|
|
102
|
+
// Validate options
|
|
103
|
+
const validation = generator.validateOptions(options);
|
|
104
|
+
if (!validation.valid) {
|
|
105
|
+
for (const error of validation.errors) {
|
|
106
|
+
logger.error(error);
|
|
107
|
+
}
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Generate content specification
|
|
112
|
+
const spec = generator.generateContentSpec(options.topic, {
|
|
113
|
+
contentType: options.contentType,
|
|
114
|
+
wordCount: options.wordCount,
|
|
115
|
+
tone: options.tone,
|
|
116
|
+
keywords: options.keywords
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
logger.header('Content Specification');
|
|
120
|
+
logger.log(`Topic: ${spec.topic}`);
|
|
121
|
+
logger.log(`Type: ${spec.contentType}`);
|
|
122
|
+
logger.log(`Word Count Target: ${spec.wordCount}`);
|
|
123
|
+
logger.log(`Tone: ${spec.tone}`);
|
|
124
|
+
logger.log(`Keywords: ${spec.keywords.length > 0 ? spec.keywords.join(', ') : 'None specified'}`);
|
|
125
|
+
logger.blank();
|
|
126
|
+
|
|
127
|
+
logger.section('Required Sections');
|
|
128
|
+
for (const section of spec.sections) {
|
|
129
|
+
logger.log(` • ${section}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
logger.section('Frontmatter Fields');
|
|
133
|
+
for (const field of spec.requiredFrontmatter) {
|
|
134
|
+
logger.log(` • ${field}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Generate filename
|
|
138
|
+
const filename = options.outputFile || generator.generateFilename(options.topic);
|
|
139
|
+
const outputPath = path.join(options.outputDir, filename);
|
|
140
|
+
|
|
141
|
+
logger.section('Output');
|
|
142
|
+
logger.log(`Filename: ${filename}`);
|
|
143
|
+
logger.log(`Path: ${outputPath}`);
|
|
144
|
+
logger.blank();
|
|
145
|
+
|
|
146
|
+
// Generate frontmatter template
|
|
147
|
+
const frontmatterData = {
|
|
148
|
+
title: options.topic,
|
|
149
|
+
description: '',
|
|
150
|
+
date: new Date().toISOString().split('T')[0],
|
|
151
|
+
author: '',
|
|
152
|
+
categories: [],
|
|
153
|
+
tags: options.keywords,
|
|
154
|
+
status: 'draft'
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const frontmatter = generator.generateFrontmatter(frontmatterData);
|
|
158
|
+
|
|
159
|
+
// Create template file
|
|
160
|
+
const templateContent = `${frontmatter}
|
|
161
|
+
# ${options.topic}
|
|
162
|
+
|
|
163
|
+
<!-- Introduction -->
|
|
164
|
+
|
|
165
|
+
## Overview
|
|
166
|
+
|
|
167
|
+
[Write introduction here]
|
|
168
|
+
|
|
169
|
+
${spec.sections.slice(1).map(section => `
|
|
170
|
+
## ${section.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')}
|
|
171
|
+
|
|
172
|
+
[Write ${section} content here]
|
|
173
|
+
`).join('\n')}
|
|
174
|
+
|
|
175
|
+
<!-- Call to Action -->
|
|
176
|
+
|
|
177
|
+
## Conclusion
|
|
178
|
+
|
|
179
|
+
[Write conclusion here]
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
await fs.ensureDir(options.outputDir);
|
|
183
|
+
await fs.writeFile(outputPath, templateContent, 'utf-8');
|
|
184
|
+
|
|
185
|
+
logger.success(`Template created: ${outputPath}`);
|
|
186
|
+
logger.blank();
|
|
187
|
+
logger.info('Use the content-writer agent to generate full content:');
|
|
188
|
+
logger.log(` /myai-content-writer "${options.topic}" --type ${options.contentType}`);
|
|
189
|
+
|
|
190
|
+
return { spec, outputPath, templateContent };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Analyze existing content file
|
|
195
|
+
* @param {string} filePath - Path to content file
|
|
196
|
+
* @param {string[]} keywords - Keywords to check
|
|
197
|
+
*/
|
|
198
|
+
async function analyzeContent(filePath, keywords) {
|
|
199
|
+
const optimizer = new SEOOptimizer();
|
|
200
|
+
|
|
201
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
202
|
+
|
|
203
|
+
// Extract title from frontmatter or first heading
|
|
204
|
+
const titleMatch = content.match(/^title:\s*(.+)$/m) || content.match(/^#\s+(.+)$/m);
|
|
205
|
+
const title = titleMatch ? titleMatch[1].trim() : '';
|
|
206
|
+
|
|
207
|
+
logger.header('SEO Analysis');
|
|
208
|
+
logger.log(`File: ${filePath}`);
|
|
209
|
+
logger.log(`Title: ${title || 'Not found'}`);
|
|
210
|
+
logger.blank();
|
|
211
|
+
|
|
212
|
+
const analysis = optimizer.analyzeSEO(content, keywords, title);
|
|
213
|
+
|
|
214
|
+
// Score display
|
|
215
|
+
const scoreColor = analysis.score >= 80 ? 'green' : analysis.score >= 60 ? 'yellow' : 'red';
|
|
216
|
+
logger.log(`SEO Score: ${analysis.score}/100 (Grade: ${analysis.grade})`);
|
|
217
|
+
logger.log(`Word Count: ${analysis.wordCount}`);
|
|
218
|
+
if (analysis.keywordDensity !== null) {
|
|
219
|
+
logger.log(`Keyword Density: ${analysis.keywordDensity}%`);
|
|
220
|
+
}
|
|
221
|
+
logger.blank();
|
|
222
|
+
|
|
223
|
+
// Issues
|
|
224
|
+
if (analysis.issues.length > 0) {
|
|
225
|
+
logger.section('Issues');
|
|
226
|
+
for (const issue of analysis.issues) {
|
|
227
|
+
logger.error(issue);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Recommendations
|
|
232
|
+
if (analysis.recommendations.length > 0) {
|
|
233
|
+
logger.section('Recommendations');
|
|
234
|
+
for (const rec of analysis.recommendations) {
|
|
235
|
+
logger.warn(rec);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Meta description
|
|
240
|
+
logger.section('Generated Meta Description');
|
|
241
|
+
const metaDesc = optimizer.generateMetaDescription(content);
|
|
242
|
+
logger.log(metaDesc);
|
|
243
|
+
logger.log(`Length: ${metaDesc.length} characters`);
|
|
244
|
+
|
|
245
|
+
// Slug
|
|
246
|
+
if (title) {
|
|
247
|
+
logger.section('Generated Slug');
|
|
248
|
+
logger.log(optimizer.generateSlug(title));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return analysis;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Main function
|
|
256
|
+
*/
|
|
257
|
+
async function main() {
|
|
258
|
+
const args = process.argv.slice(2);
|
|
259
|
+
const options = parseArgs(args);
|
|
260
|
+
|
|
261
|
+
if (options.help) {
|
|
262
|
+
showHelp();
|
|
263
|
+
process.exit(0);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!options.topic && !options.analyze) {
|
|
267
|
+
logger.error('Topic is required. Use --help for usage information.');
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
if (options.analyze && options.topic) {
|
|
273
|
+
// If topic looks like a file path, analyze it
|
|
274
|
+
if (options.topic.endsWith('.md') || options.topic.includes('/')) {
|
|
275
|
+
await analyzeContent(options.topic, options.keywords);
|
|
276
|
+
} else {
|
|
277
|
+
// Generate spec and analyze
|
|
278
|
+
const { outputPath } = await generateContentSpec(options);
|
|
279
|
+
await analyzeContent(outputPath, options.keywords);
|
|
280
|
+
}
|
|
281
|
+
} else if (options.analyze && !options.topic) {
|
|
282
|
+
logger.error('Please provide a file path to analyze.');
|
|
283
|
+
process.exit(1);
|
|
284
|
+
} else {
|
|
285
|
+
await generateContentSpec(options);
|
|
286
|
+
}
|
|
287
|
+
} catch (error) {
|
|
288
|
+
logger.error(`Error: ${error.message}`);
|
|
289
|
+
process.exit(1);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
main();
|
|
@@ -683,6 +683,130 @@ console.log(`\nReview the image and confirm it meets your requirements.`);
|
|
|
683
683
|
- Execute using standard Node.js commands
|
|
684
684
|
- All features available
|
|
685
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
|
+
|
|
686
810
|
## Summary
|
|
687
811
|
|
|
688
812
|
You are responsible for:
|
|
@@ -690,9 +814,10 @@ You are responsible for:
|
|
|
690
814
|
2. ✅ Gathering user requirements (prompt, type, service preferences)
|
|
691
815
|
3. ✅ Estimating costs and checking budgets
|
|
692
816
|
4. ✅ Generating images/videos using appropriate APIs
|
|
693
|
-
5. ✅
|
|
694
|
-
6. ✅
|
|
695
|
-
7. ✅
|
|
696
|
-
8. ✅
|
|
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
|
|
697
822
|
|
|
698
823
|
Always prioritize user experience, cost transparency, and quality results.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: myai-convert-html
|
|
3
|
+
description: Convert HTML templates to PNG, PDF, or PPTX formats for precise visual content
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# HTML Conversion Tool
|
|
7
|
+
|
|
8
|
+
Convert HTML templates and D2 diagrams to images, PDFs, and presentations with pixel-perfect accuracy.
|
|
9
|
+
|
|
10
|
+
## When to Use This Tool
|
|
11
|
+
|
|
12
|
+
Use HTML conversion when you need:
|
|
13
|
+
- **Data-driven infographics** with precise numbers and text
|
|
14
|
+
- **Comparison tables** with exact formatting
|
|
15
|
+
- **Process diagrams** with specific labels
|
|
16
|
+
- **Architecture diagrams** using D2 language
|
|
17
|
+
- **Presentation slides** (PPTX) from HTML content
|
|
18
|
+
|
|
19
|
+
## Available Commands
|
|
20
|
+
|
|
21
|
+
### List Templates
|
|
22
|
+
```bash
|
|
23
|
+
node src/scripts/html-conversion-cli.js list
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Convert HTML Template
|
|
27
|
+
```bash
|
|
28
|
+
# Basic usage
|
|
29
|
+
node src/scripts/html-conversion-cli.js template data-chart --data '{"title":"Sales Report","items":[...]}' --format png
|
|
30
|
+
|
|
31
|
+
# With output file
|
|
32
|
+
node src/scripts/html-conversion-cli.js template comparison-table --data data.json --output comparison.png
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Convert D2 Diagram
|
|
36
|
+
```bash
|
|
37
|
+
# From inline script
|
|
38
|
+
node src/scripts/html-conversion-cli.js d2 "user -> api -> database" --format png
|
|
39
|
+
|
|
40
|
+
# From file
|
|
41
|
+
node src/scripts/html-conversion-cli.js d2 diagram.d2 --format svg --theme 200
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Convert D2 Template
|
|
45
|
+
```bash
|
|
46
|
+
node src/scripts/html-conversion-cli.js d2-template architecture --data '{"title":"System Design",...}' --format svg
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Convert Raw HTML
|
|
50
|
+
```bash
|
|
51
|
+
node src/scripts/html-conversion-cli.js html custom.html --format pdf
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Generate PPTX
|
|
55
|
+
```bash
|
|
56
|
+
# From directory of HTML slides
|
|
57
|
+
node src/scripts/html-conversion-cli.js pptx ./slides/ --output presentation.pptx
|
|
58
|
+
|
|
59
|
+
# From JSON configuration
|
|
60
|
+
node src/scripts/html-conversion-cli.js pptx slides.json --title "Q4 Report" --author "Team"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Built-in Templates
|
|
64
|
+
|
|
65
|
+
### HTML Templates
|
|
66
|
+
|
|
67
|
+
1. **data-chart** - Bar/pie charts with data visualization
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"title": "Revenue by Region",
|
|
71
|
+
"chartType": "bar",
|
|
72
|
+
"items": [
|
|
73
|
+
{"label": "North America", "value": 45, "percentage": 90, "color": "#3b82f6"},
|
|
74
|
+
{"label": "Europe", "value": 32, "percentage": 64, "color": "#10b981"}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. **comparison-table** - Side-by-side feature comparisons
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"title": "Plan Comparison",
|
|
83
|
+
"layout": "table",
|
|
84
|
+
"columns": [{"name": "Basic"}, {"name": "Pro", "highlight": true}],
|
|
85
|
+
"rows": [{"feature": "Users", "values": [{"text": "5"}, {"text": "Unlimited"}]}]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3. **process-flow** - Step-by-step process diagrams
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"title": "Development Workflow",
|
|
93
|
+
"layout": "vertical",
|
|
94
|
+
"steps": [
|
|
95
|
+
{"number": 1, "title": "Planning", "description": "Define requirements"}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### D2 Templates
|
|
101
|
+
|
|
102
|
+
1. **architecture** - System architecture diagrams
|
|
103
|
+
2. **flowchart** - Decision flowcharts
|
|
104
|
+
3. **sequence** - Sequence diagrams
|
|
105
|
+
|
|
106
|
+
## HTML vs AI Image Generation
|
|
107
|
+
|
|
108
|
+
| Use Case | Recommended Tool |
|
|
109
|
+
|----------|-----------------|
|
|
110
|
+
| Infographics with exact data | HTML Conversion |
|
|
111
|
+
| Creative/artistic images | AI Image Generation |
|
|
112
|
+
| Diagrams with specific text | HTML/D2 Conversion |
|
|
113
|
+
| Photorealistic scenes | AI Image Generation |
|
|
114
|
+
| Presentations/slides | HTML → PPTX |
|
|
115
|
+
| Charts and graphs | HTML Conversion |
|
|
116
|
+
|
|
117
|
+
## Example Workflow
|
|
118
|
+
|
|
119
|
+
1. **Create data file** (data.json):
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"title": "Q4 Performance Report",
|
|
123
|
+
"subtitle": "Year over Year Growth",
|
|
124
|
+
"chartType": "bar",
|
|
125
|
+
"items": [
|
|
126
|
+
{"label": "Revenue", "value": "$2.4M", "percentage": 85, "color": "#3b82f6"},
|
|
127
|
+
{"label": "Users", "value": "150K", "percentage": 72, "color": "#10b981"},
|
|
128
|
+
{"label": "Retention", "value": "94%", "percentage": 94, "color": "#f59e0b"}
|
|
129
|
+
],
|
|
130
|
+
"source": "Internal Analytics"
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. **Generate PNG**:
|
|
135
|
+
```bash
|
|
136
|
+
node src/scripts/html-conversion-cli.js template data-chart --data data.json --format png --output q4-report.png
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
3. **Generate PDF**:
|
|
140
|
+
```bash
|
|
141
|
+
node src/scripts/html-conversion-cli.js template data-chart --data data.json --format pdf --output q4-report.pdf
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## D2 Diagram Quick Reference
|
|
145
|
+
|
|
146
|
+
D2 is a declarative diagram language. Quick syntax:
|
|
147
|
+
|
|
148
|
+
```d2
|
|
149
|
+
# Nodes
|
|
150
|
+
user: User {shape: person}
|
|
151
|
+
api: API Server
|
|
152
|
+
db: Database {shape: cylinder}
|
|
153
|
+
|
|
154
|
+
# Connections
|
|
155
|
+
user -> api: HTTP
|
|
156
|
+
api -> db: SQL
|
|
157
|
+
|
|
158
|
+
# Grouping
|
|
159
|
+
backend: Backend {
|
|
160
|
+
api
|
|
161
|
+
db
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Install D2: `curl -fsSL https://d2lang.com/install.sh | sh`
|
|
166
|
+
|
|
167
|
+
## Tips
|
|
168
|
+
|
|
169
|
+
1. **Preview templates** before generating final output:
|
|
170
|
+
```bash
|
|
171
|
+
node src/scripts/html-conversion-cli.js preview data-chart
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. **Use high DPI** for print quality:
|
|
175
|
+
```bash
|
|
176
|
+
node src/scripts/html-conversion-cli.js template data-chart --data data.json --scale 3
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
3. **Custom styling** via template data:
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"accentColor": "#6366f1",
|
|
183
|
+
"accentGradient": "#4f46e5",
|
|
184
|
+
"backgroundColor": "#fafafa"
|
|
185
|
+
}
|
|
186
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Architecture Diagram Template
|
|
2
|
+
# Variables: {{title}}, {{direction}}, {{components}}, {{connections}}
|
|
3
|
+
# Theme: 200 (Terminal theme) by default
|
|
4
|
+
|
|
5
|
+
# Layout direction
|
|
6
|
+
direction: {{direction || 'right'}}
|
|
7
|
+
|
|
8
|
+
# Title (optional)
|
|
9
|
+
{{#title}}
|
|
10
|
+
title: {{title}} {
|
|
11
|
+
near: top-center
|
|
12
|
+
shape: text
|
|
13
|
+
style: {
|
|
14
|
+
font-size: 24
|
|
15
|
+
bold: true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
{{/title}}
|
|
19
|
+
|
|
20
|
+
# Component definitions
|
|
21
|
+
{{#components}}
|
|
22
|
+
{{id}}: {{label}} {
|
|
23
|
+
{{#shape}}shape: {{shape}}{{/shape}}
|
|
24
|
+
{{#icon}}icon: {{icon}}{{/icon}}
|
|
25
|
+
{{#style}}
|
|
26
|
+
style: {
|
|
27
|
+
{{#fill}}fill: "{{fill}}"{{/fill}}
|
|
28
|
+
{{#stroke}}stroke: "{{stroke}}"{{/stroke}}
|
|
29
|
+
{{#fontSize}}font-size: {{fontSize}}{{/fontSize}}
|
|
30
|
+
}
|
|
31
|
+
{{/style}}
|
|
32
|
+
{{#children}}
|
|
33
|
+
{{#children}}
|
|
34
|
+
{{id}}: {{label}} {
|
|
35
|
+
{{#shape}}shape: {{shape}}{{/shape}}
|
|
36
|
+
}
|
|
37
|
+
{{/children}}
|
|
38
|
+
{{/children}}
|
|
39
|
+
}
|
|
40
|
+
{{/components}}
|
|
41
|
+
|
|
42
|
+
# Connections
|
|
43
|
+
{{#connections}}
|
|
44
|
+
{{from}} -> {{to}}{{#label}}: {{label}}{{/label}} {
|
|
45
|
+
{{#style}}
|
|
46
|
+
style: {
|
|
47
|
+
{{#stroke}}stroke: "{{stroke}}"{{/stroke}}
|
|
48
|
+
{{#strokeDash}}stroke-dash: {{strokeDash}}{{/strokeDash}}
|
|
49
|
+
}
|
|
50
|
+
{{/style}}
|
|
51
|
+
}
|
|
52
|
+
{{/connections}}
|