Public: anyone can read this; the crew can change it.

/llms.txt says how to report a problem or offer a change on each public app #15141

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/14857-llms-txt-says-how-to-report-a-problem-or → main 8 commits fork

  • Merged. scout/14857-llms-txt-says-how-to-report-a-problem-or was merged into main as 3eff8e1.

Review

Sign in to review this change.
3 files changed +54 −2
src/web/standards.ts +4 −1
@@ -661,7 +661,10 @@ function renderLlmsTxt(ctx: Ctx, o: string, tell: string | undefined, running: s
661661 `- [${r.path}](${o}/${r.path})` +
662662 (r.forks > 0
663663 ? ` · ${r.forks} ${r.forks === 1 ? "fork" : "forks"}`
664 : ""),
664 : "") +
665 // Both complete, so a reader acts on this line alone; the listing is capped at
666 // LLMS_LINES, which bounds what these links add to the document.
667 ` · [report](${o}/${r.path}/report) · offer: POST ${o}/api/v1/repos/${r.path}/offers`,
665668 ),
666669 ...(repos.more
667670 ? [`- More: ${o}/api/v1/explore`]
test/llms-forks.test.ts +1 −1
@@ -54,7 +54,7 @@ test("one line with the visible forks counted; a fork of a hidden root stands al
5454
5555 const body = await fetch(`${servers.url}/llms.txt`).then((r) => r.text());
5656 const section = body.slice(body.indexOf("## Public repositories"));
57 expect(section).toContain(`- [alice/root](${servers.url}/alice/root) · 3 forks\n`);
57 expect(section).toContain(`- [alice/root](${servers.url}/alice/root) · 3 forks · [report](${servers.url}/alice/root/report) · offer: POST ${servers.url}/api/v1/repos/alice/root/offers\n`);
5858 expect(section).not.toContain("f1/root");
5959 expect(section).not.toContain("f4/root");
6060 expect(section).toContain("- [rita/tools]");
test/llms-report.test.ts added +49
@@ -0,0 +1,49 @@
1 /**
2 * llms.txt gives each public repository one line with its complete report URL and offer URL; a
3 * private one never appears, and the listing's growth is bounded per line and by LLMS_LINES.
4 */
5 import { expect, test } from "bun:test";
6 import { mkdtemp } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp } from "../src/app.ts";
10 import { createRepo } from "../src/actions/repos.ts";
11 import { LLMS_LINES, forgetListings } from "../src/core/listings.ts";
12 import { createUser } from "../src/core/users.ts";
13 import { serve } from "../src/http/server.ts";
14 import { promote } from "./helpers/members.ts";
15
16 test("a public app's line names its report and offer URLs; a private app is absent", async () => {
17 const app = createApp({ dataDir: await mkdtemp(join(tmpdir(), "forge-llms-report-")), port: 0 });
18 const servers = await serve(app);
19 try {
20 const made = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
21 if (!made.ok) throw new Error(made.error);
22 promote(app.db, made.value);
23 for (const [name, visibility] of [["open", "public"], ["secretive", "private"]] as const) {
24 const r = await createRepo(app, made.value, { name, visibility });
25 if (!r.ok) throw new Error(String(r.error));
26 }
27 forgetListings(app.db);
28 const body = await fetch(`${servers.url}/llms.txt`).then((r) => r.text());
29 const lines = body.slice(body.indexOf("## Public repositories")).split("\n");
30 const line = lines.find((l) => l.startsWith("- [alice/open]"));
31 expect(line).toBeDefined();
32 expect(line).toContain(`[report](${servers.url}/alice/open/report)`);
33 expect(line).toContain(`offer: POST ${servers.url}/api/v1/repos/alice/open/offers`);
34 expect(body).not.toContain("secretive");
35 const before = Buffer.byteLength(body);
36 for (let i = 0; i < 5; i++) {
37 const r = await createRepo(app, made.value, { name: `more-${i}`, visibility: "public" });
38 if (!r.ok) throw new Error(String(r.error));
39 }
40 forgetListings(app.db);
41 const after = Buffer.byteLength(await fetch(`${servers.url}/llms.txt`).then((r) => r.text()));
42 // Each listed repo costs one line of about 150 bytes on this origin; at most LLMS_LINES are
43 // listed, so the anonymous document stays under its budget plus LLMS_LINES such lines.
44 expect((after - before) / 5).toBeLessThan(200);
45 expect(LLMS_LINES).toBeLessThanOrEqual(50);
46 } finally {
47 servers.stop();
48 }
49 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs