llmstxtv1

import llmstxtv1 "pocketone.dev/ext/contracts/llmstxt/v1"

Package llmstxtv1 is the llmstxt/v1 contract: the app's /llms.txt (llmstxt.org), the Markdown file agents read to learn what a site is and where to go. Extensions and the app's own pb_hooks add sections with Add; the provider builds the file from the app's name, its admins' preamble and every section, and serves it when the app has no llms.txt of its own.

Source: ext/contracts/llmstxt/v1.

Constants

const Path = "/llms.txt"

Path is where the file is served.

Variables

var Contract = extkit.NewContract[Builder]("llmstxt/v1", extkit.One)

Contract is llmstxt/v1.

Functions

Add

func Add(app core.App, s Section)

Add adds a section to app's llms.txt. Call it any time (in Register, from pb_hooks), whoever provides the contract.

Types

Builder

type Builder interface {
	// Build returns the whole file for the request (absolute links use its origin).
	Build(e *core.RequestEvent) (string, error)
}

Builder builds the app's llms.txt.

Section

type Section struct {
	// Heading is the section's `##` heading, without the hashes.
	Heading string
	// Content is Markdown under the heading. Render, when set, replaces it.
	Content string
	// Render builds the content per request (dynamic sections). Return "" to leave this contribution out. An error
	// leaves it out too; the provider logs it and serves the rest.
	Render func(e *core.RequestEvent) (string, error)
	// Source names who added it (an extension, "pb_hooks"), for the error log.
	Source string
}

Section is one contribution. Contributions with the same Heading merge under one `## Heading`, in the order they were added; headings appear in the order first added. "Optional" keeps its llms.txt meaning: agents may skip it.

Sections

func Sections(app core.App) []Section

Sections are the contributions, in the order added (for providers).