nuxt-ai-ready 3.6.1 → 3.6.2
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/dist/agent-skills-config-CmZq9uWW.mjs +18 -0
- package/dist/agent-skills-zGLgFB6H.mjs +468 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +656 -570
- package/dist/devtools/pages/ai-ready/debug.vue +9 -3
- package/dist/devtools/pages/ai-ready/index.vue +3 -1
- package/dist/devtools/pages/ai-ready/llms-txt.vue +15 -4
- package/dist/devtools/pages/ai-ready.vue +28 -4
- package/dist/module.d.mts +106 -112
- package/dist/module.json +3 -3
- package/dist/module.mjs +2732 -26
- package/dist/package-metadata-B1darl8W.mjs +28 -0
- package/dist/prerender-QMv07W4h.mjs +650 -0
- package/dist/runtime/app/composables/webmcp.js +90 -97
- package/dist/runtime/app/plugins/md-alternate.server.js +29 -26
- package/dist/runtime/app/plugins/md-hints.prerender.js +13 -15
- package/dist/runtime/app/plugins/webmcp.client.js +49 -53
- package/dist/runtime/app/webmcp-config.js +2 -2
- package/dist/runtime/cache-control.js +16 -10
- package/dist/runtime/i18n-url.js +6 -6
- package/dist/runtime/index.js +4 -12
- package/dist/runtime/llms-txt-directive.js +20 -13
- package/dist/runtime/llms-txt-files.js +188 -187
- package/dist/runtime/llms-txt-format.js +54 -55
- package/dist/runtime/llms-txt-i18n.js +22 -19
- package/dist/runtime/llms-txt-utils.js +140 -95
- package/dist/runtime/markdown-links.js +45 -39
- package/dist/runtime/markdown-path.js +29 -9
- package/dist/runtime/markdown-text.js +2 -1
- package/dist/runtime/mcp.js +5 -1
- package/dist/runtime/route-path.js +14 -8
- package/dist/runtime/server/db/drizzle/client.js +71 -75
- package/dist/runtime/server/db/drizzle/index.js +16 -28
- package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -1
- package/dist/runtime/server/db/drizzle/providers/bun.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/d1.js +16 -13
- package/dist/runtime/server/db/drizzle/providers/dbPath.js +60 -37
- package/dist/runtime/server/db/drizzle/providers/libsql.js +23 -11
- package/dist/runtime/server/db/drizzle/providers/neon.js +13 -10
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/postgres.js +13 -10
- package/dist/runtime/server/db/drizzle/queries.js +633 -532
- package/dist/runtime/server/db/drizzle/raw.js +200 -176
- package/dist/runtime/server/db/index.js +3 -0
- package/dist/runtime/server/db/queries.js +816 -607
- package/dist/runtime/server/db/schema/postgres.js +56 -50
- package/dist/runtime/server/db/schema/sqlite.js +56 -50
- package/dist/runtime/server/db/schema-sql.js +35 -38
- package/dist/runtime/server/db/seed.js +60 -45
- package/dist/runtime/server/db/shared.js +300 -213
- package/dist/runtime/server/index.js +1 -17
- package/dist/runtime/server/mcp/cache-key.js +5 -1
- package/dist/runtime/server/mcp/resources/pages.js +32 -33
- package/dist/runtime/server/mcp/tools/get-page-markdown.js +41 -27
- package/dist/runtime/server/mcp/tools/list-pages.js +40 -34
- package/dist/runtime/server/mcp/tools/search-pages.js +24 -16
- package/dist/runtime/server/middleware/markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.js +15 -13
- package/dist/runtime/server/middleware/markdown.prerender.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.prerender.js +135 -119
- package/dist/runtime/server/middleware/render-markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/render-markdown.js +164 -144
- package/dist/runtime/server/plugins/ai-terms.d.ts +1 -1
- package/dist/runtime/server/plugins/ai-terms.js +4 -8
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.js +7 -8
- package/dist/runtime/server/plugins/content-signal-capture.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture.prerender.js +7 -7
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +13 -14
- package/dist/runtime/server/plugins/db-lifecycle.js +13 -11
- package/dist/runtime/server/plugins/html-capture.prerender.js +6 -6
- package/dist/runtime/server/plugins/link-header-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header-nitro3.js +23 -13
- package/dist/runtime/server/plugins/link-header.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header.js +30 -30
- package/dist/runtime/server/plugins/llms-txt-directive-html.d.ts +1 -1
- package/dist/runtime/server/plugins/llms-txt-directive-html.js +4 -3
- package/dist/runtime/server/plugins/markdown-negotiation.d.ts +1 -1
- package/dist/runtime/server/plugins/markdown-negotiation.js +64 -45
- package/dist/runtime/server/plugins/sitemap-seeder.js +144 -112
- package/dist/runtime/server/routes/__ai-ready/cron.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/cron.get.js +17 -11
- package/dist/runtime/server/routes/__ai-ready/devtools.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/devtools.get.js +60 -45
- package/dist/runtime/server/routes/__ai-ready/pages.get.d.ts +36 -1
- package/dist/runtime/server/routes/__ai-ready/pages.get.js +44 -40
- package/dist/runtime/server/routes/__ai-ready/poll.post.d.ts +15 -1
- package/dist/runtime/server/routes/__ai-ready/poll.post.js +30 -30
- package/dist/runtime/server/routes/__ai-ready/prune.post.d.ts +13 -1
- package/dist/runtime/server/routes/__ai-ready/prune.post.js +29 -15
- package/dist/runtime/server/routes/__ai-ready/reindex.post.d.ts +22 -1
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +31 -21
- package/dist/runtime/server/routes/__ai-ready/restore.post.d.ts +4 -1
- package/dist/runtime/server/routes/__ai-ready/restore.post.js +28 -22
- package/dist/runtime/server/routes/__ai-ready/status.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/status.get.js +52 -53
- package/dist/runtime/server/routes/__ai-ready-debug.get.d.ts +83 -1
- package/dist/runtime/server/routes/__ai-ready-debug.get.js +209 -189
- package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-artifact.js +16 -14
- package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-index.js +8 -6
- package/dist/runtime/server/routes/ai-catalog.js +19 -19
- package/dist/runtime/server/routes/ai-terms.js +23 -19
- package/dist/runtime/server/routes/api-catalog.js +23 -23
- package/dist/runtime/server/routes/llms-full.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms-full.txt.get.js +42 -41
- package/dist/runtime/server/routes/llms.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms.txt.get.js +38 -33
- package/dist/runtime/server/routes/mcp-server-card.js +19 -19
- package/dist/runtime/server/routes/sitemap.md.get.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap.md.get.js +38 -39
- package/dist/runtime/server/tasks/ai-ready-cron.d.ts +1 -1
- package/dist/runtime/server/tasks/ai-ready-cron.js +17 -14
- package/dist/runtime/server/utils/auth.js +76 -53
- package/dist/runtime/server/utils/batchIndex.js +72 -60
- package/dist/runtime/server/utils/checkStale.js +181 -134
- package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -20
- package/dist/runtime/server/utils/cloudflare.js +69 -51
- package/dist/runtime/server/utils/content-negotiation.js +30 -18
- package/dist/runtime/server/utils/content.js +4 -1
- package/dist/runtime/server/utils/context.js +30 -19
- package/dist/runtime/server/utils/cron-plan.js +6 -6
- package/dist/runtime/server/utils/discovery-response.js +5 -6
- package/dist/runtime/server/utils/fetch.js +2 -1
- package/dist/runtime/server/utils/frontmatter.js +44 -57
- package/dist/runtime/server/utils/i18n.js +3 -8
- package/dist/runtime/server/utils/indexPage.js +152 -113
- package/dist/runtime/server/utils/keywords.js +278 -277
- package/dist/runtime/server/utils/link-header.js +67 -56
- package/dist/runtime/server/utils/llms-full.js +39 -49
- package/dist/runtime/server/utils/markdown-redirect.js +26 -14
- package/dist/runtime/server/utils/markdown-request.js +62 -47
- package/dist/runtime/server/utils/negotiation-decision.d.ts +8 -0
- package/dist/runtime/server/utils/negotiation-decision.js +106 -34
- package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
- package/dist/runtime/server/utils/negotiation-response.js +195 -144
- package/dist/runtime/server/utils/page-updated-at.js +23 -15
- package/dist/runtime/server/utils/prerender-html.js +31 -17
- package/dist/runtime/server/utils/runCron.js +263 -192
- package/dist/runtime/server/utils/sitemap-crawl-state.js +57 -39
- package/dist/runtime/server/utils/sitemap-lastmod.js +16 -14
- package/dist/runtime/server/utils/sitemap-md.js +39 -50
- package/dist/runtime/server/utils/sitemap-routes.js +7 -7
- package/dist/runtime/server/utils/sitemap.js +459 -414
- package/dist/runtime/server/utils.js +141 -122
- package/dist/runtime/site-tool-catalog.js +39 -43
- package/dist/runtime/site-tool-config.js +1 -0
- package/dist/runtime/sync-secret.js +11 -11
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/webmcp-site-tools.js +278 -250
- package/dist/runtime/webmcp.js +53 -42
- package/dist/static-headers-G7hFL3wE.mjs +328 -0
- package/dist/types.d.mts +1 -9
- package/package.json +18 -22
- package/skills/nuxt-ai-ready/SKILL.md +8 -2
- package/dist/chunks/agent-skills.mjs +0 -383
- package/dist/chunks/prerender.mjs +0 -683
- package/dist/shared/nuxt-ai-ready.Bzx0dNWj.mjs +0 -3034
- package/dist/shared/nuxt-ai-ready.DCd-1s1G.mjs +0 -29
package/dist/cli.mjs
CHANGED
|
@@ -1,612 +1,698 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync } from
|
|
3
|
-
import fsp from
|
|
4
|
-
import { defineCommand, runMain } from
|
|
5
|
-
import { consola } from
|
|
6
|
-
import { colors } from
|
|
7
|
-
import {
|
|
8
|
-
import { joinURL } from
|
|
9
|
-
import {
|
|
10
|
-
import { APPLICATION_SECRET_ERROR,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import fsp from "node:fs/promises";
|
|
4
|
+
import { defineCommand, runMain } from "citty";
|
|
5
|
+
import { consola } from "consola";
|
|
6
|
+
import { colors } from "consola/utils";
|
|
7
|
+
import { join, resolve } from "pathe";
|
|
8
|
+
import { joinURL } from "ufo";
|
|
9
|
+
import { t as readPackageMetadata } from "./package-metadata-B1darl8W.mjs";
|
|
10
|
+
import { APPLICATION_SECRET_ERROR, LEGACY_RUNTIME_SYNC_SECRET_WARNING, deriveRuntimeSyncSecret } from "./runtime/sync-secret.js";
|
|
11
|
+
// src/readiness-audit.ts
|
|
12
|
+
const capabilities = [
|
|
13
|
+
"llms",
|
|
14
|
+
"api-catalog",
|
|
15
|
+
"ai-catalog",
|
|
16
|
+
"mcp",
|
|
17
|
+
"skills"
|
|
18
|
+
];
|
|
16
19
|
function publicUrl(input, base) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (!URL.canParse(input, base)) return {
|
|
21
|
+
_tag: "Err",
|
|
22
|
+
message: "Use an absolute HTTP or HTTPS URL."
|
|
23
|
+
};
|
|
24
|
+
const url = new URL(input, base);
|
|
25
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) return {
|
|
26
|
+
_tag: "Err",
|
|
27
|
+
message: "Use an HTTP or HTTPS URL without credentials."
|
|
28
|
+
};
|
|
29
|
+
url.hash = "";
|
|
30
|
+
return {
|
|
31
|
+
_tag: "Ok",
|
|
32
|
+
value: url
|
|
33
|
+
};
|
|
24
34
|
}
|
|
25
35
|
function parseAuditOptions(input) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const url = publicUrl(input.url);
|
|
37
|
+
if (url._tag === "Err") return url;
|
|
38
|
+
const base = input.base || "/";
|
|
39
|
+
if (!base.startsWith("/") || base.startsWith("//") || /[?#\\]/.test(base)) return {
|
|
40
|
+
_tag: "Err",
|
|
41
|
+
message: "Use an application base path such as /docs/."
|
|
42
|
+
};
|
|
43
|
+
const selected = [...new Set((input.capabilities || "").split(",").map((value) => value.trim()).filter(Boolean))];
|
|
44
|
+
const unknown = selected.filter((value) => !capabilities.includes(value));
|
|
45
|
+
if (unknown.length) return {
|
|
46
|
+
_tag: "Err",
|
|
47
|
+
message: `Unknown capabilities: ${unknown.join(", ")}. Use ${capabilities.join(", ")}.`
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
_tag: "Ok",
|
|
51
|
+
value: {
|
|
52
|
+
url: url.value.href,
|
|
53
|
+
base: `${new URL(base, url.value).pathname.replace(/\/+$/, "")}/`,
|
|
54
|
+
capabilities: selected
|
|
55
|
+
}
|
|
56
|
+
};
|
|
37
57
|
}
|
|
38
58
|
async function readDocument(url, accept, dependencies) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
const maxBytes = dependencies.maxBytes ?? 2097152;
|
|
60
|
+
const signal = AbortSignal.timeout(dependencies.timeoutMs ?? 1e4);
|
|
61
|
+
return Promise.resolve().then(async () => {
|
|
62
|
+
let current = url;
|
|
63
|
+
for (let redirects = 0; redirects <= 5; redirects++) {
|
|
64
|
+
const response = await dependencies.fetch(current, {
|
|
65
|
+
headers: { accept },
|
|
66
|
+
redirect: "manual",
|
|
67
|
+
signal
|
|
68
|
+
});
|
|
69
|
+
if ([
|
|
70
|
+
301,
|
|
71
|
+
302,
|
|
72
|
+
303,
|
|
73
|
+
307,
|
|
74
|
+
308
|
|
75
|
+
].includes(response.status)) {
|
|
76
|
+
await response.body?.cancel();
|
|
77
|
+
const location = response.headers.get("location");
|
|
78
|
+
const next = location ? publicUrl(location, current) : {
|
|
79
|
+
_tag: "Err",
|
|
80
|
+
message: "Redirect has no Location header."
|
|
81
|
+
};
|
|
82
|
+
if (next._tag === "Err") return next;
|
|
83
|
+
current = next.value.href;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (Number(response.headers.get("content-length")) > maxBytes) {
|
|
87
|
+
await response.body?.cancel();
|
|
88
|
+
return {
|
|
89
|
+
_tag: "Err",
|
|
90
|
+
message: `Response exceeds the ${maxBytes} byte limit.`
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const reader = response.body?.getReader();
|
|
94
|
+
const decoder = new TextDecoder();
|
|
95
|
+
let body = "";
|
|
96
|
+
let bytes = 0;
|
|
97
|
+
if (reader) {
|
|
98
|
+
while (true) {
|
|
99
|
+
const chunk = await reader.read();
|
|
100
|
+
if (chunk.done) break;
|
|
101
|
+
bytes += chunk.value.byteLength;
|
|
102
|
+
if (bytes > maxBytes) {
|
|
103
|
+
await reader.cancel();
|
|
104
|
+
return {
|
|
105
|
+
_tag: "Err",
|
|
106
|
+
message: `Response exceeds the ${maxBytes} byte limit.`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
body += decoder.decode(chunk.value, { stream: true });
|
|
110
|
+
}
|
|
111
|
+
body += decoder.decode();
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
_tag: "Ok",
|
|
115
|
+
value: {
|
|
116
|
+
url: current,
|
|
117
|
+
status: response.status,
|
|
118
|
+
headers: response.headers,
|
|
119
|
+
body
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
_tag: "Err",
|
|
125
|
+
message: "Response exceeds the five redirect limit."
|
|
126
|
+
};
|
|
127
|
+
}).catch((error) => ({
|
|
128
|
+
_tag: "Err",
|
|
129
|
+
message: `Request failed: ${error instanceof Error ? error.message : String(error)}`
|
|
130
|
+
}));
|
|
80
131
|
}
|
|
81
132
|
function responseFailure(document) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return "Cloudflare returned a challenge. Check crawler access rules.";
|
|
86
|
-
if (document.value.status < 200 || document.value.status >= 300)
|
|
87
|
-
return `HTTP ${document.value.status}. Check this public URL.`;
|
|
133
|
+
if (document._tag === "Err") return document.message;
|
|
134
|
+
if (document.value.headers.get("cf-mitigated") === "challenge") return "Cloudflare returned a challenge. Check crawler access rules.";
|
|
135
|
+
if (document.value.status < 200 || document.value.status >= 300) return `HTTP ${document.value.status}. Check this public URL.`;
|
|
88
136
|
}
|
|
89
137
|
function isHtml(body) {
|
|
90
|
-
|
|
138
|
+
return /^\s*(?:<!doctype html|<html|<head|<body)/i.test(body);
|
|
91
139
|
}
|
|
92
140
|
function contentCheck(id, url, document, accepts, success, failure) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
141
|
+
const error = responseFailure(document);
|
|
142
|
+
if (error) return {
|
|
143
|
+
id,
|
|
144
|
+
url,
|
|
145
|
+
status: "fail",
|
|
146
|
+
detail: error
|
|
147
|
+
};
|
|
148
|
+
return document._tag === "Ok" && accepts(document.value) ? {
|
|
149
|
+
id,
|
|
150
|
+
url: document.value.url,
|
|
151
|
+
status: "pass",
|
|
152
|
+
detail: success
|
|
153
|
+
} : {
|
|
154
|
+
id,
|
|
155
|
+
url,
|
|
156
|
+
status: "fail",
|
|
157
|
+
detail: failure
|
|
158
|
+
};
|
|
97
159
|
}
|
|
98
160
|
function markdown(document) {
|
|
99
|
-
|
|
161
|
+
return /^text\/markdown(?:;|$)/i.test(document.headers.get("content-type") || "") && !!document.body.trim() && !isHtml(document.body);
|
|
100
162
|
}
|
|
101
163
|
function links(header) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
164
|
+
const source = header || "";
|
|
165
|
+
const entries = [];
|
|
166
|
+
let quoted = false;
|
|
167
|
+
let target = false;
|
|
168
|
+
let start = 0;
|
|
169
|
+
for (let i = 0; i < source.length; i++) {
|
|
170
|
+
const character = source[i];
|
|
171
|
+
if (character === "\"" && source[i - 1] !== "\\") quoted = !quoted;
|
|
172
|
+
if (!quoted) {
|
|
173
|
+
if (character === "<") target = true;
|
|
174
|
+
if (character === ">") target = false;
|
|
175
|
+
if (character === "," && !target) {
|
|
176
|
+
entries.push(source.slice(start, i));
|
|
177
|
+
start = i + 1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
entries.push(source.slice(start));
|
|
182
|
+
return entries.flatMap((entry) => {
|
|
183
|
+
const match = entry.match(/^\s*<([^>]+)>([\s\S]*)$/);
|
|
184
|
+
if (!match) return [];
|
|
185
|
+
const parameter = (name) => match[2]?.match(new RegExp(`;\\s*${name}\\s*=\\s*(?:"([^"]*)"|([^;\\s]+))`, "i"));
|
|
186
|
+
const rel = parameter("rel");
|
|
187
|
+
const type = parameter("type");
|
|
188
|
+
return [{
|
|
189
|
+
href: match[1],
|
|
190
|
+
rel: (rel?.[1] || rel?.[2] || "").split(/\s+/),
|
|
191
|
+
type: type?.[1] || type?.[2] || ""
|
|
192
|
+
}];
|
|
193
|
+
});
|
|
132
194
|
}
|
|
133
195
|
function policy(header) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
196
|
+
const signals = {};
|
|
197
|
+
for (const part of header.split(",")) {
|
|
198
|
+
const match = part.trim().match(/^(search|ai-input|ai-train)\s*=\s*(yes|no)$/);
|
|
199
|
+
if (!match) return {
|
|
200
|
+
_tag: "Err",
|
|
201
|
+
message: "Content-Signal has an invalid name or value."
|
|
202
|
+
};
|
|
203
|
+
const name = match[1];
|
|
204
|
+
const value = match[2];
|
|
205
|
+
if (signals[name] && signals[name] !== value) return {
|
|
206
|
+
_tag: "Err",
|
|
207
|
+
message: `Content-Signal contains conflicting ${name} values.`
|
|
208
|
+
};
|
|
209
|
+
signals[name] = value;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
_tag: "Ok",
|
|
213
|
+
value: signals
|
|
214
|
+
};
|
|
146
215
|
}
|
|
147
216
|
function policyCheck(html, md, id = "content-signal") {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
217
|
+
if (html._tag === "Err" || md._tag === "Err" || responseFailure(html) || responseFailure(md)) return {
|
|
218
|
+
id,
|
|
219
|
+
status: "skip",
|
|
220
|
+
detail: "Policy comparison requires both public page responses."
|
|
221
|
+
};
|
|
222
|
+
const source = html.value.headers.get("content-signal");
|
|
223
|
+
const converted = md.value.headers.get("content-signal");
|
|
224
|
+
if (!source && !converted) return {
|
|
225
|
+
id,
|
|
226
|
+
status: "warn",
|
|
227
|
+
detail: "No HTTP Content-Signal. Check whether this matches your content policy."
|
|
228
|
+
};
|
|
229
|
+
const parsedSource = source ? policy(source) : void 0;
|
|
230
|
+
const parsedConverted = converted ? policy(converted) : void 0;
|
|
231
|
+
for (const parsed of [parsedSource, parsedConverted]) if (parsed?._tag === "Err") return {
|
|
232
|
+
id,
|
|
233
|
+
status: "fail",
|
|
234
|
+
detail: parsed.message
|
|
235
|
+
};
|
|
236
|
+
if (parsedSource?._tag === "Ok" && (!parsedConverted || parsedConverted._tag !== "Ok" || Object.keys(parsedSource.value).length !== Object.keys(parsedConverted.value).length || Object.entries(parsedSource.value).some(([key, value]) => parsedConverted.value[key] !== value))) return {
|
|
237
|
+
id,
|
|
238
|
+
status: "fail",
|
|
239
|
+
detail: "Markdown does not preserve the HTML Content-Signal policy."
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
id,
|
|
243
|
+
status: "pass",
|
|
244
|
+
detail: `HTTP policy: ${converted || source}`
|
|
245
|
+
};
|
|
164
246
|
}
|
|
165
247
|
function isRecord(value) {
|
|
166
|
-
|
|
248
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
167
249
|
}
|
|
168
250
|
function parseJson(body) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
251
|
+
try {
|
|
252
|
+
return {
|
|
253
|
+
_tag: "Ok",
|
|
254
|
+
value: JSON.parse(body)
|
|
255
|
+
};
|
|
256
|
+
} catch {
|
|
257
|
+
return {
|
|
258
|
+
_tag: "Err",
|
|
259
|
+
message: "Discovery response contains invalid JSON."
|
|
260
|
+
};
|
|
261
|
+
}
|
|
174
262
|
}
|
|
175
263
|
function discoveryDocument(capability, document) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return Array.isArray(value.linkset) && value.linkset.length > 0 && value.linkset.every((entry) => isRecord(entry) && typeof entry.anchor === "string");
|
|
189
|
-
case "skills":
|
|
190
|
-
return Array.isArray(value.skills);
|
|
191
|
-
case "ai-catalog":
|
|
192
|
-
return value.specVersion === "1.0" && Array.isArray(value.entries) && value.entries.length > 0 && value.entries.every((entry) => isRecord(entry) && typeof entry.url === "string");
|
|
193
|
-
case "mcp":
|
|
194
|
-
return typeof value.name === "string" && typeof value.version === "string" && Array.isArray(value.remotes) && value.remotes.some((remote) => isRecord(remote) && remote.type === "streamable-http" && typeof remote.url === "string");
|
|
195
|
-
}
|
|
264
|
+
if (capability === "llms") return !isHtml(document.body) && /^#\s+\S/m.test(document.body);
|
|
265
|
+
if (!/^application\/(?:[\w.+-]+\+)?json(?:;|$)/i.test(document.headers.get("content-type") || "")) return false;
|
|
266
|
+
const parsed = parseJson(document.body);
|
|
267
|
+
if (parsed._tag === "Err") return false;
|
|
268
|
+
const value = parsed.value;
|
|
269
|
+
if (!isRecord(value)) return false;
|
|
270
|
+
switch (capability) {
|
|
271
|
+
case "api-catalog": return Array.isArray(value.linkset) && value.linkset.length > 0 && value.linkset.every((entry) => isRecord(entry) && typeof entry.anchor === "string");
|
|
272
|
+
case "skills": return Array.isArray(value.skills);
|
|
273
|
+
case "ai-catalog": return value.specVersion === "1.0" && Array.isArray(value.entries) && value.entries.length > 0 && value.entries.every((entry) => isRecord(entry) && typeof entry.url === "string");
|
|
274
|
+
case "mcp": return typeof value.name === "string" && typeof value.version === "string" && Array.isArray(value.remotes) && value.remotes.some((remote) => isRecord(remote) && remote.type === "streamable-http" && typeof remote.url === "string");
|
|
275
|
+
}
|
|
196
276
|
}
|
|
277
|
+
/** Inspect one public page and its discovery documents. No sync endpoint or credential is used. */
|
|
197
278
|
async function auditSite(options, dependencies) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
279
|
+
const [html, negotiated] = await Promise.all([readDocument(options.url, "text/html", dependencies), readDocument(options.url, "text/markdown", dependencies)]);
|
|
280
|
+
const pageUrl = html._tag === "Ok" && !responseFailure(html) ? html.value.url : options.url;
|
|
281
|
+
const page = new URL(pageUrl);
|
|
282
|
+
const site = new URL(options.base, page);
|
|
283
|
+
const advertised = html._tag === "Ok" ? links(html.value.headers.get("link")) : [];
|
|
284
|
+
const alternate = advertised.find((link) => link.rel.includes("alternate") && link.type.toLowerCase() === "text/markdown");
|
|
285
|
+
const linkedUrl = alternate ? publicUrl(alternate.href, pageUrl) : void 0;
|
|
286
|
+
const direct = new URL(pageUrl);
|
|
287
|
+
direct.pathname = `${direct.pathname.replace(/\/$/, "") || "/index"}.md`;
|
|
288
|
+
const robotsUrl = new URL("/robots.txt", page).href;
|
|
289
|
+
const [directMd, robots] = await Promise.all([readDocument(direct.href, "text/markdown", dependencies), readDocument(robotsUrl, "text/plain", dependencies)]);
|
|
290
|
+
const robotsSitemap = robots._tag === "Ok" ? robots.value.body.match(/^sitemap:\s*(\S+)/im)?.[1] : void 0;
|
|
291
|
+
const sitemapUrl = robotsSitemap ? publicUrl(robotsSitemap, robotsUrl) : publicUrl("sitemap.xml", site.href);
|
|
292
|
+
const sitemap = sitemapUrl._tag === "Ok" ? await readDocument(sitemapUrl.value.href, "application/xml, text/xml", dependencies) : sitemapUrl;
|
|
293
|
+
const missingUrl = new URL(".well-known/nuxt-ai-ready-audit-missing", site).href;
|
|
294
|
+
const missing = await readDocument(missingUrl, "text/markdown", dependencies);
|
|
295
|
+
const checks = [
|
|
296
|
+
contentCheck("html", options.url, html, (doc) => /^text\/html(?:;|$)/i.test(doc.headers.get("content-type") || "") && !!doc.body.trim(), "Public HTML is available.", "Expected a non-empty HTML page."),
|
|
297
|
+
contentCheck("markdown-negotiation", options.url, negotiated, markdown, "Accept: text/markdown returns Markdown.", "Expected a non-empty text/markdown response."),
|
|
298
|
+
contentCheck("markdown-url", direct.href, directMd, markdown, "The direct Markdown URL is available.", "Expected a non-empty text/markdown response."),
|
|
299
|
+
{
|
|
300
|
+
id: "markdown-link",
|
|
301
|
+
status: linkedUrl?._tag === "Ok" && linkedUrl.value.href === direct.href ? "pass" : "warn",
|
|
302
|
+
detail: linkedUrl?._tag === "Ok" && linkedUrl.value.href === direct.href ? "The Link header advertises the direct Markdown URL." : alternate ? "Inspect the alternate Markdown Link target." : "No alternate Markdown Link header."
|
|
303
|
+
},
|
|
304
|
+
contentCheck("robots", robotsUrl, robots, (doc) => !isHtml(doc.body) && /^user-agent:\s*\S/im.test(doc.body), "robots.txt is available. Inspect its crawler-specific rules.", "Expected robots.txt with a User-agent group."),
|
|
305
|
+
contentCheck("sitemap", sitemapUrl._tag === "Ok" ? sitemapUrl.value.href : site.href, sitemap, (doc) => /<(?:urlset|sitemapindex)(?:\s|>)/i.test(doc.body) && /<loc>\s*https?:\/\/[^<]+<\/loc>/i.test(doc.body), "A sitemap document is available.", "Expected a sitemap with absolute URL entries."),
|
|
306
|
+
policyCheck(html, negotiated),
|
|
307
|
+
policyCheck(html, directMd, "content-signal-markdown-url"),
|
|
308
|
+
{
|
|
309
|
+
id: "unknown-route",
|
|
310
|
+
url: missingUrl,
|
|
311
|
+
status: missing._tag === "Ok" && [404, 410].includes(missing.value.status) ? "pass" : "fail",
|
|
312
|
+
detail: missing._tag === "Err" ? missing.message : [404, 410].includes(missing.value.status) ? "Unknown routes return 404 or 410." : `Unknown route returned HTTP ${missing.value.status}. Check fallback routing.`
|
|
313
|
+
}
|
|
314
|
+
];
|
|
315
|
+
if (negotiated._tag === "Ok" && !responseFailure(negotiated)) {
|
|
316
|
+
const vary = (negotiated.value.headers.get("vary") || "").toLowerCase().split(",").map((value) => value.trim());
|
|
317
|
+
checks.push({
|
|
318
|
+
id: "vary-accept",
|
|
319
|
+
status: vary.includes("accept") || vary.includes("*") ? "pass" : "fail",
|
|
320
|
+
detail: vary.includes("accept") || vary.includes("*") ? "Vary separates HTML and Markdown cache entries." : "Set Vary: Accept on negotiated responses."
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
const paths = {
|
|
324
|
+
"llms": "llms.txt",
|
|
325
|
+
"api-catalog": ".well-known/api-catalog",
|
|
326
|
+
"ai-catalog": ".well-known/ai-catalog.json",
|
|
327
|
+
"mcp": ".well-known/mcp/server-card.json",
|
|
328
|
+
"skills": ".well-known/agent-skills/index.json"
|
|
329
|
+
};
|
|
330
|
+
const discovery = await Promise.all(capabilities.map(async (capability) => {
|
|
331
|
+
const declaredLink = capability === "api-catalog" ? advertised.find((link) => link.rel.includes("api-catalog")) : void 0;
|
|
332
|
+
if (!options.capabilities.includes(capability) && !declaredLink) return {
|
|
333
|
+
id: capability,
|
|
334
|
+
status: "skip",
|
|
335
|
+
detail: "Not declared. Use --capabilities to check this feature."
|
|
336
|
+
};
|
|
337
|
+
const url = publicUrl(declaredLink?.href || paths[capability], declaredLink ? pageUrl : site.href);
|
|
338
|
+
if (url._tag === "Err") return {
|
|
339
|
+
id: capability,
|
|
340
|
+
status: "fail",
|
|
341
|
+
detail: url.message
|
|
342
|
+
};
|
|
343
|
+
const document = await readDocument(url.value.href, capability === "llms" ? "text/plain" : "application/json", dependencies);
|
|
344
|
+
return contentCheck(capability, url.value.href, document, (doc) => discoveryDocument(capability, doc), "The discovery document is available.", "The discovery document has an unexpected format.");
|
|
345
|
+
}));
|
|
346
|
+
return {
|
|
347
|
+
schemaVersion: 1,
|
|
348
|
+
url: options.url,
|
|
349
|
+
checks: [...checks, ...discovery]
|
|
350
|
+
};
|
|
247
351
|
}
|
|
248
|
-
|
|
352
|
+
// src/cli.ts
|
|
249
353
|
async function getSecret(cwd) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return fsp.readFile(secretPath, "utf-8").then((s) => s.trim()).catch(() => {
|
|
263
|
-
return null;
|
|
264
|
-
});
|
|
354
|
+
const root = process.env.NITRO_APP_SECRET ?? process.env.NUXT_APP_SECRET;
|
|
355
|
+
if (root !== void 0 && root !== "") return deriveRuntimeSyncSecret(root);
|
|
356
|
+
const legacy = process.env.NUXT_NUXT_AI_READY_RUNTIME_SYNC_SECRET ?? process.env.NUXT_AI_READY_RUNTIME_SYNC_SECRET;
|
|
357
|
+
if (legacy) {
|
|
358
|
+
console.warn(`[nuxt-ai-ready] ${LEGACY_RUNTIME_SYNC_SECRET_WARNING}`);
|
|
359
|
+
return legacy;
|
|
360
|
+
}
|
|
361
|
+
const secretPath = join(cwd, "node_modules/.cache/nuxt/ai-ready/secret");
|
|
362
|
+
if (!existsSync(secretPath)) return null;
|
|
363
|
+
return fsp.readFile(secretPath, "utf-8").then((s) => s.trim()).catch(() => {
|
|
364
|
+
return null;
|
|
365
|
+
});
|
|
265
366
|
}
|
|
266
367
|
function authHeaders(secret) {
|
|
267
|
-
|
|
368
|
+
return { Authorization: `Bearer ${secret}` };
|
|
268
369
|
}
|
|
269
370
|
async function requireSecret(cwd) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
return secret;
|
|
371
|
+
const secret = await getSecret(cwd);
|
|
372
|
+
if (!secret) throw new Error(`${APPLICATION_SECRET_ERROR} For development, run nuxt dev to cache the runtime sync token.`);
|
|
373
|
+
return secret;
|
|
275
374
|
}
|
|
276
375
|
function describeHttpError(status, body) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
376
|
+
const error = body;
|
|
377
|
+
const message = typeof error?.message === "string" && error.message ? error.message : typeof error?.statusMessage === "string" && error.statusMessage ? error.statusMessage : typeof error?.error === "string" && error.error ? error.error : null;
|
|
378
|
+
return message ? `${status}: ${message}` : `request failed with status ${status}`;
|
|
280
379
|
}
|
|
281
380
|
async function fetchJson(url, init, errorLabel = "Failed") {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
381
|
+
const r = await fetch(url, init).catch((err) => {
|
|
382
|
+
throw new Error(`${errorLabel}: ${err instanceof Error ? err.message : String(err)}`);
|
|
383
|
+
});
|
|
384
|
+
if (!r.ok) {
|
|
385
|
+
const body = await r.json().catch(() => {
|
|
386
|
+
return null;
|
|
387
|
+
});
|
|
388
|
+
throw new Error(`${errorLabel}: ${describeHttpError(r.status, body)}`);
|
|
389
|
+
}
|
|
390
|
+
return r.json();
|
|
292
391
|
}
|
|
293
392
|
const main = defineCommand({
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
consola.success(`Indexed: ${colors.green(res.route)}`);
|
|
598
|
-
if (res.contentChanged !== void 0) {
|
|
599
|
-
consola.info(`Content changed: ${res.contentChanged ? colors.green("yes") : colors.yellow("no")}`);
|
|
600
|
-
}
|
|
601
|
-
} else if (res.skipped) {
|
|
602
|
-
consola.info(`Skipped: ${colors.yellow(res.route)} (still fresh)`);
|
|
603
|
-
} else if (res.gone) {
|
|
604
|
-
consola.success(`Removed: ${colors.green(res.route)} (HTTP 410)`);
|
|
605
|
-
} else {
|
|
606
|
-
throw new Error(`Failed to reindex ${res.route ?? args.route}${res.error ? `: ${res.error}` : ""}`);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
})
|
|
610
|
-
}
|
|
393
|
+
meta: {
|
|
394
|
+
name: "nuxt-ai-ready",
|
|
395
|
+
description: "Nuxt AI Ready CLI",
|
|
396
|
+
version: await readPackageMetadata(import.meta.url).then((p) => p.version || "0.0.0")
|
|
397
|
+
},
|
|
398
|
+
subCommands: {
|
|
399
|
+
token: () => defineCommand({
|
|
400
|
+
meta: {
|
|
401
|
+
name: "token",
|
|
402
|
+
description: "Print the runtime sync bearer token"
|
|
403
|
+
},
|
|
404
|
+
args: { cwd: {
|
|
405
|
+
type: "string",
|
|
406
|
+
description: "Working directory",
|
|
407
|
+
default: "."
|
|
408
|
+
} },
|
|
409
|
+
async run({ args }) {
|
|
410
|
+
const secret = await requireSecret(resolve(args.cwd));
|
|
411
|
+
process.stdout.write(`${secret}\n`);
|
|
412
|
+
}
|
|
413
|
+
}),
|
|
414
|
+
audit: () => defineCommand({
|
|
415
|
+
meta: {
|
|
416
|
+
name: "audit",
|
|
417
|
+
description: "Check a public page and its agent discovery documents"
|
|
418
|
+
},
|
|
419
|
+
args: {
|
|
420
|
+
url: {
|
|
421
|
+
type: "positional",
|
|
422
|
+
required: true,
|
|
423
|
+
description: "Public page URL"
|
|
424
|
+
},
|
|
425
|
+
base: {
|
|
426
|
+
type: "string",
|
|
427
|
+
default: "/",
|
|
428
|
+
description: "Application base path, such as /docs/"
|
|
429
|
+
},
|
|
430
|
+
capabilities: {
|
|
431
|
+
type: "string",
|
|
432
|
+
description: "Check declared features: llms,api-catalog,ai-catalog,mcp,skills"
|
|
433
|
+
},
|
|
434
|
+
json: {
|
|
435
|
+
type: "boolean",
|
|
436
|
+
description: "Print structured JSON results"
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
async run({ args }) {
|
|
440
|
+
const parsed = parseAuditOptions(args);
|
|
441
|
+
if (parsed._tag === "Err") throw new Error(parsed.message);
|
|
442
|
+
const report = await auditSite(parsed.value, { fetch });
|
|
443
|
+
if (args.json) process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
444
|
+
else {
|
|
445
|
+
consola.info(`Readiness audit: ${report.url}`);
|
|
446
|
+
for (const check of report.checks) consola.log(`${check.status.toUpperCase()} ${check.id}: ${check.detail}`);
|
|
447
|
+
}
|
|
448
|
+
if (report.checks.some((check) => check.status === "fail")) process.exitCode = 1;
|
|
449
|
+
}
|
|
450
|
+
}),
|
|
451
|
+
status: () => defineCommand({
|
|
452
|
+
meta: {
|
|
453
|
+
name: "status",
|
|
454
|
+
description: "Show indexing status and sync progress"
|
|
455
|
+
},
|
|
456
|
+
args: {
|
|
457
|
+
url: {
|
|
458
|
+
type: "string",
|
|
459
|
+
alias: "u",
|
|
460
|
+
description: "Site URL (default: http://localhost:3000)",
|
|
461
|
+
default: "http://localhost:3000"
|
|
462
|
+
},
|
|
463
|
+
cwd: {
|
|
464
|
+
type: "string",
|
|
465
|
+
description: "Working directory",
|
|
466
|
+
default: "."
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
async run({ args }) {
|
|
470
|
+
const secret = await requireSecret(resolve(args.cwd || "."));
|
|
471
|
+
if (!secret) return;
|
|
472
|
+
const url = joinURL(args.url, "/__ai-ready/status");
|
|
473
|
+
consola.info(`Fetching status from ${args.url}...`);
|
|
474
|
+
const res = await fetchJson(url, { headers: authHeaders(secret) }, "Failed to connect");
|
|
475
|
+
consola.box("AI Ready Status");
|
|
476
|
+
consola.info(`Total pages: ${colors.cyan(res.total?.toString() || "0")}`);
|
|
477
|
+
consola.info(`Indexed: ${colors.green(res.indexed?.toString() || "0")}`);
|
|
478
|
+
consola.info(`Pending: ${colors.yellow(res.pending?.toString() || "0")}`);
|
|
479
|
+
if (res.activity) {
|
|
480
|
+
consola.log("");
|
|
481
|
+
consola.info(colors.bold("Activity:"));
|
|
482
|
+
consola.info(` Last 1h: ${colors.cyan(res.activity.last1h?.toString() || "0")} pages indexed`);
|
|
483
|
+
consola.info(` Last 24h: ${colors.cyan(res.activity.last24h?.toString() || "0")} pages indexed`);
|
|
484
|
+
if (res.activity.recentPages?.length) {
|
|
485
|
+
consola.info(` Recent:`);
|
|
486
|
+
for (const p of res.activity.recentPages.slice(0, 5)) {
|
|
487
|
+
const ago = Date.now() - p.indexedAt;
|
|
488
|
+
const agoStr = ago < 6e4 ? `${Math.round(ago / 1e3)}s` : ago < 36e5 ? `${Math.round(ago / 6e4)}m` : `${Math.round(ago / 36e5)}h`;
|
|
489
|
+
consola.info(` ${colors.dim(`${agoStr} ago`)} ${p.route} ${colors.dim(p.title || "")}`);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (res.cron) {
|
|
494
|
+
consola.log("");
|
|
495
|
+
consola.info(colors.bold("Cron:"));
|
|
496
|
+
if (res.cron.lock?.held) consola.warn(` Lock: ${colors.yellow("held")} (${Math.round((res.cron.lock.elapsedMs || 0) / 1e3)}s)`);
|
|
497
|
+
if (res.cron.recentRuns?.length) for (const run of res.cron.recentRuns) {
|
|
498
|
+
const status = run.status === "success" ? colors.green(run.status) : run.status === "error" ? colors.red(run.status) : colors.yellow(run.status);
|
|
499
|
+
consola.info(` ${colors.dim(new Date(run.startedAt).toLocaleTimeString())} ${status} ${colors.dim(`${run.durationMs || 0}ms`)} ${run.pagesIndexed ? `${run.pagesIndexed} indexed` : ""}`);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (res.sitemaps?.length) {
|
|
503
|
+
consola.log("");
|
|
504
|
+
consola.info(colors.bold("Sitemaps:"));
|
|
505
|
+
for (const s of res.sitemaps) {
|
|
506
|
+
const err = s.errorCount > 0 ? colors.red(` (${s.errorCount} errors)`) : "";
|
|
507
|
+
consola.info(` ${s.name}: ${colors.cyan(s.urlCount?.toString() || "0")} URLs${err}`);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}),
|
|
512
|
+
poll: () => defineCommand({
|
|
513
|
+
meta: {
|
|
514
|
+
name: "poll",
|
|
515
|
+
description: "Trigger page indexing"
|
|
516
|
+
},
|
|
517
|
+
args: {
|
|
518
|
+
url: {
|
|
519
|
+
type: "string",
|
|
520
|
+
alias: "u",
|
|
521
|
+
description: "Site URL (default: http://localhost:3000)",
|
|
522
|
+
default: "http://localhost:3000"
|
|
523
|
+
},
|
|
524
|
+
limit: {
|
|
525
|
+
type: "string",
|
|
526
|
+
alias: "l",
|
|
527
|
+
description: "Max pages to process",
|
|
528
|
+
default: "10"
|
|
529
|
+
},
|
|
530
|
+
all: {
|
|
531
|
+
type: "boolean",
|
|
532
|
+
alias: "a",
|
|
533
|
+
description: "Process all pending pages"
|
|
534
|
+
},
|
|
535
|
+
cwd: {
|
|
536
|
+
type: "string",
|
|
537
|
+
description: "Working directory",
|
|
538
|
+
default: "."
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
async run({ args }) {
|
|
542
|
+
const secret = await requireSecret(resolve(args.cwd || "."));
|
|
543
|
+
if (!secret) return;
|
|
544
|
+
const params = new URLSearchParams();
|
|
545
|
+
if (args.all) params.set("all", "true");
|
|
546
|
+
else params.set("limit", args.limit || "10");
|
|
547
|
+
const url = joinURL(args.url, `/__ai-ready/poll?${params}`);
|
|
548
|
+
consola.info(`Triggering poll at ${args.url}...`);
|
|
549
|
+
const res = await fetchJson(url, {
|
|
550
|
+
method: "POST",
|
|
551
|
+
headers: authHeaders(secret)
|
|
552
|
+
});
|
|
553
|
+
consola.success(`Indexed: ${colors.green(res.indexed?.toString() || "0")} pages`);
|
|
554
|
+
consola.info(`Remaining: ${colors.yellow(res.remaining?.toString() || "0")}`);
|
|
555
|
+
if (res.errors?.length) consola.warn(`Errors: ${res.errors.length}`);
|
|
556
|
+
if (res.duration) consola.info(`Duration: ${colors.dim(`${res.duration}ms`)}`);
|
|
557
|
+
}
|
|
558
|
+
}),
|
|
559
|
+
restore: () => defineCommand({
|
|
560
|
+
meta: {
|
|
561
|
+
name: "restore",
|
|
562
|
+
description: "Restore database from prerendered dump"
|
|
563
|
+
},
|
|
564
|
+
args: {
|
|
565
|
+
url: {
|
|
566
|
+
type: "string",
|
|
567
|
+
alias: "u",
|
|
568
|
+
description: "Site URL (default: http://localhost:3000)",
|
|
569
|
+
default: "http://localhost:3000"
|
|
570
|
+
},
|
|
571
|
+
clear: {
|
|
572
|
+
type: "boolean",
|
|
573
|
+
description: "Clear existing pages first",
|
|
574
|
+
default: true,
|
|
575
|
+
negativeDescription: "Restore without clearing existing pages"
|
|
576
|
+
},
|
|
577
|
+
cwd: {
|
|
578
|
+
type: "string",
|
|
579
|
+
description: "Working directory",
|
|
580
|
+
default: "."
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
async run({ args }) {
|
|
584
|
+
const secret = await requireSecret(resolve(args.cwd || "."));
|
|
585
|
+
if (!secret) return;
|
|
586
|
+
const params = new URLSearchParams();
|
|
587
|
+
if (!args.clear) params.set("clear", "false");
|
|
588
|
+
const url = joinURL(args.url, `/__ai-ready/restore?${params}`);
|
|
589
|
+
consola.info(`Restoring database at ${args.url}...`);
|
|
590
|
+
const res = await fetchJson(url, {
|
|
591
|
+
method: "POST",
|
|
592
|
+
headers: authHeaders(secret)
|
|
593
|
+
});
|
|
594
|
+
consola.success(`Restored: ${colors.green(res.restored?.toString() || "0")} pages`);
|
|
595
|
+
if (res.cleared) consola.info(`Cleared: ${colors.yellow(res.cleared?.toString() || "0")} existing pages`);
|
|
596
|
+
}
|
|
597
|
+
}),
|
|
598
|
+
prune: () => defineCommand({
|
|
599
|
+
meta: {
|
|
600
|
+
name: "prune",
|
|
601
|
+
description: "Remove stale routes from database"
|
|
602
|
+
},
|
|
603
|
+
args: {
|
|
604
|
+
url: {
|
|
605
|
+
type: "string",
|
|
606
|
+
alias: "u",
|
|
607
|
+
description: "Site URL (default: http://localhost:3000)",
|
|
608
|
+
default: "http://localhost:3000"
|
|
609
|
+
},
|
|
610
|
+
dry: {
|
|
611
|
+
type: "boolean",
|
|
612
|
+
alias: "d",
|
|
613
|
+
description: "Preview without deleting"
|
|
614
|
+
},
|
|
615
|
+
ttl: {
|
|
616
|
+
type: "string",
|
|
617
|
+
description: "Override pruneTtl config"
|
|
618
|
+
},
|
|
619
|
+
cwd: {
|
|
620
|
+
type: "string",
|
|
621
|
+
description: "Working directory",
|
|
622
|
+
default: "."
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
async run({ args }) {
|
|
626
|
+
const secret = await getSecret(resolve(args.cwd || "."));
|
|
627
|
+
if (!secret && !args.dry) throw new Error(`${APPLICATION_SECRET_ERROR} For development, run nuxt dev to cache the runtime sync token.`);
|
|
628
|
+
const params = new URLSearchParams();
|
|
629
|
+
if (args.dry) params.set("dry", "true");
|
|
630
|
+
if (args.ttl) params.set("ttl", args.ttl);
|
|
631
|
+
const url = joinURL(args.url, `/__ai-ready/prune?${params}`);
|
|
632
|
+
consola.info(`${args.dry ? "Previewing" : "Pruning"} stale routes at ${args.url}...`);
|
|
633
|
+
const res = await fetchJson(url, {
|
|
634
|
+
method: "POST",
|
|
635
|
+
headers: secret ? authHeaders(secret) : void 0
|
|
636
|
+
});
|
|
637
|
+
if (args.dry) {
|
|
638
|
+
consola.info(`Would prune: ${colors.yellow(res.count?.toString() || "0")} routes`);
|
|
639
|
+
if (res.routes?.length) {
|
|
640
|
+
for (const route of res.routes.slice(0, 20)) consola.log(` ${colors.dim("•")} ${route}`);
|
|
641
|
+
if (res.routes.length > 20) consola.log(` ${colors.dim(`... and ${res.routes.length - 20} more`)}`);
|
|
642
|
+
}
|
|
643
|
+
} else consola.success(`Pruned: ${colors.green(res.pruned?.toString() || "0")} routes`);
|
|
644
|
+
}
|
|
645
|
+
}),
|
|
646
|
+
reindex: () => defineCommand({
|
|
647
|
+
meta: {
|
|
648
|
+
name: "reindex",
|
|
649
|
+
description: "Reindex a single route"
|
|
650
|
+
},
|
|
651
|
+
args: {
|
|
652
|
+
route: {
|
|
653
|
+
type: "positional",
|
|
654
|
+
description: "Route to reindex (e.g. /about)",
|
|
655
|
+
required: true
|
|
656
|
+
},
|
|
657
|
+
url: {
|
|
658
|
+
type: "string",
|
|
659
|
+
alias: "u",
|
|
660
|
+
description: "Site URL (default: http://localhost:3000)",
|
|
661
|
+
default: "http://localhost:3000"
|
|
662
|
+
},
|
|
663
|
+
force: {
|
|
664
|
+
type: "boolean",
|
|
665
|
+
description: "Index even when the page is still fresh",
|
|
666
|
+
default: true,
|
|
667
|
+
negativeDescription: "Skip indexing when the page is still fresh"
|
|
668
|
+
},
|
|
669
|
+
cwd: {
|
|
670
|
+
type: "string",
|
|
671
|
+
description: "Working directory",
|
|
672
|
+
default: "."
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
async run({ args }) {
|
|
676
|
+
const secret = await requireSecret(resolve(args.cwd || "."));
|
|
677
|
+
if (!secret) return;
|
|
678
|
+
const params = new URLSearchParams();
|
|
679
|
+
params.set("route", args.route);
|
|
680
|
+
if (!args.force) params.set("force", "false");
|
|
681
|
+
const url = joinURL(args.url, `/__ai-ready/reindex?${params}`);
|
|
682
|
+
consola.info(`Reindexing ${args.route} at ${args.url}...`);
|
|
683
|
+
const res = await fetchJson(url, {
|
|
684
|
+
method: "POST",
|
|
685
|
+
headers: authHeaders(secret)
|
|
686
|
+
});
|
|
687
|
+
if (res.indexed) {
|
|
688
|
+
consola.success(`Indexed: ${colors.green(res.route)}`);
|
|
689
|
+
if (res.contentChanged !== void 0) consola.info(`Content changed: ${res.contentChanged ? colors.green("yes") : colors.yellow("no")}`);
|
|
690
|
+
} else if (res.skipped) consola.info(`Skipped: ${colors.yellow(res.route)} (still fresh)`);
|
|
691
|
+
else if (res.gone) consola.success(`Removed: ${colors.green(res.route)} (HTTP 410)`);
|
|
692
|
+
else throw new Error(`Failed to reindex ${res.route ?? args.route}${res.error ? `: ${res.error}` : ""}`);
|
|
693
|
+
}
|
|
694
|
+
})
|
|
695
|
+
}
|
|
611
696
|
});
|
|
612
697
|
runMain(main);
|
|
698
|
+
export {};
|