Skip to content

Conversation

jchris
Copy link

@jchris jchris commented Mar 19, 2025

Add llms.txt Support for Multiple Libraries

Overview

This PR adds support for multiple library documentation files (llms.txt) to enhance AI-generated code in bolt.diy. It implements a system that can:

  1. Fetch and update library documentation from URLs (Fireproof, OpenRouter)
  2. Detect libraries mentioned in user prompts
  3. Detect multiple libraries in chat history
  4. Enhance prompts with relevant library documentation

Key Changes

Added Documentation Support

  • Created a structured system for storing and accessing llms.txt files
  • Added Fireproof database documentation
  • Added OpenRouter API documentation
  • Implemented an update script to fetch latest docs from URLs

Enhanced Prompt System

  • Added ability to detect libraries mentioned in prompts
  • Added ability to detect libraries mentioned throughout chat history
  • Implemented automatic prompt enhancement based on detected libraries
  • Ensures library documentation persists throughout a chat session

API and Utilities

  • Added new API endpoint for accessing library documentation
  • Created utility functions for working with library documentation
  • Enhanced the prompt enhancer to include chat history context

Implementation Details

The PR introduces a modular approach to library documentation with the following components:

  • app/lib/common/llms-docs/: Directory for library documentation files
  • scripts/update-llms-docs.js: Script for updating documentation from URLs
  • enhancePromptFromHistory(): Function to persist library context in chat sessions

Testing

  • Added comprehensive tests for library detection and prompt enhancement
  • Tests verify single and multiple library detection in chat history
  • All types and linting issues have been addressed

How to Use

Library detection and enhancement happen automatically when users mention supported libraries in their prompts. The system will automatically include the appropriate documentation in the context for better code generation.

To update library documentation:

pnpm run update-llms-docs

This PR lays the groundwork for easily adding more library documentation in the future.

jchris added 2 commits March 18, 2025 20:10
…istory

- Updated Chat component to pass messages to enhancePrompt function.
- Added OpenRouter API documentation to available documents.
- Implemented functions to detect libraries mentioned in chat history and enhance prompts accordingly.
- Updated API enhancer to utilize chat history for prompt enhancement.
- Added tests for new functionality in llms-docs.spec.ts.
{
name: 'llms-docs-import',
transform(code, id) {
if (id.endsWith('.txt')) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost want this to be .md but it goes against the llms.txt grain

@jchris jchris changed the title Auto prompt enhancement with llms.txt feat: Auto prompt enhancement with llms.txt Mar 19, 2025
@jchris jchris changed the title feat: Auto prompt enhancement with llms.txt feat: auto prompt enhancement with llms.txt Mar 19, 2025
@Stijnus Stijnus self-assigned this Sep 24, 2025
@Stijnus Stijnus self-requested a review September 24, 2025 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants