seomd-cli 1.3.0 → 2.0.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/PROVIDER_SPEC.md +125 -0
- package/README.md +54 -190
- package/SKILL.md +44 -0
- package/bin/seomd.js +78 -31
- package/package.json +11 -7
- package/src/commands/analyze.js +92 -92
- package/src/commands/check.js +301 -0
- package/src/commands/doctor.js +109 -0
- package/src/commands/generate.js +202 -0
- package/src/commands/init.js +127 -79
- package/src/commands/status.js +107 -79
- package/src/commands/sync.js +86 -72
- package/src/commands/validate.js +52 -25
- package/src/generators/directory.js +44 -143
- package/src/generators/reverse.js +46 -56
- package/src/generators/seomd.js +197 -44
- package/src/providers/http.js +67 -0
- package/src/providers/index.js +194 -0
- package/src/utils/agent-wiring.js +97 -0
- package/src/utils/api-client.js +14 -56
- package/src/utils/constants.js +110 -12
- package/src/utils/parser.js +114 -25
- package/src/utils/repo-scanner.js +207 -0
- package/src/utils/writeback.js +181 -100
- package/src/validators/seomd.js +255 -93
- package/scripts/release-contributors.js +0 -196
- package/scripts/release-notes.js +0 -194
- package/src/templates/blog/SEO.REVERSE.md +0 -176
- package/src/templates/blog/SEO.md +0 -348
- package/src/templates/ecommerce/SEO.REVERSE.md +0 -199
- package/src/templates/ecommerce/SEO.md +0 -354
- package/src/templates/local/SEO.REVERSE.md +0 -222
- package/src/templates/local/SEO.md +0 -360
- package/src/templates/marketplace/SEO.REVERSE.md +0 -222
- package/src/templates/marketplace/SEO.md +0 -360
- package/src/templates/saas/SEO.REVERSE.md +0 -268
- package/src/templates/saas/SEO.md +0 -372
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { parseSeoMd, getBrand, getPages } from '../utils/parser.js';
|
|
5
|
+
import { AI_BOTS, SCHEMA_TYPES } from '../utils/constants.js';
|
|
6
|
+
|
|
7
|
+
const VALID_TARGETS = ['robots', 'llms', 'schema'];
|
|
8
|
+
|
|
9
|
+
export function buildRobotsTxt(data) {
|
|
10
|
+
const domain = data.site?.domain || 'example.com';
|
|
11
|
+
const canonical = (data.site?.canonical || `https://${domain}`).replace(/\/$/, '');
|
|
12
|
+
const crawl = data.crawl || {};
|
|
13
|
+
const allowAi = crawl.allow_ai_bots !== false;
|
|
14
|
+
const disallow = Array.isArray(crawl.disallow) ? crawl.disallow : ['/admin', '/api/*'];
|
|
15
|
+
const sitemap = crawl.sitemap || '/sitemap.xml';
|
|
16
|
+
|
|
17
|
+
const lines = [
|
|
18
|
+
`# robots.txt generated from SEO.md — https://seomd.dev`,
|
|
19
|
+
'',
|
|
20
|
+
'User-agent: *',
|
|
21
|
+
'Allow: /',
|
|
22
|
+
...disallow.map((d) => `Disallow: ${d}`),
|
|
23
|
+
'',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
if (allowAi) {
|
|
27
|
+
lines.push('# AI Search & Citation Crawlers');
|
|
28
|
+
for (const bot of AI_BOTS) {
|
|
29
|
+
lines.push(`User-agent: ${bot.userAgent}`);
|
|
30
|
+
lines.push(`Allow: ${bot.allow}`);
|
|
31
|
+
lines.push('');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
lines.push(`Sitemap: ${sitemap.startsWith('http') ? sitemap : `${canonical}${sitemap}`}`);
|
|
36
|
+
lines.push('');
|
|
37
|
+
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function buildLlmsTxt(data, body = '') {
|
|
42
|
+
const brand = getBrand(data);
|
|
43
|
+
const domain = data.site?.domain || 'example.com';
|
|
44
|
+
const canonical = (data.site?.canonical || `https://${domain}`).replace(/\/$/, '');
|
|
45
|
+
const primaryKeyword = data.keywords?.primary || '';
|
|
46
|
+
const pages = getPages(data);
|
|
47
|
+
|
|
48
|
+
// Extract one-liner from Markdown body if present
|
|
49
|
+
const oneLinerMatch = body.match(/\*\*One-liner:\*\*\s*(.+)/i);
|
|
50
|
+
const summary = oneLinerMatch
|
|
51
|
+
? oneLinerMatch[1].trim()
|
|
52
|
+
: `${brand} (${domain}) — ${primaryKeyword || 'official documentation and product pages'}.`;
|
|
53
|
+
|
|
54
|
+
const lines = [
|
|
55
|
+
`# ${brand}`,
|
|
56
|
+
'',
|
|
57
|
+
`> ${summary}`,
|
|
58
|
+
'',
|
|
59
|
+
'## Key Pages',
|
|
60
|
+
'',
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const concretePages = pages.filter((p) => p.url && !p.url.includes('['));
|
|
64
|
+
if (concretePages.length > 0) {
|
|
65
|
+
for (const page of concretePages) {
|
|
66
|
+
const fullUrl = `${canonical}${page.url === '/' ? '' : page.url}`;
|
|
67
|
+
const label = page.primary_keyword ? `${page.id} — ${page.primary_keyword}` : page.id;
|
|
68
|
+
lines.push(`- [${label}](${fullUrl})`);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
lines.push(`- [Homepage](${canonical})`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const secondary = Array.isArray(data.keywords?.secondary) ? data.keywords.secondary : [];
|
|
75
|
+
if (primaryKeyword || secondary.length > 0) {
|
|
76
|
+
lines.push('');
|
|
77
|
+
lines.push('## Topics');
|
|
78
|
+
lines.push('');
|
|
79
|
+
if (primaryKeyword) lines.push(`- ${primaryKeyword}`);
|
|
80
|
+
for (const kw of secondary) {
|
|
81
|
+
lines.push(`- ${kw}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
lines.push('');
|
|
86
|
+
return lines.join('\n');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function buildSchemaJsonLd(data) {
|
|
90
|
+
const brand = getBrand(data);
|
|
91
|
+
const domain = data.site?.domain || 'example.com';
|
|
92
|
+
const canonical = (data.site?.canonical || `https://${domain}`).replace(/\/$/, '');
|
|
93
|
+
const siteType = data.site?.type || 'saas';
|
|
94
|
+
const types = Array.isArray(data.schema?.types) && data.schema.types.length > 0
|
|
95
|
+
? data.schema.types
|
|
96
|
+
: (SCHEMA_TYPES[siteType] || SCHEMA_TYPES.saas);
|
|
97
|
+
|
|
98
|
+
const graph = [];
|
|
99
|
+
|
|
100
|
+
if (types.includes('Organization')) {
|
|
101
|
+
graph.push({
|
|
102
|
+
'@type': 'Organization',
|
|
103
|
+
name: brand,
|
|
104
|
+
url: canonical,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (types.includes('SoftwareApplication')) {
|
|
109
|
+
graph.push({
|
|
110
|
+
'@type': 'SoftwareApplication',
|
|
111
|
+
name: brand,
|
|
112
|
+
applicationCategory: 'BusinessApplication',
|
|
113
|
+
url: canonical,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (types.includes('LocalBusiness')) {
|
|
118
|
+
graph.push({
|
|
119
|
+
'@type': 'LocalBusiness',
|
|
120
|
+
name: brand,
|
|
121
|
+
url: canonical,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (types.includes('WebSite')) {
|
|
126
|
+
graph.push({
|
|
127
|
+
'@type': 'WebSite',
|
|
128
|
+
name: brand,
|
|
129
|
+
url: canonical,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (types.includes('FAQPage')) {
|
|
134
|
+
graph.push({
|
|
135
|
+
'@type': 'FAQPage',
|
|
136
|
+
mainEntity: [
|
|
137
|
+
{
|
|
138
|
+
'@type': 'Question',
|
|
139
|
+
name: `What is ${brand}?`,
|
|
140
|
+
acceptedAnswer: {
|
|
141
|
+
'@type': 'Answer',
|
|
142
|
+
text: `Replace with a concise 40-60 word answer about ${brand}.`,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (graph.length === 0) {
|
|
150
|
+
graph.push({
|
|
151
|
+
'@type': 'WebPage',
|
|
152
|
+
name: brand,
|
|
153
|
+
url: canonical,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return JSON.stringify(
|
|
158
|
+
{
|
|
159
|
+
'@context': 'https://schema.org',
|
|
160
|
+
'@graph': graph,
|
|
161
|
+
},
|
|
162
|
+
null,
|
|
163
|
+
2
|
|
164
|
+
) + '\n';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function generateCommand(target, options = {}) {
|
|
168
|
+
const normalizedTarget = String(target || '').trim().toLowerCase();
|
|
169
|
+
|
|
170
|
+
if (!VALID_TARGETS.includes(normalizedTarget)) {
|
|
171
|
+
console.log(chalk.red(`✗ Unknown generate target '${target}'. Valid targets: ${VALID_TARGETS.join(', ')}`));
|
|
172
|
+
process.exitCode = 1;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
const cwd = process.cwd();
|
|
178
|
+
const { data, body } = await parseSeoMd(cwd);
|
|
179
|
+
|
|
180
|
+
let output = '';
|
|
181
|
+
if (normalizedTarget === 'robots') {
|
|
182
|
+
output = buildRobotsTxt(data);
|
|
183
|
+
} else if (normalizedTarget === 'llms') {
|
|
184
|
+
output = buildLlmsTxt(data, body);
|
|
185
|
+
} else if (normalizedTarget === 'schema') {
|
|
186
|
+
output = buildSchemaJsonLd(data);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (options.out) {
|
|
190
|
+
const outPath = path.resolve(cwd, options.out);
|
|
191
|
+
await fs.ensureDir(path.dirname(outPath));
|
|
192
|
+
await fs.writeFile(outPath, output, 'utf8');
|
|
193
|
+
console.log(chalk.green(`✓ Generated ${normalizedTarget} -> ${path.relative(cwd, outPath) || outPath}`));
|
|
194
|
+
} else {
|
|
195
|
+
process.stdout.write(output);
|
|
196
|
+
}
|
|
197
|
+
process.exitCode = 0;
|
|
198
|
+
} catch (err) {
|
|
199
|
+
console.log(chalk.red(`✗ Generate failed: ${err.message}`));
|
|
200
|
+
process.exitCode = 1;
|
|
201
|
+
}
|
|
202
|
+
}
|
package/src/commands/init.js
CHANGED
|
@@ -1,102 +1,148 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import enquirer from 'enquirer';
|
|
3
|
-
const { prompt } = enquirer;
|
|
4
3
|
import ora from 'ora';
|
|
5
4
|
import fs from 'fs-extra';
|
|
6
5
|
import path from 'path';
|
|
7
|
-
import {
|
|
6
|
+
import { readFileSync } from 'fs';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { generateSeoMd, normalizeDomain } from '../generators/seomd.js';
|
|
8
9
|
import { generateReverseMd } from '../generators/reverse.js';
|
|
9
10
|
import { createSeomdDir } from '../generators/directory.js';
|
|
10
|
-
import {
|
|
11
|
+
import { scanRepo } from '../utils/repo-scanner.js';
|
|
12
|
+
import { wireAgentFiles } from '../utils/agent-wiring.js';
|
|
13
|
+
import { SITE_TYPES, VALID_SITE_TYPES, SITE_TYPE_PROFILES } from '../utils/constants.js';
|
|
14
|
+
|
|
15
|
+
const { prompt } = enquirer;
|
|
16
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, '../../package.json'), 'utf8'));
|
|
11
18
|
|
|
12
|
-
export async function initCommand(options) {
|
|
19
|
+
export async function initCommand(options = {}) {
|
|
13
20
|
console.log('');
|
|
14
|
-
console.log(chalk.bold('SEO.md') + chalk.dim(
|
|
21
|
+
console.log(chalk.bold('SEO.md') + chalk.dim(` v${pkg.version} — https://seomd.dev`));
|
|
15
22
|
console.log('');
|
|
16
|
-
console.log(chalk.dim('The open standard for AI-era
|
|
23
|
+
console.log(chalk.dim('The open standard for AI-era search & citation configuration.'));
|
|
17
24
|
console.log('');
|
|
18
25
|
|
|
26
|
+
// Validate --type upfront before touching the filesystem
|
|
27
|
+
if (options.type && !VALID_SITE_TYPES.includes(options.type)) {
|
|
28
|
+
console.log(
|
|
29
|
+
chalk.red(`Invalid --type '${options.type}'. Must be one of: ${VALID_SITE_TYPES.join(', ')}`)
|
|
30
|
+
);
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
// Determine target directory
|
|
20
36
|
let workingDir = process.cwd();
|
|
21
37
|
if (options.output) {
|
|
22
38
|
const resolved = path.resolve(options.output);
|
|
23
|
-
if (await fs.pathExists(resolved) && (await fs.readdir(resolved)).length > 0) {
|
|
39
|
+
if ((await fs.pathExists(resolved)) && (await fs.readdir(resolved)).length > 0) {
|
|
24
40
|
console.log(chalk.red(`Output directory must be empty or non-existent: ${resolved}`));
|
|
25
|
-
process.
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
return;
|
|
26
43
|
}
|
|
27
44
|
await fs.ensureDir(resolved);
|
|
28
45
|
workingDir = resolved;
|
|
29
46
|
}
|
|
30
47
|
|
|
48
|
+
// Non-interactive if -y OR any config flag provided
|
|
49
|
+
const hasConfigFlags =
|
|
50
|
+
options.brand !== undefined ||
|
|
51
|
+
options.domain !== undefined ||
|
|
52
|
+
options.primaryKeyword !== undefined ||
|
|
53
|
+
options.competitors !== undefined;
|
|
54
|
+
const isNonInteractive = Boolean(options.yes || hasConfigFlags);
|
|
55
|
+
|
|
31
56
|
const seomdPath = path.join(workingDir, 'SEO.md');
|
|
32
57
|
if (await fs.pathExists(seomdPath)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
if (!isNonInteractive && !options.force) {
|
|
59
|
+
console.log(chalk.yellow('⚠ SEO.md already exists in this directory.'));
|
|
60
|
+
const { overwrite } = await prompt({
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
name: 'overwrite',
|
|
63
|
+
message: 'Overwrite existing SEO.md?',
|
|
64
|
+
initial: false,
|
|
65
|
+
});
|
|
66
|
+
if (!overwrite) {
|
|
67
|
+
console.log(chalk.dim('Aborted.'));
|
|
68
|
+
process.exitCode = 0;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
43
71
|
}
|
|
44
72
|
}
|
|
45
73
|
|
|
46
|
-
|
|
74
|
+
// Inspect repository for framework, existing routes, and crawl files
|
|
75
|
+
const repoInfo = await scanRepo(workingDir);
|
|
76
|
+
if (repoInfo.framework || repoInfo.routes.length > 0) {
|
|
77
|
+
const fwLabel = repoInfo.framework ? ` (${repoInfo.framework})` : '';
|
|
78
|
+
console.log(
|
|
79
|
+
chalk.dim(
|
|
80
|
+
`Detected project${fwLabel}: ${repoInfo.routes.length} route(s) discovered`
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
console.log('');
|
|
84
|
+
}
|
|
47
85
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
86
|
+
const inferredBrand = repoInfo.packageName
|
|
87
|
+
? repoInfo.packageName.replace(/^@[^/]+\//, '').replace(/[-_]+/g, ' ')
|
|
88
|
+
: 'My Brand';
|
|
89
|
+
const inferredDomain = repoInfo.homepage
|
|
90
|
+
? normalizeDomain(repoInfo.homepage)
|
|
91
|
+
: 'example.com';
|
|
54
92
|
|
|
55
|
-
|
|
93
|
+
let answers;
|
|
94
|
+
if (isNonInteractive) {
|
|
95
|
+
const siteType = options.type || 'saas';
|
|
96
|
+
const profile = SITE_TYPE_PROFILES[siteType];
|
|
56
97
|
answers = {
|
|
57
|
-
site_type:
|
|
58
|
-
domain: options.domain ||
|
|
59
|
-
brand: options.brand ||
|
|
60
|
-
primary_keyword: options.primaryKeyword ||
|
|
98
|
+
site_type: siteType,
|
|
99
|
+
domain: normalizeDomain(options.domain || inferredDomain),
|
|
100
|
+
brand: (options.brand || inferredBrand).trim(),
|
|
101
|
+
primary_keyword: (options.primaryKeyword || profile.defaultKeyword).trim(),
|
|
61
102
|
competitors: options.competitors
|
|
62
103
|
? options.competitors
|
|
63
104
|
.split(',')
|
|
64
|
-
.map((c) => c
|
|
105
|
+
.map((c) => normalizeDomain(c))
|
|
65
106
|
.filter(Boolean)
|
|
66
|
-
.slice(0,
|
|
107
|
+
.slice(0, 5)
|
|
67
108
|
: [],
|
|
109
|
+
provider: options.provider || null,
|
|
68
110
|
};
|
|
69
111
|
} else {
|
|
70
|
-
|
|
112
|
+
const initialTypeIdx = options.type
|
|
113
|
+
? Math.max(0, SITE_TYPES.findIndex((t) => t.value === options.type))
|
|
114
|
+
: 0;
|
|
115
|
+
|
|
71
116
|
answers = await prompt([
|
|
72
117
|
{
|
|
73
118
|
type: 'select',
|
|
74
119
|
name: 'site_type',
|
|
75
120
|
message: 'Site type:',
|
|
76
|
-
choices: SITE_TYPES.map(t => ({ name: t.value, message: t.name })),
|
|
77
|
-
initial:
|
|
121
|
+
choices: SITE_TYPES.map((t) => ({ name: t.value, message: t.name })),
|
|
122
|
+
initial: initialTypeIdx,
|
|
78
123
|
},
|
|
79
124
|
{
|
|
80
125
|
type: 'input',
|
|
81
126
|
name: 'domain',
|
|
82
127
|
message: 'Primary domain:',
|
|
128
|
+
initial: inferredDomain !== 'example.com' ? inferredDomain : undefined,
|
|
83
129
|
hint: 'e.g. myapp.com',
|
|
84
130
|
validate(value) {
|
|
85
|
-
if (!value) return 'Domain is required';
|
|
86
|
-
// Strip protocol if provided
|
|
131
|
+
if (!value || !value.trim()) return 'Domain is required';
|
|
87
132
|
return true;
|
|
88
133
|
},
|
|
89
134
|
result(value) {
|
|
90
|
-
return value
|
|
135
|
+
return normalizeDomain(value);
|
|
91
136
|
},
|
|
92
137
|
},
|
|
93
138
|
{
|
|
94
139
|
type: 'input',
|
|
95
140
|
name: 'brand',
|
|
96
141
|
message: 'Brand name:',
|
|
142
|
+
initial: inferredBrand !== 'My Brand' ? inferredBrand : undefined,
|
|
97
143
|
hint: 'e.g. MyApp',
|
|
98
144
|
validate(value) {
|
|
99
|
-
if (!value) return 'Brand name is required';
|
|
145
|
+
if (!value || !value.trim()) return 'Brand name is required';
|
|
100
146
|
return true;
|
|
101
147
|
},
|
|
102
148
|
},
|
|
@@ -106,77 +152,79 @@ export async function initCommand(options) {
|
|
|
106
152
|
message: 'Primary keyword:',
|
|
107
153
|
hint: 'e.g. project management software',
|
|
108
154
|
validate(value) {
|
|
109
|
-
if (!value) return 'Primary keyword is required';
|
|
155
|
+
if (!value || !value.trim()) return 'Primary keyword is required';
|
|
110
156
|
return true;
|
|
111
157
|
},
|
|
112
158
|
},
|
|
113
159
|
{
|
|
114
160
|
type: 'input',
|
|
115
161
|
name: 'competitors',
|
|
116
|
-
message: 'Top
|
|
162
|
+
message: 'Top competitors (comma separated, optional):',
|
|
117
163
|
hint: 'e.g. asana.com, monday.com, notion.so',
|
|
118
164
|
result(value) {
|
|
119
|
-
return value
|
|
165
|
+
return String(value || '')
|
|
120
166
|
.split(',')
|
|
121
|
-
.map(c => c
|
|
167
|
+
.map((c) => normalizeDomain(c))
|
|
122
168
|
.filter(Boolean)
|
|
123
|
-
.slice(0,
|
|
169
|
+
.slice(0, 5);
|
|
124
170
|
},
|
|
125
171
|
},
|
|
126
172
|
]);
|
|
173
|
+
answers.provider = options.provider || null;
|
|
127
174
|
}
|
|
128
175
|
|
|
129
176
|
console.log('');
|
|
130
|
-
const spinner = ora('Scaffolding your SEO.md
|
|
177
|
+
const spinner = ora('Scaffolding your SEO.md workspace...').start();
|
|
131
178
|
|
|
132
179
|
try {
|
|
133
|
-
// 1. Generate SEO.md
|
|
134
|
-
const seomdContent = generateSeoMd(answers);
|
|
180
|
+
// 1. Generate v2 SEO.md (YAML frontmatter + Markdown body)
|
|
181
|
+
const seomdContent = generateSeoMd(answers, repoInfo);
|
|
135
182
|
await fs.writeFile(path.join(workingDir, 'SEO.md'), seomdContent, 'utf8');
|
|
136
|
-
spinner.succeed(chalk.green('SEO.md created'));
|
|
137
|
-
|
|
138
|
-
// 2. Generate SEO.REVERSE.md
|
|
139
|
-
const reverseContent = generateReverseMd(answers);
|
|
140
|
-
await fs.writeFile(path.join(workingDir, 'SEO.REVERSE.md'), reverseContent, 'utf8');
|
|
141
|
-
spinner.succeed(chalk.green('SEO.REVERSE.md initialized'));
|
|
183
|
+
spinner.succeed(chalk.green('SEO.md created (spec v2.0.0)'));
|
|
142
184
|
|
|
143
|
-
//
|
|
185
|
+
// 2. Create .seo/ workspace directory
|
|
144
186
|
await createSeomdDir(workingDir, answers);
|
|
145
|
-
spinner.succeed(chalk.green('.seo/
|
|
187
|
+
spinner.succeed(chalk.green('.seo/ workspace created'));
|
|
188
|
+
|
|
189
|
+
// 3. Initialize .seo/REVERSE.md
|
|
190
|
+
const reverseContent = generateReverseMd(answers);
|
|
191
|
+
await fs.writeFile(path.join(workingDir, '.seo', 'REVERSE.md'), reverseContent, 'utf8');
|
|
192
|
+
spinner.succeed(chalk.green('.seo/REVERSE.md initialized'));
|
|
146
193
|
|
|
147
|
-
// 4.
|
|
148
|
-
|
|
194
|
+
// 4. Wire AGENTS.md / CLAUDE.md unless opted out via --no-wire-agents
|
|
195
|
+
let agentResult = { updated: [], created: [] };
|
|
196
|
+
if (options.wireAgents !== false) {
|
|
197
|
+
agentResult = await wireAgentFiles(workingDir);
|
|
198
|
+
const wiredList = [...agentResult.created, ...agentResult.updated];
|
|
199
|
+
if (wiredList.length > 0) {
|
|
200
|
+
spinner.succeed(chalk.green(`Agent instructions wired into ${wiredList.join(', ')}`));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
149
203
|
|
|
150
204
|
console.log('');
|
|
151
205
|
console.log(chalk.bold.green('✓ SEO.md initialized successfully'));
|
|
152
206
|
console.log('');
|
|
153
|
-
console.log(chalk.dim('Files created:'));
|
|
154
|
-
console.log(' ' + chalk.cyan('SEO.md') + chalk.dim(' — your
|
|
155
|
-
console.log(' ' + chalk.cyan('
|
|
156
|
-
console.log(' ' + chalk.cyan('.seo/') + chalk.dim('
|
|
207
|
+
console.log(chalk.dim('Files created / updated:'));
|
|
208
|
+
console.log(' ' + chalk.cyan('SEO.md') + chalk.dim(' — your Markdown + frontmatter SEO/AEO spec'));
|
|
209
|
+
console.log(' ' + chalk.cyan('.seo/REVERSE.md') + chalk.dim(' — competitor intelligence scaffold'));
|
|
210
|
+
console.log(' ' + chalk.cyan('.seo/') + chalk.dim(' — provider intelligence workspace'));
|
|
211
|
+
for (const f of [...agentResult.created, ...agentResult.updated]) {
|
|
212
|
+
console.log(' ' + chalk.cyan(f.padEnd(18)) + chalk.dim(' — wired so coding agents auto-read SEO.md'));
|
|
213
|
+
}
|
|
157
214
|
console.log('');
|
|
158
|
-
console.log(chalk.dim('Next steps:'));
|
|
159
|
-
console.log(' ' + chalk.white('npx seomd
|
|
160
|
-
console.log(' ' + chalk.white('npx seomd
|
|
215
|
+
console.log(chalk.dim('Next steps (works locally with zero API key):'));
|
|
216
|
+
console.log(' ' + chalk.white('npx seomd-cli validate') + chalk.dim(' — validate SEO.md'));
|
|
217
|
+
console.log(' ' + chalk.white('npx seomd-cli check ./public') + chalk.dim(' — audit local files / localhost against SEO.md'));
|
|
218
|
+
console.log(' ' + chalk.white('npx seomd-cli generate robots') + chalk.dim(' — generate AI-bot-friendly robots.txt or llms.txt'));
|
|
219
|
+
console.log(' ' + chalk.white('npx seomd-cli doctor') + chalk.dim(' — inspect repo & provider readiness'));
|
|
161
220
|
console.log('');
|
|
162
|
-
console.log(chalk.dim('
|
|
221
|
+
console.log(chalk.dim('Optional live AI citation scans (any compatible provider — see PROVIDER_SPEC.md):'));
|
|
222
|
+
console.log(' ' + chalk.white('npx seomd-cli analyze') + chalk.dim(' — run live multi-LLM citation analysis'));
|
|
163
223
|
console.log('');
|
|
164
|
-
|
|
224
|
+
process.exitCode = 0;
|
|
165
225
|
} catch (err) {
|
|
166
226
|
spinner.fail(chalk.red('Failed to scaffold SEO.md'));
|
|
167
227
|
console.error(chalk.dim(err.message));
|
|
168
|
-
process.
|
|
228
|
+
process.exitCode = 1;
|
|
169
229
|
}
|
|
170
230
|
}
|
|
171
|
-
|
|
172
|
-
async function updateGitignore(cwd) {
|
|
173
|
-
const gitignorePath = path.join(cwd, '.gitignore');
|
|
174
|
-
const entry = '\n# seomd intelligence directory\n.seo/reports/\n';
|
|
175
|
-
|
|
176
|
-
if (await fs.pathExists(gitignorePath)) {
|
|
177
|
-
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
178
|
-
if (!content.includes('.seo')) {
|
|
179
|
-
await fs.appendFile(gitignorePath, entry);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|