@pas7/llm-seo 0.1.6
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/LICENSE +201 -0
- package/README.md +164 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.js +673 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/next/index.d.ts +292 -0
- package/dist/adapters/next/index.js +673 -0
- package/dist/adapters/next/index.js.map +1 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +2232 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/config.schema-DCnBx3Gm.d.ts +824 -0
- package/dist/core/index.d.ts +752 -0
- package/dist/core/index.js +1330 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1909 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.schema-B_z3rxRV.d.ts +384 -0
- package/dist/schema/index.d.ts +72 -0
- package/dist/schema/index.js +422 -0
- package/dist/schema/index.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
import { M as ManifestItem, S as SiteManifest } from '../manifest.schema-B_z3rxRV.js';
|
|
2
|
+
import { L as LlmsSeoConfig } from '../config.schema-DCnBx3Gm.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* URL normalization utilities for deterministic SEO processing.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Options for URL normalization.
|
|
10
|
+
*/
|
|
11
|
+
interface NormalizeUrlOptions {
|
|
12
|
+
/** Base URL e.g., "https://example.com" */
|
|
13
|
+
baseUrl: string;
|
|
14
|
+
/** Path e.g., "/blog/my-post" */
|
|
15
|
+
path: string;
|
|
16
|
+
/** Trailing slash policy */
|
|
17
|
+
trailingSlash: 'always' | 'never' | 'preserve';
|
|
18
|
+
/** Strip query string (default: true) */
|
|
19
|
+
stripQuery?: boolean;
|
|
20
|
+
/** Strip hash/fragment (default: true) */
|
|
21
|
+
stripHash?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes URL according to policy:
|
|
25
|
+
* - No // in path (collapse to single /)
|
|
26
|
+
* - Strip query and hash by default
|
|
27
|
+
* - Apply trailing slash policy
|
|
28
|
+
* - Lowercase hostname
|
|
29
|
+
* - Remove default ports (80, 443)
|
|
30
|
+
* @param options - Normalization options
|
|
31
|
+
* @returns The normalized URL string
|
|
32
|
+
*/
|
|
33
|
+
declare function normalizeUrl(options: NormalizeUrlOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* Sorts URLs deterministically for consistent output ordering.
|
|
36
|
+
* @param urls - Array of URLs to sort
|
|
37
|
+
* @returns Sorted array of URLs
|
|
38
|
+
*/
|
|
39
|
+
declare function sortUrls(urls: readonly string[]): string[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Deterministic sorting utilities for SEO artifacts.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Comparator function type for sorting operations.
|
|
46
|
+
*/
|
|
47
|
+
type Comparator<T> = (a: T, b: T) => number;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a deterministic string comparator for consistent ordering.
|
|
50
|
+
* Uses localeCompare with specific locale for reproducibility.
|
|
51
|
+
* @param a - First string to compare
|
|
52
|
+
* @param b - Second string to compare
|
|
53
|
+
* @returns Negative if a < b, positive if a > b, zero if equal
|
|
54
|
+
*/
|
|
55
|
+
declare function compareStrings(a: string, b: string): number;
|
|
56
|
+
/**
|
|
57
|
+
* Sorts an array of strings deterministically.
|
|
58
|
+
* @param items - Array of strings to sort
|
|
59
|
+
* @returns New sorted array
|
|
60
|
+
*/
|
|
61
|
+
declare function sortStrings(items: readonly string[]): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Sorts an array of objects by a string key deterministically.
|
|
64
|
+
* @param items - Array of objects to sort
|
|
65
|
+
* @param keyFn - Function to extract the comparison key
|
|
66
|
+
* @returns New sorted array
|
|
67
|
+
*/
|
|
68
|
+
declare function sortBy<T>(items: readonly T[], keyFn: (item: T) => string): T[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Text normalization utilities for deterministic SEO processing.
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* Normalizes whitespace in text by collapsing multiple spaces and trimming.
|
|
75
|
+
* @param text - The text to normalize
|
|
76
|
+
* @returns Normalized text with single spaces
|
|
77
|
+
*/
|
|
78
|
+
declare function normalizeWhitespace(text: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Normalizes line endings to the specified format.
|
|
81
|
+
* @param text - The text to normalize
|
|
82
|
+
* @param lineEndings - Target line endings format ('lf' or 'crlf')
|
|
83
|
+
* @returns Text with normalized line endings
|
|
84
|
+
*/
|
|
85
|
+
declare function normalizeLineEndings(text: string, lineEndings: 'lf' | 'crlf'): string;
|
|
86
|
+
/**
|
|
87
|
+
* Normalizes whitespace in lines - trims trailing whitespace and removes multiple consecutive spaces.
|
|
88
|
+
* @param text - The text to normalize
|
|
89
|
+
* @returns Text with normalized line whitespace
|
|
90
|
+
*/
|
|
91
|
+
declare function normalizeLineWhitespace(text: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Normalizes text for use in SEO meta descriptions or titles.
|
|
94
|
+
* Collapses whitespace and truncates to a maximum length.
|
|
95
|
+
* @param text - The text to normalize
|
|
96
|
+
* @param maxLength - Maximum allowed length
|
|
97
|
+
* @returns Normalized text
|
|
98
|
+
*/
|
|
99
|
+
declare function normalizeSeoText(text: string, maxLength: number): string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Canonical URL generation from site manifests.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Options for canonical URL generation.
|
|
107
|
+
*/
|
|
108
|
+
interface CanonicalOptions {
|
|
109
|
+
/** Whether to include trailing slash (default: false) */
|
|
110
|
+
trailingSlash?: boolean;
|
|
111
|
+
/** Whether to use lowercase (default: true) */
|
|
112
|
+
lowercase?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Locale strategy for URL generation.
|
|
116
|
+
*/
|
|
117
|
+
type LocaleStrategy = 'prefix' | 'subdomain' | 'none';
|
|
118
|
+
/**
|
|
119
|
+
* Trailing slash policy.
|
|
120
|
+
*/
|
|
121
|
+
type TrailingSlashPolicy = 'always' | 'never' | 'preserve';
|
|
122
|
+
/**
|
|
123
|
+
* Options for creating canonical URLs from manifest.
|
|
124
|
+
*/
|
|
125
|
+
interface CreateCanonicalUrlsOptions {
|
|
126
|
+
/** Array of manifest items */
|
|
127
|
+
items: ManifestItem[];
|
|
128
|
+
/** Base URL e.g., "https://example.com" */
|
|
129
|
+
baseUrl: string;
|
|
130
|
+
/** Route prefix e.g., "/blog" for blog posts */
|
|
131
|
+
routePrefix?: string;
|
|
132
|
+
/** Default locale code */
|
|
133
|
+
defaultLocale: string;
|
|
134
|
+
/** Trailing slash policy */
|
|
135
|
+
trailingSlash: TrailingSlashPolicy;
|
|
136
|
+
/** Locale URL strategy */
|
|
137
|
+
localeStrategy: LocaleStrategy;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Generates a canonical URL for a given path from the site manifest.
|
|
141
|
+
* @param manifest - The site manifest containing base URL information
|
|
142
|
+
* @param path - The path to generate canonical URL for
|
|
143
|
+
* @param options - Canonical URL options
|
|
144
|
+
* @returns The canonical URL
|
|
145
|
+
*/
|
|
146
|
+
declare function generateCanonicalUrl(manifest: SiteManifest, path: string, options?: CanonicalOptions): string;
|
|
147
|
+
/**
|
|
148
|
+
* Extracts all canonical URLs from a site manifest.
|
|
149
|
+
* @param manifest - The site manifest
|
|
150
|
+
* @param options - Canonical URL options
|
|
151
|
+
* @returns Array of canonical URLs
|
|
152
|
+
*/
|
|
153
|
+
declare function extractCanonicalUrls(manifest: SiteManifest, options?: CanonicalOptions): string[];
|
|
154
|
+
/**
|
|
155
|
+
* Deduplicates URLs by converting to Set and back.
|
|
156
|
+
* @param urls - Array of URLs to deduplicate
|
|
157
|
+
* @returns Array of unique URLs
|
|
158
|
+
*/
|
|
159
|
+
declare function dedupeUrls(urls: string[]): string[];
|
|
160
|
+
/**
|
|
161
|
+
* Creates a single canonical URL for a manifest item.
|
|
162
|
+
* @param item - The manifest item
|
|
163
|
+
* @param options - Options for URL creation (without items array)
|
|
164
|
+
* @returns The canonical URL string
|
|
165
|
+
*/
|
|
166
|
+
declare function createCanonicalUrlForItem(item: ManifestItem, options: Omit<CreateCanonicalUrlsOptions, 'items'>): string;
|
|
167
|
+
/**
|
|
168
|
+
* Creates canonical URLs from manifest items:
|
|
169
|
+
* 1. For each item, select canonical locale
|
|
170
|
+
* 2. Build URL: baseUrl + localePrefix (if strategy=prefix) + routePrefix + slug
|
|
171
|
+
* 3. Apply trailing slash policy
|
|
172
|
+
* 4. Normalize URL
|
|
173
|
+
* 5. Dedupe (by URL string)
|
|
174
|
+
* 6. Sort stably
|
|
175
|
+
* @param options - Options for URL creation
|
|
176
|
+
* @returns Sorted array of canonical URLs
|
|
177
|
+
*/
|
|
178
|
+
declare function createCanonicalUrlsFromManifest(options: CreateCanonicalUrlsOptions): string[];
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Locale handling utilities for canonical URL generation.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Represents a locale configuration for a site.
|
|
186
|
+
*/
|
|
187
|
+
interface LocaleConfig {
|
|
188
|
+
/** Default locale code (e.g., 'en') */
|
|
189
|
+
default: string;
|
|
190
|
+
/** Supported locale codes */
|
|
191
|
+
supported: readonly string[];
|
|
192
|
+
/** URL strategy for locales */
|
|
193
|
+
strategy: 'subdirectory' | 'subdomain' | 'domain';
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Generates locale-prefixed path.
|
|
197
|
+
* @param path - The base path
|
|
198
|
+
* @param locale - The locale code
|
|
199
|
+
* @param config - Locale configuration
|
|
200
|
+
* @returns Path with locale prefix if applicable
|
|
201
|
+
*/
|
|
202
|
+
declare function localizePath(path: string, locale: string, config: LocaleConfig): string;
|
|
203
|
+
/**
|
|
204
|
+
* Extracts locale from a path.
|
|
205
|
+
* @param path - The path to extract locale from
|
|
206
|
+
* @param config - Locale configuration
|
|
207
|
+
* @returns Tuple of [locale, pathWithoutLocale]
|
|
208
|
+
*/
|
|
209
|
+
declare function extractLocaleFromPath(path: string, config: LocaleConfig): readonly [string, string];
|
|
210
|
+
/**
|
|
211
|
+
* Generates alternate locale URLs for a page.
|
|
212
|
+
* @param baseUrl - Base URL of the site
|
|
213
|
+
* @param path - Page path
|
|
214
|
+
* @param config - Locale configuration
|
|
215
|
+
* @returns Map of locale to full URL
|
|
216
|
+
*/
|
|
217
|
+
declare function generateAlternateUrls(baseUrl: string, path: string, config: LocaleConfig): Map<string, string>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* llms.txt generator for LLM-optimized site documentation.
|
|
221
|
+
* Generates a short brand profile with sections, URLs, policies, and contact info.
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Options for llms.txt generation.
|
|
226
|
+
*/
|
|
227
|
+
interface CreateLlmsTxtOptions {
|
|
228
|
+
/** Full LLM SEO configuration */
|
|
229
|
+
config: LlmsSeoConfig;
|
|
230
|
+
/** Pre-built canonical URLs from manifests */
|
|
231
|
+
canonicalUrls: string[];
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Result of llms.txt generation.
|
|
235
|
+
*/
|
|
236
|
+
interface CreateLlmsTxtResult {
|
|
237
|
+
/** Generated llms.txt content */
|
|
238
|
+
content: string;
|
|
239
|
+
/** Size in bytes */
|
|
240
|
+
byteSize: number;
|
|
241
|
+
/** Number of lines */
|
|
242
|
+
lineCount: number;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Creates llms.txt content with deterministic output.
|
|
246
|
+
* - Deterministic ordering of all sections
|
|
247
|
+
* - Handles missing optional fields gracefully
|
|
248
|
+
* - EOL controlled by config.format.lineEndings
|
|
249
|
+
* @param options - Generation options
|
|
250
|
+
* @returns Generated content with metadata
|
|
251
|
+
*/
|
|
252
|
+
declare function createLlmsTxt(options: CreateLlmsTxtOptions): CreateLlmsTxtResult;
|
|
253
|
+
interface LlmsTxtOptions {
|
|
254
|
+
/** Whether to include optional sections */
|
|
255
|
+
includeOptionalSections?: boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated Use createLlmsTxt instead
|
|
259
|
+
*/
|
|
260
|
+
declare function generateLlmsTxt(manifest: {
|
|
261
|
+
baseUrl: string;
|
|
262
|
+
title: string;
|
|
263
|
+
description?: string | undefined;
|
|
264
|
+
pages: Array<{
|
|
265
|
+
path: string;
|
|
266
|
+
title?: string | undefined;
|
|
267
|
+
description?: string | undefined;
|
|
268
|
+
}>;
|
|
269
|
+
}, _options?: LlmsTxtOptions): string;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* llms-full.txt generator with complete context for LLMs.
|
|
273
|
+
* Generates full brand context with all URLs, detailed policies, social/booking, and machine hints.
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Options for llms-full.txt generation.
|
|
278
|
+
*/
|
|
279
|
+
interface CreateLlmsFullTxtOptions {
|
|
280
|
+
/** Full LLM SEO configuration */
|
|
281
|
+
config: LlmsSeoConfig;
|
|
282
|
+
/** Pre-built canonical URLs from manifests */
|
|
283
|
+
canonicalUrls: string[];
|
|
284
|
+
/** Manifest items for detailed URL listing */
|
|
285
|
+
manifestItems: ManifestItem[];
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Result of llms-full.txt generation.
|
|
289
|
+
*/
|
|
290
|
+
interface CreateLlmsFullTxtResult {
|
|
291
|
+
/** Generated llms-full.txt content */
|
|
292
|
+
content: string;
|
|
293
|
+
/** Size in bytes */
|
|
294
|
+
byteSize: number;
|
|
295
|
+
/** Number of lines */
|
|
296
|
+
lineCount: number;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Creates llms-full.txt content with deterministic output.
|
|
300
|
+
* - Complete context with all URLs
|
|
301
|
+
* - Detailed policy sections
|
|
302
|
+
* - Social and booking info
|
|
303
|
+
* - EOL controlled by config.format.lineEndings
|
|
304
|
+
* @param options - Generation options
|
|
305
|
+
* @returns Generated content with metadata
|
|
306
|
+
*/
|
|
307
|
+
declare function createLlmsFullTxt(options: CreateLlmsFullTxtOptions): CreateLlmsFullTxtResult;
|
|
308
|
+
interface LlmsFullTxtOptions {
|
|
309
|
+
/** Maximum content length per page (0 = no limit) */
|
|
310
|
+
maxContentLength?: number;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Generates full page content for llms-full.txt.
|
|
314
|
+
* @deprecated Use createLlmsFullTxt instead
|
|
315
|
+
*/
|
|
316
|
+
declare function generatePageContent(page: {
|
|
317
|
+
path: string;
|
|
318
|
+
title?: string;
|
|
319
|
+
description?: string;
|
|
320
|
+
content?: string;
|
|
321
|
+
}, manifest: {
|
|
322
|
+
baseUrl: string;
|
|
323
|
+
}, _options?: LlmsFullTxtOptions): string;
|
|
324
|
+
/**
|
|
325
|
+
/**
|
|
326
|
+
* @deprecated Use createLlmsFullTxt instead
|
|
327
|
+
*/
|
|
328
|
+
declare function generateLlmsFullTxt(manifest: {
|
|
329
|
+
baseUrl: string;
|
|
330
|
+
title: string;
|
|
331
|
+
description?: string | undefined;
|
|
332
|
+
pages: Array<{
|
|
333
|
+
path: string;
|
|
334
|
+
title?: string | undefined;
|
|
335
|
+
description?: string | undefined;
|
|
336
|
+
content?: string | undefined;
|
|
337
|
+
}>;
|
|
338
|
+
}, _options?: LlmsFullTxtOptions): string;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Citation generation utilities for LLM-optimized content.
|
|
342
|
+
* Creates machine-readable citations.json for CI validation.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Citation source entry.
|
|
347
|
+
*/
|
|
348
|
+
interface CitationSource {
|
|
349
|
+
/** Canonical URL */
|
|
350
|
+
url: string;
|
|
351
|
+
/** Priority (0-100) */
|
|
352
|
+
priority: number;
|
|
353
|
+
/** Section name */
|
|
354
|
+
section: string;
|
|
355
|
+
/** Locale code */
|
|
356
|
+
locale: string;
|
|
357
|
+
/** Publication date (ISO 8601) */
|
|
358
|
+
publishedAt?: string;
|
|
359
|
+
/** Last update date (ISO 8601) */
|
|
360
|
+
updatedAt?: string;
|
|
361
|
+
/** Page title */
|
|
362
|
+
title?: string;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Site information in citations.json.
|
|
366
|
+
*/
|
|
367
|
+
interface CitationsSite {
|
|
368
|
+
/** Base URL */
|
|
369
|
+
baseUrl: string;
|
|
370
|
+
/** Site name */
|
|
371
|
+
name: string;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Policy information in citations.json.
|
|
375
|
+
*/
|
|
376
|
+
interface CitationsPolicy {
|
|
377
|
+
/** Geographic policy */
|
|
378
|
+
geoPolicy?: string;
|
|
379
|
+
/** Citation rules */
|
|
380
|
+
citationRules?: string;
|
|
381
|
+
/** Whether restricted claims are enabled */
|
|
382
|
+
restrictedClaimsEnabled: boolean;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Complete citations.json structure.
|
|
386
|
+
*/
|
|
387
|
+
interface CitationsJson {
|
|
388
|
+
/** Schema version */
|
|
389
|
+
version: string;
|
|
390
|
+
/** Generation timestamp (ISO 8601) */
|
|
391
|
+
generated: string;
|
|
392
|
+
/** Site information */
|
|
393
|
+
site: CitationsSite;
|
|
394
|
+
/** Sorted citation sources */
|
|
395
|
+
sources: CitationSource[];
|
|
396
|
+
/** Policy information */
|
|
397
|
+
policy: CitationsPolicy;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Options for citations.json generation.
|
|
401
|
+
*/
|
|
402
|
+
interface CreateCitationsJsonOptions {
|
|
403
|
+
/** Full LLM SEO configuration */
|
|
404
|
+
config: LlmsSeoConfig;
|
|
405
|
+
/** Manifest items to include */
|
|
406
|
+
manifestItems: ManifestItem[];
|
|
407
|
+
/** Section name for these items */
|
|
408
|
+
sectionName: string;
|
|
409
|
+
/** Optional fixed timestamp for deterministic output (tests) */
|
|
410
|
+
fixedTimestamp?: string;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Creates citations.json object with deterministic output.
|
|
414
|
+
* - Sorted by priority (descending), then by URL
|
|
415
|
+
* - Includes all manifest items with their metadata
|
|
416
|
+
* @param options - Generation options
|
|
417
|
+
* @returns Citations JSON object
|
|
418
|
+
*/
|
|
419
|
+
declare function createCitationsJson(options: CreateCitationsJsonOptions): CitationsJson;
|
|
420
|
+
/**
|
|
421
|
+
* Creates citations.json as a formatted string.
|
|
422
|
+
* @param options - Generation options
|
|
423
|
+
* @returns JSON string with 2-space indentation
|
|
424
|
+
*/
|
|
425
|
+
declare function createCitationsJsonString(options: CreateCitationsJsonOptions): string;
|
|
426
|
+
/**
|
|
427
|
+
* Represents a citation for a page.
|
|
428
|
+
* @deprecated Use CitationSource instead
|
|
429
|
+
*/
|
|
430
|
+
interface Citation {
|
|
431
|
+
/** The URL being cited */
|
|
432
|
+
url: string;
|
|
433
|
+
/** The title of the cited page */
|
|
434
|
+
title: string;
|
|
435
|
+
/** Optional description */
|
|
436
|
+
description?: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Generates a citation object for a page.
|
|
440
|
+
* @deprecated Use createCitationsJson instead
|
|
441
|
+
*/
|
|
442
|
+
declare function createCitation(page: {
|
|
443
|
+
path: string;
|
|
444
|
+
title?: string;
|
|
445
|
+
description?: string;
|
|
446
|
+
}, manifest: {
|
|
447
|
+
baseUrl: string;
|
|
448
|
+
}): Citation;
|
|
449
|
+
/**
|
|
450
|
+
* Generates a citation in markdown format.
|
|
451
|
+
* @deprecated
|
|
452
|
+
*/
|
|
453
|
+
declare function citationToMarkdown(citation: Citation): string;
|
|
454
|
+
/**
|
|
455
|
+
* Generates a citation in JSON-LD format.
|
|
456
|
+
* @deprecated
|
|
457
|
+
*/
|
|
458
|
+
declare function citationToJsonLd(citation: Citation): Record<string, string>;
|
|
459
|
+
/**
|
|
460
|
+
* Generates a reference list from multiple citations.
|
|
461
|
+
* @deprecated
|
|
462
|
+
*/
|
|
463
|
+
declare function generateReferenceList(citations: readonly Citation[]): string;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Issue types and utilities for SEO checking.
|
|
467
|
+
*/
|
|
468
|
+
/**
|
|
469
|
+
* Severity levels for issues.
|
|
470
|
+
*/
|
|
471
|
+
type IssueSeverity = 'error' | 'warning' | 'info';
|
|
472
|
+
/**
|
|
473
|
+
* Categories of SEO issues.
|
|
474
|
+
*/
|
|
475
|
+
type IssueCategory = 'content' | 'structure' | 'accessibility' | 'performance' | 'metadata';
|
|
476
|
+
/**
|
|
477
|
+
* Represents a check issue found during file verification.
|
|
478
|
+
*/
|
|
479
|
+
interface CheckIssue {
|
|
480
|
+
/** File path or config path */
|
|
481
|
+
path: string;
|
|
482
|
+
/** Issue code e.g., 'file_mismatch', 'missing_file' */
|
|
483
|
+
code: CheckIssueCode;
|
|
484
|
+
/** Human-readable message describing the issue */
|
|
485
|
+
message: string;
|
|
486
|
+
/** Severity of the issue */
|
|
487
|
+
severity: IssueSeverity;
|
|
488
|
+
/** Optional line number where the issue was found */
|
|
489
|
+
line?: number;
|
|
490
|
+
/** Context snippet (first N lines or relevant content) */
|
|
491
|
+
context?: string;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Issue codes for check issues.
|
|
495
|
+
*/
|
|
496
|
+
type CheckIssueCode = 'file_missing' | 'file_mismatch' | 'file_empty' | 'forbidden_term' | 'empty_section' | 'duplicate_url' | 'invalid_url' | 'config_invalid';
|
|
497
|
+
/**
|
|
498
|
+
* Legacy Issue interface for backwards compatibility.
|
|
499
|
+
*/
|
|
500
|
+
interface Issue {
|
|
501
|
+
/** Unique identifier for the issue type */
|
|
502
|
+
id: string;
|
|
503
|
+
/** The page or resource this issue applies to */
|
|
504
|
+
pageId: string;
|
|
505
|
+
/** Severity of the issue */
|
|
506
|
+
severity: IssueSeverity;
|
|
507
|
+
/** Human-readable message describing the issue */
|
|
508
|
+
message: string;
|
|
509
|
+
/** Optional category for grouping */
|
|
510
|
+
category?: IssueCategory;
|
|
511
|
+
/** Optional suggestion for fixing the issue */
|
|
512
|
+
suggestion?: string;
|
|
513
|
+
/** Optional line number where the issue was found */
|
|
514
|
+
line?: number;
|
|
515
|
+
/** Optional column number where the issue was found */
|
|
516
|
+
column?: number;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Creates a legacy Issue with default values.
|
|
520
|
+
* @param overrides - Partial issue to override defaults
|
|
521
|
+
* @returns A complete issue object
|
|
522
|
+
*/
|
|
523
|
+
declare function createIssue(overrides: Partial<Issue> & Pick<Issue, 'id' | 'pageId' | 'severity' | 'message'>): Issue;
|
|
524
|
+
/**
|
|
525
|
+
* Groups issues by severity (legacy).
|
|
526
|
+
* @param issues - List of issues
|
|
527
|
+
* @returns Map of severity to issues
|
|
528
|
+
*/
|
|
529
|
+
declare function groupBySeverity(issues: readonly Issue[]): Map<IssueSeverity, Issue[]>;
|
|
530
|
+
/**
|
|
531
|
+
* Groups issues by page.
|
|
532
|
+
* @param issues - List of issues
|
|
533
|
+
* @returns Map of pageId to issues
|
|
534
|
+
*/
|
|
535
|
+
declare function groupByPage(issues: readonly Issue[]): Map<string, Issue[]>;
|
|
536
|
+
/**
|
|
537
|
+
* Filters issues by minimum severity.
|
|
538
|
+
* @param issues - List of issues
|
|
539
|
+
* @param minSeverity - Minimum severity to include
|
|
540
|
+
* @returns Filtered list of issues
|
|
541
|
+
*/
|
|
542
|
+
declare function filterBySeverity(issues: readonly Issue[], minSeverity: IssueSeverity): Issue[];
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Exit codes for CLI commands.
|
|
546
|
+
*/
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Exit codes for the llm-seo CLI.
|
|
550
|
+
*/
|
|
551
|
+
declare const ExitCodes: {
|
|
552
|
+
/** Command completed successfully */
|
|
553
|
+
readonly OK: 0;
|
|
554
|
+
/** Warnings found (when --fail-on warn) */
|
|
555
|
+
readonly WARN: 1;
|
|
556
|
+
/** Errors found */
|
|
557
|
+
readonly ERROR: 2;
|
|
558
|
+
/** Network error (for doctor command) */
|
|
559
|
+
readonly NETWORK_ERROR: 3;
|
|
560
|
+
/** Configuration file not found */
|
|
561
|
+
readonly CONFIG_NOT_FOUND: 4;
|
|
562
|
+
/** Invalid configuration */
|
|
563
|
+
readonly INVALID_CONFIG: 5;
|
|
564
|
+
/** File not found */
|
|
565
|
+
readonly FILE_NOT_FOUND: 6;
|
|
566
|
+
/** Validation failed */
|
|
567
|
+
readonly VALIDATION_FAILED: 7;
|
|
568
|
+
/** Generation failed */
|
|
569
|
+
readonly GENERATION_FAILED: 8;
|
|
570
|
+
/** Permission denied */
|
|
571
|
+
readonly PERMISSION_DENIED: 126;
|
|
572
|
+
/** Command not found */
|
|
573
|
+
readonly COMMAND_NOT_FOUND: 127;
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* Type for exit codes.
|
|
577
|
+
*/
|
|
578
|
+
type ExitCode = (typeof ExitCodes)[keyof typeof ExitCodes];
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* SEO checker for LLM-optimized content validation.
|
|
582
|
+
*/
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Configuration for the SEO checker.
|
|
586
|
+
*/
|
|
587
|
+
interface CheckerConfig {
|
|
588
|
+
/** Enable strict mode for additional checks */
|
|
589
|
+
strict?: boolean;
|
|
590
|
+
/** Maximum allowed title length */
|
|
591
|
+
maxTitleLength?: number;
|
|
592
|
+
/** Maximum allowed description length */
|
|
593
|
+
maxDescriptionLength?: number;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Options for checking generated files.
|
|
597
|
+
*/
|
|
598
|
+
interface CheckOptions {
|
|
599
|
+
/** LLM-SEO configuration */
|
|
600
|
+
config: LlmsSeoConfig;
|
|
601
|
+
/** Path to llms.txt (default from config) */
|
|
602
|
+
llmsTxtPath?: string;
|
|
603
|
+
/** Path to llms-full.txt (default from config) */
|
|
604
|
+
llmsFullTxtPath?: string;
|
|
605
|
+
/** Path to citations.json (optional) */
|
|
606
|
+
citationsPath?: string;
|
|
607
|
+
/** Fail threshold */
|
|
608
|
+
failOn: 'warn' | 'error';
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Result of running the SEO checker.
|
|
612
|
+
*/
|
|
613
|
+
interface CheckerResult {
|
|
614
|
+
/** Whether all checks passed */
|
|
615
|
+
passed: boolean;
|
|
616
|
+
/** List of issues found */
|
|
617
|
+
issues: Issue[];
|
|
618
|
+
/** Number of pages checked */
|
|
619
|
+
pagesChecked: number;
|
|
620
|
+
/** Summary of issues by severity */
|
|
621
|
+
summary: Record<IssueSeverity, number>;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Result of checking generated files.
|
|
625
|
+
*/
|
|
626
|
+
interface CheckResult {
|
|
627
|
+
/** List of issues found */
|
|
628
|
+
issues: CheckIssue[];
|
|
629
|
+
/** Summary counts */
|
|
630
|
+
summary: {
|
|
631
|
+
errors: number;
|
|
632
|
+
warnings: number;
|
|
633
|
+
info: number;
|
|
634
|
+
filesChecked: number;
|
|
635
|
+
filesMissing: number;
|
|
636
|
+
filesMismatch: number;
|
|
637
|
+
};
|
|
638
|
+
/** Exit code for CI */
|
|
639
|
+
exitCode: ExitCode;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Result of content comparison.
|
|
643
|
+
*/
|
|
644
|
+
interface CompareResult {
|
|
645
|
+
/** Whether content matches */
|
|
646
|
+
match: boolean;
|
|
647
|
+
/** Context showing differences */
|
|
648
|
+
context: string;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Default checker configuration.
|
|
652
|
+
*/
|
|
653
|
+
declare const DEFAULT_CHECKER_CONFIG: Required<CheckerConfig>;
|
|
654
|
+
/**
|
|
655
|
+
* Runs SEO checks on a site manifest.
|
|
656
|
+
* @param manifest - The site manifest to check
|
|
657
|
+
* @param config - Checker configuration
|
|
658
|
+
* @returns Checker result with issues and summary
|
|
659
|
+
*/
|
|
660
|
+
declare function checkManifest(manifest: SiteManifest, config?: CheckerConfig): CheckerResult;
|
|
661
|
+
/**
|
|
662
|
+
* Main check function:
|
|
663
|
+
* 1. Validates config
|
|
664
|
+
* 2. Reads existing files from disk
|
|
665
|
+
* 3. Compares expected vs actual (if expected content provided)
|
|
666
|
+
* 4. Runs linting rules
|
|
667
|
+
* 5. Returns issues with summary
|
|
668
|
+
*
|
|
669
|
+
* @param options - Check options
|
|
670
|
+
* @returns Check result with issues and exit code
|
|
671
|
+
*/
|
|
672
|
+
declare function checkGeneratedFiles(options: CheckOptions): Promise<CheckResult>;
|
|
673
|
+
/**
|
|
674
|
+
* Checks if a file exists.
|
|
675
|
+
* @param filePath - Path to the file
|
|
676
|
+
* @returns Promise resolving to true if file exists
|
|
677
|
+
*/
|
|
678
|
+
declare function checkFileExists(filePath: string): Promise<boolean>;
|
|
679
|
+
/**
|
|
680
|
+
* Reads file content safely.
|
|
681
|
+
* @param filePath - Path to the file
|
|
682
|
+
* @returns File content or null if file doesn't exist
|
|
683
|
+
*/
|
|
684
|
+
declare function readFileContent(filePath: string): Promise<string | null>;
|
|
685
|
+
/**
|
|
686
|
+
* Compares two strings and returns diff context.
|
|
687
|
+
* @param expected - Expected content
|
|
688
|
+
* @param actual - Actual content
|
|
689
|
+
* @param maxContextLines - Maximum number of diff lines to show (default: 5)
|
|
690
|
+
* @returns CompareResult with match status and context
|
|
691
|
+
*/
|
|
692
|
+
declare function compareContent(expected: string, actual: string, maxContextLines?: number): CompareResult;
|
|
693
|
+
/**
|
|
694
|
+
* Checks generated files against expected content.
|
|
695
|
+
* @param llmsTxtPath - Path to llms.txt
|
|
696
|
+
* @param expectedLlmsTxt - Expected llms.txt content
|
|
697
|
+
* @param llmsFullTxtPath - Path to llms-full.txt
|
|
698
|
+
* @param expectedLlmsFullTxt - Expected llms-full.txt content
|
|
699
|
+
* @param maxContextLines - Maximum context lines for diff
|
|
700
|
+
* @returns Array of check issues
|
|
701
|
+
*/
|
|
702
|
+
declare function checkFilesAgainstExpected(llmsTxtPath: string, expectedLlmsTxt: string, llmsFullTxtPath: string, expectedLlmsFullTxt: string, maxContextLines?: number): Promise<CheckIssue[]>;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Rules linter for llms.txt and related files.
|
|
706
|
+
*/
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Rule definition for linting.
|
|
710
|
+
*/
|
|
711
|
+
interface LintRule {
|
|
712
|
+
/** Unique rule identifier */
|
|
713
|
+
id: string;
|
|
714
|
+
/** Human-readable description */
|
|
715
|
+
description: string;
|
|
716
|
+
/** Whether the rule is enabled by default */
|
|
717
|
+
enabled: boolean;
|
|
718
|
+
/** The lint function */
|
|
719
|
+
lint: (content: string, filePath: string) => Issue[];
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Result of linting content.
|
|
723
|
+
*/
|
|
724
|
+
interface LintResult {
|
|
725
|
+
/** Issues found during linting */
|
|
726
|
+
issues: CheckIssue[];
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Available lint rules.
|
|
730
|
+
*/
|
|
731
|
+
declare const LINT_RULES: readonly LintRule[];
|
|
732
|
+
/**
|
|
733
|
+
* Lints content against provided rules.
|
|
734
|
+
* @param content - The content to lint
|
|
735
|
+
* @param filePath - Path to the file being linted
|
|
736
|
+
* @param rules - Rules to apply (defaults to all enabled rules)
|
|
737
|
+
* @returns Lint result with issues
|
|
738
|
+
*/
|
|
739
|
+
declare function lintContent(content: string, filePath: string, rules?: readonly LintRule[]): LintResultLegacy;
|
|
740
|
+
/**
|
|
741
|
+
* Legacy lint result interface.
|
|
742
|
+
*/
|
|
743
|
+
interface LintResultLegacy {
|
|
744
|
+
/** File path that was linted */
|
|
745
|
+
filePath: string;
|
|
746
|
+
/** Issues found during linting */
|
|
747
|
+
issues: Issue[];
|
|
748
|
+
/** Whether the file passed all rules */
|
|
749
|
+
passed: boolean;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
export { type CanonicalOptions, type CheckOptions, type CheckResult, type CheckerConfig, type CheckerResult, type Citation, type CitationSource, type CitationsJson, type CitationsPolicy, type CitationsSite, type Comparator, type CompareResult, type CreateCanonicalUrlsOptions, type CreateCitationsJsonOptions, type CreateLlmsFullTxtOptions, type CreateLlmsFullTxtResult, type CreateLlmsTxtOptions, type CreateLlmsTxtResult, DEFAULT_CHECKER_CONFIG, type Issue, type IssueCategory, type IssueSeverity, LINT_RULES, type LintResult, type LintRule, type LlmsFullTxtOptions, type LlmsTxtOptions, type LocaleConfig, type LocaleStrategy, type TrailingSlashPolicy, checkFileExists, checkFilesAgainstExpected, checkGeneratedFiles, checkManifest, citationToJsonLd, citationToMarkdown, compareContent, compareStrings, createCanonicalUrlForItem, createCanonicalUrlsFromManifest, createCitation, createCitationsJson, createCitationsJsonString, createIssue, createLlmsFullTxt, createLlmsTxt, dedupeUrls, extractCanonicalUrls, extractLocaleFromPath, filterBySeverity, generateAlternateUrls, generateCanonicalUrl, generateLlmsFullTxt, generateLlmsTxt, generatePageContent, generateReferenceList, groupByPage, groupBySeverity, lintContent, localizePath, normalizeLineEndings, normalizeLineWhitespace, normalizeSeoText, normalizeUrl, normalizeWhitespace, readFileContent, sortBy, sortStrings, sortUrls };
|