Skip to content

Commit f9197c1

Browse files
soheimamclaudemontycheesegithub-advanced-security[bot]
authored
Feat/add llm txt (#33)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Montana <montanawong@gmail.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent c708f72 commit f9197c1

27 files changed

Lines changed: 3771 additions & 1 deletion

.claude/commands/agents.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
description: Regenerate the public AGENTS.md routing document, or check whether it is stale
3+
---
4+
5+
Manage the generated `public/AGENTS.md` — the **public** agent routing document
6+
served at `<origin>/AGENTS.md`.
7+
8+
Argument: `$ARGUMENTS` — one of `check`, `status`, `force`, or empty.
9+
10+
## Two different files
11+
12+
Get this right before doing anything:
13+
14+
- **`/AGENTS.md`** at the repo root is hand-written, follows the
15+
[agents.md](https://agents.md/) spec, and describes how to work *in* this
16+
repo. It is in no generator's `outputs`. Never regenerate it.
17+
- **`public/AGENTS.md`** is generated by `scripts/agents.mjs` and tells external
18+
developers' agents how to use the site: routing rules, freshness, network
19+
reference, route list.
20+
21+
This command only concerns the second one.
22+
23+
## Normally you do not need this
24+
25+
`githooks/post-commit` runs it automatically when a commit message contains
26+
`agents.md`, and on any added, deleted, or renamed route file:
27+
28+
```sh
29+
git commit -m "docs: refresh agents.md"
30+
```
31+
32+
## What to do
33+
34+
**No argument** — regenerate only if the route tree or config changed:
35+
36+
```sh
37+
git diff --name-only HEAD -- src/app app llms.config.mjs
38+
node scripts/agents.mjs
39+
git diff --stat public/AGENTS.md
40+
```
41+
42+
**`force`** — regenerate regardless.
43+
44+
**`check`** — report staleness and validation failures without writing; exit 1
45+
if stale:
46+
47+
```sh
48+
node scripts/agents.mjs --check
49+
```
50+
51+
**`status`** — size, mtime, route count, config. Never fails.
52+
53+
## When reviewing the diff
54+
55+
Check these specifically, because they are the parts that would be damaging
56+
rather than merely wrong:
57+
58+
- Each chain ID sits in the same `### ` block as its own RPC URL. A transposed
59+
`8453` / `84532` reads perfectly fine and would have an agent signing against
60+
the wrong network. There is a test for this; if it is failing, do not
61+
work around it.
62+
- Ephemeral networks publish a note about where to read live values, not a
63+
fabricated chain ID.
64+
- The routing rules still say which source wins on a conflict.
65+
66+
To change content, edit `llms.config.mjs` — not the generated file.

.claude/commands/llms.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
description: Regenerate llms.txt and llms-full.txt, or check whether they are stale
3+
---
4+
5+
Manage the generated `public/llms.txt` and `public/llms-full.txt`.
6+
7+
Argument: `$ARGUMENTS` — one of `check`, `status`, `install`, or empty.
8+
9+
## Normally you do not need this
10+
11+
`githooks/post-commit` runs `scripts/llms.mjs` automatically when a commit
12+
message contains `llms.txt` (case-insensitive), and when a route file is added,
13+
deleted, or renamed. So the day-to-day flow is just:
14+
15+
```sh
16+
git commit -m "feat: add a snapshots page; updates llms.txt"
17+
```
18+
19+
Use `/llms` when you want to preview output before committing, regenerate
20+
without committing, or set the hook up on a fresh clone.
21+
22+
## What to do
23+
24+
**No argument** — regenerate and show what changed:
25+
26+
```sh
27+
node scripts/llms.mjs
28+
git diff --stat public/llms.txt public/llms-full.txt
29+
```
30+
31+
Report which files changed and summarise the diff. If nothing changed, say so
32+
plainly rather than implying work happened.
33+
34+
**`check`** — report staleness without writing. Exit 1 means stale, invalid, or
35+
sitemap drift:
36+
37+
```sh
38+
node scripts/llms.mjs --check
39+
```
40+
41+
Relay the metadata-source breakdown. Any count under `metadata fallback` means
42+
those routes have no usable `export const metadata` and are being listed with a
43+
humanized slug — name them and suggest either adding metadata to the page or a
44+
`routes` override in `llms.config.mjs`.
45+
46+
**`status`** — sizes, mtimes, config, route count, drift. Never fails:
47+
48+
```sh
49+
node scripts/llms.mjs --status
50+
```
51+
52+
**`install`** — set up the hook on this clone:
53+
54+
```sh
55+
./githooks/install.sh
56+
```
57+
58+
Then confirm it is repo-scoped: `git config --global --get core.hooksPath`
59+
should print nothing.
60+
61+
## Do not
62+
63+
- Edit `public/llms.txt` or the autogen region of `public/llms-full.txt` by
64+
hand. Change the page's `export const metadata` or `llms.config.mjs` instead.
65+
- Touch the `<!-- LLMS_EXTRAS_START -->``<!-- LLMS_EXTRAS_END -->` region
66+
unless the user asked for a prose change. That region is hand-written and
67+
preserved verbatim across regenerations.
68+
- Confuse `public/AGENTS.md` (generated) with `/AGENTS.md` at the repo root
69+
(hand-written, never generated).

AGENTS.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# AGENTS.md
2+
3+
Instructions for coding agents working in this repository, per the
4+
[agents.md](https://agents.md/) convention. Agents read the nearest AGENTS.md in
5+
the directory tree, so a package in a monorepo can add its own.
6+
7+
> This file is hand-written and is never generated. The **public** agent routing
8+
> document — the one served at `/AGENTS.md` for external developers and their
9+
> agents — is `public/AGENTS.md`, generated by `scripts/agents.mjs`. Do not edit
10+
> that one by hand; your changes will be overwritten on the next commit that
11+
> mentions `agents.md`.
12+
13+
## Setup commands
14+
15+
- Install deps: `npm install`
16+
- Start dev server: `npm run dev`
17+
- Build: `npm run build`
18+
- Install git hooks (once per clone): `./githooks/install.sh`
19+
20+
## Generated files — do not edit
21+
22+
These are written by `scripts/llms.mjs` and `scripts/agents.mjs`:
23+
24+
- `public/llms.txt`
25+
- `public/llms-full.txt`
26+
- `public/AGENTS.md`
27+
28+
To change their contents, edit the source instead:
29+
30+
- **A page's title or description** → that route's `export const metadata` in
31+
its `page.tsx`. This is the same metadata Next uses for SEO, so there is one
32+
source of truth rather than two.
33+
- **Ordering, sections, network reference, routing rules, freshness**
34+
`llms.config.mjs`.
35+
- **Hand-written prose inside `llms-full.txt`** → edit between the
36+
`<!-- LLMS_EXTRAS_START -->` and `<!-- LLMS_EXTRAS_END -->` markers directly
37+
in `public/llms-full.txt`. That region is preserved verbatim across
38+
regenerations; everything outside it is not.
39+
40+
Check whether they are current: `npm run llms -- --check`
41+
42+
## Regenerating
43+
44+
Include `llms.txt` or `agents.md` in your commit message and the post-commit
45+
hook regenerates and creates one follow-up commit:
46+
47+
```
48+
git commit -m "feat: add snapshots page; updates llms.txt"
49+
```
50+
51+
Adding, deleting, or renaming a `page.tsx` triggers it automatically. To opt out
52+
of a single commit, use `SKIP_DOCS_HOOK=1` or put `[skip-docs]` in the message.
53+
54+
## Code style
55+
56+
<!-- Replace with this project's real conventions. -->
57+
58+
- TypeScript strict mode
59+
- Follow the existing formatter config; do not reformat unrelated files
60+
61+
## Testing
62+
63+
- Run the llms-kit suite: `node --test tests/`
64+
- Include liveness checks against the deployed site: `LLMS_LIVE=1 node --test tests/`
65+
66+
## Pull requests
67+
68+
- Keep the generated-file commit separate from your own work — the hook already
69+
does this for you. Do not squash it away; it is what makes the generated diff
70+
reviewable.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ npm run dev # http://localhost:3000
2222
- `npm run lint` — eslint (next/core-web-vitals)
2323
- `npm run typecheck``tsc --noEmit`
2424
- `npm test` — vitest
25+
- `npm run llms` / `npm run agents` — regenerate the agent index files
26+
- `npm run docs:check` — verify the agent index is current (CI gate)
2527

2628
## Structure
2729

@@ -39,6 +41,24 @@ See `.env.example`. `NEXT_PUBLIC_VIBENET_*` are public URLs. The snapshots API
3941
needs Cloudflare R2 credentials (`BASE_*_R2_*`), which are secrets set in the
4042
Vercel project settings.
4143

44+
## Agent index (llms.txt / AGENTS.md)
45+
46+
`public/llms.txt`, `public/llms-full.txt`, and `public/AGENTS.md` are generated
47+
from the route tree by the scripts in `scripts/`. A `post-commit` git hook keeps
48+
them fresh: mention `llms.txt` or `agents.md` in a commit message (or add/rename
49+
a route file) and the hook regenerates them in a follow-up commit.
50+
51+
The hook is off until you enable it in your clone — `core.hooksPath` is a local
52+
git setting and can't be committed, so each clone opts in once:
53+
54+
```bash
55+
./githooks/install.sh # scope: --local; never touches global/system git config
56+
```
57+
58+
Bypass a single commit with `SKIP_DOCS_HOOK=1 git commit …` or a `[skip-docs]`
59+
message. To disable: `./githooks/uninstall.sh`. See `githooks/README.md` for
60+
details.
61+
4262
## Deployment
4363

4464
Deployed on Vercel. Push to the default branch to ship; pull requests get

0 commit comments

Comments
 (0)