@rankcli/agent-runtime 0.0.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/README.md +242 -0
- package/dist/analyzer-2CSWIQGD.mjs +6 -0
- package/dist/chunk-YNZYHEYM.mjs +774 -0
- package/dist/index.d.mts +4012 -0
- package/dist/index.d.ts +4012 -0
- package/dist/index.js +29672 -0
- package/dist/index.mjs +28602 -0
- package/package.json +53 -0
- package/scripts/build-deno.ts +134 -0
- package/src/audit/ai/analyzer.ts +347 -0
- package/src/audit/ai/index.ts +29 -0
- package/src/audit/ai/prompts/content-analysis.ts +271 -0
- package/src/audit/ai/types.ts +179 -0
- package/src/audit/checks/additional-checks.ts +439 -0
- package/src/audit/checks/ai-citation-worthiness.ts +399 -0
- package/src/audit/checks/ai-content-structure.ts +325 -0
- package/src/audit/checks/ai-readiness.ts +339 -0
- package/src/audit/checks/anchor-text.ts +179 -0
- package/src/audit/checks/answer-conciseness.ts +322 -0
- package/src/audit/checks/asset-minification.ts +270 -0
- package/src/audit/checks/bing-optimization.ts +206 -0
- package/src/audit/checks/brand-mention-optimization.ts +349 -0
- package/src/audit/checks/caching-headers.ts +305 -0
- package/src/audit/checks/canonical-advanced.ts +150 -0
- package/src/audit/checks/canonical-domain.ts +196 -0
- package/src/audit/checks/citation-quality.ts +358 -0
- package/src/audit/checks/client-rendering.ts +542 -0
- package/src/audit/checks/color-contrast.ts +342 -0
- package/src/audit/checks/content-freshness.ts +170 -0
- package/src/audit/checks/content-science.ts +589 -0
- package/src/audit/checks/conversion-elements.ts +526 -0
- package/src/audit/checks/crawlability.ts +220 -0
- package/src/audit/checks/directory-listing.ts +172 -0
- package/src/audit/checks/dom-analysis.ts +191 -0
- package/src/audit/checks/dom-size.ts +246 -0
- package/src/audit/checks/duplicate-content.ts +194 -0
- package/src/audit/checks/eeat-signals.ts +990 -0
- package/src/audit/checks/entity-seo.ts +396 -0
- package/src/audit/checks/featured-snippet.ts +473 -0
- package/src/audit/checks/freshness-signals.ts +443 -0
- package/src/audit/checks/funnel-intent.ts +463 -0
- package/src/audit/checks/hreflang.ts +174 -0
- package/src/audit/checks/html-compliance.ts +302 -0
- package/src/audit/checks/image-dimensions.ts +167 -0
- package/src/audit/checks/images.ts +160 -0
- package/src/audit/checks/indexnow.ts +275 -0
- package/src/audit/checks/interactive-tools.ts +475 -0
- package/src/audit/checks/internal-link-graph.ts +436 -0
- package/src/audit/checks/keyword-analysis.ts +239 -0
- package/src/audit/checks/keyword-cannibalization.ts +385 -0
- package/src/audit/checks/keyword-placement.ts +471 -0
- package/src/audit/checks/links.ts +203 -0
- package/src/audit/checks/llms-txt.ts +224 -0
- package/src/audit/checks/local-seo.ts +296 -0
- package/src/audit/checks/mobile.ts +167 -0
- package/src/audit/checks/modern-images.ts +226 -0
- package/src/audit/checks/navboost-signals.ts +395 -0
- package/src/audit/checks/on-page.ts +209 -0
- package/src/audit/checks/page-resources.ts +285 -0
- package/src/audit/checks/pagination.ts +180 -0
- package/src/audit/checks/performance.ts +153 -0
- package/src/audit/checks/platform-presence.ts +580 -0
- package/src/audit/checks/redirect-analysis.ts +153 -0
- package/src/audit/checks/redirect-chain.ts +389 -0
- package/src/audit/checks/resource-hints.ts +420 -0
- package/src/audit/checks/responsive-css.ts +247 -0
- package/src/audit/checks/responsive-images.ts +396 -0
- package/src/audit/checks/review-ecosystem.ts +415 -0
- package/src/audit/checks/robots-validation.ts +373 -0
- package/src/audit/checks/security-headers.ts +172 -0
- package/src/audit/checks/security.ts +144 -0
- package/src/audit/checks/serp-preview.ts +251 -0
- package/src/audit/checks/site-maturity.ts +444 -0
- package/src/audit/checks/social-meta.test.ts +275 -0
- package/src/audit/checks/social-meta.ts +134 -0
- package/src/audit/checks/soft-404.ts +151 -0
- package/src/audit/checks/structured-data.ts +238 -0
- package/src/audit/checks/tech-detection.ts +496 -0
- package/src/audit/checks/topical-clusters.ts +435 -0
- package/src/audit/checks/tracker-bloat.ts +462 -0
- package/src/audit/checks/tracking-verification.test.ts +371 -0
- package/src/audit/checks/tracking-verification.ts +636 -0
- package/src/audit/checks/url-safety.ts +682 -0
- package/src/audit/deno-entry.ts +66 -0
- package/src/audit/discovery/index.ts +15 -0
- package/src/audit/discovery/link-crawler.ts +232 -0
- package/src/audit/discovery/repo-routes.ts +347 -0
- package/src/audit/engine.ts +620 -0
- package/src/audit/fixes/index.ts +209 -0
- package/src/audit/fixes/social-meta-fixes.test.ts +329 -0
- package/src/audit/fixes/social-meta-fixes.ts +463 -0
- package/src/audit/index.ts +74 -0
- package/src/audit/runner.test.ts +299 -0
- package/src/audit/runner.ts +130 -0
- package/src/audit/types.ts +1953 -0
- package/src/content/featured-snippet.ts +367 -0
- package/src/content/generator.test.ts +534 -0
- package/src/content/generator.ts +501 -0
- package/src/content/headline.ts +317 -0
- package/src/content/index.ts +62 -0
- package/src/content/intent.ts +258 -0
- package/src/content/keyword-density.ts +349 -0
- package/src/content/readability.ts +262 -0
- package/src/executor.ts +336 -0
- package/src/fixer.ts +416 -0
- package/src/frameworks/detector.test.ts +248 -0
- package/src/frameworks/detector.ts +371 -0
- package/src/frameworks/index.ts +68 -0
- package/src/frameworks/recipes/angular.yaml +171 -0
- package/src/frameworks/recipes/astro.yaml +206 -0
- package/src/frameworks/recipes/django.yaml +180 -0
- package/src/frameworks/recipes/laravel.yaml +137 -0
- package/src/frameworks/recipes/nextjs.yaml +268 -0
- package/src/frameworks/recipes/nuxt.yaml +175 -0
- package/src/frameworks/recipes/rails.yaml +188 -0
- package/src/frameworks/recipes/react.yaml +202 -0
- package/src/frameworks/recipes/sveltekit.yaml +154 -0
- package/src/frameworks/recipes/vue.yaml +137 -0
- package/src/frameworks/recipes/wordpress.yaml +209 -0
- package/src/frameworks/suggestion-engine.ts +320 -0
- package/src/geo/geo-content.test.ts +305 -0
- package/src/geo/geo-content.ts +266 -0
- package/src/geo/geo-history.test.ts +473 -0
- package/src/geo/geo-history.ts +433 -0
- package/src/geo/geo-tracker.test.ts +359 -0
- package/src/geo/geo-tracker.ts +411 -0
- package/src/geo/index.ts +10 -0
- package/src/git/commit-helper.test.ts +261 -0
- package/src/git/commit-helper.ts +329 -0
- package/src/git/index.ts +12 -0
- package/src/git/pr-helper.test.ts +284 -0
- package/src/git/pr-helper.ts +307 -0
- package/src/index.ts +66 -0
- package/src/keywords/ai-keyword-engine.ts +1062 -0
- package/src/keywords/ai-summarizer.ts +387 -0
- package/src/keywords/ci-mode.ts +555 -0
- package/src/keywords/engine.ts +359 -0
- package/src/keywords/index.ts +151 -0
- package/src/keywords/llm-judge.ts +357 -0
- package/src/keywords/nlp-analysis.ts +706 -0
- package/src/keywords/prioritizer.ts +295 -0
- package/src/keywords/site-crawler.ts +342 -0
- package/src/keywords/sources/autocomplete.ts +139 -0
- package/src/keywords/sources/competitive-search.ts +450 -0
- package/src/keywords/sources/competitor-analysis.ts +374 -0
- package/src/keywords/sources/dataforseo.ts +206 -0
- package/src/keywords/sources/free-sources.ts +294 -0
- package/src/keywords/sources/gsc.ts +123 -0
- package/src/keywords/topic-grouping.ts +327 -0
- package/src/keywords/types.ts +144 -0
- package/src/keywords/wizard.ts +457 -0
- package/src/loader.ts +40 -0
- package/src/reports/index.ts +7 -0
- package/src/reports/report-generator.test.ts +293 -0
- package/src/reports/report-generator.ts +713 -0
- package/src/scheduler/alerts.test.ts +458 -0
- package/src/scheduler/alerts.ts +328 -0
- package/src/scheduler/index.ts +8 -0
- package/src/scheduler/scheduled-audit.test.ts +377 -0
- package/src/scheduler/scheduled-audit.ts +149 -0
- package/src/test/integration-test.ts +325 -0
- package/src/tools/analyzer.ts +373 -0
- package/src/tools/crawl.ts +293 -0
- package/src/tools/files.ts +301 -0
- package/src/tools/h1-fixer.ts +249 -0
- package/src/tools/index.ts +67 -0
- package/src/tracking/github-action.ts +326 -0
- package/src/tracking/google-analytics.ts +265 -0
- package/src/tracking/index.ts +45 -0
- package/src/tracking/report-generator.ts +386 -0
- package/src/tracking/search-console.ts +335 -0
- package/src/types.ts +134 -0
- package/src/utils/http.ts +302 -0
- package/src/wasm-adapter.ts +297 -0
- package/src/wasm-entry.ts +14 -0
- package/tsconfig.json +17 -0
- package/tsup.wasm.config.ts +26 -0
- package/vitest.config.ts +15 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { httpGet, httpPost } from '../../utils/http.js';
|
|
2
|
+
import type { AuditIssue } from '../types.js';
|
|
3
|
+
import { ISSUE_DEFINITIONS } from '../types.js';
|
|
4
|
+
|
|
5
|
+
export interface PerformanceData {
|
|
6
|
+
loadTime: number; // ms
|
|
7
|
+
ttfb: number; // ms
|
|
8
|
+
htmlSize: number; // bytes
|
|
9
|
+
compressed: boolean;
|
|
10
|
+
cacheControl?: string;
|
|
11
|
+
contentEncoding?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function analyzePerformance(url: string): Promise<{ issues: AuditIssue[]; data: PerformanceData }> {
|
|
15
|
+
const issues: AuditIssue[] = [];
|
|
16
|
+
|
|
17
|
+
const startTime = Date.now();
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const response = await httpGet<string>(url, {
|
|
21
|
+
headers: {
|
|
22
|
+
'Accept-Encoding': 'gzip, deflate, br',
|
|
23
|
+
},
|
|
24
|
+
timeout: 30000,
|
|
25
|
+
validateStatus: () => true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const loadTime = Date.now() - startTime;
|
|
29
|
+
// Note: TTFB approximation - fetch doesn't expose this directly
|
|
30
|
+
const ttfbTime = Math.min(loadTime, loadTime * 0.3); // Estimate ~30% of total
|
|
31
|
+
const htmlSize = typeof response.data === 'string' ? response.data.length : 0;
|
|
32
|
+
const contentEncoding = response.headers['content-encoding'];
|
|
33
|
+
const cacheControl = response.headers['cache-control'];
|
|
34
|
+
const compressed = !!contentEncoding && ['gzip', 'deflate', 'br'].some(e => contentEncoding.includes(e));
|
|
35
|
+
|
|
36
|
+
const data: PerformanceData = {
|
|
37
|
+
loadTime,
|
|
38
|
+
ttfb: ttfbTime || loadTime,
|
|
39
|
+
htmlSize,
|
|
40
|
+
compressed,
|
|
41
|
+
cacheControl,
|
|
42
|
+
contentEncoding,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Check load time
|
|
46
|
+
if (loadTime > 3000) {
|
|
47
|
+
issues.push({
|
|
48
|
+
...ISSUE_DEFINITIONS.SLOW_PAGE,
|
|
49
|
+
affectedUrls: [url],
|
|
50
|
+
details: { loadTime: `${(loadTime / 1000).toFixed(1)}s` },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check TTFB
|
|
55
|
+
if (ttfbTime > 600) {
|
|
56
|
+
issues.push({
|
|
57
|
+
...ISSUE_DEFINITIONS.SLOW_TTFB,
|
|
58
|
+
affectedUrls: [url],
|
|
59
|
+
details: { ttfb: `${ttfbTime}ms` },
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Check HTML size
|
|
64
|
+
if (htmlSize > 100 * 1024) { // > 100KB
|
|
65
|
+
issues.push({
|
|
66
|
+
...ISSUE_DEFINITIONS.HTML_TOO_LARGE,
|
|
67
|
+
affectedUrls: [url],
|
|
68
|
+
details: { size: `${(htmlSize / 1024).toFixed(0)}KB` },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check compression
|
|
73
|
+
if (!compressed && htmlSize > 1024) {
|
|
74
|
+
issues.push({
|
|
75
|
+
...ISSUE_DEFINITIONS.UNCOMPRESSED,
|
|
76
|
+
affectedUrls: [url],
|
|
77
|
+
details: { htmlSize: `${(htmlSize / 1024).toFixed(0)}KB` },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Check cache headers
|
|
82
|
+
if (!cacheControl) {
|
|
83
|
+
issues.push({
|
|
84
|
+
...ISSUE_DEFINITIONS.NO_CACHE,
|
|
85
|
+
affectedUrls: [url],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return { issues, data };
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return {
|
|
92
|
+
issues: [{
|
|
93
|
+
...ISSUE_DEFINITIONS.SLOW_PAGE,
|
|
94
|
+
affectedUrls: [url],
|
|
95
|
+
details: { error: error instanceof Error ? error.message : 'Request failed' },
|
|
96
|
+
}],
|
|
97
|
+
data: {
|
|
98
|
+
loadTime: 0,
|
|
99
|
+
ttfb: 0,
|
|
100
|
+
htmlSize: 0,
|
|
101
|
+
compressed: false,
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Fetch Core Web Vitals from CrUX API (requires API key)
|
|
108
|
+
export async function fetchCoreWebVitals(url: string, apiKey?: string): Promise<{
|
|
109
|
+
lcp?: { value: number; rating: 'good' | 'needs-improvement' | 'poor' };
|
|
110
|
+
fid?: { value: number; rating: 'good' | 'needs-improvement' | 'poor' };
|
|
111
|
+
cls?: { value: number; rating: 'good' | 'needs-improvement' | 'poor' };
|
|
112
|
+
inp?: { value: number; rating: 'good' | 'needs-improvement' | 'poor' };
|
|
113
|
+
} | null> {
|
|
114
|
+
if (!apiKey) return null;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const response = await httpPost<{ record?: { metrics?: Record<string, { percentiles?: { p75?: number } }> } }>(
|
|
118
|
+
`https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=${apiKey}`,
|
|
119
|
+
{ url },
|
|
120
|
+
{ timeout: 10000 }
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const metrics = response.data?.record?.metrics;
|
|
124
|
+
if (!metrics) return null;
|
|
125
|
+
|
|
126
|
+
const getRating = (value: number, thresholds: [number, number]): 'good' | 'needs-improvement' | 'poor' => {
|
|
127
|
+
if (value <= thresholds[0]) return 'good';
|
|
128
|
+
if (value <= thresholds[1]) return 'needs-improvement';
|
|
129
|
+
return 'poor';
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
lcp: metrics.largest_contentful_paint?.percentiles?.p75 ? {
|
|
134
|
+
value: metrics.largest_contentful_paint.percentiles.p75,
|
|
135
|
+
rating: getRating(metrics.largest_contentful_paint.percentiles.p75, [2500, 4000]),
|
|
136
|
+
} : undefined,
|
|
137
|
+
fid: metrics.first_input_delay?.percentiles?.p75 ? {
|
|
138
|
+
value: metrics.first_input_delay.percentiles.p75,
|
|
139
|
+
rating: getRating(metrics.first_input_delay.percentiles.p75, [100, 300]),
|
|
140
|
+
} : undefined,
|
|
141
|
+
cls: metrics.cumulative_layout_shift?.percentiles?.p75 ? {
|
|
142
|
+
value: metrics.cumulative_layout_shift.percentiles.p75,
|
|
143
|
+
rating: getRating(metrics.cumulative_layout_shift.percentiles.p75, [0.1, 0.25]),
|
|
144
|
+
} : undefined,
|
|
145
|
+
inp: metrics.interaction_to_next_paint?.percentiles?.p75 ? {
|
|
146
|
+
value: metrics.interaction_to_next_paint.percentiles.p75,
|
|
147
|
+
rating: getRating(metrics.interaction_to_next_paint.percentiles.p75, [200, 500]),
|
|
148
|
+
} : undefined,
|
|
149
|
+
};
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|