@cubicecho/agent-docs 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -2
- package/_agents/docs/01-install.md +55 -0
- package/_agents/docs/checks.md +16 -0
- package/_agents/docs/ci.md +71 -0
- package/_agents/docs/cli.md +39 -0
- package/_agents/docs/common-mistakes.md +54 -0
- package/_agents/docs/config.md +25 -0
- package/dist/bin.d.ts +7 -0
- package/dist/bin.js +11 -0
- package/dist/check/check-agent-docs.d.ts +23 -0
- package/dist/check/check-agent-docs.js +314 -0
- package/dist/check/generation.d.ts +37 -0
- package/dist/check/generation.js +86 -0
- package/dist/cli/run.d.ts +24 -0
- package/dist/cli/run.js +131 -0
- package/dist/consts.d.ts +16 -0
- package/dist/consts.js +16 -0
- package/dist/core/config.d.ts +31 -0
- package/dist/core/config.js +69 -0
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/errors.js +21 -0
- package/dist/core/files.d.ts +28 -0
- package/dist/core/files.js +67 -0
- package/dist/core/json.d.ts +26 -0
- package/dist/core/json.js +44 -0
- package/dist/core/package-manifest.d.ts +38 -0
- package/dist/core/package-manifest.js +58 -0
- package/dist/defaults.d.ts +26 -0
- package/dist/defaults.js +14 -0
- package/dist/exports/entry-points.d.ts +30 -0
- package/dist/exports/entry-points.js +119 -0
- package/dist/exports/export-index.d.ts +44 -0
- package/dist/exports/export-index.js +233 -0
- package/dist/exports/module-source.d.ts +74 -0
- package/dist/exports/module-source.js +161 -0
- package/dist/exports/scan.d.ts +29 -0
- package/dist/exports/scan.js +156 -0
- package/dist/exports/summary.d.ts +36 -0
- package/dist/exports/summary.js +84 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/llms/identity.d.ts +21 -0
- package/dist/llms/identity.js +67 -0
- package/dist/llms/plan.d.ts +53 -0
- package/dist/llms/plan.js +318 -0
- package/dist/llms/sync.d.ts +16 -0
- package/dist/llms/sync.js +36 -0
- package/dist/markdown/anchors.d.ts +35 -0
- package/dist/markdown/anchors.js +66 -0
- package/dist/markdown/page.d.ts +20 -0
- package/dist/markdown/page.js +57 -0
- package/llms.txt +42 -0
- package/package.json +64 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Benjamin Van Treese
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- AI agents: read llms.txt and _agents/docs/ for the full, version-matched API. -->
|
|
2
|
+
# @cubicecho/agent-docs
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
Generates and checks the docs a package ships for AI coding agents. `agent-docs llms` writes `llms.txt` from the
|
|
5
|
+
pages in `_agents/docs/` and, for a TypeScript package, from the doc comments behind every `package.json`
|
|
6
|
+
`exports` entry. `agent-docs check` holds the README, AGENTS.md, links, page sizes and package contents to the
|
|
7
|
+
agent docs standard. Both exit 1 with one line per problem, so CI can run them as they are.
|
|
8
|
+
|
|
9
|
+
It exists because every repo had its own copy of the generator, and the copies had drifted: some indexed only
|
|
10
|
+
`src/index.ts` and missed subpath entries such as `./mdns`, and all of them cut a summary short at "e.g.". One
|
|
11
|
+
package, one set of fixes.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm i -D @cubicecho/agent-docs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Node 22 or later. No runtime dependencies.
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"scripts": {
|
|
26
|
+
"llms": "agent-docs llms",
|
|
27
|
+
"docs:check": "agent-docs check",
|
|
28
|
+
"prepack": "npm run build && agent-docs llms"
|
|
29
|
+
},
|
|
30
|
+
"files": ["dist", "llms.txt", "_agents/docs"]
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
echo /llms.txt >> .gitignore # prepack writes it on every publish, so git doesn't track it
|
|
36
|
+
npm run llms # in CI: fails on a page without a title or summary
|
|
37
|
+
npm run docs:check # in CI: fails when the docs fall short of the standard
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
- [llms.txt](https://cdn.jsdelivr.net/npm/@cubicecho/agent-docs/llms.txt), the index of everything below, as the latest release ships it
|
|
43
|
+
- [Install and wire up](https://github.com/cubicecho/agent-docs/blob/main/_agents/docs/01-install.md)
|
|
44
|
+
- [The agent-docs command](https://github.com/cubicecho/agent-docs/blob/main/_agents/docs/cli.md)
|
|
45
|
+
- [`_agents/llms.json`](https://github.com/cubicecho/agent-docs/blob/main/_agents/docs/config.md)
|
|
46
|
+
- [What check enforces](https://github.com/cubicecho/agent-docs/blob/main/_agents/docs/checks.md)
|
|
47
|
+
- [CI](https://github.com/cubicecho/agent-docs/blob/main/_agents/docs/ci.md)
|
|
48
|
+
- [Common mistakes](https://github.com/cubicecho/agent-docs/blob/main/_agents/docs/common-mistakes.md)
|
|
49
|
+
- [Changelog](https://github.com/cubicecho/agent-docs/blob/main/CHANGELOG.md)
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
[MIT](https://github.com/cubicecho/agent-docs/blob/main/LICENSE)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Install and wire up
|
|
2
|
+
|
|
3
|
+
Add `@cubicecho/agent-docs` as a dev dependency, then give the package three npm scripts: `llms` writes `llms.txt`, `prepack` runs it on every pack and publish so the file never goes stale, and `docs:check` checks the rest of the agent docs standard.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm i -D @cubicecho/agent-docs
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"scripts": {
|
|
12
|
+
"llms": "agent-docs llms",
|
|
13
|
+
"docs:check": "agent-docs check",
|
|
14
|
+
"prepack": "npm run build && agent-docs llms"
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist", "llms.txt", "_agents/docs"]
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Both commands work on the current folder, so run them from the package root. Node 22 or later; no other runtime dependencies.
|
|
21
|
+
|
|
22
|
+
## What it needs
|
|
23
|
+
|
|
24
|
+
- A manifest with a name and a description: `package.json`, `haxelib.json`, `pyproject.toml` (`[project]`) or Home Assistant's `manifest.json`, read in that order. `title` and `summary` in `_agents/llms.json` replace them.
|
|
25
|
+
- Pages in `_agents/docs/`, each a `# Title` line followed by a one-paragraph summary. See [the CLI page](cli.md#llms) for how they are listed.
|
|
26
|
+
- For TypeScript, nothing more: when `src/` holds `.ts` files, every `package.json` `exports` entry is indexed from its doc comments.
|
|
27
|
+
|
|
28
|
+
## First run
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx agent-docs llms
|
|
32
|
+
npx agent-docs check
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Don't commit `llms.txt`: add `/llms.txt` (and `/_agents/docs/exports/`, written when the index is too big for llms.txt) to `.gitignore`. `check` fails a package that packs llms.txt but lets git track it. Then add both commands to CI, as [the CI page](ci.md) shows.
|
|
36
|
+
|
|
37
|
+
A package installed straight from its repo, with nothing that packs it (a HACS integration, a git dependency), is the exception: commit llms.txt there and run `agent-docs llms --check` in CI.
|
|
38
|
+
|
|
39
|
+
## From code
|
|
40
|
+
|
|
41
|
+
The same work is exported as functions, for a build script or a test:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { checkAgentDocs, findStaleFiles, planLlms, writeLlms } from '@cubicecho/agent-docs';
|
|
45
|
+
|
|
46
|
+
const root = process.cwd();
|
|
47
|
+
const plan = planLlms({ root });
|
|
48
|
+
const stale = findStaleFiles(root, plan);
|
|
49
|
+
if (stale.length > 0) {
|
|
50
|
+
writeLlms(root, plan);
|
|
51
|
+
}
|
|
52
|
+
const { problems } = checkAgentDocs(root);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`planLlms` throws an `AgentDocsError` whose `problems` holds one line per problem; `checkAgentDocs` returns them instead.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# What check enforces
|
|
2
|
+
|
|
3
|
+
`agent-docs check` holds a package to ten rules and prints one line per broken one, saying what to change. A private workspace root (`private: true` with `workspaces`) is held to the repo-level rules only: links, CLAUDE.md and `.agents/`.
|
|
4
|
+
|
|
5
|
+
1. **Page size.** Each page in the docs folder is at most 25 KB. Skills servers and file tools truncate larger reads.
|
|
6
|
+
2. **Contents list.** A page over 100 lines lists every `##` heading as a `(#anchor)` link above its first `##`.
|
|
7
|
+
3. **Links.** Every relative link in the pages, `llms.txt` and `AGENTS.md` stays inside the repo, names a file that exists and, with `#anchor`, a heading in it. Anchors follow GitHub: lower case, punctuation dropped but `_` and `-` kept, spaces to hyphens, a repeated heading gets `-1`. `README.md` has no relative links except `#anchor`s, because npm and haxelib render it away from the repo. Links in code spans and fences are ignored.
|
|
8
|
+
4. **README.** `README.md` exists and contains `<!-- AI agents:`, the hidden pointer to the agent docs.
|
|
9
|
+
5. **CLAUDE.md.** If present, it is a symlink to `AGENTS.md` or contains `@AGENTS.md`. A file that only links to AGENTS.md hides it.
|
|
10
|
+
6. **No hidden `.agents/`.** Only `.agents/skills/` may exist, because search tools skip dot-folders.
|
|
11
|
+
7. **`files`.** A published `package.json` with a `files` list includes `llms.txt` and the docs folder, and not all of `_agents`.
|
|
12
|
+
8. **LICENSE.** A published package has a `LICENSE`, `LICENCE` or `COPYING` file, and a package that is not a workspace root has at least one page.
|
|
13
|
+
9. **haxelib.** With `haxelib.json` and a `.releaserc.json`, the `semantic-release-haxelib` plugin's `additionalFiles` lists `llms.txt` and every page, every listed file exists, and `LICENSE.md` exists. The plugin takes files, not folders, and skips a missing path silently. A missing `llms.txt` is fine when a release step writes it (rule 10).
|
|
14
|
+
10. **Generated on pack.** A published `package.json` that ships `llms.txt` has a `prepack` (or `prepublishOnly`) that runs `agent-docs llms`, directly or through `npm run`; `--check` and `--stdout` don't count. A semantic-release-haxelib release lists an `@semantic-release/exec` `prepareCmd` that runs it before the haxelib plugin. Either way, `.gitignore` holds `llms.txt` or `/llms.txt`. A package that nothing packs commits llms.txt instead, and this rule leaves it alone.
|
|
15
|
+
|
|
16
|
+
`agent-docs llms` fails on its own problems: a page without a `# Title` or a summary paragraph, a manifest without a name or description, an `exports` entry whose `src/` file is missing, a re-export of a missing module, an `export` statement it can't read (such as `export =`), and an llms.txt over 25 KB.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# CI
|
|
2
|
+
|
|
3
|
+
Generate `llms.txt` at pack time instead of committing it, run `llms` and `check` wherever the repo already runs its checks, and check what `npm pack` would ship after the build.
|
|
4
|
+
|
|
5
|
+
## npm
|
|
6
|
+
|
|
7
|
+
`prepack` writes llms.txt before every `npm pack` and `npm publish`, semantic-release's included, so the published copy always matches the pages and the source. Git doesn't track it.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
"scripts": {
|
|
11
|
+
"llms": "agent-docs llms",
|
|
12
|
+
"docs:check": "agent-docs check",
|
|
13
|
+
"prepack": "npm run build && agent-docs llms"
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```gitignore
|
|
18
|
+
/llms.txt
|
|
19
|
+
/_agents/docs/exports/
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm run build
|
|
25
|
+
- name: Agent docs
|
|
26
|
+
run: |
|
|
27
|
+
npx agent-docs llms
|
|
28
|
+
npx agent-docs check
|
|
29
|
+
- name: The package ships the agent docs
|
|
30
|
+
run: |
|
|
31
|
+
npm pack --dry-run --ignore-scripts 2>&1 | tee pack.log
|
|
32
|
+
grep -q ' llms.txt$' pack.log && grep -q '_agents/docs/' pack.log
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Running `llms` in CI fails on a page without a title or summary paragraph, and leaves an llms.txt whose links `check` then follows. `--ignore-scripts` keeps `prepack` from building a second time. In a matrix workflow, run the docs steps in one leg: they don't depend on the Node version.
|
|
36
|
+
|
|
37
|
+
## haxelib
|
|
38
|
+
|
|
39
|
+
`semantic-release-haxelib` zips the files on disk in its prepare step, so llms.txt must be written by a plugin listed before it. `@semantic-release/exec` runs its `prepareCmd` in that same step, in plugin order:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
"plugins": [
|
|
43
|
+
"@semantic-release/commit-analyzer",
|
|
44
|
+
"@semantic-release/release-notes-generator",
|
|
45
|
+
["@semantic-release/exec", { "prepareCmd": "npx -y @cubicecho/agent-docs llms" }],
|
|
46
|
+
["semantic-release-haxelib", { "additionalFiles": ["llms.txt", "_agents/docs/01-install.md"] }]
|
|
47
|
+
]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Add `@semantic-release/exec` to the release job's dependencies, and run `npx -y @cubicecho/agent-docs llms` then `check` in CI as for npm. A package on both registries keeps the npm `prepack` as well.
|
|
51
|
+
|
|
52
|
+
## Installed from git
|
|
53
|
+
|
|
54
|
+
A package with nothing that packs it, such as a HACS integration or a git dependency, ships the repo itself. There, commit llms.txt and fail CI when it is stale:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
- run: npx -y @cubicecho/agent-docs llms --check
|
|
58
|
+
- run: npx -y @cubicecho/agent-docs check
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Moving off a committed llms.txt
|
|
62
|
+
|
|
63
|
+
1. Delete any copied `scripts/llms-txt.mjs` and `scripts/check-agent-docs.mjs`.
|
|
64
|
+
2. Set the scripts above, and drop `llms:check` and any `git diff --exit-code -- llms.txt` step.
|
|
65
|
+
3. Add `"_agents/docs"` and `"llms.txt"` to `files`.
|
|
66
|
+
4. Add `/llms.txt` to `.gitignore`, then `git rm --cached llms.txt` in the same commit.
|
|
67
|
+
5. Point the README's llms.txt link at the published copy: `https://cdn.jsdelivr.net/npm/<package>/llms.txt`.
|
|
68
|
+
|
|
69
|
+
## Monorepos
|
|
70
|
+
|
|
71
|
+
Run both commands in each published package's folder (`npm run docs:check --workspaces`), give each package its own `prepack`, and run `agent-docs check` once at the root for the repo-level rules.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# The agent-docs command
|
|
2
|
+
|
|
3
|
+
`agent-docs llms` writes or checks `llms.txt`, and `agent-docs check` checks the package against the agent docs standard. Each prints one line per problem and exits 1 when there is any; otherwise it exits 0.
|
|
4
|
+
|
|
5
|
+
## llms
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
agent-docs llms # write llms.txt
|
|
9
|
+
agent-docs llms --check # CI, in a repo that commits llms.txt: exit 1 if it or an export page is stale
|
|
10
|
+
agent-docs llms --stdout # print what would be written, write nothing
|
|
11
|
+
agent-docs llms --base-url https://org.github.io/pkg/ # add a "Base URL:" line
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
What it writes, in order:
|
|
15
|
+
|
|
16
|
+
1. `# <name>`, `> <description>`, the optional `Base URL:` line, and one paragraph saying where the file comes from.
|
|
17
|
+
2. One link per page in `_agents/docs/` (or `docsDir`): the page's `# H1` is the link text, and its first plain paragraph is the note. HTML comments, code fences, lists, quotes and tables are skipped on the way to that paragraph, and links in it become their text. Top-level pages go under `## Docs`, each subfolder under its own `##`, named from the folder (`getting-started` → `Getting started`, a `01-` prefix dropped) or from `sections` in `_agents/llms.json`. Pages sort by file name, so prefix them to set the order.
|
|
18
|
+
3. When `src/` holds TypeScript: `Requires Node …` and the peer dependencies, then one `## Exports: <import path>` section per `package.json` `exports` entry. Each section opens with the first paragraph of the entry file's own doc comment and lists each export with the first sentence of its doc comment.
|
|
19
|
+
4. `extra` from `_agents/llms.json`, as written.
|
|
20
|
+
|
|
21
|
+
### How an export entry finds its source
|
|
22
|
+
|
|
23
|
+
An entry's `types` (or `import`, then `default`) target in `dist/` maps to the same path in `src/` with `.ts`: `./dist/spec/entry.js` → `src/spec/entry.ts`. Without `exports`, `src/index.ts` is the only entry. Wildcard subpaths and non-code targets (`./package.json`, CSS) are skipped. A name re-exported through `export { … } from`, `export *`, `export * as ns` or an import is followed to the declaration that documents it. Names re-exported from another package are listed on one line, since that package documents them.
|
|
24
|
+
|
|
25
|
+
### When the export index is too big
|
|
26
|
+
|
|
27
|
+
If llms.txt would pass 25 KB with the index inline, the index moves to generated pages, `_agents/docs/exports/01-index.md`, `02-mdns.md` and so on, one per entry, and llms.txt links them under `## Exports`. An entry whose page would pass 25 KB is split into `01-index-1.md`, `01-index-2.md`. Each generated page starts with a `<!-- Generated by @cubicecho/agent-docs … -->` line; a rerun replaces those and deletes the ones it no longer makes. If llms.txt is still over 25 KB after that, the command fails.
|
|
28
|
+
|
|
29
|
+
### Undocumented exports
|
|
30
|
+
|
|
31
|
+
An export with no doc comment is listed by name only, and `llms` prints `no doc comment on …` without failing.
|
|
32
|
+
|
|
33
|
+
## check
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
agent-docs check
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
It changes nothing. Every rule is on [the checks page](checks.md).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Common mistakes
|
|
2
|
+
|
|
3
|
+
The mistakes that make `llms` or `check` fail, or let a stale index through, each with its fix.
|
|
4
|
+
|
|
5
|
+
## Committing llms.txt in a package that is packed
|
|
6
|
+
|
|
7
|
+
The committed copy drifts from the pages between releases, and a `git diff` after a regenerating build passes every time. Generate it in `prepack` and keep it out of git:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
"prepack": "npm run build && agent-docs llms"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```gitignore
|
|
14
|
+
/llms.txt
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Only a package installed straight from its repo commits llms.txt and runs `llms --check`.
|
|
18
|
+
|
|
19
|
+
## Editing llms.txt or a generated export page by hand
|
|
20
|
+
|
|
21
|
+
The next `llms` run, and every `prepack`, overwrites it. Change the page in `_agents/docs/` or the doc comment in `src/`, then rerun `agent-docs llms`. A hand-written page placed in `_agents/docs/exports/` stops `llms` with "was written by hand"; move it to another folder.
|
|
22
|
+
|
|
23
|
+
## A blank line between a doc comment and its declaration
|
|
24
|
+
|
|
25
|
+
The comment is then read as the file's own comment, not the declaration's, and the export is listed with no summary. Keep the comment directly above the declaration; a `// biome-ignore` line between them is fine.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
/** Fetches a URL and parses its body as JSON. */
|
|
29
|
+
export async function fetchJson(url: string): Promise<unknown> { ... }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## An export form the index can't read
|
|
33
|
+
|
|
34
|
+
`export = x` and other forms outside declarations, `export { … }` lists and `export *` stop `llms` with the file and line. Write a declaration or an `export { … } from` list.
|
|
35
|
+
|
|
36
|
+
## An exports entry with no matching source
|
|
37
|
+
|
|
38
|
+
`exports["./x"]` pointing at `./dist/x.js` needs `src/x.ts`. For a package whose build doesn't mirror `src/`, set `"exports": false` in `_agents/llms.json`.
|
|
39
|
+
|
|
40
|
+
## Leaving the docs out of the package
|
|
41
|
+
|
|
42
|
+
`files: ["dist"]` ships neither llms.txt nor the pages, so an agent in `node_modules` gets nothing. List both, never all of `_agents`:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
"files": ["dist", "llms.txt", "_agents/docs"]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## CLAUDE.md that links to AGENTS.md
|
|
49
|
+
|
|
50
|
+
Claude Code reads only CLAUDE.md when both exist and does not follow a link. Make it a symlink (`ln -s AGENTS.md CLAUDE.md`) or a file whose first line is `@AGENTS.md`.
|
|
51
|
+
|
|
52
|
+
## Relative links in the README
|
|
53
|
+
|
|
54
|
+
npm and haxelib render the README away from the repo, so `[docs](_agents/docs/cli.md)` breaks there. Use the absolute GitHub URL in the README; relative links belong in `_agents/docs/` and llms.txt.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# _agents/llms.json
|
|
2
|
+
|
|
3
|
+
`_agents/llms.json` is the optional overrides file both commands read; without it, every field takes its default.
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"title": "dropecho.ds (haxelib) / @dropecho/ds (npm)",
|
|
8
|
+
"summary": "One line that replaces the manifest's description.",
|
|
9
|
+
"sections": { "guides": "How-to guides", "api": "API reference" },
|
|
10
|
+
"extra": "## Elsewhere\n\n- [Site](https://example.com/): the human docs.",
|
|
11
|
+
"docsDir": "skill",
|
|
12
|
+
"exports": false
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Field | Type | Default | Does |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| `title` | string | the manifest's `name` | The `# H1` of llms.txt |
|
|
19
|
+
| `summary` | string | the manifest's `description` | The `>` line; whitespace collapses to single spaces |
|
|
20
|
+
| `sections` | object of strings | none | Heading text per docs subfolder name |
|
|
21
|
+
| `extra` | string | none | Markdown appended after the generated sections |
|
|
22
|
+
| `docsDir` | string | `_agents/docs` | Where the pages are, relative to the package root. `check` reads it too, and then wants it in `package.json` `files` |
|
|
23
|
+
| `exports` | boolean | `true` | `false` turns the TypeScript export index off |
|
|
24
|
+
|
|
25
|
+
A field of the wrong type fails both commands with a line naming it. A dual haxelib and npm package sets `title` to name both, since the npm name would win otherwise.
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The `agent-docs` command.
|
|
4
|
+
*
|
|
5
|
+
* Runs in the current folder, which is the package root.
|
|
6
|
+
*/
|
|
7
|
+
import { runCli } from './cli/run.js';
|
|
8
|
+
process.exitCode = runCli(process.argv.slice(2), process.cwd(), {
|
|
9
|
+
out: (line) => console.log(line),
|
|
10
|
+
err: (line) => console.error(line),
|
|
11
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type LimitSettings } from '../defaults.ts';
|
|
2
|
+
/** What {@link checkAgentDocs} found. */
|
|
3
|
+
export interface CheckResult {
|
|
4
|
+
/** One line per problem, each saying what to change; empty when the package meets the standard. */
|
|
5
|
+
problems: string[];
|
|
6
|
+
/** How many pages the docs folder holds. */
|
|
7
|
+
pageCount: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Checks a package against the agent documentation standard, changing nothing.
|
|
11
|
+
*
|
|
12
|
+
* @param root - Package root.
|
|
13
|
+
* @param overrides - Limits to change, for a test or an unusual repo.
|
|
14
|
+
* @returns The problems found and the page count.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* The rules: pages within `pageLimitKb`, a contents list on a page over `contentsAfterLines`, relative links that
|
|
18
|
+
* resolve inside the repo (README has none but `#anchor`s), the README's hidden pointer, CLAUDE.md as a link to
|
|
19
|
+
* AGENTS.md, no hidden `.agents/`, a LICENSE and the right `files` for a published package, the
|
|
20
|
+
* semantic-release-haxelib file list, and llms.txt generated when the package is packed and kept out of git. A
|
|
21
|
+
* private workspace root is held to the repo-level rules only.
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkAgentDocs(root: string, overrides?: Partial<LimitSettings>): CheckResult;
|