Skip to content

Commit f1045b0

Browse files
TMHSDigitalclaude
andcommitted
site: llms.txt and llms-full.txt indexes
llms.txt follows the llmstxt.org shape: title, tagline, a paragraph on the catalog's rules, then one line per non-deprecated entry by category with licence, commercial label, credit and status, linking its page. llms-full.txt adds each entry's source, verified date, summary and Notes (384 KB). Both are rebuilt with the site. 7 new assertions (89). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wc67NX9MM964uaVGn4bpZJ
1 parent 0cb1cbd commit f1045b0

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

‎site/build.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url";
99
import { commercialLabel, esc, PERSPECTIVE_LABELS, verifiedAge } from "./lib/shared.mjs";
1010
import { entryPageHtml } from "./lib/entry-page.mjs";
1111
import { LinkError, makeLinkResolver } from "./lib/links.mjs";
12+
import { llmsFullTxt, llmsTxt } from "./lib/llms.mjs";
1213
import { deprecationReason, MarkdownError, renderBlocks, renderInline, splitEntryBody } from "./lib/markdown.mjs";
1314
import { checkPage } from "./lib/page-checks.mjs";
1415

@@ -529,6 +530,11 @@ function main() {
529530
fs.writeFileSync(path.join(DIST, "sitemap.xml"), sitemapXml(config.site, visible));
530531
fs.writeFileSync(path.join(DIST, "robots.txt"), robotsTxt(config.site));
531532
fs.writeFileSync(path.join(DIST, "404.html"), notFoundHtml(config.site));
533+
fs.writeFileSync(path.join(DIST, "llms.txt"), llmsTxt({ entries, site: config.site, categories: config.categories }));
534+
fs.writeFileSync(
535+
path.join(DIST, "llms-full.txt"),
536+
llmsFullTxt({ entries, site: config.site, categories: config.categories, bodies })
537+
);
532538

533539
const pages = writeEntryPages({ entries, bodies, config, stats, stamp, hasCard, now });
534540
const pageErrors = [...pages.errors, ...checkPages(["index.html", ...pages.written])];

‎site/lib/lib.test.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,23 @@ has("dangling link", checkPage(okPage.replace("../e2/", "../e3/"), opts).join(),
149149
has("link leaving the site", checkPage(okPage.replace("../e2/", "../../../x/"), opts).join(), "leaves the site");
150150
eq("query and hash are ignored", checkPage(okPage.replace("../e2/", "../../?cat=2d#catalog"), opts).length, 0);
151151

152+
/* llms ------------------------------------------------------------------- */
153+
import { llmsFullTxt, llmsTxt } from "./llms.mjs";
154+
const cats = { "2d": { label: "2D" }, audio: { label: "Audio" } };
155+
const llmsEntries = [
156+
{ ...base, id: "a1", name: "Alpha", category: "2d", status: "active", attribution_required: false, commercial: true, license: "CC0" },
157+
{ ...base, id: "d1", name: "Gone", category: "2d", status: "deprecated" },
158+
];
159+
const lt = llmsTxt({ entries: llmsEntries, site, categories: cats });
160+
has("llms header", lt, "# Free Game Dev Assets\n\n> T");
161+
has("llms entry line", lt, "- [Alpha](https://x.test/s/entry/a1/): CC0; commercial OK; no credit required; active");
162+
lacks("llms skips deprecated", lt, "Gone");
163+
lacks("llms skips empty categories", lt, "## Audio");
164+
const lf = llmsFullTxt({ entries: llmsEntries, site, categories: cats, bodies: new Map([["a1", "# A\n\nLead\n\n## Notes\n\n- catch one\n\n## Evidence\n\n- e"]]) });
165+
has("full carries notes", lf, "- catch one");
166+
lacks("full leaves evidence out", lf, "## Evidence");
167+
has("full carries the source", lf, "Source: https://src.test/");
168+
152169
/* report (keep last) ------------------------------------------------------ */
153170
if (failures.length) {
154171
console.error(`lib.test failed (${failures.length}):`);

‎site/lib/llms.mjs‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/** Plain-text indexes of the catalog for AI assistants (llmstxt.org format). */
2+
import { sectionMarkdown } from "./markdown.mjs";
3+
import { commercialLabel, entryPageUrl } from "./shared.mjs";
4+
5+
const creditWord = (e) =>
6+
e.attribution_required === true ? "credit required" : e.attribution_required === false ? "no credit required" : "credit unclear";
7+
8+
const facts = (e) => `${e.license}; ${commercialLabel(e.commercial)}; ${creditWord(e)}; ${e.status}`;
9+
10+
function header(site) {
11+
return `# ${site.title}
12+
13+
> ${site.tagline}
14+
15+
A curated catalog of free game assets, libraries and tools. It holds links and licence metadata only; nothing is rehosted. Each licence was read at its source on the entry's verified date, and the entry page quotes it with dates. "needs-review" means a real question is open: read the entry's Notes before shipping. Deprecated entries are not listed.
16+
`;
17+
}
18+
19+
function groups(entries, categories) {
20+
return Object.entries(categories)
21+
.map(([cat, meta]) => ({ label: meta.label || cat, items: entries.filter((e) => e.category === cat && e.status !== "deprecated") }))
22+
.filter((g) => g.items.length);
23+
}
24+
25+
export function llmsTxt({ entries, site, categories }) {
26+
const out = [header(site)];
27+
for (const g of groups(entries, categories)) {
28+
out.push(`\n## ${g.label}\n`);
29+
for (const e of g.items) out.push(`- [${e.name}](${entryPageUrl(site, e.id)}): ${facts(e)}`);
30+
}
31+
return `${out.join("\n")}\n`;
32+
}
33+
34+
export function llmsFullTxt({ entries, site, categories, bodies }) {
35+
const out = [header(site)];
36+
for (const g of groups(entries, categories)) {
37+
out.push(`\n## ${g.label}\n`);
38+
for (const e of g.items) {
39+
const notes = sectionMarkdown(bodies.get(e.id) || "", "Notes");
40+
out.push(
41+
`### ${e.name}\n\nPage: ${entryPageUrl(site, e.id)}\nSource: ${e.url}\nLicence: ${facts(e)}; verified ${e.verified}\n\n${e.summary || ""}${notes ? `\n\n${notes}` : ""}\n`
42+
);
43+
}
44+
}
45+
return `${out.join("\n")}\n`;
46+
}

0 commit comments

Comments
 (0)