You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most llms are under-trained on bun, which is especially noticeable with new or novel bun features (such as Bun.serve or the new static option). When using llms with bun I have to add a lot of instructions on which apis to use, or copy and paste docs, or go in and correct node APIs to bun APIs manually.
What is the feature you are proposing to solve the problem?
/llms.txt is a new emerging standard for presenting a website in an llm-friendly format. In this case, I'm proposing to add a build step to docs generation to output an llms.txt and llms-full.txt to the docs url. So if an llm is attempting to use http://bun.sh/docs they can find http://bun.sh/docs/llms.txt or http://bun.sh/docs/llms-full.txt
I wrote a simple sample script that would output these files, but I don't know where this actually belongs or what would run it, so I'm just putting it here instead of a PR.
In my personal tests using Cursor and this prompt:
make a static server that imports an index.html file and serves it. follow bun best practices
I got the best results by adding llms-full.txt to my Cursor Docs. Similar results by using Cursor's built-in Docs indexer on the regular http://bun.sh/docs site. Cursor didn't do much with the simple link list of llms.txt (results weren't much better than without the llms.txt) but I don't know how other llms will handle it.
Here's my script:
importdocsfrom"./nav";constROOT_URL="https://bun.sh/docs";constheader=`# Bun## Docs`;asyncfunctiongenerateOutline(){// Generate markdown content with dividers and linksconstcontent=docs.items.map(item=>{if(item.type==="divider"){return`\n### ${item.title}\n`;// Add newlines around divider for better readability}// For pages, create markdown link with descriptionif(item.disabled){return`- ${item.title} _(Coming soon)_: ${item.description}`;}return`- [${item.title}](${ROOT_URL}/${item.slug}): ${item.description}`;}).join("\n");awaitBun.write(`${import.meta.dir}/llms.txt`,`${header}\n${content}`);}// Generate full content by reading each markdown fileasyncfunctiongenerateFullContent(){constfullContent: string[]=[header];for(constitemofdocs.items){if(item.type==="divider"){fullContent.push(`\n# ${item.title}\n`);continue;}if(item.disabled){fullContent.push(`\n## ${item.title} _(Coming soon)_\n\n${item.description}\n`);continue;}try{// Handle nested paths by splitting the slug on '/' and joining with the directoryconstbasePath=`./${item.slug.split("/").join("/")}`;letmdPath: string;// Try direct .md file firsttry{mdPath=Bun.resolveSync(`${basePath}.md`,import.meta.dir);}catch{// If that fails, try index.md in a directorymdPath=Bun.resolveSync(`${basePath}/index.md`,import.meta.dir);}constfile=Bun.file(mdPath);if(awaitfile.exists()){fullContent.push(`\n## ${item.title}\n`);constcontent=awaitfile.text();// Remove HTML commentsletcleanContent=content.replace(/<!--[\s\S]*?-->/g,"");// TODO: handle blocks like codetabs, etc.fullContent.push(cleanContent);}else{console.warn(`File does not exist: ${mdPath}`);continue;}}catch(error){console.warn(`Could not resolve file for ${item.slug}:`,error);continue;}}// Write the full content to llms-full.txtawaitBun.write(`${import.meta.dir}/llms-full.txt`,fullContent.join("\n"));}// Generate both filesawaitgenerateOutline();awaitgenerateFullContent();
What alternatives have you considered?
Cursor's built-in docs indexer keeps getting better, this is actually the first time I've tried it where it did better than me manually telling it about bun apis.
Also, now that I've generated these myself I don't NEED it to be a part of the official project, I can self-host these for myself.
I could also continue to write bun code by hand the old-fashioned way!
What is the problem this feature would solve?
Most llms are under-trained on bun, which is especially noticeable with new or novel bun features (such as
Bun.serve
or the newstatic
option). When using llms with bun I have to add a lot of instructions on which apis to use, or copy and paste docs, or go in and correct node APIs to bun APIs manually.What is the feature you are proposing to solve the problem?
/llms.txt
is a new emerging standard for presenting a website in an llm-friendly format. In this case, I'm proposing to add a build step to docs generation to output anllms.txt
andllms-full.txt
to the docs url. So if an llm is attempting to usehttp://bun.sh/docs
they can findhttp://bun.sh/docs/llms.txt
orhttp://bun.sh/docs/llms-full.txt
Here's a directory of these llms.txt files for reference: https://directory.llmstxt.cloud
I wrote a simple sample script that would output these files, but I don't know where this actually belongs or what would run it, so I'm just putting it here instead of a PR.
In my personal tests using Cursor and this prompt:
I got the best results by adding llms-full.txt to my Cursor Docs. Similar results by using Cursor's built-in Docs indexer on the regular http://bun.sh/docs site. Cursor didn't do much with the simple link list of llms.txt (results weren't much better than without the llms.txt) but I don't know how other llms will handle it.
Here's my script:
What alternatives have you considered?
Cursor's built-in docs indexer keeps getting better, this is actually the first time I've tried it where it did better than me manually telling it about bun apis.
Also, now that I've generated these myself I don't NEED it to be a part of the official project, I can self-host these for myself.
I could also continue to write bun code by hand the old-fashioned way!
llms.txt
llms-full.txt
The text was updated successfully, but these errors were encountered: