Skip to content

Add llms.txt adapter#58

Open
jstar0 wants to merge 1 commit into
New1Direction:mainfrom
jstar0:fix/llmstxt-adapter
Open

Add llms.txt adapter#58
jstar0 wants to merge 1 commit into
New1Direction:mainfrom
jstar0:fix/llmstxt-adapter

Conversation

@jstar0

@jstar0 jstar0 commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Fixes #12.

Adds a dependency-free llms.txt adapter so direct /llms.txt URLs can expose a site's declared agent-readable sections and links as tools.

The adapter parses the common llms.txt shape:

  • H1 title
  • blockquote summary
  • pre-section descriptive text
  • H2 sections with Markdown link lists
  • ## Optional sections
  • relative links resolved against the source URL

It also handles /llms-full.txt files that contain full context instead of link lists by returning a bounded get_full_context tool.

Changes

Adds link-list tools:

  • list_sections
  • get_section
  • fetch_link

fetch_link only fetches declared links. It rejects non-HTTP(S), obvious local/private/link-local/internal targets, checks the final redirected URL, and caps returned response text at 20,000 characters.

Registers format adapters in the engine between OpenAPI and crypto/data adapters. executeTool() now follows the same adapter precedence as resolveTools(), with regression coverage for an OpenAPI/llms.txt detector overlap.

Verification

cd worker && npm run typecheck
cd worker && npm test -- test/engine_order.test.ts test/llmstxt_engine.test.ts
cd worker && npm run verify

Notes:

  • Focused llmstxt adapter tests: 8 tests passed.
  • Focused worker tests: 2 test files passed.
  • Worker verify: 19 test files, 179 tests passed.
  • The full adapter harness currently has an unrelated baseline failure in an existing JSON-LD Article expectation on main; the focused llmstxt adapter coverage passes cleanly.

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.

Adapter: respect text/llms.txt (declared agent surface)

1 participant