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
|
@@ -1,187 +1,88 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { REQUIRED_PAGES } from '../utils/constants.js';
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Creates the .seo/ intelligence workspace directory with a README.
|
|
6
|
+
* Does NOT pre-create empty placeholder page files — per-page playbooks
|
|
7
|
+
* are materialized on demand when `analyze` or `sync` runs.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} cwd - Project root directory
|
|
10
|
+
* @param {object} answers - Scaffolding inputs (brand, domain)
|
|
11
|
+
*/
|
|
5
12
|
export async function createSeomdDir(cwd, answers) {
|
|
6
|
-
const {
|
|
7
|
-
const pages = REQUIRED_PAGES[site_type] || REQUIRED_PAGES.saas;
|
|
13
|
+
const { brand, domain } = answers;
|
|
8
14
|
const seomdDir = path.join(cwd, '.seo');
|
|
9
15
|
|
|
10
|
-
// Create directory structure
|
|
11
16
|
await fs.ensureDir(path.join(seomdDir, 'pages'));
|
|
12
|
-
await fs.ensureDir(path.join(seomdDir, 'reports'));
|
|
13
|
-
await fs.ensureDir(path.join(seomdDir, 'competitors'));
|
|
14
17
|
|
|
15
|
-
// Create README inside .seo/
|
|
16
18
|
await fs.writeFile(
|
|
17
19
|
path.join(seomdDir, 'README.md'),
|
|
18
20
|
generateSeomdReadme(brand, domain),
|
|
19
21
|
'utf8'
|
|
20
22
|
);
|
|
21
|
-
|
|
22
|
-
// Create placeholder page files
|
|
23
|
-
for (const page of pages) {
|
|
24
|
-
await fs.writeFile(
|
|
25
|
-
path.join(seomdDir, 'pages', `${page.id}.md`),
|
|
26
|
-
generatePagePlaceholder(page, brand),
|
|
27
|
-
'utf8'
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Create initial empty report
|
|
32
|
-
const date = new Date().toISOString().split('T')[0];
|
|
33
|
-
await fs.writeFile(
|
|
34
|
-
path.join(seomdDir, 'reports', `${date}.md`),
|
|
35
|
-
generateInitialReport(brand, domain, date),
|
|
36
|
-
'utf8'
|
|
37
|
-
);
|
|
38
23
|
}
|
|
39
24
|
|
|
40
25
|
function generateSeomdReadme(brand, domain) {
|
|
41
26
|
return `# .seo/
|
|
42
27
|
|
|
43
|
-
AI search
|
|
28
|
+
AI search & citation intelligence workspace for **${brand}** (${domain})
|
|
44
29
|
Generated by SEO.md CLI — https://seomd.dev
|
|
45
30
|
|
|
46
31
|
## What is this?
|
|
47
32
|
|
|
48
|
-
\`.seo/\` stores
|
|
33
|
+
\`.seo/\` stores provider-generated intelligence from citation audits, competitor analysis, and reverse-engineered playbooks. It lives alongside your source code so SEO/AEO strategy and diffs are version-controlled and reviewable in PRs.
|
|
49
34
|
|
|
50
35
|
## Directory Structure
|
|
51
36
|
|
|
52
37
|
\`\`\`
|
|
53
38
|
.seo/
|
|
54
|
-
├── pages/ # per-page
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
│ └── ...
|
|
58
|
-
├── reports/ # dated snapshot reports (gitignored by default)
|
|
59
|
-
│ └── 2026-06-10.md
|
|
60
|
-
└── competitors/ # competitor citation profiles
|
|
61
|
-
└── comp-1.md
|
|
39
|
+
├── pages/ # per-page playbooks (created on analyze/sync)
|
|
40
|
+
├── STATUS.yml # gap scores and citation metrics (provider generated)
|
|
41
|
+
└── REVERSE.md # competitor playbooks (provider generated)
|
|
62
42
|
\`\`\`
|
|
63
43
|
|
|
64
|
-
##
|
|
65
|
-
|
|
66
|
-
| Path | Git | Why |
|
|
67
|
-
|------|-----|-----|
|
|
68
|
-
| \`.seo/pages/\` | tracked | actionable playbooks belong in code review |
|
|
69
|
-
| \`.seo/competitors/\` | tracked | competitor intel is project state |
|
|
70
|
-
| \`.seo/reports/\` | ignored | dated snapshots are noise in git history |
|
|
71
|
-
|
|
72
|
-
\`.seo/reports/\` is added to \`.gitignore\` automatically by \`seomd init\`.
|
|
73
|
-
|
|
74
|
-
## When to run what
|
|
44
|
+
## Local Commands (Zero API Key Required)
|
|
75
45
|
|
|
76
46
|
\`\`\`bash
|
|
77
|
-
#
|
|
78
|
-
npx seomd
|
|
47
|
+
# Validate SEO.md syntax and schema
|
|
48
|
+
npx seomd-cli validate
|
|
49
|
+
|
|
50
|
+
# Audit local HTML / build output or localhost against SEO.md
|
|
51
|
+
npx seomd-cli check ./out
|
|
52
|
+
npx seomd-cli check http://localhost:3000
|
|
79
53
|
|
|
80
|
-
#
|
|
81
|
-
npx seomd
|
|
54
|
+
# Generate robots.txt, llms.txt, or JSON-LD from SEO.md
|
|
55
|
+
npx seomd-cli generate robots --out public/robots.txt
|
|
56
|
+
npx seomd-cli generate llms --out public/llms.txt
|
|
57
|
+
npx seomd-cli generate schema
|
|
82
58
|
|
|
83
|
-
# Check
|
|
84
|
-
npx seomd
|
|
85
|
-
npx seomd status --json
|
|
59
|
+
# Check repo health, agent wiring, and provider config
|
|
60
|
+
npx seomd-cli doctor
|
|
86
61
|
\`\`\`
|
|
87
62
|
|
|
88
|
-
|
|
89
|
-
|---------|----------|
|
|
90
|
-
| \`analyze\` | You want a fresh audit, new competitor data, or updated playbooks |
|
|
91
|
-
| \`sync\` | You just want the latest cached data from your platform |
|
|
92
|
-
| \`status\` | You want a quick health check without writebacks |
|
|
63
|
+
## Live Intelligence Commands (Requires a Connected Provider)
|
|
93
64
|
|
|
94
|
-
|
|
65
|
+
\`\`\`bash
|
|
66
|
+
# Run a live AI citation audit
|
|
67
|
+
npx seomd-cli analyze
|
|
95
68
|
|
|
96
|
-
|
|
69
|
+
# Pull cached provider intelligence
|
|
70
|
+
npx seomd-cli sync
|
|
97
71
|
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
- **fastest_win** — highest ROI action to take now
|
|
103
|
-
- **suggested_content_outline** — ready-to-use outline for your writer or AI
|
|
72
|
+
# View current citation rates and gap scores
|
|
73
|
+
npx seomd-cli status
|
|
74
|
+
npx seomd-cli status --json
|
|
75
|
+
\`\`\`
|
|
104
76
|
|
|
105
|
-
## File
|
|
77
|
+
## File Ownership
|
|
106
78
|
|
|
107
|
-
|
|
|
108
|
-
|
|
79
|
+
| Path | Owner | Editable? |
|
|
80
|
+
|------|-------|-----------|
|
|
109
81
|
| \`SEO.md\` | you | yes |
|
|
110
|
-
|
|
|
111
|
-
| \`.seo/
|
|
112
|
-
| \`.seo/
|
|
113
|
-
| \`.seo/reports/*.md\` | platform | no |
|
|
114
|
-
|
|
115
|
-
Platform-generated files are overwritten on each \`analyze\` or \`sync\`.
|
|
116
|
-
|
|
117
|
-
## Platform connection
|
|
118
|
-
|
|
119
|
-
To enable live writebacks:
|
|
120
|
-
|
|
121
|
-
1. Connect at https://seomd.dev/connect
|
|
122
|
-
2. Add \`SEOMD_API_KEY\` to your \`.env\`
|
|
123
|
-
3. Run \`npx seomd analyze\`
|
|
124
|
-
|
|
125
|
-
_Note: Never commit API keys or \`.env\` files to version control._
|
|
126
|
-
`;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function generatePagePlaceholder(page, brand) {
|
|
130
|
-
const date = new Date().toISOString().split('T')[0];
|
|
131
|
-
return `# ${page.id}
|
|
132
|
-
|
|
133
|
-
## Page: ${page.url}
|
|
134
|
-
|
|
135
|
-
### Priority: ${page.priority}
|
|
136
|
-
|
|
137
|
-
### Last analyzed: null
|
|
138
|
-
|
|
139
|
-
### Run \`npx seomd analyze --page ${page.url}\` to populate
|
|
140
|
-
|
|
141
|
-
brand: "${brand}"
|
|
142
|
-
page_id: ${page.id}
|
|
143
|
-
url: ${page.url}
|
|
144
|
-
status: planned
|
|
145
|
-
citation_rate: null
|
|
146
|
-
gap_score: null
|
|
147
|
-
top_cited_competitor: null
|
|
148
|
-
last_analyzed: null
|
|
149
|
-
|
|
150
|
-
why_page_won: []
|
|
151
|
-
citation_hooks: []
|
|
152
|
-
gaps_for_brand: []
|
|
153
|
-
remediation_playbook: []
|
|
82
|
+
| \`.seo/STATUS.yml\` | provider | no |
|
|
83
|
+
| \`.seo/REVERSE.md\` | provider | no |
|
|
84
|
+
| \`.seo/pages/*.md\` | provider | no |
|
|
154
85
|
|
|
155
|
-
|
|
156
|
-
action: null
|
|
157
|
-
estimated_gap_score_improvement: null
|
|
158
|
-
effort: null
|
|
159
|
-
|
|
160
|
-
suggested_content_outline: []
|
|
86
|
+
Provider-generated files are updated on each \`analyze\` or \`sync\`.
|
|
161
87
|
`;
|
|
162
88
|
}
|
|
163
|
-
|
|
164
|
-
function generateInitialReport(brand, domain, date) {
|
|
165
|
-
return `# SEO.md Report — ${date}
|
|
166
|
-
|
|
167
|
-
## ${brand} (${domain})
|
|
168
|
-
|
|
169
|
-
### Initial report — run \`npx seomd analyze\` to populate
|
|
170
|
-
|
|
171
|
-
date: ${date}
|
|
172
|
-
brand: "${brand}"
|
|
173
|
-
domain: ${domain}
|
|
174
|
-
overall_citation_rate: null
|
|
175
|
-
overall_gap_score: null
|
|
176
|
-
|
|
177
|
-
intent_summary:
|
|
178
|
-
informational: null
|
|
179
|
-
comparison: null
|
|
180
|
-
transactional: null
|
|
181
|
-
reputational: null
|
|
182
|
-
category: null
|
|
183
|
-
|
|
184
|
-
top_opportunities: []
|
|
185
|
-
completed_wins: []
|
|
186
|
-
`;
|
|
187
|
-
}
|
|
@@ -1,62 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
1
|
+
import YAML from 'yaml';
|
|
2
|
+
import { SPEC_VERSION, VALID_SITE_TYPES } from '../utils/constants.js';
|
|
3
|
+
import { normalizeDomain } from './seomd.js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
* Generates the
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @returns {string} The filled template content
|
|
6
|
+
* Generates the initial .seo/REVERSE.md scaffold using safe YAML serialization.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} answers - Scaffolding inputs (brand, domain, site_type, competitors)
|
|
9
|
+
* @returns {string}
|
|
13
10
|
*/
|
|
14
11
|
export function generateReverseMd(answers) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// Resolve template file path
|
|
19
|
-
const templatePath = path.join(__dirname, '../templates', site_type, 'SEO.REVERSE.md');
|
|
20
|
-
|
|
21
|
-
if (!fs.existsSync(templatePath)) {
|
|
22
|
-
throw new Error(`Template not found for site type: ${site_type}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let content = fs.readFileSync(templatePath, 'utf8');
|
|
26
|
-
|
|
27
|
-
const date = new Date().toISOString().split('T')[0];
|
|
28
|
-
const brandLower = brand.toLowerCase();
|
|
29
|
-
const brandSnake = brandLower.replace(/\s+/g, '_');
|
|
30
|
-
const primaryCompetitor = competitorList[0] || '[competitor]';
|
|
31
|
-
|
|
32
|
-
// Formatting YAML blocks for competitors
|
|
33
|
-
let reverseCompetitors = '';
|
|
34
|
-
if (competitorList.length > 0) {
|
|
35
|
-
reverseCompetitors = competitorList.map(c => ` - domain: ${c}
|
|
36
|
-
overall_citation_rate: null
|
|
37
|
-
strongest_intent_category: null
|
|
38
|
-
weakest_intent_category: null
|
|
39
|
-
top_cited_pages: []
|
|
40
|
-
citation_patterns: []
|
|
41
|
-
last_analyzed: null`).join('\n\n');
|
|
42
|
-
} else {
|
|
43
|
-
reverseCompetitors = ` - domain: [competitor]
|
|
44
|
-
overall_citation_rate: null
|
|
45
|
-
strongest_intent_category: null
|
|
46
|
-
weakest_intent_category: null
|
|
47
|
-
top_cited_pages: []
|
|
48
|
-
citation_patterns: []
|
|
49
|
-
last_analyzed: null`;
|
|
12
|
+
const siteType = answers.site_type || 'saas';
|
|
13
|
+
if (!VALID_SITE_TYPES.includes(siteType)) {
|
|
14
|
+
throw new Error(`Invalid site type '${siteType}'. Must be one of: ${VALID_SITE_TYPES.join(', ')}`);
|
|
50
15
|
}
|
|
51
16
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
17
|
+
const domain = normalizeDomain(answers.domain || 'example.com');
|
|
18
|
+
const brand = String(answers.brand || 'My Brand').trim();
|
|
19
|
+
const competitorList = Array.isArray(answers.competitors)
|
|
20
|
+
? answers.competitors.map(normalizeDomain).filter(Boolean)
|
|
21
|
+
: [];
|
|
22
|
+
|
|
23
|
+
const doc = {
|
|
24
|
+
spec: SPEC_VERSION,
|
|
25
|
+
domain,
|
|
26
|
+
brand,
|
|
27
|
+
primary_competitor: competitorList[0] || null,
|
|
28
|
+
last_analyzed: null,
|
|
29
|
+
next_analysis: null,
|
|
30
|
+
source: null,
|
|
31
|
+
pages: [],
|
|
32
|
+
competitors: competitorList.map((c) => ({
|
|
33
|
+
domain: c,
|
|
34
|
+
overall_citation_rate: null,
|
|
35
|
+
strongest_intent_category: null,
|
|
36
|
+
weakest_intent_category: null,
|
|
37
|
+
top_cited_pages: [],
|
|
38
|
+
citation_patterns: [],
|
|
39
|
+
last_analyzed: null,
|
|
40
|
+
})),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const header = [
|
|
44
|
+
'# .seo/REVERSE.md',
|
|
45
|
+
'#',
|
|
46
|
+
'# Auto-generated by your connected SEO.md provider.',
|
|
47
|
+
'# Do not edit manually — run `npx seomd-cli analyze` or `npx seomd-cli sync` to update.',
|
|
48
|
+
'',
|
|
49
|
+
].join('\n');
|
|
50
|
+
|
|
51
|
+
return `${header}\n${YAML.stringify(doc, { lineWidth: 100 })}`;
|
|
52
|
+
}
|
package/src/generators/seomd.js
CHANGED
|
@@ -1,55 +1,208 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import YAML from 'yaml';
|
|
2
|
+
import {
|
|
3
|
+
SPEC_VERSION,
|
|
4
|
+
INTENT_PRIORITIES,
|
|
5
|
+
REQUIRED_PAGES,
|
|
6
|
+
SCHEMA_TYPES,
|
|
7
|
+
SITE_TYPE_PROFILES,
|
|
8
|
+
VALID_SITE_TYPES,
|
|
9
|
+
} from '../utils/constants.js';
|
|
10
|
+
import { routeToPageId } from '../utils/repo-scanner.js';
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.replace(/^(https?:\/\/)?(www\.)?/, '')
|
|
12
|
+
function getBrandNameFromDomain(domain) {
|
|
13
|
+
return String(domain || '')
|
|
14
|
+
.replace(/^(https?:\/\/)?(www\.)?/i, '')
|
|
15
|
+
.replace(/\/.*$/, '')
|
|
10
16
|
.replace(/\.[a-z]{2,6}(\.[a-z]{2,6})?$/i, '');
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
* Normalizes a domain string by stripping protocol, leading/trailing slashes, and whitespace.
|
|
21
|
+
*/
|
|
22
|
+
export function normalizeDomain(domain) {
|
|
23
|
+
return String(domain || '')
|
|
24
|
+
.trim()
|
|
25
|
+
.replace(/^https?:\/\//i, '')
|
|
26
|
+
.replace(/\/+$/, '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generates a v2.0.0 SEO.md file (YAML frontmatter + agent-readable Markdown body).
|
|
31
|
+
* Safely serializes all user inputs via YAML.stringify (zero YAML injection).
|
|
32
|
+
*
|
|
33
|
+
* @param {object} answers
|
|
34
|
+
* @param {object} [repoInfo] - Optional output from scanRepo()
|
|
35
|
+
* @returns {string}
|
|
19
36
|
*/
|
|
20
|
-
export function generateSeoMd(answers) {
|
|
21
|
-
const
|
|
22
|
-
|
|
37
|
+
export function generateSeoMd(answers, repoInfo = null) {
|
|
38
|
+
const siteType = answers.site_type || 'saas';
|
|
39
|
+
if (!VALID_SITE_TYPES.includes(siteType)) {
|
|
40
|
+
throw new Error(`Invalid site type '${siteType}'. Must be one of: ${VALID_SITE_TYPES.join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const profile = SITE_TYPE_PROFILES[siteType];
|
|
44
|
+
const priorities = INTENT_PRIORITIES[siteType];
|
|
45
|
+
const domain = normalizeDomain(answers.domain || 'example.com');
|
|
46
|
+
const brand = String(answers.brand || 'My Brand').trim();
|
|
47
|
+
const brandLower = brand.toLowerCase();
|
|
48
|
+
const primaryKeyword = String(answers.primary_keyword || profile.defaultKeyword).trim();
|
|
49
|
+
const competitorList = Array.isArray(answers.competitors)
|
|
50
|
+
? answers.competitors.map(normalizeDomain).filter(Boolean)
|
|
51
|
+
: [];
|
|
52
|
+
const year = new Date().getFullYear();
|
|
53
|
+
|
|
54
|
+
// Build intent queries tailored to site type
|
|
55
|
+
const comparisonQueries = competitorList.length > 0
|
|
56
|
+
? [
|
|
57
|
+
...competitorList.map((c) => `${getBrandNameFromDomain(c)} vs ${brandLower}`),
|
|
58
|
+
profile.comparisonSuffix(primaryKeyword),
|
|
59
|
+
]
|
|
60
|
+
: [
|
|
61
|
+
`${brandLower} alternatives`,
|
|
62
|
+
profile.comparisonSuffix(primaryKeyword),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const intent = {
|
|
66
|
+
informational: {
|
|
67
|
+
priority: priorities.informational,
|
|
68
|
+
queries: [
|
|
69
|
+
`what is ${primaryKeyword}`,
|
|
70
|
+
`how does ${primaryKeyword} work`,
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
comparison: {
|
|
74
|
+
priority: priorities.comparison,
|
|
75
|
+
queries: comparisonQueries,
|
|
76
|
+
},
|
|
77
|
+
transactional: {
|
|
78
|
+
priority: priorities.transactional,
|
|
79
|
+
queries: profile.transactionalQueries(brandLower),
|
|
80
|
+
},
|
|
81
|
+
reputational: {
|
|
82
|
+
priority: priorities.reputational,
|
|
83
|
+
queries: [
|
|
84
|
+
`${brandLower} reviews`,
|
|
85
|
+
`is ${brandLower} legit`,
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
category: {
|
|
89
|
+
priority: priorities.category,
|
|
90
|
+
queries: profile.categoryQuery(primaryKeyword, year),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Merge discovered live routes with recommended site-type pages
|
|
95
|
+
const recommendedPages = REQUIRED_PAGES[siteType] || REQUIRED_PAGES.saas;
|
|
96
|
+
const discoveredRoutes = Array.isArray(repoInfo?.routes) ? repoInfo.routes : [];
|
|
97
|
+
const discoveredSet = new Set(discoveredRoutes.map((r) => r.toLowerCase()));
|
|
98
|
+
|
|
99
|
+
const pages = [];
|
|
100
|
+
const seenUrls = new Set();
|
|
101
|
+
const seenIds = new Set();
|
|
23
102
|
|
|
24
|
-
//
|
|
25
|
-
|
|
103
|
+
// First, add recommended pages (marking as 'live' if discovered in repo)
|
|
104
|
+
for (const rec of recommendedPages) {
|
|
105
|
+
const isLive = discoveredSet.has(rec.url.toLowerCase());
|
|
106
|
+
pages.push({
|
|
107
|
+
id: rec.id,
|
|
108
|
+
url: rec.url,
|
|
109
|
+
status: isLive ? 'live' : 'planned',
|
|
110
|
+
priority: rec.priority,
|
|
111
|
+
keyword: rec.url === '/' ? primaryKeyword : null,
|
|
112
|
+
});
|
|
113
|
+
seenUrls.add(rec.url.toLowerCase());
|
|
114
|
+
seenIds.add(rec.id);
|
|
115
|
+
}
|
|
26
116
|
|
|
27
|
-
|
|
28
|
-
|
|
117
|
+
// Then append any additional discovered live routes (capped at 20 total to keep manifest concise)
|
|
118
|
+
let nextPriority = pages.length + 1;
|
|
119
|
+
for (const route of discoveredRoutes) {
|
|
120
|
+
if (pages.length >= 20) break;
|
|
121
|
+
if (seenUrls.has(route.toLowerCase())) continue;
|
|
122
|
+
let id = routeToPageId(route);
|
|
123
|
+
if (seenIds.has(id)) {
|
|
124
|
+
id = `${id}-${nextPriority}`;
|
|
125
|
+
}
|
|
126
|
+
pages.push({
|
|
127
|
+
id,
|
|
128
|
+
url: route,
|
|
129
|
+
status: 'live',
|
|
130
|
+
priority: nextPriority++,
|
|
131
|
+
keyword: null,
|
|
132
|
+
});
|
|
133
|
+
seenUrls.add(route.toLowerCase());
|
|
134
|
+
seenIds.add(id);
|
|
29
135
|
}
|
|
30
136
|
|
|
31
|
-
|
|
137
|
+
const frontmatter = {
|
|
138
|
+
spec: SPEC_VERSION,
|
|
139
|
+
site: {
|
|
140
|
+
brand,
|
|
141
|
+
domain,
|
|
142
|
+
canonical: `https://${domain}`,
|
|
143
|
+
type: siteType,
|
|
144
|
+
locale: 'en-US',
|
|
145
|
+
},
|
|
146
|
+
keywords: {
|
|
147
|
+
primary: primaryKeyword,
|
|
148
|
+
secondary: [],
|
|
149
|
+
negative: profile.negativeKeywords,
|
|
150
|
+
},
|
|
151
|
+
competitors: competitorList.map((c) => ({ domain: c })),
|
|
152
|
+
intent,
|
|
153
|
+
pages,
|
|
154
|
+
schema: {
|
|
155
|
+
types: SCHEMA_TYPES[siteType] || SCHEMA_TYPES.saas,
|
|
156
|
+
},
|
|
157
|
+
crawl: {
|
|
158
|
+
sitemap: '/sitemap.xml',
|
|
159
|
+
robots: '/robots.txt',
|
|
160
|
+
llms_txt: '/llms.txt',
|
|
161
|
+
allow_ai_bots: true,
|
|
162
|
+
disallow: profile.disallow,
|
|
163
|
+
},
|
|
164
|
+
provider: {
|
|
165
|
+
name: answers.provider || null,
|
|
166
|
+
endpoint: null,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
32
169
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
170
|
+
const yamlBlock = YAML.stringify(frontmatter, { lineWidth: 100 }).trimEnd();
|
|
171
|
+
|
|
172
|
+
const rulesMarkdown = profile.agentRules.map((rule) => `- ${rule}`).join('\n');
|
|
173
|
+
const negativeMarkdown = profile.negativeKeywords.map((kw) => `\`${kw}\``).join(', ');
|
|
174
|
+
const promptLines = [
|
|
175
|
+
`- **Category:** ${intent.category.queries.map((q) => `"${q}"`).join(', ')}`,
|
|
176
|
+
`- **Comparison:** ${intent.comparison.queries.map((q) => `"${q}"`).join(', ')}`,
|
|
177
|
+
`- **Transactional:** ${intent.transactional.queries.map((q) => `"${q}"`).join(', ')}`,
|
|
178
|
+
].join('\n');
|
|
179
|
+
|
|
180
|
+
const body = `# SEO.md — ${brand}
|
|
181
|
+
|
|
182
|
+
> Open standard for search & AI-citation configuration (spec v${SPEC_VERSION} — https://seomd.dev).
|
|
183
|
+
> Coding agents: read this file and matching playbooks in \`.seo/pages/\` before creating or editing public pages.
|
|
184
|
+
|
|
185
|
+
## Canonical Product Facts
|
|
186
|
+
- **One-liner:** ${brand} — replace with a clear, factual 1-sentence description of what you offer.
|
|
187
|
+
- **Primary category:** ${primaryKeyword}
|
|
188
|
+
- **Pricing / offer:** Add real pricing or offer facts here so coding agents never invent vague copy.
|
|
189
|
+
- **Proof points:** Add concrete, verifiable metrics, certifications, or customer outcomes.
|
|
190
|
+
|
|
191
|
+
## Target Buyer Prompts (AI Search)
|
|
192
|
+
${promptLines}
|
|
193
|
+
|
|
194
|
+
## Page & AEO Rules (For Coding Agents)
|
|
195
|
+
${rulesMarkdown}
|
|
196
|
+
|
|
197
|
+
## Do Not Claim
|
|
198
|
+
- Avoid diluting intent with negative terms: ${negativeMarkdown}.
|
|
199
|
+
- Never fabricate competitor pricing, benchmarks, or unverified customer quotes.
|
|
200
|
+
|
|
201
|
+
## Live Intelligence
|
|
202
|
+
- Metrics & gap scores: \`.seo/STATUS.yml\`
|
|
203
|
+
- Competitor reverse-engineering: \`.seo/REVERSE.md\`
|
|
204
|
+
- Per-page playbooks: \`.seo/pages/<id>.md\`
|
|
205
|
+
`;
|
|
206
|
+
|
|
207
|
+
return `---\n${yamlBlock}\n---\n\n${body}`;
|
|
208
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
const getDashboardUrlFromApi = (apiUrl, explicitDashboardUrl = null) => {
|
|
4
|
+
if (explicitDashboardUrl) return explicitDashboardUrl;
|
|
5
|
+
if (apiUrl && (apiUrl.includes('127.0.0.1') || apiUrl.includes('localhost'))) {
|
|
6
|
+
return 'http://localhost:3000';
|
|
7
|
+
}
|
|
8
|
+
if (apiUrl && apiUrl.includes('api.foxcite.com')) {
|
|
9
|
+
return 'https://app.foxcite.com';
|
|
10
|
+
}
|
|
11
|
+
return 'https://seomd.dev';
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a fresh axios client using runtime credentials (never frozen at import time).
|
|
16
|
+
*/
|
|
17
|
+
export function createHttpClient({
|
|
18
|
+
baseURL,
|
|
19
|
+
apiKey = null,
|
|
20
|
+
paymentToken = null,
|
|
21
|
+
domain = null,
|
|
22
|
+
dashboardUrl = null,
|
|
23
|
+
timeout = 300000,
|
|
24
|
+
}) {
|
|
25
|
+
const client = axios.create({
|
|
26
|
+
baseURL,
|
|
27
|
+
timeout,
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
31
|
+
...(paymentToken ? { 'x-payment-token': paymentToken } : {}),
|
|
32
|
+
...(domain ? { 'x-seomd-domain': domain } : {}),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
client.interceptors.response.use(
|
|
37
|
+
(response) => response,
|
|
38
|
+
(error) => {
|
|
39
|
+
if (error.response) {
|
|
40
|
+
const status = error.response.status;
|
|
41
|
+
const detail = error.response.data?.detail || error.response.data?.message || error.message;
|
|
42
|
+
|
|
43
|
+
if (status === 401) {
|
|
44
|
+
return Promise.reject(
|
|
45
|
+
new Error('Authentication failed: Invalid or missing API key (SEOMD_API_KEY).')
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (status === 402) {
|
|
49
|
+
const dashUrl = getDashboardUrlFromApi(baseURL, dashboardUrl);
|
|
50
|
+
return Promise.reject(
|
|
51
|
+
new Error(
|
|
52
|
+
`Insufficient scan credits.\n\n` +
|
|
53
|
+
`For Humans: Recharge credits or upgrade your plan:\n` +
|
|
54
|
+
` ${dashUrl}/billing\n\n` +
|
|
55
|
+
`For Programmatic Agents:\n` +
|
|
56
|
+
` Set SEOMD_PAYMENT_TOKEN in your environment to pay-per-scan inline via x402.`
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return Promise.reject(new Error(`API Error (${status}): ${detail}`));
|
|
61
|
+
}
|
|
62
|
+
return Promise.reject(new Error(`Network Error: ${error.message}`));
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return client;
|
|
67
|
+
}
|