Skip to content

fix(web): serve llms.txt as UTF-8 - #268

Merged
kalaspuff merged 1 commit into
mainfrom
fctl/266-llms-txt-utf-8
Oct 24, 2026
Merged

kalaspuff merged 1 commit into
mainfrom
fctl/266-llms-txt-utf-8

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Since #267, app.fctl.sh serves /llms.txt as text/plain without a charset. Cloudflare's static assets declare none for .txt, unlike wrangler dev and the standalone server, which add charset=utf-8. The file has UTF-8 characters (→, …, ⌘), and clients that read text without a charset as Latin-1 garble them: browsers often do, and so does Python's requests (response.text). A rule in web/public/_headers now declares text/plain; charset=utf-8 for it. Cloudflare's docs say _headers rules override the headers it ordinarily sends.

Verified: curl -sI https://app.fctl.sh/llms.txt says content-type: text/plain today. Under wrangler dev the built assets answer /llms.txt with a single text/plain; charset=utf-8, and a scratch rule with a distinct value replaced the default rather than being joined to it. npm run check and npm test pass for the web app.

hyperstructure/fctl-site#58 does the same for fctl.sh's /llms.txt, /llms-full.txt and Markdown pages:

fctl session

Cloudflare's static assets send .txt files as text/plain without a
charset, unlike wrangler dev and the standalone server, so clients that
read such text as Latin-1 garbled llms.txt's UTF-8 (→, …, ⌘). A
_headers rule declares charset=utf-8 for it.
@kalaspuff
kalaspuff merged commit 63fd9d4 into main Oct 24, 2026
10 checks passed
@kalaspuff
kalaspuff deleted the fctl/266-llms-txt-utf-8 branch October 24, 2026 22:36
kalaspuff pushed a commit to hyperstructure/fctl-site that referenced this pull request Oct 24, 2026
## Summary

Serves fctl's guide for agents and its docs in the forms agents read
best ([llms.txt](https://llmstxt.org)):

- `/llms.txt`: fctl's new `docs/llms.txt`, copied as it is.
- `/docs/<slug>.md`: each docs page as Markdown (the overview at
`/docs/index.md`), with every link made absolute: to the other pages'
Markdown, or to the file on GitHub. Each HTML page links its Markdown as
an alternate.
- `/llms-full.txt`: `llms.txt` followed by every page, each with its
address.

`_headers` declares these files UTF-8: Cloudflare sends `.txt` and `.md`
without a charset (app.fctl.sh's `/llms.txt` does today), and clients
that then read them as Latin-1 garble their →, … and —. fctl's two new
pages, **For agents** and **HTTP API**, join the navigation after the
CLI. Heading ids now drop apostrophes as GitHub's do. Before,
"Confirming it's you" got `confirming-it-39-s-you`, so links to
`architecture.md#confirming-its-you` missed it. The page mapping and
link rewriting moved to `scripts/pages.mjs`, with tests. The deploy's
smoke test also fetches `/llms.txt` and a Markdown page.

hyperstructure/fctl#267 is merged and fctl's CI pinned it
(`fctl-docs.ref` at 45e0368), which this branch now has from `main`, so
the build finds the new pages. Verified at that commit: `npm run build`
renders 11 pages, their Markdown (all links absolute) and
`llms-full.txt`. Under `wrangler dev`, `/llms.txt` and `/llms-full.txt`
answer as `text/plain; charset=utf-8` and `/docs/*.md` as
`text/markdown; charset=utf-8`, and HTML pages are unchanged. `npm run
check` reports only the two `!important` warnings that `main` has, and
`npm test` passes all 18 tests.

- hyperstructure/fctl#267
- hyperstructure/fctl#268

## Screenshots

The new pages, built from fctl's branch, served by `wrangler dev`: **For
agents** in the light theme and **HTTP API** in the dark one, at 1440
px; **HTTP API**'s session table at 390 px.


![agents-light.png](https://app.fctl.sh/api/v1/published/wNcWGYMpGmJiyoKnXBBQEUcxHphFSrnH16plYUvKoLR/agents-light.png)


![api-dark.png](https://app.fctl.sh/api/v1/published/5lzJT91QrYmcgNVQSUgnPZM5u20it7mQiFo30SkLX2d/api-dark.png)


![api-light-390.png](https://app.fctl.sh/api/v1/published/5Q0XpLwhg443hcjjGCcr0dl3xk3lUWlp2H5MhZyulF5/api-light-390.png)

## Worth confirming

- **Decision:** The Markdown pages' links point at the other pages'
Markdown (`https://fctl.sh/docs/cli.md`), not their HTML, so an agent
that follows them keeps reading Markdown.
- **Decision:** `/docs/cli.md` and the like now serve Markdown where
they used to give the 404 page's "Did you mean /docs/cli/?".

[fctl session](https://app.fctl.sh/s/ses_01M5QX2QPKNQY8VJ8YYY0K547J)

---------

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant