readiness-audit 1.2.0 → 2.0.0
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/CHANGELOG.md +55 -0
- package/README.md +10 -7
- package/STANDARD.md +73 -41
- package/bin/readiness-audit.mjs +34 -7
- package/package.json +2 -2
- package/src/audit.mjs +128 -115
- package/src/helpers.mjs +196 -2
- package/src/http.mjs +47 -0
- package/src/logs.mjs +120 -0
package/bin/readiness-audit.mjs
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// readiness-audit: score a live site against the Agent and Search Readiness Standard.
|
|
3
3
|
//
|
|
4
|
-
// readiness-audit <domain> [--mcp /path] [--no-mcp] [--
|
|
4
|
+
// readiness-audit <domain> [--mcp /path] [--no-mcp] [--json] [--compare previous] [--base url]
|
|
5
5
|
// readiness-audit --matrix <domain> <domain> ... [--recorded results.json] (a markdown status page)
|
|
6
|
+
// readiness-audit --logs <access-log> [--json] (who requests the discovery files)
|
|
6
7
|
//
|
|
7
8
|
// Exits 1 when a required check fails, so it can gate a deploy.
|
|
8
9
|
|
|
9
|
-
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { readFileSync, createReadStream } from 'node:fs';
|
|
11
|
+
import { createInterface } from 'node:readline';
|
|
10
12
|
import { audit, matrix, score, LEVELS, REVIEW, VERSION } from '../src/audit.mjs';
|
|
11
13
|
import { parsePrevious, compareResults, formatComparison } from '../src/helpers.mjs';
|
|
14
|
+
import { logTally, formatLogs } from '../src/logs.mjs';
|
|
15
|
+
|
|
16
|
+
// engines in package.json only warns, so say it plainly before anything fails oddly.
|
|
17
|
+
const NODE_MAJOR = 26;
|
|
18
|
+
if (Number(process.versions.node.split('.')[0]) < NODE_MAJOR) {
|
|
19
|
+
console.error(`readiness-audit needs Node ${NODE_MAJOR} or later, with current security releases (this is ${process.versions.node}).`);
|
|
20
|
+
process.exit(2);
|
|
21
|
+
}
|
|
12
22
|
|
|
13
23
|
const args = process.argv.slice(2);
|
|
14
24
|
const flag = (n) => args.includes(n);
|
|
@@ -21,26 +31,37 @@ const mcpOpt = valueOf('--mcp');
|
|
|
21
31
|
const recordedPath = valueOf('--recorded');
|
|
22
32
|
const comparePath = valueOf('--compare');
|
|
23
33
|
const base = valueOf('--base');
|
|
24
|
-
const
|
|
34
|
+
const logsPath = valueOf('--logs');
|
|
35
|
+
const domains = args.filter((a, i) => !a.startsWith('-') && !['--mcp', '--recorded', '--compare', '--base', '--logs'].includes(args[i - 1]))
|
|
25
36
|
.map((d) => d.replace(/^https?:\/\//, '').replace(/\/.*$/, ''));
|
|
26
|
-
const opts = {
|
|
37
|
+
const opts = { mcpPath: flag('--no-mcp') ? null : (mcpOpt ?? '/mcp'), base: base ?? null };
|
|
27
38
|
if (base) {
|
|
28
39
|
let u;
|
|
29
40
|
try { u = new URL(base); } catch { u = null; }
|
|
30
41
|
if (!u || !['http:', 'https:'].includes(u.protocol)) { console.error(`--base needs an http(s) URL, like http://localhost:3000 (got ${base})`); process.exit(2); }
|
|
31
42
|
}
|
|
32
43
|
|
|
44
|
+
if (logsPath) {
|
|
45
|
+
const tally = logTally();
|
|
46
|
+
try {
|
|
47
|
+
for await (const line of createInterface({ input: createReadStream(logsPath), crlfDelay: Infinity })) tally.add(line);
|
|
48
|
+
} catch (e) { console.error(`Couldn't read ${logsPath}: ${e.message}`); process.exit(2); }
|
|
49
|
+
const rep = tally.result();
|
|
50
|
+
console.log(flag('--json') ? JSON.stringify(rep, null, 2) : formatLogs(rep).join('\n'));
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
33
54
|
if (!domains.length || flag('--help') || flag('-h')) {
|
|
34
55
|
console.error(`readiness-audit ${VERSION}
|
|
35
56
|
|
|
36
57
|
Usage:
|
|
37
|
-
readiness-audit <domain> [--mcp /path] [--no-mcp] [--
|
|
58
|
+
readiness-audit <domain> [--mcp /path] [--no-mcp] [--json] [--compare previous] [--base url]
|
|
38
59
|
readiness-audit --matrix <domain> <domain> ... [--recorded results.json]
|
|
60
|
+
readiness-audit --logs <access-log> [--json]
|
|
39
61
|
|
|
40
62
|
Options:
|
|
41
63
|
--mcp /path where your hosted MCP endpoint lives (default /mcp)
|
|
42
64
|
--no-mcp skip the hosted MCP checks
|
|
43
|
-
--no-api skip the API checks, for a site with no public API
|
|
44
65
|
--json print the results as JSON
|
|
45
66
|
--matrix score several sites and print a markdown status page
|
|
46
67
|
--recorded f with --matrix: add recorded T5 and T6 results from a JSON file
|
|
@@ -48,7 +69,13 @@ Options:
|
|
|
48
69
|
--matrix (docs/readiness-status.md) or a saved --json report
|
|
49
70
|
--base url score a local or preview build as the domain, before you
|
|
50
71
|
deploy (http://localhost:3000); DNS and host redirects are
|
|
51
|
-
skipped
|
|
72
|
+
skipped
|
|
73
|
+
--logs f count requests for the discovery files in an exported access
|
|
74
|
+
log (combined log format or JSON lines), by client family;
|
|
75
|
+
prints counts, never addresses
|
|
76
|
+
|
|
77
|
+
The API checks run when /openapi.json or /api answers, or the site declares
|
|
78
|
+
an API (a service-desc link, an API catalog, an API link in llms.txt).`);
|
|
52
79
|
process.exit(domains.length ? 0 : 2);
|
|
53
80
|
}
|
|
54
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "readiness-audit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Score a live site against the Agent and Search Readiness Standard: discovery files, search, API, MCP and skills, for AI agents and search engines.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"test": "node --test"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=26"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"ai-agents",
|