@edtools/cli 0.4.1 → 0.5.0
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/dist/adapters/html/index.d.ts.map +1 -1
- package/dist/adapters/html/index.js +14 -3
- package/dist/adapters/html/index.js.map +1 -1
- package/dist/adapters/html/templates/blog-index.html.ejs +342 -0
- package/dist/adapters/html/templates/blog-post.html.ejs +48 -0
- package/dist/chunk-AJSCN4WK.js +663 -0
- package/dist/chunk-INVECVSW.js +45 -0
- package/dist/chunk-UMREI3K7.js +652 -0
- package/dist/chunk-ZDV7BJZ4.js +652 -0
- package/dist/chunk-ZG6JJCRI.js +539 -0
- package/dist/cli/index.js +4 -3
- package/dist/content-helpers-TXVEJMQK.js +16 -0
- package/dist/core/generator.d.ts +2 -0
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +120 -8
- package/dist/core/generator.js.map +1 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +2 -1
- package/dist/types/content.d.ts +45 -0
- package/dist/types/content.d.ts.map +1 -1
- package/dist/ui/banner.js +1 -1
- package/dist/utils/content-helpers.d.ts +7 -0
- package/dist/utils/content-helpers.d.ts.map +1 -0
- package/dist/utils/content-helpers.js +48 -0
- package/dist/utils/content-helpers.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
// src/types/adapter.ts
|
|
2
|
+
var AdapterRegistry = class {
|
|
3
|
+
adapters;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.adapters = /* @__PURE__ */ new Map();
|
|
6
|
+
}
|
|
7
|
+
register(adapter) {
|
|
8
|
+
this.adapters.set(adapter.name, adapter);
|
|
9
|
+
}
|
|
10
|
+
get(name) {
|
|
11
|
+
return this.adapters.get(name);
|
|
12
|
+
}
|
|
13
|
+
async detectAdapter(projectPath) {
|
|
14
|
+
for (const adapter of this.adapters.values()) {
|
|
15
|
+
if (await adapter.detect(projectPath)) {
|
|
16
|
+
return adapter;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
list() {
|
|
22
|
+
return Array.from(this.adapters.keys());
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/adapters/html/index.ts
|
|
27
|
+
import fs from "fs-extra";
|
|
28
|
+
import path from "path";
|
|
29
|
+
import { fileURLToPath } from "url";
|
|
30
|
+
import ejs from "ejs";
|
|
31
|
+
import { marked } from "marked";
|
|
32
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
33
|
+
var __dirname = path.dirname(__filename);
|
|
34
|
+
var HTMLAdapter = class {
|
|
35
|
+
name = "html";
|
|
36
|
+
async detect(projectPath) {
|
|
37
|
+
try {
|
|
38
|
+
const files = await fs.readdir(projectPath);
|
|
39
|
+
const hasHtmlInRoot = files.some((f) => f.endsWith(".html"));
|
|
40
|
+
const hasIndexHtml = await fs.pathExists(path.join(projectPath, "index.html"));
|
|
41
|
+
const commonDirs = ["public", "dist", "build", "src"];
|
|
42
|
+
for (const dir of commonDirs) {
|
|
43
|
+
const dirPath = path.join(projectPath, dir);
|
|
44
|
+
if (await fs.pathExists(dirPath)) {
|
|
45
|
+
const dirFiles = await fs.readdir(dirPath);
|
|
46
|
+
const hasHtmlInDir = dirFiles.some((f) => f.endsWith(".html"));
|
|
47
|
+
if (hasHtmlInDir) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return hasHtmlInRoot || hasIndexHtml;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async render(content) {
|
|
58
|
+
const templatePath = path.join(__dirname, "templates", "blog-post.html.ejs");
|
|
59
|
+
if (!await fs.pathExists(templatePath)) {
|
|
60
|
+
throw new Error(`Template not found at: ${templatePath}`);
|
|
61
|
+
}
|
|
62
|
+
const template = await fs.readFile(templatePath, "utf-8");
|
|
63
|
+
const templateData = {
|
|
64
|
+
metadata: content.metadata,
|
|
65
|
+
schemaOrg: JSON.stringify(content.schemaOrg, null, 2),
|
|
66
|
+
intro: await this.markdownToHTML(content.content.intro),
|
|
67
|
+
sections: await Promise.all(
|
|
68
|
+
content.content.sections.map(async (section) => ({
|
|
69
|
+
...section,
|
|
70
|
+
content: await this.renderSectionContent(section)
|
|
71
|
+
}))
|
|
72
|
+
),
|
|
73
|
+
conclusion: await this.markdownToHTML(content.content.conclusion),
|
|
74
|
+
cta: content.content.cta,
|
|
75
|
+
relatedPosts: content.relatedPosts || [],
|
|
76
|
+
seoScore: content.seo.score
|
|
77
|
+
};
|
|
78
|
+
const html = ejs.render(template, templateData);
|
|
79
|
+
return html;
|
|
80
|
+
}
|
|
81
|
+
async write(output, outputPath) {
|
|
82
|
+
await fs.ensureDir(path.dirname(outputPath));
|
|
83
|
+
await fs.writeFile(outputPath, output, "utf-8");
|
|
84
|
+
}
|
|
85
|
+
getFileExtension() {
|
|
86
|
+
return ".html";
|
|
87
|
+
}
|
|
88
|
+
transformPath(basePath) {
|
|
89
|
+
if (!basePath.endsWith(".html")) {
|
|
90
|
+
return basePath + "/index.html";
|
|
91
|
+
}
|
|
92
|
+
return basePath;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Convert markdown to HTML
|
|
96
|
+
*/
|
|
97
|
+
async markdownToHTML(markdown) {
|
|
98
|
+
return marked(markdown);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Render section content based on type
|
|
102
|
+
*/
|
|
103
|
+
async renderSectionContent(section) {
|
|
104
|
+
switch (section.type) {
|
|
105
|
+
case "text":
|
|
106
|
+
return await this.markdownToHTML(section.content);
|
|
107
|
+
case "comparison":
|
|
108
|
+
return this.renderComparisonTable(section.data);
|
|
109
|
+
case "list":
|
|
110
|
+
return this.renderList(section.data);
|
|
111
|
+
case "code":
|
|
112
|
+
return this.renderCode(section.data);
|
|
113
|
+
default:
|
|
114
|
+
return await this.markdownToHTML(section.content);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Render comparison table
|
|
119
|
+
*/
|
|
120
|
+
renderComparisonTable(data) {
|
|
121
|
+
if (!data || !data.headers || !data.rows) {
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
let html = '<table class="comparison-table">\n';
|
|
125
|
+
html += " <thead>\n <tr>\n";
|
|
126
|
+
data.headers.forEach((header) => {
|
|
127
|
+
html += ` <th>${header}</th>
|
|
128
|
+
`;
|
|
129
|
+
});
|
|
130
|
+
html += " </tr>\n </thead>\n";
|
|
131
|
+
html += " <tbody>\n";
|
|
132
|
+
data.rows.forEach((row) => {
|
|
133
|
+
html += " <tr>\n";
|
|
134
|
+
row.forEach((cell) => {
|
|
135
|
+
html += ` <td>${cell}</td>
|
|
136
|
+
`;
|
|
137
|
+
});
|
|
138
|
+
html += " </tr>\n";
|
|
139
|
+
});
|
|
140
|
+
html += " </tbody>\n";
|
|
141
|
+
html += "</table>";
|
|
142
|
+
return html;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Render list
|
|
146
|
+
*/
|
|
147
|
+
renderList(data) {
|
|
148
|
+
if (!data || !data.items) {
|
|
149
|
+
return "";
|
|
150
|
+
}
|
|
151
|
+
const tag = data.ordered ? "ol" : "ul";
|
|
152
|
+
let html = `<${tag} class="content-list">
|
|
153
|
+
`;
|
|
154
|
+
data.items.forEach((item) => {
|
|
155
|
+
html += " <li>\n";
|
|
156
|
+
html += ` <strong>${item.title}</strong>
|
|
157
|
+
`;
|
|
158
|
+
if (item.description) {
|
|
159
|
+
html += ` <p>${item.description}</p>
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
html += " </li>\n";
|
|
163
|
+
});
|
|
164
|
+
html += `</${tag}>`;
|
|
165
|
+
return html;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Render code block
|
|
169
|
+
*/
|
|
170
|
+
renderCode(data) {
|
|
171
|
+
if (!data || !data.code) {
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
174
|
+
let html = '<div class="code-block">\n';
|
|
175
|
+
if (data.caption) {
|
|
176
|
+
html += ` <div class="code-caption">${data.caption}</div>
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
html += ` <pre><code class="language-${data.language || "plaintext"}">${this.escapeHtml(data.code)}</code></pre>
|
|
180
|
+
`;
|
|
181
|
+
html += "</div>";
|
|
182
|
+
return html;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Escape HTML entities
|
|
186
|
+
*/
|
|
187
|
+
escapeHtml(text) {
|
|
188
|
+
const map = {
|
|
189
|
+
"&": "&",
|
|
190
|
+
"<": "<",
|
|
191
|
+
">": ">",
|
|
192
|
+
'"': """,
|
|
193
|
+
"'": "'"
|
|
194
|
+
};
|
|
195
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/core/generator.ts
|
|
200
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
201
|
+
import OpenAI from "openai";
|
|
202
|
+
import path2 from "path";
|
|
203
|
+
import fs2 from "fs-extra";
|
|
204
|
+
import slugify from "slugify";
|
|
205
|
+
var ContentGenerator = class {
|
|
206
|
+
anthropic = null;
|
|
207
|
+
openai = null;
|
|
208
|
+
provider;
|
|
209
|
+
adapters;
|
|
210
|
+
constructor(apiKey, provider = "anthropic") {
|
|
211
|
+
this.provider = provider;
|
|
212
|
+
if (provider === "anthropic") {
|
|
213
|
+
this.anthropic = new Anthropic({
|
|
214
|
+
apiKey: apiKey || process.env.ANTHROPIC_API_KEY || ""
|
|
215
|
+
});
|
|
216
|
+
} else if (provider === "openai") {
|
|
217
|
+
this.openai = new OpenAI({
|
|
218
|
+
apiKey: apiKey || process.env.OPENAI_API_KEY || ""
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
this.adapters = new AdapterRegistry();
|
|
222
|
+
this.adapters.register(new HTMLAdapter());
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Main generate method
|
|
226
|
+
*/
|
|
227
|
+
async generate(config) {
|
|
228
|
+
const results = {
|
|
229
|
+
success: true,
|
|
230
|
+
posts: [],
|
|
231
|
+
warnings: [],
|
|
232
|
+
errors: []
|
|
233
|
+
};
|
|
234
|
+
try {
|
|
235
|
+
const adapter = await this.adapters.detectAdapter(config.projectPath);
|
|
236
|
+
if (!adapter) {
|
|
237
|
+
throw new Error("No suitable adapter found for this project");
|
|
238
|
+
}
|
|
239
|
+
console.log(`\u2713 Using adapter: ${adapter.name}`);
|
|
240
|
+
const topics = config.topics || await this.generateTopics(config.productInfo, config.count || 3);
|
|
241
|
+
for (const topic of topics.slice(0, config.count || 3)) {
|
|
242
|
+
try {
|
|
243
|
+
console.log(`
|
|
244
|
+
\u{1F4DD} Generating: ${topic}`);
|
|
245
|
+
const content = await this.generateContent(config.productInfo, topic);
|
|
246
|
+
const output = await adapter.render(content);
|
|
247
|
+
const slug = content.metadata.slug;
|
|
248
|
+
const fileName = adapter.transformPath?.(slug) || `${slug}/index${adapter.getFileExtension()}`;
|
|
249
|
+
const outputPath = path2.join(config.outputDir, fileName);
|
|
250
|
+
await adapter.write(output, outputPath);
|
|
251
|
+
results.posts.push({
|
|
252
|
+
title: content.metadata.title,
|
|
253
|
+
slug,
|
|
254
|
+
path: outputPath,
|
|
255
|
+
seoScore: content.seo.score
|
|
256
|
+
});
|
|
257
|
+
console.log(`\u2713 Generated: ${outputPath}`);
|
|
258
|
+
console.log(` SEO Score: ${content.seo.score}/100`);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
results.errors?.push(`Failed to generate "${topic}": ${error.message}`);
|
|
261
|
+
results.success = false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (results.posts.length > 0) {
|
|
265
|
+
await this.updateSitemap(config.projectPath, config.outputDir, results.posts);
|
|
266
|
+
}
|
|
267
|
+
} catch (error) {
|
|
268
|
+
results.success = false;
|
|
269
|
+
results.errors?.push(error.message);
|
|
270
|
+
}
|
|
271
|
+
return results;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Generate blog post content using the selected AI provider
|
|
275
|
+
*/
|
|
276
|
+
async generateContent(productInfo, topic) {
|
|
277
|
+
const prompt = this.buildPrompt(productInfo, topic);
|
|
278
|
+
let contentData;
|
|
279
|
+
if (this.provider === "anthropic") {
|
|
280
|
+
contentData = await this.generateWithAnthropic(prompt);
|
|
281
|
+
} else if (this.provider === "openai") {
|
|
282
|
+
contentData = await this.generateWithOpenAI(prompt);
|
|
283
|
+
} else {
|
|
284
|
+
throw new Error(`Unsupported provider: ${this.provider}`);
|
|
285
|
+
}
|
|
286
|
+
const slug = slugify(contentData.metadata.title, { lower: true, strict: true });
|
|
287
|
+
const content = {
|
|
288
|
+
metadata: {
|
|
289
|
+
...contentData.metadata,
|
|
290
|
+
slug,
|
|
291
|
+
datePublished: (/* @__PURE__ */ new Date()).toISOString(),
|
|
292
|
+
author: productInfo.name
|
|
293
|
+
},
|
|
294
|
+
schemaOrg: this.generateSchemaOrg({
|
|
295
|
+
...contentData.metadata,
|
|
296
|
+
slug,
|
|
297
|
+
datePublished: (/* @__PURE__ */ new Date()).toISOString(),
|
|
298
|
+
author: productInfo.name
|
|
299
|
+
}, productInfo),
|
|
300
|
+
content: contentData.content,
|
|
301
|
+
relatedPosts: [],
|
|
302
|
+
seo: await this.calculateSEOScore(contentData)
|
|
303
|
+
};
|
|
304
|
+
return content;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Generate content using Anthropic's Claude API
|
|
308
|
+
*/
|
|
309
|
+
async generateWithAnthropic(prompt) {
|
|
310
|
+
if (!this.anthropic) {
|
|
311
|
+
throw new Error("Anthropic client not initialized");
|
|
312
|
+
}
|
|
313
|
+
const response = await this.anthropic.messages.create({
|
|
314
|
+
model: "claude-3-5-sonnet-20241022",
|
|
315
|
+
max_tokens: 4096,
|
|
316
|
+
temperature: 0.7,
|
|
317
|
+
messages: [
|
|
318
|
+
{
|
|
319
|
+
role: "user",
|
|
320
|
+
content: prompt
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
});
|
|
324
|
+
const textContent = response.content[0].type === "text" ? response.content[0].text : "";
|
|
325
|
+
const jsonMatch = textContent.match(/\{[\s\S]*\}/);
|
|
326
|
+
if (!jsonMatch) {
|
|
327
|
+
throw new Error("Failed to extract JSON from Claude response");
|
|
328
|
+
}
|
|
329
|
+
return JSON.parse(jsonMatch[0]);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Generate content using OpenAI's ChatGPT API
|
|
333
|
+
*/
|
|
334
|
+
async generateWithOpenAI(prompt) {
|
|
335
|
+
if (!this.openai) {
|
|
336
|
+
throw new Error("OpenAI client not initialized");
|
|
337
|
+
}
|
|
338
|
+
const response = await this.openai.chat.completions.create({
|
|
339
|
+
model: "gpt-4-turbo-preview",
|
|
340
|
+
max_tokens: 4096,
|
|
341
|
+
temperature: 0.7,
|
|
342
|
+
messages: [
|
|
343
|
+
{
|
|
344
|
+
role: "user",
|
|
345
|
+
content: prompt
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
response_format: { type: "json_object" }
|
|
349
|
+
});
|
|
350
|
+
const textContent = response.choices[0]?.message?.content || "";
|
|
351
|
+
if (!textContent) {
|
|
352
|
+
throw new Error("Failed to get response from OpenAI");
|
|
353
|
+
}
|
|
354
|
+
return JSON.parse(textContent);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Build prompt for Claude API
|
|
358
|
+
*/
|
|
359
|
+
buildPrompt(productInfo, topic) {
|
|
360
|
+
return `You are an expert SEO content writer. Generate a comprehensive blog post about: "${topic}"
|
|
361
|
+
|
|
362
|
+
Product context:
|
|
363
|
+
- Name: ${productInfo.name}
|
|
364
|
+
- Tagline: ${productInfo.tagline || ""}
|
|
365
|
+
- Category: ${productInfo.category}
|
|
366
|
+
- Features: ${productInfo.features.join(", ")}
|
|
367
|
+
- Pricing: ${productInfo.pricingModel || "Not specified"}
|
|
368
|
+
${productInfo.useCases ? `- Use cases: ${productInfo.useCases.join(", ")}` : ""}
|
|
369
|
+
|
|
370
|
+
IMPORTANT INSTRUCTIONS:
|
|
371
|
+
1. Write for users searching on Google and being recommended by AI assistants (Claude, ChatGPT)
|
|
372
|
+
2. Focus on being helpful, not promotional
|
|
373
|
+
3. Include comparisons with alternatives when relevant
|
|
374
|
+
4. Use natural language, avoid keyword stuffing
|
|
375
|
+
5. Make it comprehensive (1000-1500 words worth of content)
|
|
376
|
+
6. Structure with clear sections (intro, 3-5 main sections, conclusion)
|
|
377
|
+
7. Be factual - do NOT invent statistics or make false claims
|
|
378
|
+
|
|
379
|
+
Output ONLY valid JSON in this exact format (no markdown, no code blocks):
|
|
380
|
+
{
|
|
381
|
+
"metadata": {
|
|
382
|
+
"title": "SEO-optimized title (under 60 chars)",
|
|
383
|
+
"description": "Meta description (under 160 chars)",
|
|
384
|
+
"keywords": ["keyword1", "keyword2", "keyword3"],
|
|
385
|
+
"category": "${productInfo.category}"
|
|
386
|
+
},
|
|
387
|
+
"content": {
|
|
388
|
+
"intro": "Engaging introduction paragraph in markdown format",
|
|
389
|
+
"sections": [
|
|
390
|
+
{
|
|
391
|
+
"heading": "Section title",
|
|
392
|
+
"level": 2,
|
|
393
|
+
"content": "Section content in markdown format",
|
|
394
|
+
"type": "text"
|
|
395
|
+
}
|
|
396
|
+
],
|
|
397
|
+
"conclusion": "Conclusion paragraph in markdown",
|
|
398
|
+
"cta": {
|
|
399
|
+
"text": "Try ${productInfo.name}",
|
|
400
|
+
"url": "${productInfo.websiteUrl || "/signup"}"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}`;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Generate Schema.org structured data
|
|
407
|
+
*/
|
|
408
|
+
generateSchemaOrg(metadata, productInfo) {
|
|
409
|
+
return {
|
|
410
|
+
"@context": "https://schema.org",
|
|
411
|
+
"@type": "BlogPosting",
|
|
412
|
+
headline: metadata.title,
|
|
413
|
+
description: metadata.description,
|
|
414
|
+
author: {
|
|
415
|
+
"@type": "Organization",
|
|
416
|
+
name: productInfo.name,
|
|
417
|
+
url: productInfo.websiteUrl
|
|
418
|
+
},
|
|
419
|
+
datePublished: metadata.datePublished,
|
|
420
|
+
publisher: {
|
|
421
|
+
"@type": "Organization",
|
|
422
|
+
name: productInfo.name
|
|
423
|
+
},
|
|
424
|
+
keywords: metadata.keywords.join(", "),
|
|
425
|
+
articleSection: metadata.category
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Calculate SEO score
|
|
430
|
+
*/
|
|
431
|
+
async calculateSEOScore(content) {
|
|
432
|
+
let score = 100;
|
|
433
|
+
const suggestions = [];
|
|
434
|
+
if (content.metadata.title.length > 60) {
|
|
435
|
+
score -= 10;
|
|
436
|
+
suggestions.push("Title is too long (should be under 60 chars)");
|
|
437
|
+
}
|
|
438
|
+
if (content.metadata.description.length > 160) {
|
|
439
|
+
score -= 10;
|
|
440
|
+
suggestions.push("Meta description is too long (should be under 160 chars)");
|
|
441
|
+
}
|
|
442
|
+
if (content.metadata.keywords.length < 3) {
|
|
443
|
+
score -= 5;
|
|
444
|
+
suggestions.push("Add more keywords (at least 3)");
|
|
445
|
+
}
|
|
446
|
+
if (content.content.sections.length < 3) {
|
|
447
|
+
score -= 10;
|
|
448
|
+
suggestions.push("Add more sections for better structure (at least 3)");
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
score: Math.max(0, score),
|
|
452
|
+
suggestions
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Generate topic suggestions
|
|
457
|
+
*/
|
|
458
|
+
async generateTopics(productInfo, count) {
|
|
459
|
+
const prompt = `Generate ${count} SEO-friendly blog post topics for a product called "${productInfo.name}" in the ${productInfo.category} category.
|
|
460
|
+
|
|
461
|
+
Product description: ${productInfo.description}
|
|
462
|
+
Features: ${productInfo.features.join(", ")}
|
|
463
|
+
|
|
464
|
+
Requirements:
|
|
465
|
+
- Topics should be helpful for potential customers
|
|
466
|
+
- Focus on solving problems or answering questions
|
|
467
|
+
- Include comparisons, guides, and use cases
|
|
468
|
+
- Optimize for search engines and AI recommendations
|
|
469
|
+
|
|
470
|
+
Output ONLY a JSON array of topic strings, no markdown:
|
|
471
|
+
["Topic 1", "Topic 2", "Topic 3"]`;
|
|
472
|
+
try {
|
|
473
|
+
if (this.provider === "anthropic" && this.anthropic) {
|
|
474
|
+
const response = await this.anthropic.messages.create({
|
|
475
|
+
model: "claude-3-5-sonnet-20241022",
|
|
476
|
+
max_tokens: 1024,
|
|
477
|
+
messages: [{ role: "user", content: prompt }]
|
|
478
|
+
});
|
|
479
|
+
const textContent = response.content[0].type === "text" ? response.content[0].text : "";
|
|
480
|
+
const jsonMatch = textContent.match(/\[[\s\S]*\]/);
|
|
481
|
+
if (jsonMatch) {
|
|
482
|
+
return JSON.parse(jsonMatch[0]);
|
|
483
|
+
}
|
|
484
|
+
} else if (this.provider === "openai" && this.openai) {
|
|
485
|
+
const response = await this.openai.chat.completions.create({
|
|
486
|
+
model: "gpt-4-turbo-preview",
|
|
487
|
+
max_tokens: 1024,
|
|
488
|
+
messages: [{ role: "user", content: prompt }],
|
|
489
|
+
response_format: { type: "json_object" }
|
|
490
|
+
});
|
|
491
|
+
const textContent = response.choices[0]?.message?.content || "";
|
|
492
|
+
if (textContent) {
|
|
493
|
+
const data = JSON.parse(textContent);
|
|
494
|
+
const topicsArray = data.topics || data;
|
|
495
|
+
if (Array.isArray(topicsArray)) {
|
|
496
|
+
return topicsArray;
|
|
497
|
+
}
|
|
498
|
+
if (typeof topicsArray === "object") {
|
|
499
|
+
return Object.values(topicsArray).filter((v) => typeof v === "string");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
} catch (error) {
|
|
504
|
+
console.warn("Failed to generate topics with AI, using fallback");
|
|
505
|
+
}
|
|
506
|
+
return [
|
|
507
|
+
`Best ${productInfo.category} software ${(/* @__PURE__ */ new Date()).getFullYear()}`,
|
|
508
|
+
`How to choose ${productInfo.category} solution`,
|
|
509
|
+
`${productInfo.name} vs alternatives: Complete comparison`
|
|
510
|
+
];
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Update sitemap.xml
|
|
514
|
+
*/
|
|
515
|
+
async updateSitemap(projectPath, blogDir, posts) {
|
|
516
|
+
const sitemapPath = path2.join(projectPath, "sitemap.xml");
|
|
517
|
+
const urls = posts.map((post) => {
|
|
518
|
+
return ` <url>
|
|
519
|
+
<loc>${post.slug}/</loc>
|
|
520
|
+
<lastmod>${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}</lastmod>
|
|
521
|
+
<changefreq>weekly</changefreq>
|
|
522
|
+
<priority>0.8</priority>
|
|
523
|
+
</url>`;
|
|
524
|
+
}).join("\n");
|
|
525
|
+
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
|
526
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
527
|
+
${urls}
|
|
528
|
+
</urlset>`;
|
|
529
|
+
await fs2.writeFile(sitemapPath, sitemap, "utf-8");
|
|
530
|
+
console.log(`
|
|
531
|
+
\u2713 Updated sitemap.xml`);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
export {
|
|
536
|
+
AdapterRegistry,
|
|
537
|
+
HTMLAdapter,
|
|
538
|
+
ContentGenerator
|
|
539
|
+
};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ContentGenerator
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-AJSCN4WK.js";
|
|
5
|
+
import "../chunk-INVECVSW.js";
|
|
5
6
|
|
|
6
7
|
// src/cli/index.ts
|
|
7
8
|
import { Command } from "commander";
|
|
@@ -55,7 +56,7 @@ function showWelcome() {
|
|
|
55
56
|
}
|
|
56
57
|
function getVersion() {
|
|
57
58
|
try {
|
|
58
|
-
return "0.
|
|
59
|
+
return "0.5.0";
|
|
59
60
|
} catch {
|
|
60
61
|
return "dev";
|
|
61
62
|
}
|
|
@@ -721,7 +722,7 @@ Error: ${error.message}
|
|
|
721
722
|
|
|
722
723
|
// src/cli/index.ts
|
|
723
724
|
var program = new Command();
|
|
724
|
-
program.name("edtools").description("AI-Powered Content Marketing CLI").version("0.
|
|
725
|
+
program.name("edtools").description("AI-Powered Content Marketing CLI").version("0.5.0");
|
|
725
726
|
program.command("init").description("Initialize edtools in your project").option("-p, --path <path>", "Project path", process.cwd()).action(initCommand);
|
|
726
727
|
program.command("generate").description("Generate blog posts").option("-n, --posts <number>", "Number of posts to generate", "3").option("-t, --topics <topics...>", "Specific topics to write about").option("-o, --output <dir>", "Output directory", "./blog").option("--api-key <key>", "Anthropic API key (or set ANTHROPIC_API_KEY env var)").option("--from-csv", "Generate from CSV analysis opportunities").action(generateCommand);
|
|
727
728
|
program.command("analyze").description("Analyze Google Search Console CSV data").option("-f, --file <path>", "Path to CSV file (auto-detects if not provided)").option("--min-impressions <number>", "Minimum impressions for opportunities", "50").option("--min-position <number>", "Minimum position for opportunities", "20").option("--limit <number>", "Number of opportunities to show", "10").action(analyzeCommand);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateAvgReadTime,
|
|
3
|
+
calculateReadTime,
|
|
4
|
+
calculateWordCount,
|
|
5
|
+
extractShortDescription,
|
|
6
|
+
generateTimestamp,
|
|
7
|
+
generateUUID
|
|
8
|
+
} from "./chunk-INVECVSW.js";
|
|
9
|
+
export {
|
|
10
|
+
calculateAvgReadTime,
|
|
11
|
+
calculateReadTime,
|
|
12
|
+
calculateWordCount,
|
|
13
|
+
extractShortDescription,
|
|
14
|
+
generateTimestamp,
|
|
15
|
+
generateUUID
|
|
16
|
+
};
|
package/dist/core/generator.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAWA,OAAO,EAKL,cAAc,EACd,cAAc,EAEd,UAAU,EAGX,MAAM,mBAAmB,CAAC;AAW3B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,QAAQ,CAAkB;gBAEtB,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,UAAwB;IAuBzD,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;YAkFjD,eAAe;YAsEf,qBAAqB;YA+BrB,kBAAkB;IA8BhC,OAAO,CAAC,WAAW;IAkDnB,OAAO,CAAC,iBAAiB;YAwBX,iBAAiB;YAsCjB,cAAc;YAqEd,gBAAgB;YA4DhB,iBAAiB;YA8CjB,aAAa;CAkC5B"}
|