openvibers/openvibe.bench Commits

/llms-full.txt holds the API page in full (SEO-33) (#112)

OP OpenVibers committed 10 days ago · 870962aad1 · 2 files, +23 −2

It was one line a page, 314 characters in all. The /docs page now goes in as text,
from the same view /docs renders.

Changes

ddiff --git a/server/http/discovery.js b/server/http/discovery.js
iindex 0862e8a..d65ee95 100644
---- a/server/http/discovery.js
++++ b/server/http/discovery.js
@@@ -62,10 +62,11 @@ function createDiscoveryRoutes(ctx) {
r.get('/llms-full.txt', (_req, res) => {
res.type('text/plain').set('Cache-Control', TEXT).send(seo.llmsFull({
site: SITE_NAME,
-- summary: 'The Bench home and its API docs.',
++ summary: 'The Bench home and its API docs, in full.',
base: site,
maxBytes: 256 * 1024,
-- sections: [{ title: 'Pages', pages: PAGES.map((p) => ({ url: p.path, title: p.title, text: p.text })) }],
++ // The API page in full (SEO-33: it was one line), from the same view /docs renders.
++ sections: [{ title: 'Pages', pages: PAGES.map((p) => (p.path === '/docs' ? { url: p.path, title: p.title, html: require('../views').docs() } : { url: p.path, title: p.title, text: p.text })) }],
}));
});
ddiff --git a/test/llms-full.test.js b/test/llms-full.test.js
nnew file mode 100644
iindex 0000000..fe3914e
---- /dev/null
++++ b/test/llms-full.test.js
@@@ -0,0 +1,20 @@
++'use strict';
++// SEO-33: /llms-full.txt holds the API page in full (it was one line a page, 314 characters in all), from the same
++// view /docs renders, so a language model reading it learns the API without fetching HTML.
++const assert = require('assert');
++const { boot, check, done } = require('./helpers/boot');
++
++(async () => {
++ const t = await boot();
++ await check('llms-full.txt: the home, then the API page in full', async () => {
++ const r = await t.get('/llms-full.txt');
++ assert.strictEqual(r.status, 200);
++ assert.match(r.headers.get('content-type') || '', /^text\/plain/);
++ assert.ok(r.text.startsWith('# OpenVibe.Bench'));
++ assert.match(r.text, /### The Bench API\n\nURL: [^\n]*\/docs\n/);
++ assert.ok(r.text.length > 2000, `${r.text.length} characters`);
++ assert.ok(!/<\/?(div|p|span|a|code|pre|section|h[1-6]|li|ul|ol|table|tr|td|th|button|nav)\b[^>]*>/i.test(r.text.split('### The Bench API')[1] || ''), 'the page as text, no markup');
++ });
++ await check('stop', async () => { await t.close(); });
++ done();
++})();