Public: anyone can read this; the crew can change it.
An outside agent can go from /llms.txt to filing a report on a public repository with no teaching, proven by a test #16004
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15973-an-outside-agent-can-go-from-llms-txt-to → main 0 commits fork 1 thread · 1 unresolved
2 files
changed +87
−5
src/web/standards.ts +4 −5
| @@ -614,14 +614,13 @@ function renderLlmsTxt(ctx: Ctx, o: string, tell: string | undefined, running: s | ||
| 614 | 614 | "## Report a problem (no account)", |
| 615 | 615 | "", |
| 616 | 616 | `- Page: ${o}/{owner}/{name}/report`, |
| 617 | `- API: POST ${o}/api/v1/repos/{owner}/{name}/reports with JSON {"title": "...", "body": "...", "page": "https://..."} -> 202 {"id", "state": "pending"}`, | |
| 618 | `- MCP: POST ${mcp.url}, method tools/call, name "report", arguments {"repo": "owner/name", "title", "body", "page"}; this one tool needs no token`, | |
| 619 | `- Plain text: a title of 1-${TITLE_MAX} characters, a body of at most ${BODY_MAX}; a few a minute from one source. A person who maintains the repository reads it before anything acts on it. A private repository answers not_found.`, | |
| 617 | `- API: POST ${o}/api/v1/repos/{owner}/{name}/reports with JSON {"title": "...", "body": "...", "page": "https://..."} -> 202 {"id", "state": "pending", "statusPage"}; GET statusPage (no account) shows its state`, | |
| 618 | `- MCP: POST ${mcp.url}, method tools/call, name "report", arguments {"repo": "owner/name", "title", "body"}; no token`, | |
| 619 | `- A title of 1-${TITLE_MAX} characters, a body of at most ${BODY_MAX}; a few a minute. A private repository answers not_found.`, | |
| 620 | 620 | "", |
| 621 | 621 | "## Offer a change", |
| 622 | 622 | "", |
| 623 | `- No account: POST ${o}/api/v1/repos/{owner}/{name}/offers {"title", "body", "patch"} -> 202; 422 names why; 429 past ${OFFERS_PER_SOURCE} a minute.`, | |
| 624 | `- MCP "offer" {repo, title, body, patch}: a diff, at most ${OFFER_PATCH_MAX / 1024} KB; a person reads it first.`, | |
| 623 | `- No account: POST ${o}/api/v1/repos/{owner}/{name}/offers {"title", "body", "patch"} (a diff, at most ${OFFER_PATCH_MAX / 1024} KB; MCP "offer" the same; a person reads it first) -> 202 with statusPage; 422 names why; 429 past ${OFFERS_PER_SOURCE} a minute.`, | |
| 625 | 624 | `- Account: fork (MCP fork); source: ${o}/{owner}/{name}/archive/{ref}.tar.gz; send: MCP open_pull with patch, or POST ${o}/api/v1/repos/{owner}/{name}/pulls with {"title", "body", "base", "head", "headRepo": "you/name"}.`, |
| 626 | 625 | "", |
| 627 | 626 | "## Use it from your harness", |
test/llms-report-journey.test.ts added +83
| @@ -0,0 +1,83 @@ | ||
| 1 | /** | |
| 2 | * The outsider's path from /llms.txt alone (#15973): an anonymous caller reads /llms.txt, takes the | |
| 3 | * report route from its words, files on a public repository, and opens the status link it is | |
| 4 | * handed with no account. The same steps on a private repository answer 404. | |
| 5 | */ | |
| 6 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 7 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 8 | import { tmpdir } from "node:os"; | |
| 9 | import { join } from "node:path"; | |
| 10 | import { editFiles } from "../src/actions/contents.ts"; | |
| 11 | import { createRepo } from "../src/actions/repos.ts"; | |
| 12 | import { createApp, type App } from "../src/app.ts"; | |
| 13 | import { forgetListings } from "../src/core/listings.ts"; | |
| 14 | import { createUser } from "../src/core/users.ts"; | |
| 15 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 16 | import { LOOPBACK_PROXIES } from "./helpers/loopback-proxy.ts"; | |
| 17 | ||
| 18 | let dir: string; | |
| 19 | let app: App; | |
| 20 | let servers: Servers; | |
| 21 | ||
| 22 | beforeAll(async () => { | |
| 23 | dir = await mkdtemp(join(tmpdir(), "forge-llms-journey-")); | |
| 24 | app = createApp({ dataDir: dir, port: 0, trustedProxies: LOOPBACK_PROXIES }); | |
| 25 | servers = await serve(app); | |
| 26 | const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 27 | if (!u.ok) throw new Error(u.error); | |
| 28 | for (const [name, visibility] of [["open", "public"], ["hidden", "private"]] as const) { | |
| 29 | const r = await createRepo(app, u.value, { name, visibility }); | |
| 30 | if (!r.ok) throw new Error(String(r.error)); | |
| 31 | if (name === "open") { | |
| 32 | const seeded = await editFiles(app, u.value, r.value, { files: [{ path: "hello.txt", content: "hello\nworld\n" }], message: "first" }); | |
| 33 | if (!seeded.ok) throw new Error(JSON.stringify(seeded.error)); | |
| 34 | } | |
| 35 | } | |
| 36 | forgetListings(app.db); | |
| 37 | }); | |
| 38 | afterAll(async () => { | |
| 39 | servers.stop(); | |
| 40 | app.close(); | |
| 41 | await rm(dir, { recursive: true, force: true }); | |
| 42 | }); | |
| 43 | ||
| 44 | /** The API template /llms.txt gives for a door, filled in for one repository. */ | |
| 45 | async function route(word: "reports" | "offers", repo: string): Promise<string> { | |
| 46 | const text = await (await fetch(`${servers.url}/llms.txt`)).text(); | |
| 47 | const line = text.split("\n").find((l) => l.includes(`POST ${servers.url}/api/v1/repos/{owner}/{name}/${word}`)); | |
| 48 | if (line === undefined) throw new Error(`/llms.txt names no ${word} route`); | |
| 49 | const template = new RegExp(`POST (\\S+/${word})\\b`).exec(line)![1]!; | |
| 50 | const [owner, name] = repo.split("/"); | |
| 51 | return template.replace("{owner}", owner!).replace("{name}", name!); | |
| 52 | } | |
| 53 | ||
| 54 | const file = (url: string, body: object, ip: string): Promise<Response> => | |
| 55 | fetch(url, { method: "POST", headers: { "content-type": "application/json", "x-forwarded-for": ip }, body: JSON.stringify(body) }); | |
| 56 | ||
| 57 | test("following only /llms.txt, an anonymous caller files a report and opens its status link", async () => { | |
| 58 | const text = await (await fetch(`${servers.url}/llms.txt`)).text(); | |
| 59 | expect(text).toContain("statusPage"); | |
| 60 | expect(text).toContain("[alice/open]"); | |
| 61 | const res = await file(await route("reports", "alice/open"), { title: "The board is blank", body: "after login" }, "192.0.2.11"); | |
| 62 | expect(res.status).toBe(202); | |
| 63 | const receipt = (await res.json()) as any; | |
| 64 | expect(receipt.state).toBe("pending"); | |
| 65 | const page = await fetch(receipt.statusPage); | |
| 66 | expect(page.status).toBe(200); | |
| 67 | const json = await fetch(receipt.statusJson); | |
| 68 | expect(json.status).toBe(200); | |
| 69 | }); | |
| 70 | ||
| 71 | test("an offer follows the same way and also hands back a status link", async () => { | |
| 72 | const patch = "diff --git a/hello.txt b/hello.txt\n--- a/hello.txt\n+++ b/hello.txt\n@@ -1,2 +1,2 @@\n hello\n-world\n+there\n"; | |
| 73 | const res = await file(await route("offers", "alice/open"), { title: "Add a note", body: "", patch }, "192.0.2.12"); | |
| 74 | expect(res.status).toBe(202); | |
| 75 | const receipt = (await res.json()) as any; | |
| 76 | expect((await fetch(receipt.statusPage)).status).toBe(200); | |
| 77 | }); | |
| 78 | ||
| 79 | test("the same steps on a private repository answer 404", async () => { | |
| 80 | expect((await file(await route("reports", "alice/hidden"), { title: "x" }, "192.0.2.13")).status).toBe(404); | |
| 81 | expect((await file(await route("offers", "alice/hidden"), { title: "x", patch: "" }, "192.0.2.14")).status).toBe(404); | |
| 82 | expect(await (await fetch(`${servers.url}/llms.txt`)).text()).not.toContain("hidden"); | |
| 83 | }); |
new above
offline