@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
package/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# @rankcli/agent-runtime
|
|
2
|
+
|
|
3
|
+
Core audit engine for RankCLI. Runs 280+ SEO checks and powers both the CLI and SaaS edge functions.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
This package is **isomorphic** - it works in both Node.js and Deno environments:
|
|
8
|
+
|
|
9
|
+
- **Node.js**: Used by the CLI (`packages/cli`)
|
|
10
|
+
- **Deno**: Used by Supabase Edge Functions (`packages/saas/supabase/functions`)
|
|
11
|
+
|
|
12
|
+
The isomorphic design uses native `fetch` API instead of Node-specific modules like `axios` or `https`.
|
|
13
|
+
|
|
14
|
+
## Directory Structure
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
src/
|
|
18
|
+
├── audit/
|
|
19
|
+
│ ├── engine.ts # Main audit orchestrator
|
|
20
|
+
│ ├── types.ts # Issue definitions & types
|
|
21
|
+
│ ├── deno-entry.ts # Deno-specific entry point
|
|
22
|
+
│ └── checks/ # Individual check modules
|
|
23
|
+
│ ├── crawlability.ts
|
|
24
|
+
│ ├── on-page.ts
|
|
25
|
+
│ ├── performance.ts
|
|
26
|
+
│ ├── security.ts
|
|
27
|
+
│ ├── ai-readiness.ts
|
|
28
|
+
│ └── ... (40+ check modules)
|
|
29
|
+
├── utils/
|
|
30
|
+
│ └── http.ts # Isomorphic HTTP utilities
|
|
31
|
+
├── content/ # Content generation
|
|
32
|
+
├── geo/ # GEO tracking
|
|
33
|
+
├── git/ # Git/PR helpers
|
|
34
|
+
└── index.ts # Main entry point
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Development
|
|
38
|
+
|
|
39
|
+
### Prerequisites
|
|
40
|
+
|
|
41
|
+
- Node.js 18+
|
|
42
|
+
- pnpm
|
|
43
|
+
|
|
44
|
+
### Commands
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Install dependencies
|
|
48
|
+
pnpm install
|
|
49
|
+
|
|
50
|
+
# Development mode (watches both Node and Deno bundles)
|
|
51
|
+
pnpm dev
|
|
52
|
+
|
|
53
|
+
# Run tests
|
|
54
|
+
pnpm test # Watch mode
|
|
55
|
+
pnpm test:run # Single run
|
|
56
|
+
|
|
57
|
+
# Build for production
|
|
58
|
+
pnpm build # Builds Node.js + Deno bundles
|
|
59
|
+
|
|
60
|
+
# Build only Deno bundle
|
|
61
|
+
pnpm build:deno
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Development Workflow
|
|
65
|
+
|
|
66
|
+
When you run `pnpm dev`, it:
|
|
67
|
+
|
|
68
|
+
1. Builds the Deno bundle first
|
|
69
|
+
2. Starts tsup in watch mode for Node.js
|
|
70
|
+
3. Rebuilds the Deno bundle on every successful Node.js build
|
|
71
|
+
|
|
72
|
+
This ensures both the CLI (Node.js) and edge functions (Deno) stay in sync during development.
|
|
73
|
+
|
|
74
|
+
### Available Scripts
|
|
75
|
+
|
|
76
|
+
| Script | Description |
|
|
77
|
+
|--------|-------------|
|
|
78
|
+
| `pnpm dev` | Watch mode - rebuilds Node + Deno on changes |
|
|
79
|
+
| `pnpm dev:node` | Watch mode - Node.js only |
|
|
80
|
+
| `pnpm dev:deno` | Watch mode - Deno bundle only |
|
|
81
|
+
| `pnpm build` | Production build (Node.js + Deno) |
|
|
82
|
+
| `pnpm build:deno` | Build Deno bundle only |
|
|
83
|
+
| `pnpm test` | Run tests in watch mode |
|
|
84
|
+
| `pnpm test:run` | Run tests once |
|
|
85
|
+
|
|
86
|
+
## Deno Bundle
|
|
87
|
+
|
|
88
|
+
The Deno bundle is generated at:
|
|
89
|
+
```
|
|
90
|
+
packages/saas/supabase/functions/_shared/audit/
|
|
91
|
+
├── engine.bundle.js # Bundled audit engine
|
|
92
|
+
└── index.ts # Wrapper with cheerio import
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Edge functions import from the shared bundle:
|
|
96
|
+
```typescript
|
|
97
|
+
import { runFullAudit } from '../_shared/audit/index.ts';
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### How It Works
|
|
101
|
+
|
|
102
|
+
1. `scripts/build-deno.ts` uses esbuild to bundle `src/audit/deno-entry.ts`
|
|
103
|
+
2. The bundle excludes `cheerio` (imported from esm.sh at runtime)
|
|
104
|
+
3. Node-specific APIs are polyfilled or replaced with web-compatible alternatives
|
|
105
|
+
|
|
106
|
+
### Isomorphic Considerations
|
|
107
|
+
|
|
108
|
+
When adding new features to the audit engine:
|
|
109
|
+
|
|
110
|
+
- Use `fetch` instead of `axios` or Node's `http`/`https`
|
|
111
|
+
- Use the helpers in `src/utils/http.ts` for HTTP requests
|
|
112
|
+
- Avoid Node-specific modules (`fs`, `path`, `dns`, `crypto`, etc.)
|
|
113
|
+
- For DNS lookups, use DNS-over-HTTPS (see `additional-checks.ts`)
|
|
114
|
+
- Test in both Node.js (`pnpm test`) and edge functions
|
|
115
|
+
|
|
116
|
+
## VS Code Tasks
|
|
117
|
+
|
|
118
|
+
If using VS Code, these tasks are available (Cmd/Ctrl+Shift+P → "Tasks: Run Task"):
|
|
119
|
+
|
|
120
|
+
| Task | Description |
|
|
121
|
+
|------|-------------|
|
|
122
|
+
| Dev: Agent Runtime (with Deno watch) | Watches and rebuilds both bundles |
|
|
123
|
+
| Dev: SaaS Frontend | Runs the Vite dev server |
|
|
124
|
+
| Dev: Full Stack | Runs both in parallel |
|
|
125
|
+
| Build: Deno Bundle | One-time Deno bundle build |
|
|
126
|
+
| Deploy: Edge Functions | Deploys to Supabase |
|
|
127
|
+
|
|
128
|
+
## DevContainer
|
|
129
|
+
|
|
130
|
+
When using the devcontainer:
|
|
131
|
+
|
|
132
|
+
- The Deno bundle is built automatically on container creation
|
|
133
|
+
- Run `pnpm dev` in `packages/agent-runtime` to start watching for changes
|
|
134
|
+
- The bundle is rebuilt automatically when you modify audit code
|
|
135
|
+
|
|
136
|
+
## API
|
|
137
|
+
|
|
138
|
+
### runFullAudit
|
|
139
|
+
|
|
140
|
+
Main entry point for running audits:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { runFullAudit } from '@rankcli/agent-runtime';
|
|
144
|
+
|
|
145
|
+
const report = await runFullAudit('https://example.com', {
|
|
146
|
+
maxPages: 10, // Max pages to crawl
|
|
147
|
+
includeAdvanced: true, // Run advanced checks
|
|
148
|
+
includeAI: false, // Run AI-powered analysis
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
console.log(report.overallScore); // 0-100
|
|
152
|
+
console.log(report.issues); // Array of issues
|
|
153
|
+
console.log(report.healthScores); // Category scores
|
|
154
|
+
console.log(report.checksRun); // Number of checks run
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Issue Structure
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface AuditIssue {
|
|
161
|
+
code: string; // e.g., 'TITLE_MISSING'
|
|
162
|
+
severity: 'error' | 'warning' | 'notice';
|
|
163
|
+
category: string; // e.g., 'on-page', 'security'
|
|
164
|
+
title: string; // Human-readable title
|
|
165
|
+
description?: string; // Detailed description
|
|
166
|
+
impact?: string; // SEO impact explanation
|
|
167
|
+
howToFix?: string; // Fix instructions
|
|
168
|
+
affectedUrls?: string[];
|
|
169
|
+
details?: Record<string, unknown>;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Health Scores
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
interface HealthScores {
|
|
177
|
+
crawlability: number; // 0-100
|
|
178
|
+
onPage: number;
|
|
179
|
+
content: number;
|
|
180
|
+
performance: number;
|
|
181
|
+
security: number;
|
|
182
|
+
socialMeta: number;
|
|
183
|
+
aiReadiness: number;
|
|
184
|
+
mobile: number;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Adding New Checks
|
|
189
|
+
|
|
190
|
+
1. Create a new file in `src/audit/checks/` or add to an existing one
|
|
191
|
+
2. Export the check function
|
|
192
|
+
3. Add to `src/audit/engine.ts` to include in the audit flow
|
|
193
|
+
4. Add to `src/audit/deno-entry.ts` to export for Deno
|
|
194
|
+
5. Run `pnpm build:deno` to regenerate the bundle
|
|
195
|
+
6. Add tests in a `.test.ts` file
|
|
196
|
+
|
|
197
|
+
Example check:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// src/audit/checks/my-check.ts
|
|
201
|
+
import { httpGet } from '../../utils/http.js';
|
|
202
|
+
import type { AuditIssue } from '../types.js';
|
|
203
|
+
|
|
204
|
+
export async function checkMyThing(url: string): Promise<AuditIssue[]> {
|
|
205
|
+
const issues: AuditIssue[] = [];
|
|
206
|
+
|
|
207
|
+
const response = await httpGet(url);
|
|
208
|
+
|
|
209
|
+
if (/* condition */) {
|
|
210
|
+
issues.push({
|
|
211
|
+
code: 'MY_ISSUE_CODE',
|
|
212
|
+
severity: 'warning',
|
|
213
|
+
category: 'my-category',
|
|
214
|
+
title: 'Issue title',
|
|
215
|
+
description: 'What this means',
|
|
216
|
+
howToFix: 'How to fix it',
|
|
217
|
+
affectedUrls: [url],
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return issues;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Testing
|
|
226
|
+
|
|
227
|
+
Tests use Vitest:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Run all tests
|
|
231
|
+
pnpm test:run
|
|
232
|
+
|
|
233
|
+
# Run specific test file
|
|
234
|
+
pnpm test:run src/audit/checks/social-meta.test.ts
|
|
235
|
+
|
|
236
|
+
# Run with coverage
|
|
237
|
+
pnpm test:coverage
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT
|