seomd-cli 1.0.3 ā 1.1.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/seomd.js +1 -0
- package/package.json +1 -1
- package/src/commands/analyze.js +37 -7
- package/src/commands/sync.js +2 -1
- package/src/utils/writeback.js +3 -3
package/bin/seomd.js
CHANGED
|
@@ -32,6 +32,7 @@ program
|
|
|
32
32
|
.description('Run citation analysis and write back _analysis blocks')
|
|
33
33
|
.option('--page <url>', 'analyze a specific page only')
|
|
34
34
|
.option('--intent <category>', 'analyze a specific intent category only')
|
|
35
|
+
.option('--engines <list>', 'comma-separated list of engines to scan (e.g. chatgpt,claude)')
|
|
35
36
|
.action(analyzeCommand);
|
|
36
37
|
|
|
37
38
|
program
|
package/package.json
CHANGED
package/src/commands/analyze.js
CHANGED
|
@@ -9,6 +9,23 @@ import { writeAnalysisToSeoMd, writeReverseMd, writePageAnalysis } from '../util
|
|
|
9
9
|
|
|
10
10
|
dotenv.config();
|
|
11
11
|
|
|
12
|
+
function matchRoute(pattern, url) {
|
|
13
|
+
const cleanPattern = pattern.replace(/\/$/, '');
|
|
14
|
+
const cleanUrl = url.replace(/\/$/, '');
|
|
15
|
+
|
|
16
|
+
if (cleanPattern.toLowerCase() === cleanUrl.toLowerCase()) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Replace "/[param]" with optional group "(?:/([^/]+))?"
|
|
21
|
+
const regexPattern = cleanPattern
|
|
22
|
+
.replace(/\/\[[^\]]+\]/g, '(?:\\/([^/]+))?')
|
|
23
|
+
.replace(/\//g, '\\/');
|
|
24
|
+
|
|
25
|
+
const regex = new RegExp('^' + regexPattern + '\\/?$', 'i');
|
|
26
|
+
return regex.test(url);
|
|
27
|
+
}
|
|
28
|
+
|
|
12
29
|
export async function analyzeCommand(options) {
|
|
13
30
|
const apiKey = process.env.SEOMD_API_KEY;
|
|
14
31
|
const paymentToken = process.env.SEOMD_PAYMENT_TOKEN;
|
|
@@ -68,21 +85,31 @@ export async function analyzeCommand(options) {
|
|
|
68
85
|
|
|
69
86
|
// Filter by options.page if specified
|
|
70
87
|
if (options.page) {
|
|
71
|
-
pagesList = pagesList.filter(p => p.url
|
|
88
|
+
pagesList = pagesList.filter(p => matchRoute(p.url, options.page));
|
|
72
89
|
}
|
|
73
90
|
|
|
74
|
-
// Default
|
|
91
|
+
// Default fallback if no page matches or list is empty
|
|
75
92
|
if (pagesList.length === 0) {
|
|
93
|
+
let fallbackId = 'homepage';
|
|
94
|
+
if (options.page && options.page !== '/') {
|
|
95
|
+
fallbackId = options.page
|
|
96
|
+
.replace(/^\//, '')
|
|
97
|
+
.replace(/\/$/, '')
|
|
98
|
+
.replace(/[^a-zA-Z0-9-]/g, '-');
|
|
99
|
+
}
|
|
76
100
|
pagesList.push({
|
|
77
|
-
id:
|
|
101
|
+
id: fallbackId,
|
|
78
102
|
url: options.page || '/',
|
|
79
|
-
primary_keyword: `best ${niche}`,
|
|
103
|
+
primary_keyword: data.keywords?.primary || `best ${niche}`,
|
|
80
104
|
status: 'planned'
|
|
81
105
|
});
|
|
82
106
|
}
|
|
83
107
|
|
|
84
108
|
// Extract engines
|
|
85
|
-
|
|
109
|
+
let engines = data.aeo?._analysis?.engines_tracked || ['ChatGPT'];
|
|
110
|
+
if (options.engines) {
|
|
111
|
+
engines = options.engines.split(',').map(e => e.trim());
|
|
112
|
+
}
|
|
86
113
|
|
|
87
114
|
console.log(chalk.bold.cyan(`\nš Foxcite: Running AI Search Audit for ${chalk.white(domain)}`));
|
|
88
115
|
console.log(chalk.dim(`Engines: ${engines.join(', ')}`));
|
|
@@ -92,14 +119,16 @@ export async function analyzeCommand(options) {
|
|
|
92
119
|
const spinner = ora('Initializing scan sessions...').start();
|
|
93
120
|
|
|
94
121
|
try {
|
|
122
|
+
const brand = data.identity?.brand || 'My Brand';
|
|
95
123
|
const payload = {
|
|
96
124
|
domain,
|
|
97
125
|
niche,
|
|
126
|
+
brand,
|
|
98
127
|
queries,
|
|
99
128
|
engines,
|
|
100
129
|
pages: pagesList.map(p => ({
|
|
101
130
|
id: p.id,
|
|
102
|
-
url: p.url,
|
|
131
|
+
url: options.page || p.url, // Use the specific page requested if provided
|
|
103
132
|
primary_keyword: p.primary_keyword || data.keywords?.primary || `best ${niche}`,
|
|
104
133
|
status: p.status
|
|
105
134
|
}))
|
|
@@ -116,7 +145,8 @@ export async function analyzeCommand(options) {
|
|
|
116
145
|
await writeAnalysisToSeoMd(doc, results, cwd);
|
|
117
146
|
|
|
118
147
|
// Writeback to SEO.REVERSE.md
|
|
119
|
-
|
|
148
|
+
const brandName = data.identity?.brand || 'My Brand';
|
|
149
|
+
await writeReverseMd(cwd, results, domain, brandName);
|
|
120
150
|
|
|
121
151
|
// Writeback to .seomd/pages/*.md
|
|
122
152
|
await writePageAnalysis(cwd, results);
|
package/src/commands/sync.js
CHANGED
|
@@ -88,7 +88,8 @@ export async function syncCommand(options) {
|
|
|
88
88
|
await writeAnalysisToSeoMd(doc, results, cwd);
|
|
89
89
|
|
|
90
90
|
// Writeback to SEO.REVERSE.md
|
|
91
|
-
|
|
91
|
+
const brandName = data.identity?.brand || 'My Brand';
|
|
92
|
+
await writeReverseMd(cwd, results, domain, brandName);
|
|
92
93
|
|
|
93
94
|
// Writeback to .seomd/pages/*.md
|
|
94
95
|
await writePageAnalysis(cwd, results);
|
package/src/utils/writeback.js
CHANGED
|
@@ -67,7 +67,7 @@ export async function writeAnalysisToSeoMd(doc, response, cwd) {
|
|
|
67
67
|
* @param {string} cwd - Current working directory
|
|
68
68
|
* @param {any} response - The API response from analyze/sync
|
|
69
69
|
*/
|
|
70
|
-
export async function writeReverseMd(cwd, response) {
|
|
70
|
+
export async function writeReverseMd(cwd, response, defaultDomain = 'example.com', defaultBrand = 'My Brand') {
|
|
71
71
|
const reversePath = path.join(cwd, 'SEO.REVERSE.md');
|
|
72
72
|
|
|
73
73
|
const reversePages = response.page_analysis.map(p => ({
|
|
@@ -88,8 +88,8 @@ export async function writeReverseMd(cwd, response) {
|
|
|
88
88
|
const primaryCompetitor = response.intent_analysis?.comparison?.top_cited_competitor || 'None';
|
|
89
89
|
|
|
90
90
|
const reverseDoc = {
|
|
91
|
-
domain: response.domain ||
|
|
92
|
-
brand: response.brand_name ||
|
|
91
|
+
domain: response.domain || defaultDomain,
|
|
92
|
+
brand: response.brand_name || defaultBrand,
|
|
93
93
|
primary_competitor: primaryCompetitor,
|
|
94
94
|
last_analyzed: response.aeo_analysis.last_analyzed,
|
|
95
95
|
next_analysis: response.aeo_analysis.next_analysis,
|