-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaicheck.mjs
More file actions
82 lines (76 loc) · 1.94 KB
/
Copy pathaicheck.mjs
File metadata and controls
82 lines (76 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
80
81
82
import { readFile } from "node:fs/promises";
import { join } from "node:path";
const root = process.cwd();
const rules = [
{
file: "app/llms.txt/route.ts",
name: "llms-index",
patterns: ['from "@/app/api/_lib/text"', "return send("],
},
{
file: "app/llms-full.txt/route.ts",
name: "llms-full",
patterns: ['from "@/app/api/_lib/text"', "return send("],
},
{
file: "app/api/raw/[...slug]/route.ts",
name: "raw-markdown",
patterns: ['from "@/app/api/_lib/text"', "return send("],
},
{
file: "app/api/raw/route.ts",
name: "raw-root",
patterns: ['from "@/app/api/_lib/text"', "return send("],
},
{
file: "app/api/llms/route.ts",
name: "llms-root",
patterns: ['from "@/app/api/_lib/text"', "return send("],
},
{
file: "app/api/docs/[...slug]/route.ts",
name: "docs-markdown",
patterns: ['from "@/app/api/_lib/text"', "return sendMarkdown("],
},
{
file: "app/api/mcp/route.ts",
name: "mcp-route",
patterns: ['from "@/app/api/_lib/json"', "sendJson("],
},
{
file: "app/.well-known/llms.txt/route.ts",
name: "well-known-llms",
patterns: ['redirect("/llms.txt")'],
},
{
file: "app/.well-known/llms-full.txt/route.ts",
name: "well-known-llms-full",
patterns: ['redirect("/llms-full.txt")'],
},
];
const issues = [];
for (const rule of rules) {
const path = join(root, rule.file);
let text = "";
try {
text = await readFile(path, "utf8");
} catch {
issues.push(`${rule.name} missing file: ${rule.file}`);
continue;
}
for (const pattern of rule.patterns) {
if (!text.includes(pattern)) {
issues.push(`${rule.name} missing pattern: ${pattern}`);
}
}
}
if (issues.length > 0) {
console.error("x ai endpoint contract validation failed");
for (const issue of issues) {
console.error(issue);
}
process.exit(1);
}
console.log(
`o ai endpoint contract validation passed (${rules.length} routes)`
);