-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadme.test.ts
More file actions
96 lines (81 loc) · 4.34 KB
/
Copy pathreadme.test.ts
File metadata and controls
96 lines (81 loc) · 4.34 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const forbiddenReadmeFragments = [
'"gateSummary"',
'"comparisons"',
'"generatedAt"',
"Total output lines",
"\uFFFD",
"\u00EC",
"\u00EB",
"\u00ED",
"\u00EA",
];
describe("README", () => {
it("stays concise and avoids generated or mojibake content", async () => {
const readme = await readFile(join(process.cwd(), "README.md"), "utf8");
const lines = readme.split(/\r?\n/);
expect(lines.length).toBeLessThan(120);
expect(Math.max(...lines.map((line) => line.length))).toBeLessThan(140);
for (const fragment of forbiddenReadmeFragments) {
expect(readme).not.toContain(fragment);
}
expect(readme).toContain('<div align="center">');
expect(readme).toContain('<img src="./docs/assets/ax-grep-og.png" alt="ax-grep promo image" width="920">');
expect(readme).toContain("coverage-100%25-brightgreen.svg");
expect(readme).toContain("[Agent handoff loop](./docs/agent-handoff.md)");
expect(readme).not.toContain("## Compact JSON Example");
});
it("keeps the README promo image available for GitHub social preview", async () => {
const image = await readFile(join(process.cwd(), "docs", "assets", "ax-grep-og.png"));
expect(image.subarray(0, 8)).toEqual(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]));
expect(image.length).toBeGreaterThan(100_000);
});
it("puts skill install before library and WebView usage", async () => {
const readme = await readFile(join(process.cwd(), "README.md"), "utf8");
const packageJson = JSON.parse(await readFile(join(process.cwd(), "package.json"), "utf8")) as {
files?: string[];
};
const skill = await readFile(join(process.cwd(), "skills", "ax-grep-cli", "SKILL.md"), "utf8");
const installer = await readFile(join(process.cwd(), "skills.sh"), "utf8");
const skillIndex = readme.indexOf("## 1. Install The CLI Skill");
const serverIndex = readme.indexOf("## 2. Use From A Server");
const webviewIndex = readme.indexOf("## 3. Use In WebViews Or Pages");
expect(skillIndex).toBeGreaterThan(-1);
expect(serverIndex).toBeGreaterThan(skillIndex);
expect(webviewIndex).toBeGreaterThan(serverIndex);
expect(readme).toContain("curl -fsSL https://raw.githubusercontent.com/hmmhmmhm/ax-grep/main/skills.sh | sh");
expect(readme).toContain("[CLI skill prompt](./skills/ax-grep-cli/SKILL.md)");
expect(skill).toContain("Use `ax-grep` before browser automation");
expect(skill).toContain("agent.executor");
expect(installer).toContain("ax-grep-cli");
expect(packageJson.files).toEqual(expect.arrayContaining(["skills", "skills.sh"]));
});
it("keeps the agent continuation contract in docs", async () => {
const handoff = await readFile(join(process.cwd(), "docs", "agent-handoff.md"), "utf8");
expect(handoff).toContain("Executors can usually switch");
expect(handoff).toContain("only on `agent.executor.decision`");
expect(handoff).toContain("const step: AgentExecutorStep = payload.agent.executor");
expect(handoff).toContain("commandArgs.slice(1)");
expect(handoff).toContain("sourceLinkRef");
});
it("keeps agent-readiness evidence outside the root README", async () => {
const docsIndex = await readFile(join(process.cwd(), "docs", "README.md"), "utf8");
const readiness = await readFile(join(process.cwd(), "docs", "agent-readiness.md"), "utf8");
expect(docsIndex).toContain("[agent-readiness.md](./agent-readiness.md)");
expect(readiness).toContain("Evidence Map");
expect(readiness).toContain("Completion Gate");
expect(readiness).toContain("Browser-backed comparison suites must run sequentially");
});
it("documents the non-browser fixture gate outside the root README", async () => {
const pkg = JSON.parse(await readFile(join(process.cwd(), "package.json"), "utf8")) as {
scripts?: Record<string, string>;
};
const benchmarks = await readFile(join(process.cwd(), "docs", "benchmarks.md"), "utf8");
expect(pkg.scripts?.["compare:static:fixtures:gate"]).toBe("tsx scripts/check-fixture-static-gate.ts");
expect(benchmarks).toContain("pnpm compare:static:fixtures:gate");
expect(benchmarks).toContain("non-browser smoke gate");
expect(benchmarks).toContain("should not fetch remote pages or launch");
});
});